112 std::string name =
"Barretenberg\nYour favo(u)rite zkSNARK library written in C++, a perfectly good computer "
113 "programming language.";
117 name +=
"\nAztec Virtual Machine (AVM): enabled";
119 name +=
"\nAztec Virtual Machine (AVM): disabled";
121#ifdef ENABLE_AVM_TRANSPILER
122 name +=
"\nAVM Transpiler: enabled";
124 name +=
"\nAVM Transpiler: disabled";
126#ifdef STARKNET_GARAGA_FLAVORS
127 name +=
"\nStarknet Garaga Extensions: enabled";
129 name +=
"\nStarknet Garaga Extensions: disabled";
131 CLI::App app{ name };
132 argv = app.ensure_utf8(argv);
142 app.require_subcommand(0, 1);
146 std::filesystem::path bytecode_path{
"./target/program.json" };
147 std::filesystem::path witness_path{
"./target/witness.gz" };
148 std::filesystem::path ivc_inputs_path{
"./ivc-inputs.msgpack" };
149 std::filesystem::path output_path{
152 std::filesystem::path public_inputs_path{
"./target/public_inputs" };
153 std::filesystem::path proof_path{
"./target/proof" };
154 std::filesystem::path vk_path{
"./target/vk" };
156 flags.oracle_hash_type =
"poseidon2";
158 flags.include_gates_per_opcode =
false;
164 bool show_extended_help =
false;
165 for (
int i = 1; i < argc; ++i) {
166 if (std::string(argv[i]) ==
"--help-extended") {
167 show_extended_help =
true;
172 const std::string advanced_group = show_extended_help ?
"Advanced Options (Aztec/Power Users)" :
"";
173 const std::string aztec_internal_group = show_extended_help ?
"Aztec Internal Commands" :
"";
175 const auto add_output_path_option = [&](CLI::App* subcommand,
auto& _output_path) {
176 return subcommand->add_option(
"--output_path, -o",
178 "Directory to write files or path of file to write, depending on subcommand.");
182 const auto add_help_extended_flag = [&](CLI::App* subcommand) {
183 subcommand->add_flag(
"--help-extended",
"Show all options including advanced ones.");
190 const auto add_ipa_accumulation_flag = [&](CLI::App* subcommand) {
192 ->add_flag(
"--ipa_accumulation",
193 flags.ipa_accumulation,
194 "Accumulate/Aggregate IPA (Inner Product Argument) claims")
195 ->group(advanced_group);
198 const auto add_scheme_option = [&](CLI::App* subcommand) {
203 "The type of proof to be constructed. This can specify a proving system, an accumulation scheme, or a "
204 "particular type of circuit to be constructed and proven for some implicit scheme.")
205 ->envname(
"BB_SCHEME")
206 ->default_val(
"ultra_honk")
207 ->check(CLI::IsMember({
"chonk",
"avm",
"ultra_honk" }).name(
"is_member"))
208 ->
group(advanced_group);
211 const auto add_crs_path_option = [&](CLI::App* subcommand) {
213 ->add_option(
"--crs_path, -c",
215 "Path CRS directory. Missing CRS files will be retrieved from the internet.")
216 ->check(CLI::ExistingDirectory)
217 ->group(advanced_group);
220 const auto add_oracle_hash_option = [&](CLI::App* subcommand) {
224 flags.oracle_hash_type,
225 "The hash function used by the prover as random oracle standing in for a verifier's challenge "
226 "generation. Poseidon2 is to be used for proofs that are intended to be verified inside of a "
227 "circuit. Keccak is optimized for verification in an Ethereum smart contract, where Keccak "
228 "has a privileged position due to the existence of an EVM precompile. Starknet is optimized "
229 "for verification in a Starknet smart contract, which can be generated using the Garaga library. "
230 "Prefer using --verifier_target instead.")
231 ->check(CLI::IsMember({
"poseidon2",
"keccak",
"starknet" }).name(
"is_member"))
232 ->
group(advanced_group);
235 const auto add_verifier_target_option = [&](CLI::App* subcommand) {
237 ->add_option(
"--verifier_target, -t",
238 flags.verifier_target,
239 "Target verification environment. Determines hash function and ZK settings.\n"
242 " evm Ethereum/Solidity (keccak, ZK)\n"
243 " evm-no-zk Ethereum/Solidity without ZK\n"
244 " noir-recursive Noir circuits (poseidon2, ZK)\n"
245 " noir-recursive-no-zk Noir circuits without ZK\n"
246 " noir-rollup Rollup with IPA (poseidon2, ZK)\n"
247 " noir-rollup-no-zk Rollup without ZK\n"
248 " starknet Starknet via Garaga (ZK)\n"
249 " starknet-no-zk Starknet without ZK")
250 ->envname(
"BB_VERIFIER_TARGET")
251 ->check(CLI::IsMember({
"evm",
254 "noir-recursive-no-zk",
258 "starknet-no-zk" }));
261 const auto add_write_vk_flag = [&](CLI::App* subcommand) {
262 return subcommand->add_flag(
"--write_vk", flags.write_vk,
"Write the provided circuit's verification key");
265 const auto remove_zk_option = [&](CLI::App* subcommand) {
267 ->add_flag(
"--disable_zk",
269 "Use a non-zk version of --scheme. Prefer using --verifier_target *-no-zk variants instead.")
270 ->group(advanced_group);
273 const auto add_bytecode_path_option = [&](CLI::App* subcommand) {
274 subcommand->add_option(
"--bytecode_path, -b", bytecode_path,
"Path to ACIR bytecode generated by Noir.")
278 const auto add_witness_path_option = [&](CLI::App* subcommand) {
279 subcommand->add_option(
"--witness_path, -w", witness_path,
"Path to partial witness generated by Noir.")
283 const auto add_ivc_inputs_path_options = [&](CLI::App* subcommand) {
286 "--ivc_inputs_path", ivc_inputs_path,
"For IVC, path to input stack with bytecode and witnesses.")
287 ->group(advanced_group);
290 const auto add_public_inputs_path_option = [&](CLI::App* subcommand) {
291 return subcommand->add_option(
292 "--public_inputs_path, -i", public_inputs_path,
"Path to public inputs.") ;
295 const auto add_proof_path_option = [&](CLI::App* subcommand) {
296 return subcommand->add_option(
297 "--proof_path, -p", proof_path,
"Path to a proof.") ;
300 const auto add_vk_path_option = [&](CLI::App* subcommand) {
301 return subcommand->add_option(
"--vk_path, -k", vk_path,
"Path to a verification key.")
305 const auto add_verbose_flag = [&](CLI::App* subcommand) {
306 return subcommand->add_flag(
"--verbose, --verbose_logging, -v", flags.verbose,
"Output all logs to stderr.")
307 ->group(advanced_group);
310 const auto add_debug_flag = [&](CLI::App* subcommand) {
311 return subcommand->add_flag(
"--debug_logging, -d", flags.debug,
"Output debug logs to stderr.")
312 ->group(advanced_group);
315 bool disable_asserts =
false;
316 const auto add_disable_asserts_flag = [&](CLI::App* subcommand) {
318 ->add_flag(
"--disable_asserts",
320 "Disable BB assertions (asserts become warnings). Not for production use.")
321 ->group(advanced_group);
324 const auto add_include_gates_per_opcode_flag = [&](CLI::App* subcommand) {
325 return subcommand->add_flag(
"--include_gates_per_opcode",
326 flags.include_gates_per_opcode,
327 "Include gates_per_opcode in the output of the gates command.");
330 const auto add_slow_low_memory_flag = [&](CLI::App* subcommand) {
332 ->add_flag(
"--slow_low_memory", flags.slow_low_memory,
"Enable low memory mode (can be 2x slower or more).")
333 ->group(advanced_group);
336 const auto add_storage_budget_option = [&](CLI::App* subcommand) {
338 ->add_option(
"--storage_budget",
339 flags.storage_budget,
340 "Storage budget for FileBackedMemory (e.g. '500m', '2g'). When exceeded, falls "
341 "back to RAM (requires --slow_low_memory).")
342 ->group(advanced_group);
345 const auto add_vk_policy_option = [&](CLI::App* subcommand) {
347 ->add_option(
"--vk_policy",
349 "Policy for handling verification keys. 'default' uses the provided VK as-is, 'check' "
350 "verifies the provided VK matches the computed VK (throws error on mismatch), 'recompute' "
351 "always ignores the provided VK and treats it as nullptr, 'rewrite' checks the VK and "
352 "rewrites the input file with the correct VK if there's a mismatch (for check command).")
353 ->check(CLI::IsMember({
"default",
"check",
"recompute",
"rewrite" }).name(
"is_member"))
354 ->
group(advanced_group);
357 const auto add_use_zk_flavor_flag = [&](CLI::App* subcommand) {
359 ->add_flag(
"--use_zk_flavor",
361 "Chonk-only: derive the VK against MegaZKFlavor rather than MegaFlavor. "
362 "Set this for the IVC hiding kernel (the only Chonk circuit proven as MegaZK).")
363 ->group(advanced_group);
366 const auto add_optimized_solidity_verifier_flag = [&](CLI::App* subcommand) {
367 return subcommand->add_flag(
368 "--optimized", flags.optimized_solidity_verifier,
"Use the optimized Solidity verifier.");
371 const auto add_output_format_option = [&](CLI::App* subcommand) {
373 ->add_option(
"--output_format",
375 "Output format for proofs and verification keys: 'binary' (default) or 'json'.\n"
376 "JSON format includes metadata like bb_version, scheme, and verifier_target.")
377 ->check(CLI::IsMember({
"binary",
"json" }).name(
"is_member"));
380 bool print_bench =
false;
381 const auto add_print_bench_flag = [&](CLI::App* subcommand) {
384 "--print_bench", print_bench,
"Pretty print op counts to standard error in a human-readable format.")
385 ->group(advanced_group);
388 std::string bench_out;
389 const auto add_bench_out_option = [&](CLI::App* subcommand) {
390 return subcommand->add_option(
"--bench_out", bench_out,
"Path to write the op counts in a json.")
391 ->group(advanced_group);
393 std::string bench_out_hierarchical;
394 const auto add_bench_out_hierarchical_option = [&](CLI::App* subcommand) {
396 ->add_option(
"--bench_out_hierarchical",
397 bench_out_hierarchical,
398 "Path to write the hierarchical benchmark data (op counts and timings with "
399 "parent-child relationships) as json.")
400 ->group(advanced_group);
402 std::string memory_profile_out;
403 const auto add_memory_profile_out_option = [&](CLI::App* subcommand) {
405 ->add_option(
"--memory_profile_out",
407 "Path to write memory profile data (polynomial breakdown by category, RSS "
408 "checkpoints, CRS size) as json.")
409 ->group(advanced_group);
412 std::string trace_out_perfetto;
413 const auto add_trace_out_perfetto_option = [&](CLI::App* subcommand) {
415 ->add_option(
"--trace_out_perfetto",
417 "Path to write a Chrome Trace Event Format JSON of every instrumented "
418 "BB_BENCH scope (per-call timeline). Drop the file into ui.perfetto.dev "
419 "or chrome://tracing.")
420 ->group(advanced_group);
422 std::string trace_out_perfetto_aggregate;
423 const auto add_trace_out_perfetto_aggregate_option = [&](CLI::App* subcommand) {
425 ->add_option(
"--trace_out_perfetto_aggregate",
426 trace_out_perfetto_aggregate,
427 "Path to write a synthesized Chrome Trace Event Format JSON derived from the "
428 "aggregate stats. Smaller than --trace_out_perfetto but lossy about individual "
430 ->group(advanced_group);
436 add_verbose_flag(&app);
437 add_debug_flag(&app);
438 add_crs_path_option(&app);
443 app.set_version_flag(
"--version",
BB_VERSION,
"Print the version string.");
448 app.add_flag(
"--help-extended",
"Show all options including advanced and Aztec-specific commands.");
453 std::filesystem::path acir_roundtrip_output_path;
454 CLI::App* acir_roundtrip_cmd =
455 app.add_subcommand(
"acir_roundtrip",
456 "[Internal testing] Deserialize an ACIR program from bytecode (msgpack), "
457 "re-serialize it back to msgpack, and write it to an output JSON file "
458 "in nargo-compatible format. Functional equivalence should then be verified "
459 "externally (e.g. by proving with the roundtripped bytecode).");
461 acir_roundtrip_cmd->group(aztec_internal_group);
462 add_bytecode_path_option(acir_roundtrip_cmd);
464 ->add_option(
"--output_path,-o", acir_roundtrip_output_path,
"Output path for the roundtripped bytecode JSON.")
470 CLI::App* check = app.add_subcommand(
472 "A debugging tool to quickly check whether a witness satisfies a circuit The "
473 "function constructs the execution trace and iterates through it row by row, applying the "
474 "polynomial relations defining the gate types. For Chonk, we check the VKs in the folding stack.");
476 add_help_extended_flag(check);
477 add_scheme_option(check);
478 add_bytecode_path_option(check);
479 add_witness_path_option(check);
480 add_ivc_inputs_path_options(check);
481 add_vk_policy_option(check);
482 add_disable_asserts_flag(check);
487 CLI::App* gates = app.add_subcommand(
"gates",
488 "Construct a circuit from the given bytecode (in particular, expand black box "
489 "functions) and return the gate count information.");
491 add_help_extended_flag(gates);
492 add_scheme_option(gates);
493 add_verbose_flag(gates);
494 add_bytecode_path_option(gates);
495 add_include_gates_per_opcode_flag(gates);
496 add_verifier_target_option(gates);
497 add_oracle_hash_option(gates);
498 add_ipa_accumulation_flag(gates);
503 CLI::App* prove = app.add_subcommand(
"prove",
"Generate a proof.");
505 add_help_extended_flag(prove);
506 add_scheme_option(prove);
507 add_bytecode_path_option(prove);
508 add_witness_path_option(prove);
509 add_output_path_option(prove, output_path);
510 add_ivc_inputs_path_options(prove);
511 add_vk_path_option(prove);
512 add_vk_policy_option(prove);
513 add_verbose_flag(prove);
514 add_debug_flag(prove);
515 add_crs_path_option(prove);
516 add_verifier_target_option(prove);
517 add_oracle_hash_option(prove);
518 add_write_vk_flag(prove);
519 add_ipa_accumulation_flag(prove);
520 remove_zk_option(prove);
521 add_slow_low_memory_flag(prove);
522 add_print_bench_flag(prove);
523 add_bench_out_option(prove);
524 add_bench_out_hierarchical_option(prove);
525 add_memory_profile_out_option(prove);
526 add_trace_out_perfetto_option(prove);
527 add_trace_out_perfetto_aggregate_option(prove);
528 add_storage_budget_option(prove);
529 add_output_format_option(prove);
531 prove->add_flag(
"--verify",
"Verify the proof natively, resulting in a boolean output. Useful for testing.");
537 app.add_subcommand(
"write_vk",
538 "Write the verification key of a circuit. The circuit is constructed using "
539 "quickly generated but invalid witnesses (which must be supplied in Barretenberg in order "
540 "to expand ACIR black box opcodes), and no proof is constructed.");
542 add_help_extended_flag(write_vk);
543 add_scheme_option(write_vk);
544 add_bytecode_path_option(write_vk);
545 add_output_path_option(write_vk, output_path);
546 add_ivc_inputs_path_options(write_vk);
548 add_verbose_flag(write_vk);
549 add_debug_flag(write_vk);
550 add_crs_path_option(write_vk);
551 add_verifier_target_option(write_vk);
552 add_oracle_hash_option(write_vk);
553 add_ipa_accumulation_flag(write_vk);
554 remove_zk_option(write_vk);
555 add_output_format_option(write_vk);
556 add_use_zk_flavor_flag(write_vk);
561 CLI::App* verify = app.add_subcommand(
"verify",
"Verify a proof.");
563 add_help_extended_flag(verify);
564 add_public_inputs_path_option(verify);
565 add_proof_path_option(verify);
566 add_vk_path_option(verify);
568 add_verbose_flag(verify);
569 add_debug_flag(verify);
570 add_scheme_option(verify);
571 add_crs_path_option(verify);
572 add_verifier_target_option(verify);
573 add_oracle_hash_option(verify);
574 remove_zk_option(verify);
575 add_ipa_accumulation_flag(verify);
580 std::filesystem::path batch_verify_proofs_dir{
"./proofs" };
581 CLI::App* batch_verify =
582 app.add_subcommand(
"batch_verify",
"Batch-verify multiple Chonk proofs with a single IPA SRS MSM.");
584 add_help_extended_flag(batch_verify);
585 add_scheme_option(batch_verify);
586 batch_verify->add_option(
"--proofs_dir", batch_verify_proofs_dir,
"Directory containing proof_N/vk_N pairs.");
587 add_verbose_flag(batch_verify);
588 add_debug_flag(batch_verify);
589 add_crs_path_option(batch_verify);
594 CLI::App* proof_stats =
595 app.add_subcommand(
"proof_stats",
"Output proof statistics (compressed size, number of public inputs).");
597 add_help_extended_flag(proof_stats);
598 add_scheme_option(proof_stats);
599 add_proof_path_option(proof_stats);
600 add_output_path_option(proof_stats, output_path);
601 add_verbose_flag(proof_stats);
606 CLI::App* write_solidity_verifier =
607 app.add_subcommand(
"write_solidity_verifier",
608 "Write a Solidity smart contract suitable for verifying proofs of circuit "
609 "satisfiability for the circuit with verification key at vk_path. Not all "
610 "hash types are implemented due to efficiency concerns.");
612 add_help_extended_flag(write_solidity_verifier);
613 add_scheme_option(write_solidity_verifier);
614 add_vk_path_option(write_solidity_verifier);
615 add_output_path_option(write_solidity_verifier, output_path);
617 add_verbose_flag(write_solidity_verifier);
618 add_verifier_target_option(write_solidity_verifier);
619 remove_zk_option(write_solidity_verifier);
620 add_crs_path_option(write_solidity_verifier);
621 add_optimized_solidity_verifier_flag(write_solidity_verifier);
623 std::filesystem::path avm_inputs_path{
"./target/avm_inputs.bin" };
624 const auto add_avm_inputs_option = [&](CLI::App* subcommand) {
625 return subcommand->add_option(
"--avm-inputs", avm_inputs_path,
"");
627 std::filesystem::path avm_public_inputs_path{
"./target/avm_public_inputs.bin" };
628 const auto add_avm_public_inputs_option = [&](CLI::App* subcommand) {
629 return subcommand->add_option(
"--avm-public-inputs", avm_public_inputs_path,
"");
635 CLI::App* avm_simulate_command = app.add_subcommand(
"avm_simulate",
"Simulate AVM execution.");
636 avm_simulate_command->group(aztec_internal_group);
637 add_verbose_flag(avm_simulate_command);
638 add_debug_flag(avm_simulate_command);
639 add_avm_inputs_option(avm_simulate_command);
644 CLI::App* avm_prove_command = app.add_subcommand(
"avm_prove",
"Generate an AVM proof.");
645 avm_prove_command->group(aztec_internal_group);
646 add_verbose_flag(avm_prove_command);
647 add_debug_flag(avm_prove_command);
648 add_crs_path_option(avm_prove_command);
649 std::filesystem::path avm_prove_output_path{
"./proofs" };
650 add_output_path_option(avm_prove_command, avm_prove_output_path);
651 add_avm_inputs_option(avm_prove_command);
656 CLI::App* avm_write_vk_command = app.add_subcommand(
"avm_write_vk",
"Write AVM verification key.");
657 avm_write_vk_command->group(aztec_internal_group);
658 add_verbose_flag(avm_write_vk_command);
659 add_debug_flag(avm_write_vk_command);
660 add_crs_path_option(avm_write_vk_command);
661 std::filesystem::path avm_write_vk_output_path{
"./keys" };
662 add_output_path_option(avm_write_vk_command, avm_write_vk_output_path);
667 CLI::App* avm_check_circuit_command = app.add_subcommand(
"avm_check_circuit",
"Check AVM circuit satisfiability.");
668 avm_check_circuit_command->group(aztec_internal_group);
669 add_verbose_flag(avm_check_circuit_command);
670 add_debug_flag(avm_check_circuit_command);
671 add_crs_path_option(avm_check_circuit_command);
672 add_avm_inputs_option(avm_check_circuit_command);
677 CLI::App* avm_verify_command = app.add_subcommand(
"avm_verify",
"Verify an AVM proof.");
678 avm_verify_command->group(aztec_internal_group);
679 add_verbose_flag(avm_verify_command);
680 add_debug_flag(avm_verify_command);
681 add_crs_path_option(avm_verify_command);
682 add_avm_public_inputs_option(avm_verify_command);
683 add_proof_path_option(avm_verify_command);
688 CLI::App* aztec_process = app.add_subcommand(
690 "Process Aztec contract artifacts: transpile and generate verification keys for all private functions.\n"
691 "If input is a directory (and no output specified), recursively processes all artifacts found in the "
693 "Multiple -i flags can be specified when no -o flag is present for parallel processing.");
694 aztec_process->group(aztec_internal_group);
696 std::vector<std::string> artifact_input_paths;
697 std::string artifact_output_path;
698 bool force_regenerate =
false;
700 aztec_process->add_option(
"-i,--input",
701 artifact_input_paths,
702 "Input artifact JSON path or directory to search (optional, defaults to current "
703 "directory). Can be specified multiple times when no -o flag is present.");
704 aztec_process->add_option(
706 artifact_output_path,
707 "Output artifact JSON path (optional, same as input if not specified). Cannot be used with multiple -i flags.");
708 aztec_process->add_flag(
"-f,--force", force_regenerate,
"Force regeneration of verification keys");
709 add_verbose_flag(aztec_process);
710 add_debug_flag(aztec_process);
715 CLI::App* cache_paths_command =
716 aztec_process->add_subcommand(
"cache_paths",
717 "Output cache paths for verification keys in an artifact.\n"
718 "Format: <hash>:<cache_path>:<function_name> (one per line).");
720 std::string cache_paths_input;
721 cache_paths_command->add_option(
"input", cache_paths_input,
"Input artifact JSON path (required).")->required();
722 add_verbose_flag(cache_paths_command);
723 add_debug_flag(cache_paths_command);
728 CLI::App* msgpack_command = app.add_subcommand(
"msgpack",
"Msgpack API interface.");
731 CLI::App* msgpack_schema_command =
732 msgpack_command->add_subcommand(
"schema",
"Output a msgpack schema encoded as JSON to stdout.");
733 add_verbose_flag(msgpack_schema_command);
736 CLI::App* msgpack_curve_constants_command =
737 msgpack_command->add_subcommand(
"curve_constants",
"Output curve constants as msgpack to stdout.");
738 add_verbose_flag(msgpack_curve_constants_command);
741 CLI::App* msgpack_run_command =
742 msgpack_command->add_subcommand(
"run",
"Execute msgpack API commands from stdin or file.");
743 add_verbose_flag(msgpack_run_command);
744 std::string msgpack_input_file;
745 msgpack_run_command->add_option(
746 "-i,--input", msgpack_input_file,
"Input file containing msgpack buffers (defaults to stdin)");
747 size_t request_ring_size = 1024 * 1024;
750 "--request-ring-size", request_ring_size,
"Request ring buffer size for shared memory IPC (default: 1MB)")
751 ->check(CLI::PositiveNumber);
752 size_t response_ring_size = 1024 * 1024;
754 ->add_option(
"--response-ring-size",
756 "Response ring buffer size for shared memory IPC (default: 1MB)")
757 ->check(CLI::PositiveNumber);
760 ->add_option(
"--max-clients",
762 "Maximum concurrent clients for socket IPC servers (default: 1, only used for .sock files)")
763 ->check(CLI::PositiveNumber);
772 if (show_extended_help) {
779 if (!flags.verifier_target.empty()) {
783 if (active_sub !=
nullptr) {
785 auto get_option_count = [](CLI::App* sub,
const std::string& name) ->
size_t {
787 return sub->get_option(name)->count();
788 }
catch (
const CLI::OptionNotFound&) {
793 if (get_option_count(active_sub,
"--oracle_hash") > 0) {
794 throw_or_abort(
"Cannot use --verifier_target with --oracle_hash. "
795 "The --verifier_target flag sets oracle_hash automatically.");
797 if (get_option_count(active_sub,
"--disable_zk") > 0) {
799 "Use a '-no-zk' variant of --verifier_target instead (e.g., 'evm-no-zk').");
801 if (get_option_count(active_sub,
"--ipa_accumulation") > 0) {
802 throw_or_abort(
"Cannot use --verifier_target with --ipa_accumulation. "
803 "Use '--verifier_target noir-rollup' for IPA accumulation.");
808 if (flags.verifier_target ==
"evm") {
809 flags.oracle_hash_type =
"keccak";
810 }
else if (flags.verifier_target ==
"evm-no-zk") {
811 flags.oracle_hash_type =
"keccak";
812 flags.disable_zk =
true;
813 }
else if (flags.verifier_target ==
"noir-recursive") {
814 flags.oracle_hash_type =
"poseidon2";
815 }
else if (flags.verifier_target ==
"noir-recursive-no-zk") {
816 flags.oracle_hash_type =
"poseidon2";
817 flags.disable_zk =
true;
818 }
else if (flags.verifier_target ==
"noir-rollup") {
819 flags.oracle_hash_type =
"poseidon2";
820 flags.ipa_accumulation =
true;
821 }
else if (flags.verifier_target ==
"noir-rollup-no-zk") {
822 flags.oracle_hash_type =
"poseidon2";
823 flags.ipa_accumulation =
true;
824 flags.disable_zk =
true;
825 }
else if (flags.verifier_target ==
"starknet") {
826 flags.oracle_hash_type =
"starknet";
827 }
else if (flags.verifier_target ==
"starknet-no-zk") {
828 flags.oracle_hash_type =
"starknet";
829 flags.disable_zk =
true;
831 vinfo(
"verifier_target '",
832 flags.verifier_target,
833 "' -> oracle_hash_type='",
834 flags.oracle_hash_type,
837 ", ipa_accumulation=",
838 flags.ipa_accumulation);
844 if ((prove->parsed() || write_vk->parsed()) && output_path !=
"-") {
846 std::filesystem::create_directories(output_path);
850 }
else if (flags.verbose) {
854#if !defined(__wasm__) || defined(ENABLE_WASM_BENCH)
855 if (!flags.storage_budget.empty()) {
858 if (!memory_profile_out.empty()) {
860 vinfo(
"Memory profiling enabled via --memory_profile_out");
862 if (print_bench || !bench_out.empty() || !bench_out_hierarchical.empty() || !trace_out_perfetto.empty() ||
863 !trace_out_perfetto_aggregate.empty()) {
865 vinfo(
"BB_BENCH enabled via --print_bench / --bench_out / --trace_out_perfetto");
867 if (!trace_out_perfetto.empty()) {
869 vinfo(
"Per-call BB_BENCH event capture enabled via --trace_out_perfetto");
881 const auto execute_non_prove_command = [&](
API& api) {
882 if (check->parsed()) {
883 api.check(flags, bytecode_path, witness_path);
886 if (gates->parsed()) {
887 api.gates(flags, bytecode_path);
890 if (write_vk->parsed()) {
891 api.write_vk(flags, bytecode_path, output_path);
894 if (verify->parsed()) {
895 const bool verified = api.verify(flags, public_inputs_path, proof_path, vk_path);
896 vinfo(
"verified: ", verified);
897 return verified ? 0 : 1;
899 if (write_solidity_verifier->parsed()) {
901 if (!flags.verifier_target.empty() && flags.verifier_target !=
"evm" &&
902 flags.verifier_target !=
"evm-no-zk") {
903 throw_or_abort(
"write_solidity_verifier requires --verifier_target to be 'evm' or 'evm-no-zk', got '" +
904 flags.verifier_target +
"'");
906 api.write_solidity_verifier(flags, output_path, vk_path);
909 auto subcommands = app.get_subcommands();
910 const std::string message = std::string(
"No handler for subcommand ") + subcommands[0]->get_name();
917 if (acir_roundtrip_cmd->parsed()) {
923 if (msgpack_schema_command->parsed()) {
927 if (msgpack_curve_constants_command->parsed()) {
931 if (msgpack_run_command->parsed()) {
932 return execute_msgpack_run(msgpack_input_file, max_clients, request_ring_size, response_ring_size);
934 if (aztec_process->parsed()) {
936 throw_or_abort(
"Aztec artifact processing is not supported in WASM builds.");
939 if (cache_paths_command->parsed()) {
944 if (!artifact_output_path.empty() && artifact_input_paths.size() > 1) {
945 throw_or_abort(
"Cannot specify --output when multiple --input flags are provided.");
949 if (artifact_input_paths.empty()) {
950 artifact_input_paths.push_back(
".");
954 if (artifact_input_paths.size() > 1) {
956 for (
const auto& input : artifact_input_paths) {
957 if (std::filesystem::is_directory(input)) {
958 throw_or_abort(
"When using multiple --input flags, all inputs must be files, not directories.");
963 std::atomic<bool> all_success =
true;
964 std::vector<std::string> failures;
965 std::mutex failures_mutex;
967 parallel_for(artifact_input_paths.size(), [&](
size_t i) {
968 const auto& input = artifact_input_paths[i];
969 if (!process_aztec_artifact(input, input, force_regenerate)) {
971 std::lock_guard<std::mutex> lock(failures_mutex);
972 failures.push_back(input);
977 info(
"Failed to process ", failures.size(),
" artifact(s)");
980 info(
"Successfully processed ", artifact_input_paths.size(),
" artifact(s)");
985 std::string input = artifact_input_paths[0];
988 if (std::filesystem::is_directory(input)) {
990 if (!artifact_output_path.empty()) {
992 "Cannot specify --output when input is a directory. Artifacts are updated in-place.");
999 std::string output = artifact_output_path.empty() ? input : artifact_output_path;
1004 else if (avm_prove_command->parsed()) {
1006 avm_prove(avm_inputs_path, avm_prove_output_path);
1007 }
else if (avm_check_circuit_command->parsed()) {
1009 }
else if (avm_verify_command->parsed()) {
1010 return avm_verify(proof_path, avm_public_inputs_path) ? 0 : 1;
1011 }
else if (avm_simulate_command->parsed()) {
1013 }
else if (avm_write_vk_command->parsed()) {
1015 }
else if (flags.scheme ==
"chonk") {
1017 if (prove->parsed()) {
1018 if (!std::filesystem::exists(ivc_inputs_path)) {
1019 throw_or_abort(
"The prove command for Chonk expect a valid file passed with --ivc_inputs_path "
1020 "<ivc-inputs.msgpack> (default ./ivc-inputs.msgpack)");
1022 api.
prove(flags, ivc_inputs_path, output_path);
1023#if !defined(__wasm__) || defined(ENABLE_WASM_BENCH)
1025 vinfo(
"Printing BB_BENCH results...");
1029 if (!bench_out.empty()) {
1030 std::ofstream file(bench_out);
1033 if (!bench_out_hierarchical.empty()) {
1034 std::ofstream file(bench_out_hierarchical);
1037 if (!trace_out_perfetto.empty()) {
1038 std::ofstream file(trace_out_perfetto);
1040 vinfo(
"Perfetto per-call trace written to ", trace_out_perfetto);
1042 if (!trace_out_perfetto_aggregate.empty()) {
1043 std::ofstream file(trace_out_perfetto_aggregate);
1045 vinfo(
"Perfetto aggregate trace written to ", trace_out_perfetto_aggregate);
1048 if (!memory_profile_out.empty()) {
1049 std::ofstream file(memory_profile_out);
1051 vinfo(
"Memory profile written to ", memory_profile_out);
1055 if (check->parsed()) {
1056 if (!std::filesystem::exists(ivc_inputs_path)) {
1057 throw_or_abort(
"The check command for Chonk expect a valid file passed with --ivc_inputs_path "
1058 "<ivc-inputs.msgpack> (default ./ivc-inputs.msgpack)");
1060 if (disable_asserts) {
1066 if (batch_verify->parsed()) {
1067 const bool verified = api.
batch_verify(flags, batch_verify_proofs_dir);
1068 vinfo(
"batch verified: ", verified);
1069 return verified ? 0 : 1;
1071 if (proof_stats->parsed()) {
1075 return execute_non_prove_command(api);
1076 }
else if (flags.scheme ==
"ultra_honk") {
1078 if (prove->parsed()) {
1079 api.
prove(flags, bytecode_path, witness_path, vk_path, output_path);
1080#if !defined(__wasm__) || defined(ENABLE_WASM_BENCH)
1084 if (!bench_out.empty()) {
1085 std::ofstream file(bench_out);
1088 if (!bench_out_hierarchical.empty()) {
1089 std::ofstream file(bench_out_hierarchical);
1092 if (!trace_out_perfetto.empty()) {
1093 std::ofstream file(trace_out_perfetto);
1095 vinfo(
"Perfetto per-call trace written to ", trace_out_perfetto);
1097 if (!trace_out_perfetto_aggregate.empty()) {
1098 std::ofstream file(trace_out_perfetto_aggregate);
1100 vinfo(
"Perfetto aggregate trace written to ", trace_out_perfetto_aggregate);
1105 return execute_non_prove_command(api);
1110 }
catch (std::runtime_error
const& err) {
1111#ifndef BB_NO_EXCEPTIONS