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/switch groth16 key #1357

Merged
merged 17 commits into from
Mar 20, 2025
Merged

Conversation

lucasmenendez
Copy link
Contributor

Description

This PR implements SwitchVerificationKey for groth16 recursion. By including two verification keys for similar circuits, it allows recursive verification of multiple proofs for both circuits, seamlessly switching between their corresponding verification keys as needed.

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?

There are three similar tests that verify that two proofs from two different circuits are in the third circuit. Each test uses different curves for the inner and outer circuits:

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

Sorry, something went wrong.

@ivokub ivokub self-requested a review January 9, 2025 08:19
@ivokub
Copy link
Collaborator

ivokub commented Jan 9, 2025

I'm a bit behind on reviews and will get to it soon

@ivokub ivokub force-pushed the feat/switch-groth16-key branch from 6ffa023 to 4e1aa27 Compare January 28, 2025 09:16
@ivokub
Copy link
Collaborator

ivokub commented Jan 28, 2025

I'm a bit behind on reviews and will get to it soon

I rebased on top of master and fixed conflicting changes. I'll still have a look at the Groth16 test and add tests for MuxG2/MuxGt. And I'd like to write documentation example. But in general looks good.

@lucasmenendez
Copy link
Contributor Author

Super nice!!

I'm a bit behind on reviews and will get to it soon

I rebased on top of master and fixed conflicting changes. I'll still have a look at the Groth16 test and add tests for MuxG2/MuxGt. And I'd like to write documentation example. But in general looks good.

@lucasmenendez lucasmenendez force-pushed the feat/switch-groth16-key branch from 1f67b21 to 59fb979 Compare January 31, 2025 15:17
@lucasmenendez lucasmenendez marked this pull request as ready for review March 18, 2025 10:25
@ivokub ivokub force-pushed the feat/switch-groth16-key branch from b64c6e1 to 716ab04 Compare March 20, 2025 14:45
@ivokub ivokub requested a review from Copilot March 20, 2025 14:45
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements key switching for Groth16 recursion by adding a new function SwitchVerificationKey that selects among multiple verification keys based on a runtime selector. Additionally, it provides new helper methods (MuxG2 and MuxGt) along with comprehensive tests across several pairing and verifier packages to support recursive verification for multiple circuits.

Reviewed Changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
std/algebra/native/sw_bls24315/pairing2_test.go Added helper functions and tests for MuxG2/MuxGt in the context of Groth16 key switching.
std/algebra/emulated/sw_bw6761/pairing.go Implemented MuxG2 and MuxGt functions and integrated them into the pairing API.
std/algebra/emulated/sw_bn254/pairing_test.go Updated tests to exercise pairing mux functions for BN254 curves.
std/algebra/native/sw_bls12377/pairing2_test.go Updated tests and circuit definitions to validate Groth16 key switching for BLS12-377 proofs.
std/recursion/groth16/verifier.go Introduced the SwitchVerificationKey functionality and updated references to commitment verification.
std/algebra/interfaces.go & std/recursion/plonk/verifier.go Minor interface updates to support the new MuxG2 and MuxGt methods.

@ivokub
Copy link
Collaborator

ivokub commented Mar 20, 2025

Thanks! It is super useful. It also revealed a bug we had before.

@ivokub ivokub merged commit b51a3d4 into Consensys:master Mar 20, 2025
3 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