Skip to content

Commit b31292e

Browse files
MarcosNicolauJuArceMauroToscano
authored
feat: risc0 for sdk and cli (#1886)
Co-authored-by: Julian Arce <[email protected]> Co-authored-by: Mauro Toscano <[email protected]> Co-authored-by: MauroFab <[email protected]>
1 parent d9e91f6 commit b31292e

File tree

3 files changed

+60
-14
lines changed

3 files changed

+60
-14
lines changed

Makefile

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,30 @@ start_proof_aggregator: is_aggregator_set ## Starts proof aggregator with provin
175175
start_proof_aggregator_gpu: is_aggregator_set ## Starts proof aggregator with proving + GPU acceleration (CUDA)
176176
AGGREGATOR=$(AGGREGATOR) SP1_PROVER=cuda cargo run --manifest-path ./aggregation_mode/Cargo.toml --release --features prove,gpu -- config-files/config-proof-aggregator.yaml
177177

178+
verify_aggregated_proof_sp1_holesky_stage:
179+
@echo "Verifying SP1 in aggregated proofs on holesky..."
180+
@cd batcher/aligned/ && \
181+
cargo run verify-agg-proof \
182+
--network holesky-stage \
183+
--from-block $(FROM_BLOCK) \
184+
--proving_system SP1 \
185+
--public_input ../../scripts/test_files/sp1/sp1_fibonacci_4_1_3.pub \
186+
--program-id-file ../../scripts/test_files/sp1/sp1_fibonacci_4_1_3.vk \
187+
--beacon_url $(BEACON_URL) \
188+
--rpc_url https://ethereum-holesky-rpc.publicnode.com
189+
190+
verify_aggregated_proof_risc0_holesky_stage:
191+
@echo "Verifying RISC0 in aggregated proofs on holesky..."
192+
@cd batcher/aligned/ && \
193+
cargo run verify-agg-proof \
194+
--network holesky-stage \
195+
--from-block $(FROM_BLOCK) \
196+
--proving_system Risc0 \
197+
--program-id-file ../../scripts/test_files/risc_zero/fibonacci_proof_generator/fibonacci_id_2_0.bin \
198+
--public_input ../../scripts/test_files/risc_zero/fibonacci_proof_generator/risc_zero_fibonacci_2_0.pub \
199+
--beacon_url $(BEACON_URL) \
200+
--rpc_url https://ethereum-holesky-rpc.publicnode.com
201+
178202
install_aggregation_mode: ## Install the aggregation mode with proving enabled
179203
cargo install --path aggregation_mode --features prove
180204

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)