Skip to content

Commit 9878029

Browse files
committed
fix: u8 for u16 in proving system id
1 parent 85db268 commit 9878029

File tree

10 files changed

+32
-21
lines changed

10 files changed

+32
-21
lines changed

aggregation_mode/abi/AlignedProofAggregationService.json

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

aggregation_mode/src/aggregators/risc0_aggregator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ pub const RISC0_CHUNK_AGGREGATOR_PROGRAM_ID_BYTES: [u8; 32] = {
8181
impl Risc0ProofReceiptAndImageId {
8282
pub fn hash_image_id_and_public_inputs(&self) -> [u8; 32] {
8383
let mut hasher = Keccak256::new();
84-
hasher.update([AggregationModeProvingSystem::RISC0.id()]);
84+
hasher.update(AggregationModeProvingSystem::RISC0.id_bytes());
8585
hasher.update(self.image_id);
8686
hasher.update(self.public_inputs());
8787
hasher.finalize().into()

aggregation_mode/src/aggregators/sp1_aggregator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ impl SP1ProofWithPubValuesAndElf {
6464

6565
pub fn hash_vk_and_pub_inputs(&self) -> [u8; 32] {
6666
let mut hasher = Keccak256::new();
67-
hasher.update([AggregationModeProvingSystem::SP1.id()]);
67+
hasher.update(AggregationModeProvingSystem::SP1.id_bytes());
6868
let vk_bytes = &self.vk.hash_bytes();
6969
hasher.update(vk_bytes);
7070
hasher.update(self.proof_with_pub_values.public_values.as_slice());

contracts/src/core/AlignedProofAggregationService.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,14 +111,14 @@ contract AlignedProofAggregationService is
111111
/// - The function returns `true` if this Merkle root is known to correspond to a valid aggregated proof.
112112
///
113113
/// @param merklePath The Merkle proof (sibling hashes) needed to reconstruct the Merkle root.
114-
/// @param provingSystemId The id of the proving system (0 for SP1, 1 for RISC0).
114+
/// @param provingSystemId The id of the proving system (1 for SP1, 2 for RISC0).
115115
/// @param programId The identifier for the ZK program (image_id in RISC0 or vk hash in SP1).
116116
/// @param publicInputs The public inputs bytes of the proof.
117117
///
118118
/// @return bool Returns true if the computed Merkle root is a recognized valid aggregated proof.
119119
function verifyProofInclusion(
120120
bytes32[] calldata merklePath,
121-
uint8 provingSystemId,
121+
uint16 provingSystemId,
122122
bytes32 programId,
123123
bytes calldata publicInputs
124124
) public view returns (bool) {

contracts/src/core/IAlignedProofAggregationService.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ interface IAlignedProofAggregationService {
3030

3131
function verifyProofInclusion(
3232
bytes32[] calldata merklePath,
33-
uint8 provingSystemId,
33+
uint16 provingSystemId,
3434
bytes32 programId,
3535
bytes calldata publicInputs
3636
) external view returns (bool);

crates/sdk/abi/AlignedProofAggregationService.json

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

crates/sdk/src/aggregation_layer/types.rs

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,24 @@ use sha3::{Digest, Keccak256};
33

44
use crate::beacon::BeaconClientError;
55

6-
#[repr(u8)]
6+
#[repr(u16)]
77
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
88
pub enum AggregationModeProvingSystem {
9-
SP1 = 0,
10-
RISC0 = 1,
9+
SP1 = 1,
10+
RISC0 = 2,
1111
}
1212

1313
impl AggregationModeProvingSystem {
14-
pub const fn as_u8(self) -> u8 {
15-
self as u8
14+
pub const fn as_u16(self) -> u16 {
15+
self as u16
1616
}
1717

18-
pub const fn id(self) -> u8 {
19-
self.as_u8()
18+
pub const fn id(self) -> u16 {
19+
self.as_u16()
20+
}
21+
22+
pub const fn id_bytes(self) -> [u8; 2] {
23+
self.as_u16().to_be_bytes()
2024
}
2125
}
2226

@@ -59,18 +63,25 @@ impl AggregationModeVerificationData {
5963
}
6064
}
6165

62-
pub fn proving_system_id(&self) -> u8 {
66+
pub fn proving_system_id(&self) -> u16 {
6367
match self {
6468
Self::SP1 { .. } => AggregationModeProvingSystem::SP1.id(),
6569
Self::Risc0 { .. } => AggregationModeProvingSystem::RISC0.id(),
6670
}
6771
}
6872

73+
pub fn proving_system_id_bytes(&self) -> [u8; 2] {
74+
match self {
75+
Self::SP1 { .. } => AggregationModeProvingSystem::SP1.id_bytes(),
76+
Self::Risc0 { .. } => AggregationModeProvingSystem::RISC0.id_bytes(),
77+
}
78+
}
79+
6980
pub fn commitment(&self) -> [u8; 32] {
7081
match self {
7182
AggregationModeVerificationData::SP1 { vk, public_inputs } => {
7283
let mut hasher = Keccak256::new();
73-
hasher.update([self.proving_system_id()]);
84+
hasher.update(self.proving_system_id_bytes());
7485
hasher.update(vk);
7586
hasher.update(public_inputs);
7687
hasher.finalize().into()
@@ -80,7 +91,7 @@ impl AggregationModeVerificationData {
8091
public_inputs,
8192
} => {
8293
let mut hasher = Keccak256::new();
83-
hasher.update([self.proving_system_id()]);
94+
hasher.update(self.proving_system_id_bytes());
8495
hasher.update(image_id);
8596
hasher.update(public_inputs);
8697
hasher.finalize().into()

examples/l2/contracts/src/StateTransition.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ contract StateTransition {
2222
stateRoot = initialStateRoot;
2323
}
2424

25-
function updateState(uint8 provingSystemId, bytes calldata publicInputs, bytes32[] calldata merkleProof)
25+
function updateState(uint16 provingSystemId, bytes calldata publicInputs, bytes32[] calldata merkleProof)
2626
public
2727
onlyOwner
2828
{
2929
bytes memory callData = abi.encodeWithSignature(
30-
"verifyProofInclusion(bytes32[],uint8,bytes32,bytes)",
30+
"verifyProofInclusion(bytes32[],uint16,bytes32,bytes)",
3131
merkleProof,
3232
provingSystemId,
3333
PROGRAM_ID,

examples/l2/crates/l2/abi/StateTransition.json

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

examples/l2/crates/l2/src/eth.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ pub async fn send_state_transition_to_chain(
3838

3939
let res = state_transition_contract
4040
.updateState(
41-
AggregationModeProvingSystem::SP1.id().into(),
41+
AggregationModeProvingSystem::SP1.id(),
4242
public_inputs.into(),
4343
merkle_proof,
4444
)

0 commit comments

Comments
 (0)