@@ -14,15 +14,17 @@ pub const USER_PROOFS_PROGRAM_ROM_VK: [u64; 4] =
1414 vk_bytes_to_u64_4 ( USER_PROOFS_PROGRAM_ROM_VK_BYTES ) ;
1515pub const CHUNK_PROGRAM_ROM_VK : [ u64 ; 4 ] = vk_bytes_to_u64_4 ( CHUNK_PROGRAM_ROM_VK_BYTES ) ;
1616
17- // ELF files for zisk programs
18- const USER_PROOFS_ELF_PATH : & str =
19- "../../aggregation_programs/zisk/elf/zisk_user_proofs_aggregator_program" ;
20- const CHUNK_ELF_PATH : & str = "../../aggregation_programs/zisk/elf/zisk_chunk_aggregator_program" ;
21-
22- // Paths for cargo-zisk prove commands (relative to current_dir)
23- const INPUT_PATH : & str = "input.bin" ;
24- const OUTPUT_PATH : & str = "output" ;
25- const SNARK_OUTPUT_PATH : & str = "snark_output" ;
17+ // Directory where zisk aggregation programs are located (relative to repo root, intended to be run from root with make proof_aggregator_start)
18+ const ZISK_PROGRAMS_DIR : & str = "aggregation_mode/proof_aggregator/aggregation_programs/zisk" ;
19+
20+ // ELF files for zisk programs (relative to ZISK_PROGRAMS_DIR)
21+ const USER_PROOFS_ELF_PATH : & str = "./elf/zisk_user_proofs_aggregator_program" ;
22+ const CHUNK_ELF_PATH : & str = "./elf/zisk_chunk_aggregator_program" ;
23+
24+ // Paths for cargo-zisk prove commands (relative to ZISK_PROGRAMS_DIR)
25+ const INPUT_PATH : & str = "./input.bin" ;
26+ const OUTPUT_PATH : & str = "./output" ;
27+ const SNARK_OUTPUT_PATH : & str = "./snark_output" ;
2628const PROVING_KEY_SNARK_DIR : & str = ".zisk/provingKeySnark" ;
2729
2830const fn vk_bytes_to_u64_4 ( bytes : & [ u8 ] ) -> [ u64 ; 4 ] {
@@ -104,9 +106,12 @@ pub(crate) fn run_user_proofs_aggregator(
104106 ) ;
105107 let input_bytes =
106108 bincode:: serialize ( & input) . map_err ( |e| AlignedZiskError :: Serialization ( e. to_string ( ) ) ) ?;
107- std:: fs:: write ( INPUT_PATH , input_bytes. as_slice ( ) ) ?;
108109
109- command
110+ // Write input file to the zisk programs directory
111+ let input_file_path = format ! ( "{ZISK_PROGRAMS_DIR}/input.bin" ) ;
112+ std:: fs:: write ( & input_file_path, input_bytes. as_slice ( ) ) ?;
113+
114+ let status = command
110115 . env ( "RUSTC" , & zisk_rustc_path)
111116 . args ( [
112117 "prove" ,
@@ -119,9 +124,18 @@ pub(crate) fn run_user_proofs_aggregator(
119124 "-a" ,
120125 "-y" ,
121126 ] )
122- . current_dir ( "../../aggregation_programs/zisk/" ) ;
127+ . current_dir ( ZISK_PROGRAMS_DIR )
128+ . status ( ) ?;
129+
130+ if !status. success ( ) {
131+ return Err ( AlignedZiskError :: Aggregation ( format ! (
132+ "cargo-zisk prove failed with exit code: {:?}" ,
133+ status. code( )
134+ ) ) ) ;
135+ }
123136
124- let proof_bytes = std:: fs:: read ( format ! ( "{OUTPUT_PATH}/vadcop_final_proof.bin" ) ) ?;
137+ let proof_path = format ! ( "{ZISK_PROGRAMS_DIR}/output/vadcop_final_proof.bin" ) ;
138+ let proof_bytes = std:: fs:: read ( & proof_path) ?;
125139 let proof = ZiskStarkProof { proof : proof_bytes } ;
126140
127141 Ok ( proof)
@@ -151,10 +165,13 @@ pub(crate) fn run_chunk_aggregator(
151165 } ;
152166 let input_bytes =
153167 bincode:: serialize ( & input) . map_err ( |e| AlignedZiskError :: Serialization ( e. to_string ( ) ) ) ?;
154- std:: fs:: write ( INPUT_PATH , input_bytes. as_slice ( ) ) ?;
168+
169+ // Write input file to the zisk programs directory
170+ let input_file_path = format ! ( "{ZISK_PROGRAMS_DIR}/input.bin" ) ;
171+ std:: fs:: write ( & input_file_path, input_bytes. as_slice ( ) ) ?;
155172
156173 // generate stark proof
157- command
174+ let status = command
158175 . env ( "RUSTC" , & zisk_rustc_path)
159176 . args ( [
160177 "prove" ,
@@ -168,14 +185,22 @@ pub(crate) fn run_chunk_aggregator(
168185 "-y" ,
169186 "-f" ,
170187 ] )
171- . current_dir ( "../../aggregation_programs/zisk/" ) ;
188+ . current_dir ( ZISK_PROGRAMS_DIR )
189+ . status ( ) ?;
190+
191+ if !status. success ( ) {
192+ return Err ( AlignedZiskError :: Aggregation ( format ! (
193+ "cargo-zisk prove (chunk) failed with exit code: {:?}" ,
194+ status. code( )
195+ ) ) ) ;
196+ }
172197
173198 // wrap it to snark
174199 let stark_proof_path = format ! ( "{OUTPUT_PATH}/vadcop_final_proof.bin" ) ;
175200 let home_dir = std:: env:: var ( "HOME" ) . expect ( "HOME environment variable not set" ) ;
176201 let proving_key_path = format ! ( "{home_dir}/{PROVING_KEY_SNARK_DIR}" ) ;
177202 let mut snark_command = std:: process:: Command :: new ( "cargo-zisk" ) ;
178- snark_command
203+ let snark_status = snark_command
179204 . env ( "RUSTC" , & zisk_rustc_path)
180205 . args ( [
181206 "prove-snark" ,
@@ -186,12 +211,21 @@ pub(crate) fn run_chunk_aggregator(
186211 "-o" ,
187212 SNARK_OUTPUT_PATH ,
188213 ] )
189- . current_dir ( "../../aggregation_programs/zisk/" ) ;
214+ . current_dir ( ZISK_PROGRAMS_DIR )
215+ . status ( ) ?;
216+
217+ if !snark_status. success ( ) {
218+ return Err ( AlignedZiskError :: Aggregation ( format ! (
219+ "cargo-zisk prove-snark failed with exit code: {:?}" ,
220+ snark_status. code( )
221+ ) ) ) ;
222+ }
190223
191- let proof_bytes = std:: fs:: read ( format ! ( "{SNARK_OUTPUT_PATH}/proofs/final_snark_proof.bin" ) ) ?;
192- let public_values_bytes = std:: fs:: read ( format ! (
193- "{SNARK_OUTPUT_PATH}/proofs/final_snark_publics.bin"
194- ) ) ?;
224+ let proof_path = format ! ( "{ZISK_PROGRAMS_DIR}/snark_output/proofs/final_snark_proof.bin" ) ;
225+ let public_values_path =
226+ format ! ( "{ZISK_PROGRAMS_DIR}/snark_output/proofs/final_snark_publics.bin" ) ;
227+ let proof_bytes = std:: fs:: read ( & proof_path) ?;
228+ let public_values_bytes = std:: fs:: read ( & public_values_path) ?;
195229
196230 let proof = ZiskSnarkProof {
197231 proof : proof_bytes,
0 commit comments