@@ -4,55 +4,22 @@ use ultrahonk_rust_verifier::UltraHonkVerifier;
44fn run ( dir : & str ) -> Result < ( ) , String > {
55 let path = Path :: new ( dir) ;
66
7- // Prefer raw proof bytes; fallback to JSON fields if missing
8- let proof_path = path. join ( "proof" ) ;
9- let proof_bytes: Vec < u8 > = if proof_path. exists ( ) {
10- fs:: read ( & proof_path) . map_err ( |e| e. to_string ( ) ) ?
11- } else {
12- let proof_fields_json =
13- fs:: read_to_string ( path. join ( "proof_fields.json" ) ) . map_err ( |e| e. to_string ( ) ) ?;
14- let proof_fields: Vec < String > =
15- serde_json:: from_str ( & proof_fields_json) . map_err ( |e| e. to_string ( ) ) ?;
16- let mut out: Vec < u8 > = Vec :: with_capacity ( proof_fields. len ( ) * 32 ) ;
17- for h in proof_fields {
18- let raw = h. trim_start_matches ( "0x" ) ;
19- let bytes = hex:: decode ( raw) . map_err ( |e| e. to_string ( ) ) ?;
20- let mut padded = vec ! [ 0u8 ; 32 - bytes. len( ) ] ;
21- padded. extend_from_slice ( & bytes) ;
22- out. extend_from_slice ( & padded) ;
23- }
24- out
25- } ;
7+ // Proof bytes
8+ let proof_bytes: Vec < u8 > = fs:: read ( path. join ( "proof" ) ) . map_err ( |e| e. to_string ( ) ) ?;
269
27- // Use JSON VK for deterministic ordering (bb v0.87)
10+ // Use JSON VK
2811 let vk_json = fs:: read_to_string ( path. join ( "vk_fields.json" ) ) . map_err ( |e| e. to_string ( ) ) ?;
2912 let verifier = UltraHonkVerifier :: new_from_json ( & vk_json) ;
3013
31- // Public inputs: prefer raw bytes; fallback to JSON fields
32- let mut pub_inputs_bytes: Vec < Vec < u8 > > = Vec :: new ( ) ;
33- let pub_inputs_path = path. join ( "public_inputs" ) ;
34- if pub_inputs_path. exists ( ) {
35- let buf = fs:: read ( & pub_inputs_path) . map_err ( |e| e. to_string ( ) ) ?;
36- assert ! (
37- buf. len( ) % 32 == 0 ,
38- "public_inputs must be multiple of 32 bytes"
39- ) ;
40- for chunk in buf. chunks ( 32 ) {
41- pub_inputs_bytes. push ( chunk. to_vec ( ) ) ;
42- }
43- } else {
44- let pub_inputs_fields_json = fs:: read_to_string ( path. join ( "public_inputs_fields.json" ) )
45- . map_err ( |e| e. to_string ( ) ) ?;
46- let pub_inputs_fields: Vec < String > =
47- serde_json:: from_str ( & pub_inputs_fields_json) . map_err ( |e| e. to_string ( ) ) ?;
48- pub_inputs_bytes. reserve ( pub_inputs_fields. len ( ) ) ;
49- for h in pub_inputs_fields {
50- let raw = h. trim_start_matches ( "0x" ) ;
51- let bytes = hex:: decode ( raw) . map_err ( |e| e. to_string ( ) ) ?;
52- let mut padded = vec ! [ 0u8 ; 32 - bytes. len( ) ] ;
53- padded. extend_from_slice ( & bytes) ;
54- pub_inputs_bytes. push ( padded) ;
55- }
14+ // Public inputs bytes
15+ let buf = fs:: read ( path. join ( "public_inputs" ) ) . map_err ( |e| e. to_string ( ) ) ?;
16+ assert ! (
17+ buf. len( ) % 32 == 0 ,
18+ "public_inputs must be multiple of 32 bytes"
19+ ) ;
20+ let mut pub_inputs_bytes: Vec < Vec < u8 > > = Vec :: with_capacity ( buf. len ( ) / 32 ) ;
21+ for chunk in buf. chunks ( 32 ) {
22+ pub_inputs_bytes. push ( chunk. to_vec ( ) ) ;
5623 }
5724
5825 verifier. verify ( & proof_bytes, & pub_inputs_bytes) ?;
0 commit comments