11// Copyright 2025 Irreducible Inc.
2- use criterion:: { Criterion , black_box, criterion_group, criterion_main} ;
3- use leansig_core:: spec:: { SPEC_1 , SPEC_2 , Spec } ;
4- use sp1_sdk:: { ProverClient , SP1Stdin , SP1ProofWithPublicValues } ;
2+ use criterion:: { black_box, criterion_group, criterion_main, Criterion } ;
3+ use leansig_core:: spec:: { Spec , SPEC_1 , SPEC_2 } ;
54use leansig_shared:: { create_test_data, XmssTestData } ;
5+ use sp1_sdk:: { ProverClient , SP1ProofWithPublicValues , SP1Stdin } ;
66use std:: time:: { Duration , Instant } ;
77
8- const ELF : & [ u8 ] = include_bytes ! ( "../../../../target/elf-compilation/riscv32im-succinct-zkvm-elf/release/sp1-guest" ) ;
8+ const ELF : & [ u8 ] = include_bytes ! (
9+ "../../../../target/elf-compilation/riscv32im-succinct-zkvm-elf/release/sp1-guest"
10+ ) ;
911
1012/// Configuration parameters for benchmarking
1113struct BenchmarkConfig {
@@ -64,40 +66,35 @@ impl Job {
6466 config. num_validators ,
6567 config. spec . clone ( ) ,
6668 config. tree_height ,
67- 10000 , // max_retries for nonce grinding
68- None , // use default message [42; 32]
69- None , // use default epoch 0
69+ 10000 , // max_retries for nonce grinding
70+ None , // use default message [42; 32]
71+ None , // use default epoch 0
7072 ) ;
7173
72- Self {
73- test_data,
74- }
74+ Self { test_data }
7575 }
7676
7777 /// Execute witness generation phase (SP1 setup + stdin preparation)
7878 fn exec_compute ( & self ) -> ( SP1Stdin , Duration ) {
7979 let start = Instant :: now ( ) ;
80-
80+
8181 let mut stdin = SP1Stdin :: new ( ) ;
8282 stdin. write ( & self . test_data ) ;
83-
83+
8484 let elapsed = start. elapsed ( ) ;
8585
8686 ( stdin, elapsed)
8787 }
8888
8989 /// Execute proving phase
90- fn prove_stdin (
91- & self ,
92- stdin : & SP1Stdin ,
93- ) -> ( SP1ProofWithPublicValues , Duration ) {
90+ fn prove_stdin ( & self , stdin : & SP1Stdin ) -> ( SP1ProofWithPublicValues , Duration ) {
9491 let client = ProverClient :: from_env ( ) ;
9592 let ( pk, _vk) = client. setup ( ELF ) ;
96-
93+
9794 let start = Instant :: now ( ) ;
9895 let proof = client. prove ( & pk, stdin) . run ( ) . unwrap ( ) ;
9996 let elapsed = start. elapsed ( ) ;
100-
97+
10198 ( proof, elapsed)
10299 }
103100}
@@ -156,7 +153,7 @@ fn xmss_benchmarks(c: &mut Criterion) {
156153 // We need to recreate stdin for each iteration since it gets consumed
157154 let mut fresh_stdin = SP1Stdin :: new ( ) ;
158155 fresh_stdin. write ( & job. test_data ) ;
159-
156+
160157 let ( proof, _duration) = job. prove_stdin ( & fresh_stdin) ;
161158 black_box ( proof) ;
162159 } ) ;
@@ -177,7 +174,7 @@ fn xmss_benchmarks(c: &mut Criterion) {
177174 group. bench_function ( "proof_verification" , |b| {
178175 let client = ProverClient :: from_env ( ) ;
179176 let ( _pk, vk) = client. setup ( ELF ) ;
180-
177+
181178 b. iter ( || {
182179 client. verify ( & proof, & vk) . unwrap ( ) ;
183180 } ) ;
@@ -186,10 +183,14 @@ fn xmss_benchmarks(c: &mut Criterion) {
186183 // Print additional metrics
187184 println ! ( "\n SP1 Additional Metrics:" ) ;
188185 let proof_size_bytes = bincode:: serialize ( & proof) . unwrap ( ) . len ( ) ;
189- println ! ( " Proof Size: {:.2} KiB ({} bytes)" , proof_size_bytes as f64 / 1024.0 , proof_size_bytes) ;
186+ println ! (
187+ " Proof Size: {:.2} KiB ({} bytes)" ,
188+ proof_size_bytes as f64 / 1024.0 ,
189+ proof_size_bytes
190+ ) ;
190191
191192 group. finish ( ) ;
192193}
193194
194195criterion_group ! ( sp1_xmss_signature, xmss_benchmarks) ;
195- criterion_main ! ( sp1_xmss_signature) ;
196+ criterion_main ! ( sp1_xmss_signature) ;
0 commit comments