Two curve NTT correctness issue hotfix #254
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR resolves the problem occurring in gnark groth16 circuits that use more than one curve simultaneously. More specifically, verification fails due to
krs2
MSM being incorrect, in turn caused bycomputeH
function returning incorrect result. On closer inspection it turned out thattemplate_normalize_kernel
here just doesn't launch. It does so silently, without throwing any errors or visible memory leaks. It does seem that the problem has to do with compilation because simply using the same kernel with a different name helps as well as only using a single curve. The "fix" in this PR just replaces a second use-case oftemplate_normalize_kernel
with a more correct Montgomery treatment cherry-picked from our new API branch. I will try to get more info about this error in the following days while for now this fix should suffice.PS: guess it's one more point for unified compilation for different wrapper languages - hopefully we'll have fewer strange hard-to-debug C++ compilation bugs that way lol...