-
Notifications
You must be signed in to change notification settings - Fork 396
feat(aggregation_mode): aggregate proofs in chunks #1896
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
Merged
Merged
Changes from 64 commits
Commits
Show all changes
68 commits
Select commit
Hold shift + click to select a range
3200e0c
feat: risc0 aggregation program
MarcosNicolau 2f54502
feat: [wip] risc0 aggregator backend
MarcosNicolau 62bfb60
feat: ProofAggregationService risc0 verification
MarcosNicolau c475a63
feat: error handling + fetch risc0 proofs
MarcosNicolau e2dcf30
feat: send risc0 aggregated proof to AlignedProofAggregationService c…
MarcosNicolau 1c4440b
feat: deploy AlignedProofAggregationService contract with risc0 verifier
MarcosNicolau df1d83a
feat: allow risc0 succinct proofs
MarcosNicolau 4bc1a52
chore: modified risc0 no_pub_inputs to generate a succinct proof inst…
MarcosNicolau 56a9d87
feat: fetch proofs based on zkvm engine
MarcosNicolau 6c544d0
chore: commands to start proof agregator based on verifier
MarcosNicolau b137020
fix: compute image id bytes in little endian not in be
MarcosNicolau d0a4be6
feat: local verification of aggregated risc0 proof
MarcosNicolau 8309ea8
Merge branch 'staging' into feat/aggregation-mode-risc0
MarcosNicolau 369cdc6
chore: add gpu feature flag to run with cuda
MarcosNicolau 7720553
docs: add gpu command
MarcosNicolau ebdc910
chore: undo no_pub_input file changes
MarcosNicolau 1b8873a
ci: fix contracts build + install risc0 toolchain
MarcosNicolau 01f60f4
chore: better proof aggregator makefile targets
MarcosNicolau 20b7d61
docs: update how to run proof aggregator readme
MarcosNicolau 454f80c
ci: skip build on clippy
MarcosNicolau 5e43630
chore: address clippy warnings
MarcosNicolau 79eb6b3
fix: correctly setting risc0 tiny-keccak patch
MarcosNicolau bd5ad9d
chore: rename prove feature to proving to prevent collision with risc…
MarcosNicolau ef2b968
Revert "chore: rename prove feature to proving to prevent collision w…
MarcosNicolau 319c112
chore: address juli's comments
MarcosNicolau ac646c6
refactor: replace sp1,risc0 features for .env variables
MarcosNicolau 74f15be
chore: update makefile for new aggregator env config
MarcosNicolau b63e875
refactor: aggregation mode reduce amount of types and abstractions
MarcosNicolau 02987a4
Merge branch 'staging' into refactor/agg-mode-redundancies
MarcosNicolau 4059b2c
feat: aggregate proofs in chunks of 512 proofs
MarcosNicolau e39ed67
fix: aggregated proofs commitment for the second layer
MarcosNicolau eae61ba
chore: add comments for aggregation function
MarcosNicolau e957da2
chore: add tracing for chunk aggregation
MarcosNicolau 618688f
Merge branch 'staging' into feat/aggregate-proofs-in-chunks
MarcosNicolau 4f778ad
Merge branch 'staging' into feat/aggregate-proofs-in-chunks
MarcosNicolau 5afbf67
feat: split aggregation in two programs
MarcosNicolau 4487597
Merge and fix sp1
MauroToscano a095608
feat: update risc0 programs to correctly compute the merkle tree
MarcosNicolau e20cffc
feat: update sp1 programs to correctly compute the merkle tree
MarcosNicolau 5335d2a
feat: aggregator backends for new programs
MarcosNicolau 1bea52d
feat: update write_program_image_id_vk_hash with new programs
MarcosNicolau 68418b6
chore: build program and update chunk aggregator program id in root a…
MarcosNicolau 4bb095b
Merge remote-tracking branch 'origin/staging' into feat/aggregate-pro…
MarcosNicolau 8382808
chore: update anvil state
MarcosNicolau 8b7305a
chore: address warnings and increase max proofs per aggregation to 512
MarcosNicolau af3fc45
Merge branch 'staging' into feat/aggregate-proofs-in-chunks
MarcosNicolau 566d351
chore: script to build programs and write the proper program ids
MarcosNicolau 17dc278
chore: address clippy warnings
MarcosNicolau af3b1c7
docs: aggregation mode how to compile instructions
MarcosNicolau c408d44
chore: add docs for merkle tree backend for Hash32 in root programs
MarcosNicolau eb94954
chore: update docs in functions
MarcosNicolau b5aeb01
chore: make sp1 aggregation work on dev mode
MarcosNicolau 5bdfd4a
chore: agg_mode_write_program_ids run build_programs script
MarcosNicolau 9a9ac6d
fix: compilation issues on cuda
MarcosNicolau b6ede8b
Merge branch 'staging' into feat/aggregate-proofs-in-chunks
MarcosNicolau 767122b
chore: update ethereum package and anvil state
MarcosNicolau c20f22a
chore: rename program names
MarcosNicolau 76741ca
chore: deploy aligned conctrats with new program ids
MarcosNicolau 9c496fc
chore: fix sp1 USER_PROOFS_AGGREGATOR_PROGRAM_VK_HASH constant
MarcosNicolau a68908c
chore: redeploy anvil contracts for new program ids
MarcosNicolau 48f3ca7
chore: fix risc0_user_proofs_aggregator_image_id
MarcosNicolau 7fbb748
chore: update ethereum package contracts
MarcosNicolau f641ba6
chore: logs typos
MarcosNicolau b08ea28
fix: network params ethereum package
MarcosNicolau 42febf2
Update aggregation_mode/aggregation_programs/sp1/src/chunk_aggregator…
MarcosNicolau 46ebd22
feat: proofs per chunk as a config param instead of const
MarcosNicolau 8490e66
nit: add missing new lines
JuArce 5a4f008
chore: update comments
MarcosNicolau 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
50 changes: 50 additions & 0 deletions
50
aggregation_mode/aggregation_programs/risc0/src/chunk_aggregator_main.rs
This file contains hidden or 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,50 @@ | ||
| #![no_main] | ||
|
|
||
| use lambdaworks_crypto::merkle_tree::merkle::MerkleTree; | ||
| use risc0_aggregation_program::{ChunkAggregatorInput, Hash32}; | ||
| use risc0_zkvm::guest::env; | ||
|
|
||
| risc0_zkvm::guest::entry!(main); | ||
|
|
||
| // Generated with `make agg_mode_write_program_ids` and copied from program_ids.json | ||
| pub const USER_PROOFS_AGGREGATOR_PROGRAM_IMAGE_ID: [u8; 32] = [ | ||
| 83, 145, 39, 254, 127, 217, 146, 127, 63, 217, 69, 190, 11, 204, 170, 138, 215, 35, 175, 246, | ||
| 209, 154, 52, 243, 85, 37, 177, 147, 22, 153, 155, 156, | ||
| ]; | ||
|
|
||
| fn main() { | ||
| let input = env::read::<ChunkAggregatorInput>(); | ||
|
|
||
| let mut leaves: Vec<Hash32> = vec![]; | ||
|
|
||
| for (proof, leaves_commitment) in input.proofs_and_leaves_commitment { | ||
| let image_id = proof.image_id; | ||
|
|
||
| // Ensure the aggregated chunk originates from the L1 aggregation program. | ||
| // This validation step guarantees that the proof was genuinely verified | ||
| // by this program. Without this check, a different program using the | ||
| // same public inputs could bypass verification. | ||
| assert!(image_id == USER_PROOFS_AGGREGATOR_PROGRAM_IMAGE_ID); | ||
|
|
||
| // Ensure the committed root matches the root of the provided leaves | ||
| let merkle_root: [u8; 32] = proof | ||
| .public_inputs | ||
| .clone() | ||
| .try_into() | ||
| .expect("Public input to be the chunk merkle root"); | ||
|
|
||
| let leaves_commitment: Vec<Hash32> = | ||
| leaves_commitment.into_iter().map(|el| Hash32(el)).collect(); | ||
| let merkle_tree = MerkleTree::<Hash32>::build(&leaves_commitment).unwrap(); | ||
| assert!(merkle_root == merkle_tree.root); | ||
|
|
||
| leaves.extend(leaves_commitment); | ||
|
|
||
| // finally verify the proof | ||
| env::verify(image_id, &proof.public_inputs).expect("proof to be verified correctly"); | ||
| } | ||
|
|
||
| let merkle_tree = MerkleTree::<Hash32>::build(&leaves).unwrap(); | ||
|
|
||
| env::commit_slice(&merkle_tree.root); | ||
| } |
This file contains hidden or 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 was deleted.
Oops, something went wrong.
22 changes: 22 additions & 0 deletions
22
aggregation_mode/aggregation_programs/risc0/src/user_proofs_aggregator_main.rs
This file contains hidden or 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,22 @@ | ||
| #![no_main] | ||
|
|
||
| use lambdaworks_crypto::merkle_tree::merkle::MerkleTree; | ||
| use risc0_aggregation_program::{Risc0ImageIdAndPubInputs, UserProofsAggregatorInput}; | ||
| use risc0_zkvm::guest::env; | ||
|
|
||
| risc0_zkvm::guest::entry!(main); | ||
|
|
||
| fn main() { | ||
| let input = env::read::<UserProofsAggregatorInput>(); | ||
|
|
||
| for proof in &input.proofs_image_id_and_pub_inputs { | ||
| env::verify(proof.image_id.clone(), &proof.public_inputs) | ||
| .expect("proof to be verified correctly"); | ||
| } | ||
|
|
||
| let merkle_tree = | ||
| MerkleTree::<Risc0ImageIdAndPubInputs>::build(&input.proofs_image_id_and_pub_inputs) | ||
| .unwrap(); | ||
|
|
||
| env::commit_slice(&merkle_tree.root); | ||
| } |
This file contains hidden or 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
50 changes: 50 additions & 0 deletions
50
aggregation_mode/aggregation_programs/sp1/src/chunk_aggregator_main.rs
This file contains hidden or 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,50 @@ | ||
| #![no_main] | ||
| sp1_zkvm::entrypoint!(main); | ||
|
|
||
| use lambdaworks_crypto::merkle_tree::merkle::MerkleTree; | ||
| use sha2::{Digest, Sha256}; | ||
| use sp1_aggregation_program::{ChunkAggregatorInput, Hash32}; | ||
|
|
||
| // Generated with `make agg_mode_write_program_ids` and copied from program_ids.json | ||
| pub const USER_PROOFS_AGGREGATOR_PROGRAM_VK_HASH: [u32; 8] = [ | ||
| 684911098, 272834847, 1514192666, 1104122402, 1853418149, 488480116, 2005139814, 1901405498, | ||
| ]; | ||
|
|
||
| pub fn main() { | ||
| let input = sp1_zkvm::io::read::<ChunkAggregatorInput>(); | ||
|
|
||
| let mut leaves = vec![]; | ||
|
|
||
| // Verify the proofs. | ||
| for (proof, leaves_commitment) in input.proofs_and_leaves_commitment { | ||
| let vkey = proof.vk; | ||
| let public_values_digest = Sha256::digest(&proof.public_inputs); | ||
|
|
||
| // Ensure the aggregated chunk originates from the L1 aggregation program. | ||
| // This validation step guarantees that the proof was genuinely verified | ||
| // by this program. Without this check, a different program using the | ||
| // same public inputs could bypass verification. | ||
| assert!(proof.vk == USER_PROOFS_AGGREGATOR_PROGRAM_VK_HASH); | ||
|
|
||
| let merkle_root: [u8; 32] = proof | ||
| .public_inputs | ||
| .clone() | ||
| .try_into() | ||
| .expect("Public input to be the hash of the chunk tree"); | ||
|
|
||
| // Reconstruct the merkle tree and verify that the roots match | ||
| let leaves_commitment: Vec<Hash32> = | ||
| leaves_commitment.into_iter().map(|el| Hash32(el)).collect(); | ||
| let merkle_tree: MerkleTree<Hash32> = MerkleTree::build(&leaves_commitment).unwrap(); | ||
| assert!(merkle_tree.root == merkle_root); | ||
|
|
||
| leaves.extend(leaves_commitment); | ||
|
|
||
| sp1_zkvm::lib::verify::verify_sp1_proof(&vkey, &public_values_digest.into()); | ||
| } | ||
|
|
||
| // Finally, compute the final merkle root with all the leaves | ||
| let merkle_tree: MerkleTree<Hash32> = MerkleTree::build(&leaves).unwrap(); | ||
|
|
||
| sp1_zkvm::io::commit_slice(&merkle_tree.root); | ||
| } | ||
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.