Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Two curve NTT correctness issue hotfix #254

Merged
merged 2 commits into from
Nov 5, 2023

Conversation

DmytroTym
Copy link
Contributor

@DmytroTym DmytroTym commented Oct 28, 2023

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 by computeH function returning incorrect result. On closer inspection it turned out that template_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 of template_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...

ImmanuelSegol
ImmanuelSegol previously approved these changes Oct 29, 2023
Copy link
Contributor

@ImmanuelSegol ImmanuelSegol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix makes sense to me.

Was just wondering if it would be possible perhaps for you to add some comments explaining this in the code.

jeremyfelder
jeremyfelder previously approved these changes Oct 30, 2023
@jeremyfelder jeremyfelder dismissed stale reviews from ImmanuelSegol and themself via f909f8e November 1, 2023 09:54
@jeremyfelder jeremyfelder force-pushed the fix/dima/two-curve-ntt-correctness-issue branch from 08b05e5 to bea3c24 Compare November 2, 2023 15:00
@DmytroTym
Copy link
Contributor Author

@ImmanuelSegol yea I thought about commenting it somewhere but not sure where tbh. And I'm still not 100% sure when this happens too...
I will take some time in several days to try to see when the issue reproduces but for now I'm not really sure

@jeremyfelder jeremyfelder merged commit e4e9130 into main Nov 5, 2023
19 of 22 checks passed
@jeremyfelder jeremyfelder deleted the fix/dima/two-curve-ntt-correctness-issue branch November 5, 2023 06:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants