Skip to content

Commit cb3829a

Browse files
MarcosNicolaumaximopalopoliMauroToscano
authored
feat(aggregation-mode): proving system id for proof commitments (#2174)
Co-authored-by: Maximo Palopoli <[email protected]> Co-authored-by: Mauro Toscano <[email protected]>
1 parent d603f66 commit cb3829a

23 files changed

+2268
-2301
lines changed

aggregation_mode/abi/AlignedProofAggregationService.json

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

aggregation_mode/aggregation_programs/risc0/src/chunk_aggregator_main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ risc0_zkvm::guest::entry!(main);
88

99
// Generated with `make proof_aggregator_write_program_ids` and copied from program_ids.json
1010
pub const USER_PROOFS_AGGREGATOR_PROGRAM_IMAGE_ID: [u8; 32] = [
11-
246, 152, 137, 29, 200, 71, 68, 14, 148, 211, 69, 210, 38, 88, 167, 181, 85, 190, 249, 99, 59,
12-
170, 43, 133, 188, 222, 95, 79, 87, 222, 76, 175,
11+
253, 36, 51, 43, 163, 223, 190, 136, 60, 123, 233, 240, 170, 213, 170, 76, 117, 219, 15, 0, 47,
12+
81, 218, 228, 232, 218, 86, 42, 145, 190, 144, 161,
1313
];
1414

1515
fn main() {

aggregation_mode/aggregation_programs/risc0/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ use lambdaworks_crypto::merkle_tree::traits::IsMerkleTreeBackend;
22
use serde::{Deserialize, Serialize};
33
use tiny_keccak::{Hasher, Keccak};
44

5+
const RISC0_PROVING_SYSTEM_ID: u16 = 2;
6+
57
#[derive(Serialize, Deserialize)]
68
pub struct Risc0ImageIdAndPubInputs {
79
pub image_id: [u8; 32],
@@ -11,6 +13,7 @@ pub struct Risc0ImageIdAndPubInputs {
1113
impl Risc0ImageIdAndPubInputs {
1214
pub fn commitment(&self) -> [u8; 32] {
1315
let mut hasher = Keccak::v256();
16+
hasher.update(&RISC0_PROVING_SYSTEM_ID.to_be_bytes());
1417
for &word in &self.image_id {
1518
hasher.update(&word.to_be_bytes());
1619
}

aggregation_mode/aggregation_programs/sp1/src/chunk_aggregator_main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use sp1_aggregation_program::{ChunkAggregatorInput, Hash32};
77

88
// Generated with `make proof_aggregator_write_program_ids` and copied from program_ids.json
99
pub const USER_PROOFS_AGGREGATOR_PROGRAM_VK_HASH: [u32; 8] = [
10-
1568672557, 1699162914, 9186125, 1196115399, 1766446440, 1385693297, 1976910968, 278007428,
10+
1783055897, 486133361, 187778113, 1130718359, 781594768, 1430967573, 1107098593, 1119970919,
1111
];
1212

1313
pub fn main() {

aggregation_mode/aggregation_programs/sp1/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ use lambdaworks_crypto::merkle_tree::traits::IsMerkleTreeBackend;
22
use serde::{Deserialize, Serialize};
33
use sha3::{Digest, Keccak256};
44

5+
const SP1_PROVING_SYSTEM_ID: u16 = 1;
6+
57
#[derive(Serialize, Deserialize)]
68
pub struct SP1VkAndPubInputs {
79
pub vk: [u32; 8],
@@ -11,6 +13,7 @@ pub struct SP1VkAndPubInputs {
1113
impl SP1VkAndPubInputs {
1214
pub fn commitment(&self) -> [u8; 32] {
1315
let mut hasher = Keccak256::new();
16+
hasher.update(&SP1_PROVING_SYSTEM_ID.to_be_bytes());
1417
for &word in &self.vk {
1518
hasher.update(word.to_be_bytes());
1619
}

aggregation_mode/programs_ids.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
2-
"risc0_chunk_aggregator_image_id": "0x4cc11a4ac146ce4fc71493d694a9707194316cbb609603a195ffbe0c4c099c97",
3-
"risc0_user_proofs_aggregator_image_id": "0xf698891dc847440e94d345d22658a7b555bef9633baa2b85bcde5f4f57de4caf",
4-
"risc0_user_proofs_aggregator_image_id_bytes": "[246, 152, 137, 29, 200, 71, 68, 14, 148, 211, 69, 210, 38, 88, 167, 181, 85, 190, 249, 99, 59, 170, 43, 133, 188, 222, 95, 79, 87, 222, 76, 175]",
5-
"sp1_chunk_aggregator_vk_hash": "0x00a18429d092a8e1f58aea6ff650ad715ad4e6d7056600bb201d38460244507b",
6-
"sp1_user_proofs_aggregator_vk_hash": "0x00bb00165b951cac8804615a6c74b45c7d293aad14a6001c7aeaa23c10920e84",
7-
"sp1_user_proofs_aggregator_vk_hash_words": "[1568672557, 1699162914, 9186125, 1196115399, 1766446440, 1385693297, 1976910968, 278007428]"
2+
"risc0_chunk_aggregator_image_id": "0xd8cfdd5410c70395c0a1af1842a0148428cc46e353355faccfba694dd4862dbf",
3+
"risc0_user_proofs_aggregator_image_id": "0xfd24332ba3dfbe883c7be9f0aad5aa4c75db0f002f51dae4e8da562a91be90a1",
4+
"risc0_user_proofs_aggregator_image_id_bytes": "[253, 36, 51, 43, 163, 223, 190, 136, 60, 123, 233, 240, 170, 213, 170, 76, 117, 219, 15, 0, 47, 81, 218, 228, 232, 218, 86, 42, 145, 190, 144, 161]",
5+
"sp1_chunk_aggregator_vk_hash": "0x00ba19eed0aaeb0151f07b8d3ee7c659bcd29f3021e48fb42766882f55b84509",
6+
"sp1_user_proofs_aggregator_vk_hash": "0x00d48e8c3273e739c4598a220c36564975d2c6121552b54560fe7df0c2c16667",
7+
"sp1_user_proofs_aggregator_vk_hash_words": "[1783055897, 486133361, 187778113, 1130718359, 781594768, 1430967573, 1107098593, 1119970919]"
88
}

aggregation_mode/src/aggregators/risc0_aggregator.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
include!(concat!(env!("OUT_DIR"), "/methods.rs"));
22

3+
use aligned_sdk::aggregation_layer::AggregationModeProvingSystem;
34
use risc0_zkvm::{default_prover, ExecutorEnv, ProverOpts, Receipt};
45
use sha3::{Digest, Keccak256};
56

@@ -80,6 +81,7 @@ pub const RISC0_CHUNK_AGGREGATOR_PROGRAM_ID_BYTES: [u8; 32] = {
8081
impl Risc0ProofReceiptAndImageId {
8182
pub fn hash_image_id_and_public_inputs(&self) -> [u8; 32] {
8283
let mut hasher = Keccak256::new();
84+
hasher.update(AggregationModeProvingSystem::RISC0.id_bytes());
8385
hasher.update(self.image_id);
8486
hasher.update(self.public_inputs());
8587
hasher.finalize().into()

aggregation_mode/src/aggregators/sp1_aggregator.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use std::sync::LazyLock;
22

3+
use aligned_sdk::aggregation_layer::AggregationModeProvingSystem;
34
use alloy::primitives::Keccak256;
45
use sp1_aggregation_program::SP1VkAndPubInputs;
56
#[cfg(feature = "prove")]
@@ -63,6 +64,7 @@ impl SP1ProofWithPubValuesAndElf {
6364

6465
pub fn hash_vk_and_pub_inputs(&self) -> [u8; 32] {
6566
let mut hasher = Keccak256::new();
67+
hasher.update(AggregationModeProvingSystem::SP1.id_bytes());
6668
let vk_bytes = &self.vk.hash_bytes();
6769
hasher.update(vk_bytes);
6870
hasher.update(self.proof_with_pub_values.public_values.as_slice());

contracts/script/deploy/config/devnet/proof-aggregator-service.devnet.config.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
"alignedAggregatorAddressPrivateKey": "0x2a871d0798f97d79848a013d4936a73bf4cc922c825d33c1cf7073dff6d409c6"
77
},
88
"programs_id": {
9-
"sp1AggregationProgramVKHash": "0x00a18429d092a8e1f58aea6ff650ad715ad4e6d7056600bb201d38460244507b",
10-
"risc0AggregationProgramImageId": "0x4cc11a4ac146ce4fc71493d694a9707194316cbb609603a195ffbe0c4c099c97"
9+
"sp1AggregationProgramVKHash": "0x00ba19eed0aaeb0151f07b8d3ee7c659bcd29f3021e48fb42766882f55b84509",
10+
"risc0AggregationProgramImageId": "0xd8cfdd5410c70395c0a1af1842a0148428cc46e353355faccfba694dd4862dbf"
1111
},
1212
"permissions": {
1313
"owner": "0x14dC79964da2C08b23698B3D3cc7Ca32193d9955"

contracts/script/deploy/config/devnet/proof-aggregator-service.devnet.mock.config.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
"alignedAggregatorAddressPrivateKey": "0x2a871d0798f97d79848a013d4936a73bf4cc922c825d33c1cf7073dff6d409c6"
77
},
88
"programs_id": {
9-
"sp1AggregationProgramVKHash": "0x00a18429d092a8e1f58aea6ff650ad715ad4e6d7056600bb201d38460244507b",
10-
"risc0AggregationProgramImageId": "0x4cc11a4ac146ce4fc71493d694a9707194316cbb609603a195ffbe0c4c099c97"
9+
"sp1AggregationProgramVKHash": "0x00ba19eed0aaeb0151f07b8d3ee7c659bcd29f3021e48fb42766882f55b84509",
10+
"risc0AggregationProgramImageId": "0xd8cfdd5410c70395c0a1af1842a0148428cc46e353355faccfba694dd4862dbf"
1111
},
1212
"permissions": {
1313
"owner": "0x14dC79964da2C08b23698B3D3cc7Ca32193d9955"

0 commit comments

Comments
 (0)