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

fix: assign baseChallenge correctly while verifying gkr solution #1020

Merged
merged 1 commit into from Jan 24, 2024

Conversation

ahmetyalp
Copy link
Contributor

@ahmetyalp ahmetyalp commented Jan 23, 2024

Description

Fixes failed assertion while verifying GKR solution((gkr.Solution).Verify function) with other than non-constant hash functions (like mimc or poseidon). Inspired by https://github.com/Consensys/gnark-crypto/blob/master/ecc/bn254/fr/gkr/gkr.go#L688

I added new test case TestMiMCFullDepthNoDepSolveWithMiMCHash, which fails without this change with following error:

Error:      	Received unexpected error:
        	            	constraint #37111 is not satisfied: [assertIsEqual] 10420734889032269308690831442195287995987323506521353207282897974178519295845 == 19485199868485599785212267512534296132678646505698908814492864400056160446973
        	            	r1cs.(*builder).AssertIsEqual
        	            		/Users/ahmety/gnark/frontend/cs/r1cs/api_assertions.go:38
        	            	gkr.(*eqTimesGateEvalSumcheckLazyClaims).VerifyFinalEval
        	            		/Users/ahmety/gnark/std/gkr/gkr.go:110
        	            	sumcheck.Verify
        	            		/Users/ahmety/gnark/std/sumcheck/sumcheck.go:104
        	            	gkr.Verify
        	            		/Users/ahmety/gnark/std/gkr/gkr.go:339
        	            	gkr.Solution.Verify
        	            		/Users/ahmety/gnark/std/gkr/compile.go:197
        	            	gkr.(*mimcNoDepCircuit).Define
        	            		/Users/ahmety/gnark/std/gkr/api_test.go:596

        	Test:       	TestMiMCFullDepthNoDepSolveWithMiMCHash

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How has this been tested?

Any GKR solution verification with non-constant hash function is failing at same step(VerifyFinalEval). TestMiMCFullDepthNoDepSolveWithMiMCHash added to reproduce the error

How has this been benchmarked?

Not benchmarked

Checklist:

  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • I did not modify files generated from templates
  • golangci-lint does not output errors locally
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@CLAassistant
Copy link

CLAassistant commented Jan 23, 2024

CLA assistant check
All committers have signed the CLA.

Copy link
Collaborator

@ivokub ivokub left a comment

Choose a reason for hiding this comment

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

Looks perfect! Thanks for reporting the issue and proposing a fix. I'll merge after CI completes.

@ahmetyalp
Copy link
Contributor Author

@ivokub Thanks for a quick review. Is there any chance to backport this fix to version 0.9.1?

@ivokub ivokub merged commit 9627e98 into Consensys:master Jan 24, 2024
4 of 5 checks passed
@ivokub
Copy link
Collaborator

ivokub commented Jan 24, 2024

Hmm, I'll see what we can do - I think we can soon release v0.9.2 or v0.10.0 from master as we try to keep it stable and have a few new features what would be nice to have released. Would this (i.e. new release from master instead of backporting to v0.9.1) work or are there any incompatibilities? For example, if in your project you would go get github.com/consensys/gnark@master then should be using latest stable rolling release.

@ahmetyalp
Copy link
Contributor Author

ahmetyalp commented Jan 24, 2024

@ivokub It probably works. Do you have an estimation for a new release date?

Update: master worked fine, thanks for your support ❤️

@ivokub
Copy link
Collaborator

ivokub commented Jan 24, 2024

Great it worked!

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