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: add groth16 #1313

Merged
merged 16 commits into from
Aug 17, 2024
Merged

feat: add groth16 #1313

merged 16 commits into from
Aug 17, 2024

Conversation

mattstam
Copy link
Contributor

@mattstam mattstam commented Aug 13, 2024

Adds Groth16 to the circuits artifacts generated, and supports generating and verifying proofs for it.

Notes:

  • Does not implement a real trusted setup
  • The circuit tar contains files for both plonk and groth16, so that provers that download it will be able to prove for either proof type.
  • Instead of circuit artifacts stored in ~/.sp1/circuits/plonk_bn254/<version>/, they are now stored in ~/.sp1/circuits/<version>/, and the full output looks like:
-rw-rw-r-- 1 ubuntu ubuntu  249660953 Aug 16 20:05 constraints.json
-rw-rw-r-- 1 ubuntu ubuntu  889966358 Aug 16 20:12 groth16_circuit.bin
-rw-rw-r-- 1 ubuntu ubuntu 2691757795 Aug 16 20:13 groth16_pk.bin
-rw-rw-r-- 1 ubuntu ubuntu       2509 Aug 16 20:13 Groth16SP1Verifier.sol
-rw-rw-r-- 1 ubuntu ubuntu      31661 Aug 16 20:12 Groth16Verifier.sol
-rw-rw-r-- 1 ubuntu ubuntu        556 Aug 16 20:12 groth16_vk.bin
-rw-rw-r-- 1 ubuntu ubuntu    1021306 Aug 16 20:05 groth16_witness.json
-rw-rw-r-- 1 ubuntu ubuntu  828550683 Aug 16 19:55 plonk_circuit.bin
-rw-rw-r-- 1 ubuntu ubuntu 4295001768 Aug 16 19:57 plonk_pk.bin
-rw-rw-r-- 1 ubuntu ubuntu       2503 Aug 16 19:57 PlonkSP1Verifier.sol
-rw-rw-r-- 1 ubuntu ubuntu      58508 Aug 16 19:55 PlonkVerifier.sol
-rw-rw-r-- 1 ubuntu ubuntu      34368 Aug 16 19:55 plonk_vk.bin
-rw-rw-r-- 1 ubuntu ubuntu    1021739 Aug 16 19:10 plonk_witness.json
-rw-rw-r-- 1 ubuntu ubuntu 3225633956 Aug 16 19:14 srs.bin
-rw-rw-r-- 1 ubuntu ubuntu 2147517604 Aug 16 19:50 srs_lagrange.bin

@mattstam mattstam marked this pull request as ready for review August 16, 2024 18:23
@@ -1,8 +1,8 @@
# Building PLONK Artifacts
# Building circuit Artifacts
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: circuit -> Circuit

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

pub struct SP1Groth16Bn254ProofData(pub Groth16Bn254Proof);

#[derive(Serialize, Deserialize, Clone)]
pub enum SP1ProofData {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: SP1Bn254ProofData

Copy link
Contributor

Choose a reason for hiding this comment

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

SP1ProofData is a bit too general.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

}

impl SP1ProofData {
pub fn get_proof_system(&self) -> &str {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: can you use an enum here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@mattstam mattstam merged commit 5085525 into dev Aug 17, 2024
@mattstam mattstam deleted the mattstam/groth16 branch August 17, 2024 01:37
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.

2 participants