Skip to content

Commit 4478134

Browse files
committed
feat: risc0 sdk and aligned cli
1 parent 5e43630 commit 4478134

2 files changed

Lines changed: 36 additions & 14 deletions

File tree

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ pub enum AggregationModeVerificationData {
1818
vk: [u8; 32],
1919
public_inputs: Vec<u8>,
2020
},
21+
Risc0 {
22+
image_id: [u8; 32],
23+
public_inputs: Vec<u8>,
24+
},
2125
}
2226

2327
impl AggregationModeVerificationData {
@@ -29,6 +33,15 @@ impl AggregationModeVerificationData {
2933
hasher.update(public_inputs);
3034
hasher.finalize().into()
3135
}
36+
AggregationModeVerificationData::Risc0 {
37+
image_id,
38+
public_inputs,
39+
} => {
40+
let mut hasher = Keccak256::new();
41+
hasher.update(image_id);
42+
hasher.update(public_inputs);
43+
hasher.finalize().into()
44+
}
3245
}
3346
}
3447
}

batcher/aligned/src/main.rs

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -325,8 +325,12 @@ pub struct VerifyProofInAggModeArgs {
325325
proving_system: ProvingSystemArg,
326326
#[arg(name = "Public input file name", long = "public_input")]
327327
pub_input_file_name: Option<PathBuf>,
328-
#[arg(name = "Verification key hash", long = "vk", required = true)]
329-
verification_key_hash: PathBuf,
328+
#[arg(
329+
name = "Verification key hash",
330+
long = "--program-id-file",
331+
required = true
332+
)]
333+
program_id_file: PathBuf,
330334
}
331335

332336
#[derive(Args, Debug)]
@@ -790,20 +794,25 @@ async fn main() -> Result<(), AlignedError> {
790794
return Ok(());
791795
}
792796
AlignedCommands::VerifyProofInAggMode(args) => {
793-
let proof_data = match args.proving_system {
794-
ProvingSystemArg::SP1 => {
795-
let vk = read_file(args.verification_key_hash)?
796-
.try_into()
797-
.expect("Invalid hexadecimal encoded vk hash");
797+
let program_id_key = read_file(args.program_id_file)?
798+
.try_into()
799+
.expect("Invalid hexadecimal encoded vk hash");
798800

799-
let Some(pub_inputs_file_name) = args.pub_input_file_name else {
800-
error!("Public input file not provided");
801-
return Ok(());
802-
};
803-
let public_inputs = read_file(pub_inputs_file_name)?;
801+
let Some(pub_inputs_file_name) = args.pub_input_file_name else {
802+
error!("Public input file not provided");
803+
return Ok(());
804+
};
805+
let public_inputs = read_file(pub_inputs_file_name)?;
804806

805-
AggregationModeVerificationData::SP1 { vk, public_inputs }
806-
}
807+
let proof_data = match args.proving_system {
808+
ProvingSystemArg::SP1 => AggregationModeVerificationData::SP1 {
809+
vk: program_id_key,
810+
public_inputs,
811+
},
812+
ProvingSystemArg::Risc0 => AggregationModeVerificationData::Risc0 {
813+
image_id: program_id_key,
814+
public_inputs,
815+
},
807816
_ => {
808817
error!("Proving system not supported in aggregation mode");
809818
return Ok(());

0 commit comments

Comments
 (0)