Skip to content

Commit fd188cf

Browse files
fix: use the chunk aggregator program IDs in verification
1 parent 3329021 commit fd188cf

File tree

5 files changed

+59
-3
lines changed

5 files changed

+59
-3
lines changed

aggregation_mode/src/backend/mod.rs

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ use fetcher::{ProofsFetcher, ProofsFetcherError};
3737
use merkle_tree::compute_proofs_merkle_root;
3838
use risc0_ethereum_contracts::encode_seal;
3939
use secp256k1::SecretKey;
40-
use sp1_sdk::HashableKey;
4140
use std::str::FromStr;
4241
use tracing::{error, info, warn};
4342
use types::{AlignedProofAggregationService, AlignedProofAggregationServiceContract};
@@ -56,6 +55,7 @@ pub enum AggregatedProofSubmissionError {
5655
ZKVMAggregation(ProofAggregationError),
5756
BuildingMerkleRoot,
5857
MerkleRootMisMatch,
58+
BuildingVKHash(String),
5959
}
6060

6161
pub struct ProofAggregator {
@@ -191,7 +191,24 @@ impl ProofAggregator {
191191
) -> Result<H256, AggregatedProofSubmissionError> {
192192
let calldata = match aggregated_proof {
193193
AlignedProof::SP1(proof) => {
194-
let vk_hash = proof.vk.hash_bytes();
194+
let vk_hash: [u8; 32] = {
195+
let hex_str = self
196+
.config
197+
.sp1_chunk_aggregator_vk_hash
198+
.strip_prefix("0x")
199+
.unwrap_or(&self.config.sp1_chunk_aggregator_vk_hash);
200+
let bytes = hex::decode(hex_str).map_err(|e| {
201+
AggregatedProofSubmissionError::BuildingVKHash(e.to_string())
202+
})?;
203+
if bytes.len() != 32 {
204+
return Err(AggregatedProofSubmissionError::BuildingVKHash(
205+
"vk hash not 32 bytes".into(),
206+
));
207+
}
208+
let mut arr = [0u8; 32];
209+
arr.copy_from_slice(&bytes);
210+
arr
211+
};
195212

196213
encode_calldata(
197214
"verifySP1(bytes32,bytes,bytes,bytes32)",
@@ -215,6 +232,25 @@ impl ProofAggregator {
215232
AggregatedProofSubmissionError::Risc0EncodingSeal(e.to_string())
216233
})?;
217234

235+
let risc0_image_id: [u8; 32] = {
236+
let hex_str = self
237+
.config
238+
.risc0_chunk_aggregator_image_id
239+
.strip_prefix("0x")
240+
.unwrap_or(&self.config.risc0_chunk_aggregator_image_id);
241+
let bytes = hex::decode(hex_str).map_err(|e| {
242+
AggregatedProofSubmissionError::BuildingVKHash(e.to_string())
243+
})?;
244+
if bytes.len() != 32 {
245+
return Err(AggregatedProofSubmissionError::BuildingVKHash(
246+
"risc0 image id not 32 bytes".into(),
247+
));
248+
}
249+
let mut arr = [0u8; 32];
250+
arr.copy_from_slice(&bytes);
251+
arr
252+
};
253+
218254
encode_calldata(
219255
"verifyRisc0(bytes32,bytes,bytes,bytes32)",
220256
&[
@@ -226,7 +262,7 @@ impl ProofAggregator {
226262
proof.receipt.journal.bytes.into(),
227263
),
228264
ethrex_l2_common::calldata::Value::FixedBytes(
229-
proof.image_id.to_vec().into(),
265+
risc0_image_id.to_vec().into(),
230266
),
231267
],
232268
)

config-files/config-proof-aggregator-ethereum-package.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ proofs_per_chunk: 512 # Amount of proofs to process per chunk
1313
# We can aggregate as much proofs as 126.976 / 32 = 3968 per blob
1414
total_proofs_limit: 3968
1515

16+
# These program ids are the ones from the chunk aggregator programs
17+
# Can be found in the Proof Aggregation Service deployment config
18+
sp1_chunk_aggregator_vk_hash: "0x00a18429d092a8e1f58aea6ff650ad715ad4e6d7056600bb201d38460244507b"
19+
risc0_chunk_aggregator_image_id: "0x4cc11a4ac146ce4fc71493d694a9707194316cbb609603a195ffbe0c4c099c97"
20+
1621
ecdsa:
1722
private_key_store_path: "config-files/anvil.proof-aggregator.ecdsa.key.json"
1823
private_key_store_password: ""

config-files/config-proof-aggregator-mock-ethereum-package.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ proofs_per_chunk: 512 # Amount of proofs to process per chunk
1313
# We can aggregate as much proofs as 126.976 / 32 = 3968 per blob
1414
total_proofs_limit: 3968
1515

16+
# These program ids are the ones from the chunk aggregator programs
17+
# Can be found in the Proof Aggregation Service deployment config
18+
sp1_chunk_aggregator_vk_hash: "0x00a18429d092a8e1f58aea6ff650ad715ad4e6d7056600bb201d38460244507b"
19+
risc0_chunk_aggregator_image_id: "0x4cc11a4ac146ce4fc71493d694a9707194316cbb609603a195ffbe0c4c099c97"
20+
1621

1722
ecdsa:
1823
private_key_store_path: "config-files/anvil.proof-aggregator.ecdsa.key.json"

config-files/config-proof-aggregator-mock.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ proofs_per_chunk: 512 # Amount of proofs to process per chunk
1313
# We can aggregate as much proofs as 126.976 / 32 = 3968 per blob
1414
total_proofs_limit: 3968
1515

16+
# These program ids are the ones from the chunk aggregator programs
17+
# Can be found in the Proof Aggregation Service deployment config
18+
sp1_chunk_aggregator_vk_hash: "0x00a18429d092a8e1f58aea6ff650ad715ad4e6d7056600bb201d38460244507b"
19+
risc0_chunk_aggregator_image_id: "0x4cc11a4ac146ce4fc71493d694a9707194316cbb609603a195ffbe0c4c099c97"
20+
1621

1722
ecdsa:
1823
private_key_store_path: "config-files/anvil.proof-aggregator.ecdsa.key.json"

config-files/config-proof-aggregator.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ proofs_per_chunk: 512 # Amount of proofs to process per chunk
1313
# We can aggregate as much proofs as 126.976 / 32 = 3968 per blob
1414
total_proofs_limit: 3968
1515

16+
# These program ids are the ones from the chunk aggregator programs
17+
# Can be found in the Proof Aggregation Service deployment config
18+
sp1_chunk_aggregator_vk_hash: "0x00a18429d092a8e1f58aea6ff650ad715ad4e6d7056600bb201d38460244507b"
19+
risc0_chunk_aggregator_image_id: "0x4cc11a4ac146ce4fc71493d694a9707194316cbb609603a195ffbe0c4c099c97"
20+
1621

1722
ecdsa:
1823
private_key_store_path: "config-files/anvil.proof-aggregator.ecdsa.key.json"

0 commit comments

Comments
 (0)