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

Optimized BN254 Groth16 Solidity template with compressed proof support #810

Merged
merged 22 commits into from
Sep 1, 2023

Conversation

recmo
Copy link
Contributor

@recmo recmo commented Aug 11, 2023

New verifier BN254 Groth16 Solidity template that is more gas efficient and supports compressed proofs (efficient on rollups).

External audit scheduled for this week.

It has two public functions verifyProof and verifyCompressedProof.

The verifyProof is heavily gas optimized and should be drop-in replacement for the existing function (except it will always revert on invalid proof, instead of sometimes returning false).

The verifyCompressedProof is optimized for reducing calldata, and less optimized for compute. This is to keep readability in the much more complex math. The intended use case is rollups where calldata is relatively much more expensive than compute.

@CLAassistant
Copy link

CLAassistant commented Aug 11, 2023

CLA assistant check
All committers have signed the CLA.

@recmo recmo marked this pull request as draft August 11, 2023 06:13
@recmo recmo changed the title Use optimized template Optimized BN254 Groth16 Solidity template with compressed proof support Aug 11, 2023
@gbotrel
Copy link
Collaborator

gbotrel commented Aug 11, 2023

Hi -- thanks for the contrib! FYI; there is something planned (not started yet) to update the Groth16 verifier to support the api.Commit feature (on develop branch). This PR could serve as a better basis 👍

@recmo recmo marked this pull request as ready for review August 14, 2023 09:18
@gbotrel
Copy link
Collaborator

gbotrel commented Aug 23, 2023

External audit scheduled for this week.
hi @recmo --> when is the report due?

@recmo
Copy link
Contributor Author

recmo commented Aug 24, 2023

Received the first iteration yesterday and am now implementing the three suggestions (there where no issues):

  • Suggestion 1: Use Custom Error Messages
  • Suggestion 2: Collaborate With Gnark To Implement the Compress Function
  • Suggestion 3: Adhere to Natspec Guidelines

I've asked if I can share the report.

@recmo
Copy link
Contributor Author

recmo commented Aug 25, 2023

@recmo
Copy link
Contributor Author

recmo commented Aug 25, 2023

@gbotrel From my side this is ready to merge. LMK what next steps are.

@kustosz
Copy link
Contributor

kustosz commented Aug 25, 2023

@gbotrel I also have a wip branch on gnark-tests to run against this version (https://github.com/kustosz/gnark-tests/tree/evm-verifier), though I had to make some other changes due to version mismatch between gnark master and whatever gnark-test is building against. Please let me know how and when to best PR the test changes.

@gbotrel
Copy link
Collaborator

gbotrel commented Aug 28, 2023

@kustosz so, we are now running solidity integration test within gnark main repo CI;

func (assert *Assert) solidityVerification(b backend.ID, vk interface {

so if you can add the test for the compress proof in there and it passes the CI looks good to merge on our side.

Q: @Tabaie @ThomasPiellard I suspect plugging the multi commit on top of that shouldn't be an issue?

@kustosz
Copy link
Contributor

kustosz commented Aug 29, 2023

Thanks for the pointer, will get this sorted tomorrow!

@kustosz
Copy link
Contributor

kustosz commented Aug 30, 2023

@gbotrel here's a PR to the solidity checker that makes the tests here pass locally – can you please verify against your CI?

@kustosz
Copy link
Contributor

kustosz commented Aug 30, 2023

just to be clear: the CI here won't pass until Consensys/gnark-solidity-checker#1 gets merged (or at least put on a branch in that repo so we can refer to it in CI config here)

@gbotrel gbotrel merged commit 1b3ba0d into Consensys:master Sep 1, 2023
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.

4 participants