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 std::filesystem::path batch_verify_proofs_dir{
"./proofs" };
526 CLI::App* batch_verify =
527 app.add_subcommand(
"batch_verify",
"Batch-verify multiple Chonk proofs with a single IPA SRS MSM.");
529 add_help_extended_flag(batch_verify);
530 add_scheme_option(batch_verify);
531 batch_verify->add_option(
"--proofs_dir", batch_verify_proofs_dir,
"Directory containing proof_N/vk_N pairs.");
532 add_verbose_flag(batch_verify);
533 add_debug_flag(batch_verify);
534 add_crs_path_option(batch_verify);
539 CLI::App* write_solidity_verifier =
540 app.add_subcommand(
"write_solidity_verifier",
541 "Write a Solidity smart contract suitable for verifying proofs of circuit "
542 "satisfiability for the circuit with verification key at vk_path. Not all "
543 "hash types are implemented due to efficiency concerns.");
545 add_help_extended_flag(write_solidity_verifier);
546 add_scheme_option(write_solidity_verifier);
547 add_vk_path_option(write_solidity_verifier);
548 add_output_path_option(write_solidity_verifier, output_path);
550 add_verbose_flag(write_solidity_verifier);
551 add_verifier_target_option(write_solidity_verifier);
552 remove_zk_option(write_solidity_verifier);
553 add_crs_path_option(write_solidity_verifier);
554 add_optimized_solidity_verifier_flag(write_solidity_verifier);
556 std::filesystem::path avm_inputs_path{
"./target/avm_inputs.bin" };
557 const auto add_avm_inputs_option = [&](CLI::App* subcommand) {
558 return subcommand->add_option(
"--avm-inputs", avm_inputs_path,
"");
560 std::filesystem::path avm_public_inputs_path{
"./target/avm_public_inputs.bin" };
561 const auto add_avm_public_inputs_option = [&](CLI::App* subcommand) {
562 return subcommand->add_option(
"--avm-public-inputs", avm_public_inputs_path,
"");
568 CLI::App* avm_simulate_command = app.add_subcommand(
"avm_simulate",
"Simulate AVM execution.");
569 avm_simulate_command->group(aztec_internal_group);
570 add_verbose_flag(avm_simulate_command);
571 add_debug_flag(avm_simulate_command);
572 add_avm_inputs_option(avm_simulate_command);
577 CLI::App* avm_prove_command = app.add_subcommand(
"avm_prove",
"Generate an AVM proof.");
578 avm_prove_command->group(aztec_internal_group);
579 add_verbose_flag(avm_prove_command);
580 add_debug_flag(avm_prove_command);
581 add_crs_path_option(avm_prove_command);
582 std::filesystem::path avm_prove_output_path{
"./proofs" };
583 add_output_path_option(avm_prove_command, avm_prove_output_path);
584 add_avm_inputs_option(avm_prove_command);
589 CLI::App* avm_write_vk_command = app.add_subcommand(
"avm_write_vk",
"Write AVM verification key.");
590 avm_write_vk_command->group(aztec_internal_group);
591 add_verbose_flag(avm_write_vk_command);
592 add_debug_flag(avm_write_vk_command);
593 add_crs_path_option(avm_write_vk_command);
594 std::filesystem::path avm_write_vk_output_path{
"./keys" };
595 add_output_path_option(avm_write_vk_command, avm_write_vk_output_path);
600 CLI::App* avm_check_circuit_command = app.add_subcommand(
"avm_check_circuit",
"Check AVM circuit satisfiability.");
601 avm_check_circuit_command->group(aztec_internal_group);
602 add_verbose_flag(avm_check_circuit_command);
603 add_debug_flag(avm_check_circuit_command);
604 add_crs_path_option(avm_check_circuit_command);
605 add_avm_inputs_option(avm_check_circuit_command);
610 CLI::App* avm_verify_command = app.add_subcommand(
"avm_verify",
"Verify an AVM proof.");
611 avm_verify_command->group(aztec_internal_group);
612 add_verbose_flag(avm_verify_command);
613 add_debug_flag(avm_verify_command);
614 add_crs_path_option(avm_verify_command);
615 add_avm_public_inputs_option(avm_verify_command);
616 add_proof_path_option(avm_verify_command);
621 CLI::App* aztec_process = app.add_subcommand(
623 "Process Aztec contract artifacts: transpile and generate verification keys for all private functions.\n"
624 "If input is a directory (and no output specified), recursively processes all artifacts found in the "
626 "Multiple -i flags can be specified when no -o flag is present for parallel processing.");
627 aztec_process->group(aztec_internal_group);
629 std::vector<std::string> artifact_input_paths;
630 std::string artifact_output_path;
631 bool force_regenerate =
false;
633 aztec_process->add_option(
"-i,--input",
634 artifact_input_paths,
635 "Input artifact JSON path or directory to search (optional, defaults to current "
636 "directory). Can be specified multiple times when no -o flag is present.");
637 aztec_process->add_option(
639 artifact_output_path,
640 "Output artifact JSON path (optional, same as input if not specified). Cannot be used with multiple -i flags.");
641 aztec_process->add_flag(
"-f,--force", force_regenerate,
"Force regeneration of verification keys");
642 add_verbose_flag(aztec_process);
643 add_debug_flag(aztec_process);
648 CLI::App* cache_paths_command =
649 aztec_process->add_subcommand(
"cache_paths",
650 "Output cache paths for verification keys in an artifact.\n"
651 "Format: <hash>:<cache_path>:<function_name> (one per line).");
653 std::string cache_paths_input;
654 cache_paths_command->add_option(
"input", cache_paths_input,
"Input artifact JSON path (required).")->required();
655 add_verbose_flag(cache_paths_command);
656 add_debug_flag(cache_paths_command);
661 CLI::App* msgpack_command = app.add_subcommand(
"msgpack",
"Msgpack API interface.");
664 CLI::App* msgpack_schema_command =
665 msgpack_command->add_subcommand(
"schema",
"Output a msgpack schema encoded as JSON to stdout.");
666 add_verbose_flag(msgpack_schema_command);
669 CLI::App* msgpack_curve_constants_command =
670 msgpack_command->add_subcommand(
"curve_constants",
"Output curve constants as msgpack to stdout.");
671 add_verbose_flag(msgpack_curve_constants_command);
674 CLI::App* msgpack_run_command =
675 msgpack_command->add_subcommand(
"run",
"Execute msgpack API commands from stdin or file.");
676 add_verbose_flag(msgpack_run_command);
677 std::string msgpack_input_file;
678 msgpack_run_command->add_option(
679 "-i,--input", msgpack_input_file,
"Input file containing msgpack buffers (defaults to stdin)");
680 size_t request_ring_size = 1024 * 1024;
683 "--request-ring-size", request_ring_size,
"Request ring buffer size for shared memory IPC (default: 1MB)")
684 ->check(CLI::PositiveNumber);
685 size_t response_ring_size = 1024 * 1024;
687 ->add_option(
"--response-ring-size",
689 "Response ring buffer size for shared memory IPC (default: 1MB)")
690 ->check(CLI::PositiveNumber);
693 ->add_option(
"--max-clients",
695 "Maximum concurrent clients for socket IPC servers (default: 1, only used for .sock files)")
696 ->check(CLI::PositiveNumber);
705 if (show_extended_help) {
712 if (!flags.verifier_target.empty()) {
716 if (active_sub !=
nullptr) {
718 auto get_option_count = [](CLI::App* sub,
const std::string& name) ->
size_t {
720 return sub->get_option(name)->count();
721 }
catch (
const CLI::OptionNotFound&) {
726 if (get_option_count(active_sub,
"--oracle_hash") > 0) {
727 throw_or_abort(
"Cannot use --verifier_target with --oracle_hash. "
728 "The --verifier_target flag sets oracle_hash automatically.");
730 if (get_option_count(active_sub,
"--disable_zk") > 0) {
732 "Use a '-no-zk' variant of --verifier_target instead (e.g., 'evm-no-zk').");
734 if (get_option_count(active_sub,
"--ipa_accumulation") > 0) {
735 throw_or_abort(
"Cannot use --verifier_target with --ipa_accumulation. "
736 "Use '--verifier_target noir-rollup' for IPA accumulation.");
741 if (flags.verifier_target ==
"evm") {
742 flags.oracle_hash_type =
"keccak";
743 }
else if (flags.verifier_target ==
"evm-no-zk") {
744 flags.oracle_hash_type =
"keccak";
745 flags.disable_zk =
true;
746 }
else if (flags.verifier_target ==
"noir-recursive") {
747 flags.oracle_hash_type =
"poseidon2";
748 }
else if (flags.verifier_target ==
"noir-recursive-no-zk") {
749 flags.oracle_hash_type =
"poseidon2";
750 flags.disable_zk =
true;
751 }
else if (flags.verifier_target ==
"noir-rollup") {
752 flags.oracle_hash_type =
"poseidon2";
753 flags.ipa_accumulation =
true;
754 }
else if (flags.verifier_target ==
"noir-rollup-no-zk") {
755 flags.oracle_hash_type =
"poseidon2";
756 flags.ipa_accumulation =
true;
757 flags.disable_zk =
true;
758 }
else if (flags.verifier_target ==
"starknet") {
759 flags.oracle_hash_type =
"starknet";
760 }
else if (flags.verifier_target ==
"starknet-no-zk") {
761 flags.oracle_hash_type =
"starknet";
762 flags.disable_zk =
true;
764 vinfo(
"verifier_target '",
765 flags.verifier_target,
766 "' -> oracle_hash_type='",
767 flags.oracle_hash_type,
770 ", ipa_accumulation=",
771 flags.ipa_accumulation);
777 if ((prove->parsed() || write_vk->parsed()) && output_path !=
"-") {
779 std::filesystem::create_directories(output_path);
783 }
else if (flags.verbose) {
787#if !defined(__wasm__) || defined(ENABLE_WASM_BENCH)
788 if (!flags.storage_budget.empty()) {
791 if (print_bench || !bench_out.empty() || !bench_out_hierarchical.empty()) {
793 vinfo(
"BB_BENCH enabled via --print_bench or --bench_out");
805 const auto execute_non_prove_command = [&](
API& api) {
806 if (check->parsed()) {
807 api.check(flags, bytecode_path, witness_path);
810 if (gates->parsed()) {
811 api.gates(flags, bytecode_path);
814 if (write_vk->parsed()) {
815 api.write_vk(flags, bytecode_path, output_path);
818 if (verify->parsed()) {
819 const bool verified = api.verify(flags, public_inputs_path, proof_path, vk_path);
820 vinfo(
"verified: ", verified);
821 return verified ? 0 : 1;
823 if (write_solidity_verifier->parsed()) {
825 if (!flags.verifier_target.empty() && flags.verifier_target !=
"evm" &&
826 flags.verifier_target !=
"evm-no-zk") {
827 throw_or_abort(
"write_solidity_verifier requires --verifier_target to be 'evm' or 'evm-no-zk', got '" +
828 flags.verifier_target +
"'");
830 if (flags.optimized_solidity_verifier && !flags.disable_zk) {
832 "An optimized ZK Solidity verifier is not currently available. "
833 "Use --verifier_target evm-no-zk, or remove --optimized to use the non-optimized ZK verifier.");
835 api.write_solidity_verifier(flags, output_path, vk_path);
838 auto subcommands = app.get_subcommands();
839 const std::string message = std::string(
"No handler for subcommand ") + subcommands[0]->get_name();
846 if (acir_roundtrip_cmd->parsed()) {
852 if (msgpack_schema_command->parsed()) {
856 if (msgpack_curve_constants_command->parsed()) {
860 if (msgpack_run_command->parsed()) {
861 return execute_msgpack_run(msgpack_input_file, max_clients, request_ring_size, response_ring_size);
863 if (aztec_process->parsed()) {
865 throw_or_abort(
"Aztec artifact processing is not supported in WASM builds.");
868 if (cache_paths_command->parsed()) {
873 if (!artifact_output_path.empty() && artifact_input_paths.size() > 1) {
874 throw_or_abort(
"Cannot specify --output when multiple --input flags are provided.");
878 if (artifact_input_paths.empty()) {
879 artifact_input_paths.push_back(
".");
883 if (artifact_input_paths.size() > 1) {
885 for (
const auto& input : artifact_input_paths) {
886 if (std::filesystem::is_directory(input)) {
887 throw_or_abort(
"When using multiple --input flags, all inputs must be files, not directories.");
892 std::atomic<bool> all_success =
true;
893 std::vector<std::string> failures;
894 std::mutex failures_mutex;
896 parallel_for(artifact_input_paths.size(), [&](
size_t i) {
897 const auto& input = artifact_input_paths[i];
898 if (!process_aztec_artifact(input, input, force_regenerate)) {
900 std::lock_guard<std::mutex> lock(failures_mutex);
901 failures.push_back(input);
906 info(
"Failed to process ", failures.size(),
" artifact(s)");
909 info(
"Successfully processed ", artifact_input_paths.size(),
" artifact(s)");
914 std::string input = artifact_input_paths[0];
917 if (std::filesystem::is_directory(input)) {
919 if (!artifact_output_path.empty()) {
921 "Cannot specify --output when input is a directory. Artifacts are updated in-place.");
928 std::string output = artifact_output_path.empty() ? input : artifact_output_path;
933 else if (avm_prove_command->parsed()) {
935 avm_prove(avm_inputs_path, avm_prove_output_path);
936 }
else if (avm_check_circuit_command->parsed()) {
938 }
else if (avm_verify_command->parsed()) {
939 return avm_verify(proof_path, avm_public_inputs_path) ? 0 : 1;
940 }
else if (avm_simulate_command->parsed()) {
942 }
else if (avm_write_vk_command->parsed()) {
944 }
else if (flags.scheme ==
"chonk") {
946 if (prove->parsed()) {
947 if (!std::filesystem::exists(ivc_inputs_path)) {
948 throw_or_abort(
"The prove command for Chonk expect a valid file passed with --ivc_inputs_path "
949 "<ivc-inputs.msgpack> (default ./ivc-inputs.msgpack)");
951 api.
prove(flags, ivc_inputs_path, output_path);
952#if !defined(__wasm__) || defined(ENABLE_WASM_BENCH)
954 vinfo(
"Printing BB_BENCH results...");
958 if (!bench_out.empty()) {
959 std::ofstream file(bench_out);
962 if (!bench_out_hierarchical.empty()) {
963 std::ofstream file(bench_out_hierarchical);
969 if (check->parsed()) {
970 if (!std::filesystem::exists(ivc_inputs_path)) {
971 throw_or_abort(
"The check command for Chonk expect a valid file passed with --ivc_inputs_path "
972 "<ivc-inputs.msgpack> (default ./ivc-inputs.msgpack)");
976 if (batch_verify->parsed()) {
977 const bool verified = api.
batch_verify(flags, batch_verify_proofs_dir);
978 vinfo(
"batch verified: ", verified);
979 return verified ? 0 : 1;
981 return execute_non_prove_command(api);
982 }
else if (flags.scheme ==
"ultra_honk") {
984 if (prove->parsed()) {
985 api.
prove(flags, bytecode_path, witness_path, vk_path, output_path);
986#if !defined(__wasm__) || defined(ENABLE_WASM_BENCH)
990 if (!bench_out.empty()) {
991 std::ofstream file(bench_out);
994 if (!bench_out_hierarchical.empty()) {
995 std::ofstream file(bench_out_hierarchical);
1001 return execute_non_prove_command(api);
1006 }
catch (std::runtime_error
const& err) {
1007#ifndef BB_NO_EXCEPTIONS