-
Notifications
You must be signed in to change notification settings - Fork 401
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
feat: add groth16 #1313
Changes from 13 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
ead5a5f
feat: add groth16
mattstam d1e829c
fix merge conflicts
mattstam 57bf725
refactor: add to sdk
mattstam db72ec3
fix vk paths
mattstam 5471e21
rm the unsafe
mattstam 3535436
cleanup 1
mattstam 03e9752
different SP1Verifier files
mattstam fb9704f
re-use SP1Verifier.txt
mattstam 2c227bf
cleanup docker.rs
mattstam 5a02321
cleanup native.rs
mattstam 22e6fe1
cleanup 2
mattstam 5b3d0e3
cleanup 3
mattstam 2198522
fix: circuit -> Circuit
mattstam 9874334
SP1Bn254ProofData and use enum
mattstam 4bf964c
fix test
mattstam f493f39
nit: get_raw_proof
mattstam File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { | ||
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)] | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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: SP1Bn254ProofData
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.
SP1ProofData is a bit too general.
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