110 std::string name =
"Barretenberg\nYour favo(u)rite zkSNARK library written in C++, a perfectly good computer "
111 "programming language.";
115 name +=
"\nAztec Virtual Machine (AVM): enabled";
117 name +=
"\nAztec Virtual Machine (AVM): disabled";
119#ifdef ENABLE_AVM_TRANSPILER
120 name +=
"\nAVM Transpiler: enabled";
122 name +=
"\nAVM Transpiler: disabled";
124#ifdef STARKNET_GARAGA_FLAVORS
125 name +=
"\nStarknet Garaga Extensions: enabled";
127 name +=
"\nStarknet Garaga Extensions: disabled";
129 CLI::App app{ name };
130 argv = app.ensure_utf8(argv);
140 app.require_subcommand(0, 1);
144 std::filesystem::path bytecode_path{
"./target/program.json" };
145 std::filesystem::path witness_path{
"./target/witness.gz" };
146 std::filesystem::path ivc_inputs_path{
"./ivc-inputs.msgpack" };
147 std::filesystem::path output_path{
150 std::filesystem::path public_inputs_path{
"./target/public_inputs" };
151 std::filesystem::path proof_path{
"./target/proof" };
152 std::filesystem::path vk_path{
"./target/vk" };
154 flags.oracle_hash_type =
"poseidon2";
156 flags.include_gates_per_opcode =
false;
162 bool show_extended_help =
false;
163 for (
int i = 1; i < argc; ++i) {
164 if (std::string(argv[i]) ==
"--help-extended") {
165 show_extended_help =
true;
170 const std::string advanced_group = show_extended_help ?
"Advanced Options (Aztec/Power Users)" :
"";
171 const std::string aztec_internal_group = show_extended_help ?
"Aztec Internal Commands" :
"";
173 const auto add_output_path_option = [&](CLI::App* subcommand,
auto& _output_path) {
174 return subcommand->add_option(
"--output_path, -o",
176 "Directory to write files or path of file to write, depending on subcommand.");
180 const auto add_help_extended_flag = [&](CLI::App* subcommand) {
181 subcommand->add_flag(
"--help-extended",
"Show all options including advanced ones.");
188 const auto add_ipa_accumulation_flag = [&](CLI::App* subcommand) {
190 ->add_flag(
"--ipa_accumulation",
191 flags.ipa_accumulation,
192 "Accumulate/Aggregate IPA (Inner Product Argument) claims")
193 ->group(advanced_group);
196 const auto add_scheme_option = [&](CLI::App* subcommand) {
201 "The type of proof to be constructed. This can specify a proving system, an accumulation scheme, or a "
202 "particular type of circuit to be constructed and proven for some implicit scheme.")
203 ->envname(
"BB_SCHEME")
204 ->default_val(
"ultra_honk")
205 ->check(CLI::IsMember({
"chonk",
"avm",
"ultra_honk" }).name(
"is_member"))
206 ->
group(advanced_group);
209 const auto add_crs_path_option = [&](CLI::App* subcommand) {
211 ->add_option(
"--crs_path, -c",
213 "Path CRS directory. Missing CRS files will be retrieved from the internet.")
214 ->check(CLI::ExistingDirectory)
215 ->group(advanced_group);
218 const auto add_oracle_hash_option = [&](CLI::App* subcommand) {
222 flags.oracle_hash_type,
223 "The hash function used by the prover as random oracle standing in for a verifier's challenge "
224 "generation. Poseidon2 is to be used for proofs that are intended to be verified inside of a "
225 "circuit. Keccak is optimized for verification in an Ethereum smart contract, where Keccak "
226 "has a privileged position due to the existence of an EVM precompile. Starknet is optimized "
227 "for verification in a Starknet smart contract, which can be generated using the Garaga library. "
228 "Prefer using --verifier_target instead.")
229 ->check(CLI::IsMember({
"poseidon2",
"keccak",
"starknet" }).name(
"is_member"))
230 ->
group(advanced_group);
233 const auto add_verifier_target_option = [&](CLI::App* subcommand) {
235 ->add_option(
"--verifier_target, -t",
236 flags.verifier_target,
237 "Target verification environment. Determines hash function and ZK settings.\n"
240 " evm Ethereum/Solidity (keccak, ZK)\n"
241 " evm-no-zk Ethereum/Solidity without ZK\n"
242 " noir-recursive Noir circuits (poseidon2, ZK)\n"
243 " noir-recursive-no-zk Noir circuits without ZK\n"
244 " noir-rollup Rollup with IPA (poseidon2, ZK)\n"
245 " noir-rollup-no-zk Rollup without ZK\n"
246 " starknet Starknet via Garaga (ZK)\n"
247 " starknet-no-zk Starknet without ZK")
248 ->envname(
"BB_VERIFIER_TARGET")
249 ->check(CLI::IsMember({
"evm",
252 "noir-recursive-no-zk",
256 "starknet-no-zk" }));
259 const auto add_write_vk_flag = [&](CLI::App* subcommand) {
260 return subcommand->add_flag(
"--write_vk", flags.write_vk,
"Write the provided circuit's verification key");
263 const auto remove_zk_option = [&](CLI::App* subcommand) {
265 ->add_flag(
"--disable_zk",
267 "Use a non-zk version of --scheme. Prefer using --verifier_target *-no-zk variants instead.")
268 ->group(advanced_group);
271 const auto add_bytecode_path_option = [&](CLI::App* subcommand) {
272 subcommand->add_option(
"--bytecode_path, -b", bytecode_path,
"Path to ACIR bytecode generated by Noir.")
276 const auto add_witness_path_option = [&](CLI::App* subcommand) {
277 subcommand->add_option(
"--witness_path, -w", witness_path,
"Path to partial witness generated by Noir.")
281 const auto add_ivc_inputs_path_options = [&](CLI::App* subcommand) {
284 "--ivc_inputs_path", ivc_inputs_path,
"For IVC, path to input stack with bytecode and witnesses.")
285 ->group(advanced_group);
288 const auto add_public_inputs_path_option = [&](CLI::App* subcommand) {
289 return subcommand->add_option(
290 "--public_inputs_path, -i", public_inputs_path,
"Path to public inputs.") ;
293 const auto add_proof_path_option = [&](CLI::App* subcommand) {
294 return subcommand->add_option(
295 "--proof_path, -p", proof_path,
"Path to a proof.") ;
298 const auto add_vk_path_option = [&](CLI::App* subcommand) {
299 return subcommand->add_option(
"--vk_path, -k", vk_path,
"Path to a verification key.")
303 const auto add_verbose_flag = [&](CLI::App* subcommand) {
304 return subcommand->add_flag(
"--verbose, --verbose_logging, -v", flags.verbose,
"Output all logs to stderr.")
305 ->group(advanced_group);
308 const auto add_debug_flag = [&](CLI::App* subcommand) {
309 return subcommand->add_flag(
"--debug_logging, -d", flags.debug,
"Output debug logs to stderr.")
310 ->group(advanced_group);
313 const auto add_include_gates_per_opcode_flag = [&](CLI::App* subcommand) {
314 return subcommand->add_flag(
"--include_gates_per_opcode",
315 flags.include_gates_per_opcode,
316 "Include gates_per_opcode in the output of the gates command.");
319 const auto add_slow_low_memory_flag = [&](CLI::App* subcommand) {
321 ->add_flag(
"--slow_low_memory", flags.slow_low_memory,
"Enable low memory mode (can be 2x slower or more).")
322 ->group(advanced_group);
325 const auto add_storage_budget_option = [&](CLI::App* subcommand) {
327 ->add_option(
"--storage_budget",
328 flags.storage_budget,
329 "Storage budget for FileBackedMemory (e.g. '500m', '2g'). When exceeded, falls "
330 "back to RAM (requires --slow_low_memory).")
331 ->group(advanced_group);
334 const auto add_vk_policy_option = [&](CLI::App* subcommand) {
336 ->add_option(
"--vk_policy",
338 "Policy for handling verification keys. 'default' uses the provided VK as-is, 'check' "
339 "verifies the provided VK matches the computed VK (throws error on mismatch), 'recompute' "
340 "always ignores the provided VK and treats it as nullptr, 'rewrite' checks the VK and "
341 "rewrites the input file with the correct VK if there's a mismatch (for check command).")
342 ->check(CLI::IsMember({
"default",
"check",
"recompute",
"rewrite" }).name(
"is_member"))
343 ->
group(advanced_group);
346 const auto add_optimized_solidity_verifier_flag = [&](CLI::App* subcommand) {
347 return subcommand->add_flag(
348 "--optimized", flags.optimized_solidity_verifier,
"Use the optimized Solidity verifier.");
351 const auto add_output_format_option = [&](CLI::App* subcommand) {
353 ->add_option(
"--output_format",
355 "Output format for proofs and verification keys: 'binary' (default) or 'json'.\n"
356 "JSON format includes metadata like bb_version, scheme, and verifier_target.")
357 ->check(CLI::IsMember({
"binary",
"json" }).name(
"is_member"));
360 bool print_bench =
false;
361 const auto add_print_bench_flag = [&](CLI::App* subcommand) {
364 "--print_bench", print_bench,
"Pretty print op counts to standard error in a human-readable format.")
365 ->group(advanced_group);
368 std::string bench_out;
369 const auto add_bench_out_option = [&](CLI::App* subcommand) {
370 return subcommand->add_option(
"--bench_out", bench_out,
"Path to write the op counts in a json.")
371 ->group(advanced_group);
373 std::string bench_out_hierarchical;
374 const auto add_bench_out_hierarchical_option = [&](CLI::App* subcommand) {
376 ->add_option(
"--bench_out_hierarchical",
377 bench_out_hierarchical,
378 "Path to write the hierarchical benchmark data (op counts and timings with "
379 "parent-child relationships) as json.")
380 ->group(advanced_group);
386 add_verbose_flag(&app);
387 add_debug_flag(&app);
388 add_crs_path_option(&app);
393 app.set_version_flag(
"--version",
BB_VERSION,
"Print the version string.");
398 app.add_flag(
"--help-extended",
"Show all options including advanced and Aztec-specific commands.");
403 std::filesystem::path acir_roundtrip_output_path;
404 CLI::App* acir_roundtrip_cmd =
405 app.add_subcommand(
"acir_roundtrip",
406 "[Internal testing] Deserialize an ACIR program from bytecode (msgpack), "
407 "re-serialize it back to msgpack, and write it to an output JSON file "
408 "in nargo-compatible format. Functional equivalence should then be verified "
409 "externally (e.g. by proving with the roundtripped bytecode).");
411 acir_roundtrip_cmd->group(aztec_internal_group);
412 add_bytecode_path_option(acir_roundtrip_cmd);
414 ->add_option(
"--output_path,-o", acir_roundtrip_output_path,
"Output path for the roundtripped bytecode JSON.")
420 CLI::App* check = app.add_subcommand(
422 "A debugging tool to quickly check whether a witness satisfies a circuit The "
423 "function constructs the execution trace and iterates through it row by row, applying the "
424 "polynomial relations defining the gate types. For Chonk, we check the VKs in the folding stack.");
426 add_help_extended_flag(check);
427 add_scheme_option(check);
428 add_bytecode_path_option(check);
429 add_witness_path_option(check);
430 add_ivc_inputs_path_options(check);
431 add_vk_policy_option(check);
436 CLI::App* gates = app.add_subcommand(
"gates",
437 "Construct a circuit from the given bytecode (in particular, expand black box "
438 "functions) and return the gate count information.");
440 add_help_extended_flag(gates);
441 add_scheme_option(gates);
442 add_verbose_flag(gates);
443 add_bytecode_path_option(gates);
444 add_include_gates_per_opcode_flag(gates);
445 add_verifier_target_option(gates);
446 add_oracle_hash_option(gates);
447 add_ipa_accumulation_flag(gates);
452 CLI::App* prove = app.add_subcommand(
"prove",
"Generate a proof.");
454 add_help_extended_flag(prove);
455 add_scheme_option(prove);
456 add_bytecode_path_option(prove);
457 add_witness_path_option(prove);
458 add_output_path_option(prove, output_path);
459 add_ivc_inputs_path_options(prove);
460 add_vk_path_option(prove);
461 add_vk_policy_option(prove);
462 add_verbose_flag(prove);
463 add_debug_flag(prove);
464 add_crs_path_option(prove);
465 add_verifier_target_option(prove);
466 add_oracle_hash_option(prove);
467 add_write_vk_flag(prove);
468 add_ipa_accumulation_flag(prove);
469 remove_zk_option(prove);
470 add_slow_low_memory_flag(prove);
471 add_print_bench_flag(prove);
472 add_bench_out_option(prove);
473 add_bench_out_hierarchical_option(prove);
474 add_storage_budget_option(prove);
475 add_output_format_option(prove);
477 prove->add_flag(
"--verify",
"Verify the proof natively, resulting in a boolean output. Useful for testing.");
483 app.add_subcommand(
"write_vk",
484 "Write the verification key of a circuit. The circuit is constructed using "
485 "quickly generated but invalid witnesses (which must be supplied in Barretenberg in order "
486 "to expand ACIR black box opcodes), and no proof is constructed.");
488 add_help_extended_flag(write_vk);
489 add_scheme_option(write_vk);
490 add_bytecode_path_option(write_vk);
491 add_output_path_option(write_vk, output_path);
492 add_ivc_inputs_path_options(write_vk);
494 add_verbose_flag(write_vk);
495 add_debug_flag(write_vk);
496 add_crs_path_option(write_vk);
497 add_verifier_target_option(write_vk);
498 add_oracle_hash_option(write_vk);
499 add_ipa_accumulation_flag(write_vk);
500 remove_zk_option(write_vk);
501 add_output_format_option(write_vk);
506 CLI::App* verify = app.add_subcommand(
"verify",
"Verify a proof.");
508 add_help_extended_flag(verify);
509 add_public_inputs_path_option(verify);
510 add_proof_path_option(verify);
511 add_vk_path_option(verify);
513 add_verbose_flag(verify);
514 add_debug_flag(verify);
515 add_scheme_option(verify);
516 add_crs_path_option(verify);
517 add_verifier_target_option(verify);
518 add_oracle_hash_option(verify);
519 remove_zk_option(verify);
520 add_ipa_accumulation_flag(verify);
525 CLI::App* write_solidity_verifier =
526 app.add_subcommand(
"write_solidity_verifier",
527 "Write a Solidity smart contract suitable for verifying proofs of circuit "
528 "satisfiability for the circuit with verification key at vk_path. Not all "
529 "hash types are implemented due to efficiency concerns.");
531 add_help_extended_flag(write_solidity_verifier);
532 add_scheme_option(write_solidity_verifier);
533 add_vk_path_option(write_solidity_verifier);
534 add_output_path_option(write_solidity_verifier, output_path);
536 add_verbose_flag(write_solidity_verifier);
537 add_verifier_target_option(write_solidity_verifier);
538 remove_zk_option(write_solidity_verifier);
539 add_crs_path_option(write_solidity_verifier);
540 add_optimized_solidity_verifier_flag(write_solidity_verifier);
542 std::filesystem::path avm_inputs_path{
"./target/avm_inputs.bin" };
543 const auto add_avm_inputs_option = [&](CLI::App* subcommand) {
544 return subcommand->add_option(
"--avm-inputs", avm_inputs_path,
"");
546 std::filesystem::path avm_public_inputs_path{
"./target/avm_public_inputs.bin" };
547 const auto add_avm_public_inputs_option = [&](CLI::App* subcommand) {
548 return subcommand->add_option(
"--avm-public-inputs", avm_public_inputs_path,
"");
554 CLI::App* avm_simulate_command = app.add_subcommand(
"avm_simulate",
"Simulate AVM execution.");
555 avm_simulate_command->group(aztec_internal_group);
556 add_verbose_flag(avm_simulate_command);
557 add_debug_flag(avm_simulate_command);
558 add_avm_inputs_option(avm_simulate_command);
563 CLI::App* avm_prove_command = app.add_subcommand(
"avm_prove",
"Generate an AVM proof.");
564 avm_prove_command->group(aztec_internal_group);
565 add_verbose_flag(avm_prove_command);
566 add_debug_flag(avm_prove_command);
567 add_crs_path_option(avm_prove_command);
568 std::filesystem::path avm_prove_output_path{
"./proofs" };
569 add_output_path_option(avm_prove_command, avm_prove_output_path);
570 add_avm_inputs_option(avm_prove_command);
575 CLI::App* avm_write_vk_command = app.add_subcommand(
"avm_write_vk",
"Write AVM verification key.");
576 avm_write_vk_command->group(aztec_internal_group);
577 add_verbose_flag(avm_write_vk_command);
578 add_debug_flag(avm_write_vk_command);
579 add_crs_path_option(avm_write_vk_command);
580 std::filesystem::path avm_write_vk_output_path{
"./keys" };
581 add_output_path_option(avm_write_vk_command, avm_write_vk_output_path);
586 CLI::App* avm_check_circuit_command = app.add_subcommand(
"avm_check_circuit",
"Check AVM circuit satisfiability.");
587 avm_check_circuit_command->group(aztec_internal_group);
588 add_verbose_flag(avm_check_circuit_command);
589 add_debug_flag(avm_check_circuit_command);
590 add_crs_path_option(avm_check_circuit_command);
591 add_avm_inputs_option(avm_check_circuit_command);
596 CLI::App* avm_verify_command = app.add_subcommand(
"avm_verify",
"Verify an AVM proof.");
597 avm_verify_command->group(aztec_internal_group);
598 add_verbose_flag(avm_verify_command);
599 add_debug_flag(avm_verify_command);
600 add_crs_path_option(avm_verify_command);
601 add_avm_public_inputs_option(avm_verify_command);
602 add_proof_path_option(avm_verify_command);
607 CLI::App* aztec_process = app.add_subcommand(
609 "Process Aztec contract artifacts: transpile and generate verification keys for all private functions.\n"
610 "If input is a directory (and no output specified), recursively processes all artifacts found in the "
612 "Multiple -i flags can be specified when no -o flag is present for parallel processing.");
613 aztec_process->group(aztec_internal_group);
615 std::vector<std::string> artifact_input_paths;
616 std::string artifact_output_path;
617 bool force_regenerate =
false;
619 aztec_process->add_option(
"-i,--input",
620 artifact_input_paths,
621 "Input artifact JSON path or directory to search (optional, defaults to current "
622 "directory). Can be specified multiple times when no -o flag is present.");
623 aztec_process->add_option(
625 artifact_output_path,
626 "Output artifact JSON path (optional, same as input if not specified). Cannot be used with multiple -i flags.");
627 aztec_process->add_flag(
"-f,--force", force_regenerate,
"Force regeneration of verification keys");
628 add_verbose_flag(aztec_process);
629 add_debug_flag(aztec_process);
634 CLI::App* cache_paths_command =
635 aztec_process->add_subcommand(
"cache_paths",
636 "Output cache paths for verification keys in an artifact.\n"
637 "Format: <hash>:<cache_path>:<function_name> (one per line).");
639 std::string cache_paths_input;
640 cache_paths_command->add_option(
"input", cache_paths_input,
"Input artifact JSON path (required).")->required();
641 add_verbose_flag(cache_paths_command);
642 add_debug_flag(cache_paths_command);
647 CLI::App* msgpack_command = app.add_subcommand(
"msgpack",
"Msgpack API interface.");
650 CLI::App* msgpack_schema_command =
651 msgpack_command->add_subcommand(
"schema",
"Output a msgpack schema encoded as JSON to stdout.");
652 add_verbose_flag(msgpack_schema_command);
655 CLI::App* msgpack_curve_constants_command =
656 msgpack_command->add_subcommand(
"curve_constants",
"Output curve constants as msgpack to stdout.");
657 add_verbose_flag(msgpack_curve_constants_command);
660 CLI::App* msgpack_run_command =
661 msgpack_command->add_subcommand(
"run",
"Execute msgpack API commands from stdin or file.");
662 add_verbose_flag(msgpack_run_command);
663 std::string msgpack_input_file;
664 msgpack_run_command->add_option(
665 "-i,--input", msgpack_input_file,
"Input file containing msgpack buffers (defaults to stdin)");
666 size_t request_ring_size = 1024 * 1024;
669 "--request-ring-size", request_ring_size,
"Request ring buffer size for shared memory IPC (default: 1MB)")
670 ->check(CLI::PositiveNumber);
671 size_t response_ring_size = 1024 * 1024;
673 ->add_option(
"--response-ring-size",
675 "Response ring buffer size for shared memory IPC (default: 1MB)")
676 ->check(CLI::PositiveNumber);
679 ->add_option(
"--max-clients",
681 "Maximum concurrent clients for socket IPC servers (default: 1, only used for .sock files)")
682 ->check(CLI::PositiveNumber);
691 if (show_extended_help) {
698 if (!flags.verifier_target.empty()) {
702 if (active_sub !=
nullptr) {
704 auto get_option_count = [](CLI::App* sub,
const std::string& name) ->
size_t {
706 return sub->get_option(name)->count();
707 }
catch (
const CLI::OptionNotFound&) {
712 if (get_option_count(active_sub,
"--oracle_hash") > 0) {
713 throw_or_abort(
"Cannot use --verifier_target with --oracle_hash. "
714 "The --verifier_target flag sets oracle_hash automatically.");
716 if (get_option_count(active_sub,
"--disable_zk") > 0) {
718 "Use a '-no-zk' variant of --verifier_target instead (e.g., 'evm-no-zk').");
720 if (get_option_count(active_sub,
"--ipa_accumulation") > 0) {
721 throw_or_abort(
"Cannot use --verifier_target with --ipa_accumulation. "
722 "Use '--verifier_target noir-rollup' for IPA accumulation.");
727 if (flags.verifier_target ==
"evm") {
728 flags.oracle_hash_type =
"keccak";
729 }
else if (flags.verifier_target ==
"evm-no-zk") {
730 flags.oracle_hash_type =
"keccak";
731 flags.disable_zk =
true;
732 }
else if (flags.verifier_target ==
"noir-recursive") {
733 flags.oracle_hash_type =
"poseidon2";
734 }
else if (flags.verifier_target ==
"noir-recursive-no-zk") {
735 flags.oracle_hash_type =
"poseidon2";
736 flags.disable_zk =
true;
737 }
else if (flags.verifier_target ==
"noir-rollup") {
738 flags.oracle_hash_type =
"poseidon2";
739 flags.ipa_accumulation =
true;
740 }
else if (flags.verifier_target ==
"noir-rollup-no-zk") {
741 flags.oracle_hash_type =
"poseidon2";
742 flags.ipa_accumulation =
true;
743 flags.disable_zk =
true;
744 }
else if (flags.verifier_target ==
"starknet") {
745 flags.oracle_hash_type =
"starknet";
746 }
else if (flags.verifier_target ==
"starknet-no-zk") {
747 flags.oracle_hash_type =
"starknet";
748 flags.disable_zk =
true;
750 vinfo(
"verifier_target '",
751 flags.verifier_target,
752 "' -> oracle_hash_type='",
753 flags.oracle_hash_type,
756 ", ipa_accumulation=",
757 flags.ipa_accumulation);
763 if ((prove->parsed() || write_vk->parsed()) && output_path !=
"-") {
765 std::filesystem::create_directories(output_path);
769 }
else if (flags.verbose) {
773#if !defined(__wasm__) || defined(ENABLE_WASM_BENCH)
774 if (!flags.storage_budget.empty()) {
777 if (print_bench || !bench_out.empty() || !bench_out_hierarchical.empty()) {
779 vinfo(
"BB_BENCH enabled via --print_bench or --bench_out");
791 const auto execute_non_prove_command = [&](
API& api) {
792 if (check->parsed()) {
793 api.check(flags, bytecode_path, witness_path);
796 if (gates->parsed()) {
797 api.gates(flags, bytecode_path);
800 if (write_vk->parsed()) {
801 api.write_vk(flags, bytecode_path, output_path);
804 if (verify->parsed()) {
805 const bool verified = api.verify(flags, public_inputs_path, proof_path, vk_path);
806 vinfo(
"verified: ", verified);
807 return verified ? 0 : 1;
809 if (write_solidity_verifier->parsed()) {
811 if (!flags.verifier_target.empty() && flags.verifier_target !=
"evm" &&
812 flags.verifier_target !=
"evm-no-zk") {
813 throw_or_abort(
"write_solidity_verifier requires --verifier_target to be 'evm' or 'evm-no-zk', got '" +
814 flags.verifier_target +
"'");
816 api.write_solidity_verifier(flags, output_path, vk_path);
819 auto subcommands = app.get_subcommands();
820 const std::string message = std::string(
"No handler for subcommand ") + subcommands[0]->get_name();
827 if (acir_roundtrip_cmd->parsed()) {
833 if (msgpack_schema_command->parsed()) {
837 if (msgpack_curve_constants_command->parsed()) {
841 if (msgpack_run_command->parsed()) {
842 return execute_msgpack_run(msgpack_input_file, max_clients, request_ring_size, response_ring_size);
844 if (aztec_process->parsed()) {
846 throw_or_abort(
"Aztec artifact processing is not supported in WASM builds.");
849 if (cache_paths_command->parsed()) {
854 if (!artifact_output_path.empty() && artifact_input_paths.size() > 1) {
855 throw_or_abort(
"Cannot specify --output when multiple --input flags are provided.");
859 if (artifact_input_paths.empty()) {
860 artifact_input_paths.push_back(
".");
864 if (artifact_input_paths.size() > 1) {
866 for (
const auto& input : artifact_input_paths) {
867 if (std::filesystem::is_directory(input)) {
868 throw_or_abort(
"When using multiple --input flags, all inputs must be files, not directories.");
873 std::atomic<bool> all_success =
true;
874 std::vector<std::string> failures;
875 std::mutex failures_mutex;
877 parallel_for(artifact_input_paths.size(), [&](
size_t i) {
878 const auto& input = artifact_input_paths[i];
879 if (!process_aztec_artifact(input, input, force_regenerate)) {
881 std::lock_guard<std::mutex> lock(failures_mutex);
882 failures.push_back(input);
887 info(
"Failed to process ", failures.size(),
" artifact(s)");
890 info(
"Successfully processed ", artifact_input_paths.size(),
" artifact(s)");
895 std::string input = artifact_input_paths[0];
898 if (std::filesystem::is_directory(input)) {
900 if (!artifact_output_path.empty()) {
902 "Cannot specify --output when input is a directory. Artifacts are updated in-place.");
909 std::string output = artifact_output_path.empty() ? input : artifact_output_path;
914 else if (avm_prove_command->parsed()) {
916 avm_prove(avm_inputs_path, avm_prove_output_path);
917 }
else if (avm_check_circuit_command->parsed()) {
919 }
else if (avm_verify_command->parsed()) {
920 return avm_verify(proof_path, avm_public_inputs_path) ? 0 : 1;
921 }
else if (avm_simulate_command->parsed()) {
923 }
else if (avm_write_vk_command->parsed()) {
925 }
else if (flags.scheme ==
"chonk") {
927 if (prove->parsed()) {
928 if (!std::filesystem::exists(ivc_inputs_path)) {
929 throw_or_abort(
"The prove command for Chonk expect a valid file passed with --ivc_inputs_path "
930 "<ivc-inputs.msgpack> (default ./ivc-inputs.msgpack)");
932 api.
prove(flags, ivc_inputs_path, output_path);
933#if !defined(__wasm__) || defined(ENABLE_WASM_BENCH)
935 vinfo(
"Printing BB_BENCH results...");
939 if (!bench_out.empty()) {
940 std::ofstream file(bench_out);
943 if (!bench_out_hierarchical.empty()) {
944 std::ofstream file(bench_out_hierarchical);
950 if (check->parsed()) {
951 if (!std::filesystem::exists(ivc_inputs_path)) {
952 throw_or_abort(
"The check command for Chonk expect a valid file passed with --ivc_inputs_path "
953 "<ivc-inputs.msgpack> (default ./ivc-inputs.msgpack)");
957 return execute_non_prove_command(api);
958 }
else if (flags.scheme ==
"ultra_honk") {
960 if (prove->parsed()) {
961 api.
prove(flags, bytecode_path, witness_path, vk_path, output_path);
962#if !defined(__wasm__) || defined(ENABLE_WASM_BENCH)
966 if (!bench_out.empty()) {
967 std::ofstream file(bench_out);
970 if (!bench_out_hierarchical.empty()) {
971 std::ofstream file(bench_out_hierarchical);
977 return execute_non_prove_command(api);
982 }
catch (std::runtime_error
const& err) {
983#ifndef BB_NO_EXCEPTIONS