Skip to content

Commit 4603044

Browse files
committed
docs: add comments on IsMerkleTreeBackend implementations
1 parent 93116ec commit 4603044

4 files changed

Lines changed: 39 additions & 3 deletions

File tree

aggregation_mode/aggregation_programs/risc0/src/lib.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,16 @@ impl Risc0ImageIdAndPubInputs {
2222
}
2323
}
2424

25+
// Note: this MerkleTreeBackend is defined in three places
26+
// aggregation_mode/src/aggregators/mod.rs
27+
// aggregation_mode/src/aggregators/risc0_aggregator.rs and
28+
// aggregation_mode/src/aggregators/sp1_aggregator.rs
29+
// All 3 implementations should match
30+
// The definition on aggregator/mod.rs supports taking proofs from both Risc0 and SP1,
31+
// Additionally, a version that takes the leaves as already hashed data is defined on:
32+
// batcher/aligned-sdk/src/sdk/aggregation.rs
33+
// This one is used in the SDK since,
34+
// the user may not have access to the proofs that he didn't submit
2535
impl IsMerkleTreeBackend for Risc0ImageIdAndPubInputs {
2636
type Data = Risc0ImageIdAndPubInputs;
2737
type Node = [u8; 32];

aggregation_mode/aggregation_programs/sp1/src/lib.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,16 @@ impl SP1VkAndPubInputs {
1919
}
2020
}
2121

22+
// Note: this MerkleTreeBackend is defined in three places
23+
// aggregation_mode/src/aggregators/mod.rs
24+
// aggregation_mode/src/aggregators/risc0_aggregator.rs and
25+
// aggregation_mode/src/aggregators/sp1_aggregator.rs
26+
// All 3 implementations should match
27+
// The definition on aggregator/mod.rs supports taking proofs from both Risc0 and SP1,
28+
// Additionally, a version that takes the leaves as already hashed data is defined on:
29+
// batcher/aligned-sdk/src/sdk/aggregation.rs
30+
// This one is used in the SDK since,
31+
// the user may not have access to the proofs that he didn't submit
2232
impl IsMerkleTreeBackend for SP1VkAndPubInputs {
2333
type Data = SP1VkAndPubInputs;
2434
type Node = [u8; 32];

aggregation_mode/src/aggregators/mod.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,16 @@ impl AlignedProof {
132132
/// — Public inputs.
133133
///
134134
/// Intermediate nodes in the tree are formed by computing the keccak pairs of child nodes.
135-
///
136-
/// Note: this commitment scheme is repeated in both risc0 and sp1 aggregation programs.
137-
/// Therefore, any change to the commitment scheme must be mirrored there.
135+
// Note: this MerkleTreeBackend is defined in three places
136+
// aggregation_mode/src/aggregators/mod.rs
137+
// aggregation_mode/src/aggregators/risc0_aggregator.rs and
138+
// aggregation_mode/src/aggregators/sp1_aggregator.rs
139+
// All 3 implementations should match
140+
// The definition on aggregator/mod.rs supports taking proofs from both Risc0 and SP1,
141+
// Additionally, a version that takes the leaves as already hashed data is defined on:
142+
// batcher/aligned-sdk/src/sdk/aggregation.rs
143+
// This one is used in the SDK since,
144+
// the user may not have access to the proofs that he didn't submit
138145
impl IsMerkleTreeBackend for AlignedProof {
139146
type Data = AlignedProof;
140147
type Node = [u8; 32];

batcher/aligned-sdk/src/sdk/aggregation.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,15 @@ impl AggregationModeVerificationData {
5252
#[derive(Default, Debug, PartialEq, Eq)]
5353
pub struct Hash32([u8; 32]);
5454

55+
// Note:
56+
// We define a version that of the backend that takes the leaves as hashed data
57+
// since the user may not have access to the proofs that he didn't submit
58+
// The original MerkleTreeBackend is defined in three places
59+
// aggregation_mode/src/aggregators/mod.rs
60+
// aggregation_mode/src/aggregators/risc0_aggregator.rs and
61+
// aggregation_mode/src/aggregators/sp1_aggregator.rs
62+
// The definition on aggregator/mod.rs supports taking proofs from both Risc0 and SP1
63+
// Hashes of all implementations should match
5564
impl IsMerkleTreeBackend for Hash32 {
5665
type Data = Hash32;
5766
type Node = [u8; 32];

0 commit comments

Comments
 (0)