-
Notifications
You must be signed in to change notification settings - Fork 370
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
feat: add groth16 #1313
Changes from 12 commits
ead5a5f
d1e829c
57bf725
db72ec3
5471e21
3535436
03e9752
fb9704f
2c227bf
5a02321
22e6fe1
5b3d0e3
2198522
9874334
4bf964c
f493f39
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
# Building PLONK Artifacts | ||
# Building circuit Artifacts | ||
|
||
To build the production Plonk Bn254 artifacts from scratch, you can use the `Makefile` inside the `prover` directory. | ||
To build the production PLONK and Groth16 Bn254 artifacts from scratch, you can use the `Makefile` inside the `prover` directory. | ||
|
||
```shell,noplayground | ||
cd prover | ||
RUST_LOG=info make build-plonk-bn254 | ||
``` | ||
RUST_LOG=info make build-circuits | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
use std::path::PathBuf; | ||
|
||
use clap::Parser; | ||
use sp1_core_machine::utils::setup_logger; | ||
use sp1_prover::build::build_groth16_bn254_artifacts_with_dummy; | ||
|
||
#[derive(Parser, Debug)] | ||
#[clap(author, version, about, long_about = None)] | ||
struct Args { | ||
#[clap(short, long)] | ||
build_dir: PathBuf, | ||
} | ||
|
||
pub fn main() { | ||
setup_logger(); | ||
let args = Args::parse(); | ||
build_groth16_bn254_artifacts_with_dummy(args.build_dir); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ use sp1_core_machine::{ | |
}; | ||
use sp1_primitives::poseidon2_hash; | ||
use sp1_recursion_core::{air::RecursionPublicValues, stark::config::BabyBearPoseidon2Outer}; | ||
use sp1_recursion_gnark_ffi::plonk_bn254::PlonkBn254Proof; | ||
use sp1_recursion_gnark_ffi::proof::{Groth16Bn254Proof, PlonkBn254Proof}; | ||
use sp1_recursion_program::machine::{ | ||
SP1CompressMemoryLayout, SP1DeferredMemoryLayout, SP1RecursionMemoryLayout, | ||
}; | ||
|
@@ -144,19 +144,45 @@ pub type SP1ReducedProof = SP1ProofWithMetadata<SP1ReducedProofData>; | |
/// An SP1 proof that has been wrapped into a single PLONK proof and can be verified onchain. | ||
pub type SP1PlonkBn254Proof = SP1ProofWithMetadata<SP1PlonkBn254ProofData>; | ||
|
||
/// An SP1 proof that has been wrapped into a single PLONK proof and can be verified onchain. | ||
pub type SP1PlonkProof = SP1ProofWithMetadata<SP1PlonkProofData>; | ||
/// An SP1 proof that has been wrapped into a single Groth16 proof and can be verified onchain. | ||
pub type SP1Groth16Bn254Proof = SP1ProofWithMetadata<SP1Groth16Bn254ProofData>; | ||
|
||
/// An SP1 proof that has been wrapped into a single proof and can be verified onchain. | ||
pub type SP1Proof = SP1ProofWithMetadata<SP1ProofData>; | ||
|
||
#[derive(Serialize, Deserialize, Clone)] | ||
pub struct SP1CoreProofData(pub Vec<ShardProof<CoreSC>>); | ||
|
||
#[derive(Serialize, Deserialize, Clone)] | ||
pub struct SP1ReducedProofData(pub ShardProof<InnerSC>); | ||
|
||
#[derive(Serialize, Deserialize, Clone)] | ||
pub struct SP1PlonkBn254ProofData(pub PlonkBn254Proof); | ||
|
||
#[derive(Serialize, Deserialize, Clone)] | ||
pub struct SP1PlonkProofData(pub PlonkBn254Proof); | ||
pub struct SP1Groth16Bn254ProofData(pub Groth16Bn254Proof); | ||
|
||
#[derive(Serialize, Deserialize, Clone)] | ||
pub enum SP1ProofData { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: SP1Bn254ProofData There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. SP1ProofData is a bit too general. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed |
||
Plonk(PlonkBn254Proof), | ||
Groth16(Groth16Bn254Proof), | ||
} | ||
|
||
impl SP1ProofData { | ||
pub fn get_proof_system(&self) -> &str { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: can you use an enum here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed |
||
match self { | ||
SP1ProofData::Plonk(_) => "Plonk", | ||
SP1ProofData::Groth16(_) => "Groth16", | ||
} | ||
} | ||
|
||
pub fn get_raw_proof(&self) -> &str { | ||
match self { | ||
SP1ProofData::Plonk(proof) => &proof.raw_proof, | ||
SP1ProofData::Groth16(proof) => &proof.raw_proof, | ||
} | ||
} | ||
} | ||
|
||
/// An intermediate proof which proves the execution over a range of shards. | ||
#[derive(Serialize, Deserialize, Clone)] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: circuit -> Circuit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed