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

feat: verify commitments in groth16 recursion verifier #1057

Merged
merged 22 commits into from Feb 19, 2024

Conversation

ahmetyalp
Copy link
Contributor

@ahmetyalp ahmetyalp commented Feb 14, 2024

Description

This PR adds commitment verification to groth16 recursion AssertProof method. This implementation only supports at most one commitment.

TODO:

Type of change

  • New feature (non-breaking change which adds functionality)

How has this been tested?

  • Added test case TestBN254InBN254Commitment to test inner circuit with commitment

How has this been 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

@ivokub
Copy link
Collaborator

ivokub commented Feb 15, 2024

Thanks for the contribution! I started reviewing the PR, but it takes a bit time. I'm proposing some refactors related to this PR and some which I wanted to include as part of a cleanup of Groth16 verifier (simpler init of groth16 verifier instance for example).

I'll have a longer response with specific items/suggestions soon.

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.

Thanks for the contribution! I refactored to be more aligned with PLONK verifier and allow for independent Pedersen commitment verification.

Could you have a look that I hadn't missed something and the refactored version works for you. If you give a go-ahead, then I'll merge.

@@ -139,6 +139,14 @@ func NoSolidityChecks() TestingOption {
}
}

// WithProverChecks forces to run prover checks and disables solver checks.
func WithProverChecks() TestingOption {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd not add the test property. The command assert.CheckCircuit is usually meant for end-to-end testing in CI and its internal behaviour is toggled with build tags:

// default options;
// go test -short 					--> testEngineOnly
// go test 							--> constraintOnlyProfile
// go test -tags=prover_checks 		--> proverOnlyProfile
// go test -tags=release_checks 	--> releaseProfile

Now, if we define and use WithProverCheck option, then when running tests with -short tag or without any tags, we would still be running the prover (which may be really slow).

Better option for testing prover is to use tags=provers_checks tag like

go test -timeout 10m -tags debug,prover_checks -run ^TestBN254InBN254Commitment$ github.com/consensys/gnark/std/recursion/groth16 -v -count=1

std/gkr/api_test.go Show resolved Hide resolved
@ahmetyalp
Copy link
Contributor Author

I run our tests with the refactored version. Everything seems fine. I left a comment about subgroupCheck, everything else LGTM. Thanks for the review and refactoring @ivokub

@ivokub ivokub merged commit 45d201a into Consensys:master Feb 19, 2024
4 of 5 checks passed
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

2 participants