Skip to content

Commit 5f000bf

Browse files
committed
feat: add Zisk aggregator support to proof aggregation system
1 parent 6e96c85 commit 5f000bf

File tree

13 files changed

+421
-37
lines changed

13 files changed

+421
-37
lines changed

aggregation_mode/Cargo.lock

Lines changed: 106 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

aggregation_mode/proof_aggregator/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ sp1_aggregation_program = { path = "./aggregation_programs/sp1" }
2929
risc0-zkvm = { workspace = true }
3030
risc0_aggregation_program = { path = "./aggregation_programs/risc0" }
3131
risc0-ethereum-contracts = { git = "https://github.com/risc0/risc0-ethereum/", tag = "v3.0.0" }
32+
zisk_aggregation_program = { path = "./aggregation_programs/zisk" }
3233

3334
[build-dependencies]
3435
sp1-build = { version = "5.0.0" }

aggregation_mode/proof_aggregator/abi/AlignedProofAggregationService.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

aggregation_mode/proof_aggregator/aggregation_programs/zisk/src/chunk_aggregator_main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ pub fn main() {
6363

6464
leaves.extend(leaves_commitment);
6565

66-
proofman_verifier::verify(&proof.proof, &proof.vk);
66+
proofman_verifier::verify(&proof.proof, &input.vk);
6767
}
6868

6969
// Finally, compute the final merkle root with all the leaves

aggregation_mode/proof_aggregator/aggregation_programs/zisk/src/lib.rs

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,41 @@ use serde::{Deserialize, Serialize};
33
use sha2::Digest;
44
use sha3::Keccak256;
55

6+
const ZISK_PROVING_SYSTEM_ID: u16 = 1;
7+
68
#[derive(Serialize, Deserialize)]
79
pub struct ChunkAggregatorInput {
8-
pub proofs_and_leaves_commitment: Vec<(ZiskProofAndVk, Vec<[u8; 32]>)>,
10+
pub proofs_and_leaves_commitment: Vec<(ZiskProof, Vec<[u8; 32]>)>,
11+
pub vk: Vec<u8>,
912
}
1013

1114
#[derive(Serialize, Deserialize)]
1215
pub struct UserProofsAggregatorInput {
13-
pub proofs_and_vk: Vec<ZiskProofAndVk>,
16+
pub proofs_and_vk: Vec<ZiskProof>,
17+
pub vk: Vec<u8>,
18+
}
19+
20+
impl UserProofsAggregatorInput {
21+
pub fn new(proofs_and_vk: Vec<ZiskProof>, vk: Vec<u8>) -> Self {
22+
Self { proofs_and_vk, vk }
23+
}
1424
}
1525

1626
#[derive(Serialize, Deserialize)]
17-
pub struct ZiskProofAndVk {
27+
pub struct ZiskProof {
1828
pub proof: Vec<u8>,
19-
pub vk: Vec<u8>,
2029
}
2130

22-
impl ZiskProofAndVk {
23-
pub fn commitment(&self) -> [u8; 32] {
24-
let hash = [0u8; 32];
31+
impl ZiskProof {
32+
pub fn new(proof: Vec<u8>) -> Self {
33+
Self { proof }
34+
}
2535

26-
hash
36+
pub fn commitment(&self) -> [u8; 32] {
37+
let mut hasher = Keccak256::new();
38+
hasher.update(ZISK_PROVING_SYSTEM_ID.to_be_bytes());
39+
hasher.update(&self.proof);
40+
hasher.finalize().into()
2741
}
2842
}
2943

@@ -37,8 +51,8 @@ impl ZiskProofAndVk {
3751
// - crates/sdk/src/aggregation_layer/types.rs
3852
// This one is used in the SDK since
3953
// the user may not have access to the proofs that they didn't submit
40-
impl IsMerkleTreeBackend for ZiskProofAndVk {
41-
type Data = ZiskProofAndVk;
54+
impl IsMerkleTreeBackend for ZiskProof {
55+
type Data = ZiskProof;
4256
type Node = [u8; 32];
4357

4458
fn hash_data(leaf: &Self::Data) -> Self::Node {

aggregation_mode/proof_aggregator/aggregation_programs/zisk/src/user_proofs_aggregator_main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22
ziskos::entrypoint!(main);
33

44
use lambdaworks_crypto::merkle_tree::merkle::MerkleTree;
5-
use zisk_aggregation_program::{UserProofsAggregatorInput, ZiskProofAndVk};
5+
use zisk_aggregation_program::{UserProofsAggregatorInput, ZiskProof};
66

77
fn main() {
88
let input = ziskos::read_input_slice();
99
let input =
1010
bincode::deserialize::<UserProofsAggregatorInput>(&input).expect("correct serialization");
1111

1212
for entry in input.proofs_and_vk.iter() {
13-
proofman_verifier::verify(&entry.proof, &entry.vk);
13+
proofman_verifier::verify(&entry.proof, &input.vk);
1414
}
1515

16-
let merkle_tree = MerkleTree::<ZiskProofAndVk>::build(&input.proofs_and_vk).unwrap();
16+
let merkle_tree = MerkleTree::<ZiskProof>::build(&input.proofs_and_vk).unwrap();
1717

1818
merkle_tree
1919
.root
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
t� ���
2+
a���_���qM�����ɌESS

0 commit comments

Comments
 (0)