107 std::string name =
"Barretenberg\nYour favo(u)rite zkSNARK library written in C++, a perfectly good computer "
108 "programming language.";
112 name +=
"\nAztec Virtual Machine (AVM): enabled";
114 name +=
"\nAztec Virtual Machine (AVM): disabled";
116#ifdef ENABLE_AVM_TRANSPILER
117 name +=
"\nAVM Transpiler: enabled";
119 name +=
"\nAVM Transpiler: disabled";
121#ifdef STARKNET_GARAGA_FLAVORS
122 name +=
"\nStarknet Garaga Extensions: enabled";
124 name +=
"\nStarknet Garaga Extensions: disabled";
126 CLI::App app{ name };
127 argv = app.ensure_utf8(argv);
137 app.require_subcommand(0, 1);
141 std::filesystem::path bytecode_path{
"./target/program.json" };
142 std::filesystem::path witness_path{
"./target/witness.gz" };
143 std::filesystem::path ivc_inputs_path{
"./ivc-inputs.msgpack" };
144 std::filesystem::path output_path{
147 std::filesystem::path public_inputs_path{
"./target/public_inputs" };
148 std::filesystem::path proof_path{
"./target/proof" };
149 std::filesystem::path vk_path{
"./target/vk" };
151 flags.oracle_hash_type =
"poseidon2";
153 flags.include_gates_per_opcode =
false;
159 bool show_extended_help =
false;
160 for (
int i = 1; i < argc; ++i) {
161 if (std::string(argv[i]) ==
"--help-extended") {
162 show_extended_help =
true;
167 const std::string advanced_group = show_extended_help ?
"Advanced Options (Aztec/Power Users)" :
"";
168 const std::string aztec_internal_group = show_extended_help ?
"Aztec Internal Commands" :
"";
170 const auto add_output_path_option = [&](CLI::App* subcommand,
auto& _output_path) {
171 return subcommand->add_option(
"--output_path, -o",
173 "Directory to write files or path of file to write, depending on subcommand.");
177 const auto add_help_extended_flag = [&](CLI::App* subcommand) {
178 subcommand->add_flag(
"--help-extended",
"Show all options including advanced ones.");
185 const auto add_ipa_accumulation_flag = [&](CLI::App* subcommand) {
187 ->add_flag(
"--ipa_accumulation",
188 flags.ipa_accumulation,
189 "Accumulate/Aggregate IPA (Inner Product Argument) claims")
190 ->group(advanced_group);
193 const auto add_scheme_option = [&](CLI::App* subcommand) {
198 "The type of proof to be constructed. This can specify a proving system, an accumulation scheme, or a "
199 "particular type of circuit to be constructed and proven for some implicit scheme.")
200 ->envname(
"BB_SCHEME")
201 ->default_val(
"ultra_honk")
202 ->check(CLI::IsMember({
"chonk",
"avm",
"ultra_honk" }).name(
"is_member"))
203 ->
group(advanced_group);
206 const auto add_crs_path_option = [&](CLI::App* subcommand) {
208 ->add_option(
"--crs_path, -c",
210 "Path CRS directory. Missing CRS files will be retrieved from the internet.")
211 ->check(CLI::ExistingDirectory)
212 ->group(advanced_group);
215 const auto add_oracle_hash_option = [&](CLI::App* subcommand) {
219 flags.oracle_hash_type,
220 "The hash function used by the prover as random oracle standing in for a verifier's challenge "
221 "generation. Poseidon2 is to be used for proofs that are intended to be verified inside of a "
222 "circuit. Keccak is optimized for verification in an Ethereum smart contract, where Keccak "
223 "has a privileged position due to the existence of an EVM precompile. Starknet is optimized "
224 "for verification in a Starknet smart contract, which can be generated using the Garaga library. "
225 "Prefer using --verifier_target instead.")
226 ->check(CLI::IsMember({
"poseidon2",
"keccak",
"starknet" }).name(
"is_member"))
227 ->
group(advanced_group);
230 const auto add_verifier_target_option = [&](CLI::App* subcommand) {
232 ->add_option(
"--verifier_target, -t",
233 flags.verifier_target,
234 "Target verification environment. Determines hash function and ZK settings.\n"
237 " evm Ethereum/Solidity (keccak, ZK)\n"
238 " evm-no-zk Ethereum/Solidity without ZK\n"
239 " noir-recursive Noir circuits (poseidon2, ZK)\n"
240 " noir-recursive-no-zk Noir circuits without ZK\n"
241 " noir-rollup Rollup with IPA (poseidon2, ZK)\n"
242 " noir-rollup-no-zk Rollup without ZK\n"
243 " starknet Starknet via Garaga (ZK)\n"
244 " starknet-no-zk Starknet without ZK")
245 ->envname(
"BB_VERIFIER_TARGET")
246 ->check(CLI::IsMember({
"evm",
249 "noir-recursive-no-zk",
253 "starknet-no-zk" }));
256 const auto add_write_vk_flag = [&](CLI::App* subcommand) {
257 return subcommand->add_flag(
"--write_vk", flags.write_vk,
"Write the provided circuit's verification key");
260 const auto remove_zk_option = [&](CLI::App* subcommand) {
262 ->add_flag(
"--disable_zk",
264 "Use a non-zk version of --scheme. Prefer using --verifier_target *-no-zk variants instead.")
265 ->group(advanced_group);
268 const auto add_bytecode_path_option = [&](CLI::App* subcommand) {
269 subcommand->add_option(
"--bytecode_path, -b", bytecode_path,
"Path to ACIR bytecode generated by Noir.")
273 const auto add_witness_path_option = [&](CLI::App* subcommand) {
274 subcommand->add_option(
"--witness_path, -w", witness_path,
"Path to partial witness generated by Noir.")
278 const auto add_ivc_inputs_path_options = [&](CLI::App* subcommand) {
281 "--ivc_inputs_path", ivc_inputs_path,
"For IVC, path to input stack with bytecode and witnesses.")
282 ->group(advanced_group);
285 const auto add_public_inputs_path_option = [&](CLI::App* subcommand) {
286 return subcommand->add_option(
287 "--public_inputs_path, -i", public_inputs_path,
"Path to public inputs.") ;
290 const auto add_proof_path_option = [&](CLI::App* subcommand) {
291 return subcommand->add_option(
292 "--proof_path, -p", proof_path,
"Path to a proof.") ;
295 const auto add_vk_path_option = [&](CLI::App* subcommand) {
296 return subcommand->add_option(
"--vk_path, -k", vk_path,
"Path to a verification key.")
300 const auto add_verbose_flag = [&](CLI::App* subcommand) {
301 return subcommand->add_flag(
"--verbose, --verbose_logging, -v", flags.verbose,
"Output all logs to stderr.")
302 ->group(advanced_group);
305 const auto add_debug_flag = [&](CLI::App* subcommand) {
306 return subcommand->add_flag(
"--debug_logging, -d", flags.debug,
"Output debug logs to stderr.")
307 ->group(advanced_group);
310 const auto add_include_gates_per_opcode_flag = [&](CLI::App* subcommand) {
311 return subcommand->add_flag(
"--include_gates_per_opcode",
312 flags.include_gates_per_opcode,
313 "Include gates_per_opcode in the output of the gates command.");
316 const auto add_slow_low_memory_flag = [&](CLI::App* subcommand) {
318 ->add_flag(
"--slow_low_memory", flags.slow_low_memory,
"Enable low memory mode (can be 2x slower or more).")
319 ->group(advanced_group);
322 const auto add_storage_budget_option = [&](CLI::App* subcommand) {
324 ->add_option(
"--storage_budget",
325 flags.storage_budget,
326 "Storage budget for FileBackedMemory (e.g. '500m', '2g'). When exceeded, falls "
327 "back to RAM (requires --slow_low_memory).")
328 ->group(advanced_group);
331 const auto add_vk_policy_option = [&](CLI::App* subcommand) {
333 ->add_option(
"--vk_policy",
335 "Policy for handling verification keys. 'default' uses the provided VK as-is, 'check' "
336 "verifies the provided VK matches the computed VK (throws error on mismatch), 'recompute' "
337 "always ignores the provided VK and treats it as nullptr, 'rewrite' checks the VK and "
338 "rewrites the input file with the correct VK if there's a mismatch (for check command).")
339 ->check(CLI::IsMember({
"default",
"check",
"recompute",
"rewrite" }).name(
"is_member"))
340 ->
group(advanced_group);
343 const auto add_optimized_solidity_verifier_flag = [&](CLI::App* subcommand) {
344 return subcommand->add_flag(
345 "--optimized", flags.optimized_solidity_verifier,
"Use the optimized Solidity verifier.");
348 const auto add_output_format_option = [&](CLI::App* subcommand) {
350 ->add_option(
"--output_format",
352 "Output format for proofs and verification keys: 'binary' (default) or 'json'.\n"
353 "JSON format includes metadata like bb_version, scheme, and verifier_target.")
354 ->check(CLI::IsMember({
"binary",
"json" }).name(
"is_member"));
357 bool print_bench =
false;
358 const auto add_print_bench_flag = [&](CLI::App* subcommand) {
361 "--print_bench", print_bench,
"Pretty print op counts to standard error in a human-readable format.")
362 ->group(advanced_group);
365 std::string bench_out;
366 const auto add_bench_out_option = [&](CLI::App* subcommand) {
367 return subcommand->add_option(
"--bench_out", bench_out,
"Path to write the op counts in a json.")
368 ->group(advanced_group);
370 std::string bench_out_hierarchical;
371 const auto add_bench_out_hierarchical_option = [&](CLI::App* subcommand) {
373 ->add_option(
"--bench_out_hierarchical",
374 bench_out_hierarchical,
375 "Path to write the hierarchical benchmark data (op counts and timings with "
376 "parent-child relationships) as json.")
377 ->group(advanced_group);
383 add_verbose_flag(&app);
384 add_debug_flag(&app);
385 add_crs_path_option(&app);
390 app.set_version_flag(
"--version",
BB_VERSION,
"Print the version string.");
395 app.add_flag(
"--help-extended",
"Show all options including advanced and Aztec-specific commands.");
400 CLI::App* check = app.add_subcommand(
402 "A debugging tool to quickly check whether a witness satisfies a circuit The "
403 "function constructs the execution trace and iterates through it row by row, applying the "
404 "polynomial relations defining the gate types. For Chonk, we check the VKs in the folding stack.");
406 add_help_extended_flag(check);
407 add_scheme_option(check);
408 add_bytecode_path_option(check);
409 add_witness_path_option(check);
410 add_ivc_inputs_path_options(check);
411 add_vk_policy_option(check);
416 CLI::App* gates = app.add_subcommand(
"gates",
417 "Construct a circuit from the given bytecode (in particular, expand black box "
418 "functions) and return the gate count information.");
420 add_help_extended_flag(gates);
421 add_scheme_option(gates);
422 add_verbose_flag(gates);
423 add_bytecode_path_option(gates);
424 add_include_gates_per_opcode_flag(gates);
425 add_verifier_target_option(gates);
426 add_oracle_hash_option(gates);
427 add_ipa_accumulation_flag(gates);
432 CLI::App* prove = app.add_subcommand(
"prove",
"Generate a proof.");
434 add_help_extended_flag(prove);
435 add_scheme_option(prove);
436 add_bytecode_path_option(prove);
437 add_witness_path_option(prove);
438 add_output_path_option(prove, output_path);
439 add_ivc_inputs_path_options(prove);
440 add_vk_path_option(prove);
441 add_vk_policy_option(prove);
442 add_verbose_flag(prove);
443 add_debug_flag(prove);
444 add_crs_path_option(prove);
445 add_verifier_target_option(prove);
446 add_oracle_hash_option(prove);
447 add_write_vk_flag(prove);
448 add_ipa_accumulation_flag(prove);
449 remove_zk_option(prove);
450 add_slow_low_memory_flag(prove);
451 add_print_bench_flag(prove);
452 add_bench_out_option(prove);
453 add_bench_out_hierarchical_option(prove);
454 add_storage_budget_option(prove);
455 add_output_format_option(prove);
457 prove->add_flag(
"--verify",
"Verify the proof natively, resulting in a boolean output. Useful for testing.");
463 app.add_subcommand(
"write_vk",
464 "Write the verification key of a circuit. The circuit is constructed using "
465 "quickly generated but invalid witnesses (which must be supplied in Barretenberg in order "
466 "to expand ACIR black box opcodes), and no proof is constructed.");
468 add_help_extended_flag(write_vk);
469 add_scheme_option(write_vk);
470 add_bytecode_path_option(write_vk);
471 add_output_path_option(write_vk, output_path);
472 add_ivc_inputs_path_options(write_vk);
474 add_verbose_flag(write_vk);
475 add_debug_flag(write_vk);
476 add_crs_path_option(write_vk);
477 add_verifier_target_option(write_vk);
478 add_oracle_hash_option(write_vk);
479 add_ipa_accumulation_flag(write_vk);
480 remove_zk_option(write_vk);
481 add_output_format_option(write_vk);
486 CLI::App* verify = app.add_subcommand(
"verify",
"Verify a proof.");
488 add_help_extended_flag(verify);
489 add_public_inputs_path_option(verify);
490 add_proof_path_option(verify);
491 add_vk_path_option(verify);
493 add_verbose_flag(verify);
494 add_debug_flag(verify);
495 add_scheme_option(verify);
496 add_crs_path_option(verify);
497 add_verifier_target_option(verify);
498 add_oracle_hash_option(verify);
499 remove_zk_option(verify);
500 add_ipa_accumulation_flag(verify);
505 CLI::App* write_solidity_verifier =
506 app.add_subcommand(
"write_solidity_verifier",
507 "Write a Solidity smart contract suitable for verifying proofs of circuit "
508 "satisfiability for the circuit with verification key at vk_path. Not all "
509 "hash types are implemented due to efficiency concerns.");
511 add_help_extended_flag(write_solidity_verifier);
512 add_scheme_option(write_solidity_verifier);
513 add_vk_path_option(write_solidity_verifier);
514 add_output_path_option(write_solidity_verifier, output_path);
516 add_verbose_flag(write_solidity_verifier);
517 add_verifier_target_option(write_solidity_verifier);
518 remove_zk_option(write_solidity_verifier);
519 add_crs_path_option(write_solidity_verifier);
520 add_optimized_solidity_verifier_flag(write_solidity_verifier);
522 std::filesystem::path avm_inputs_path{
"./target/avm_inputs.bin" };
523 const auto add_avm_inputs_option = [&](CLI::App* subcommand) {
524 return subcommand->add_option(
"--avm-inputs", avm_inputs_path,
"");
526 std::filesystem::path avm_public_inputs_path{
"./target/avm_public_inputs.bin" };
527 const auto add_avm_public_inputs_option = [&](CLI::App* subcommand) {
528 return subcommand->add_option(
"--avm-public-inputs", avm_public_inputs_path,
"");
534 CLI::App* avm_simulate_command = app.add_subcommand(
"avm_simulate",
"Simulate AVM execution.");
535 avm_simulate_command->group(aztec_internal_group);
536 add_verbose_flag(avm_simulate_command);
537 add_debug_flag(avm_simulate_command);
538 add_avm_inputs_option(avm_simulate_command);
543 CLI::App* avm_prove_command = app.add_subcommand(
"avm_prove",
"Generate an AVM proof.");
544 avm_prove_command->group(aztec_internal_group);
545 add_verbose_flag(avm_prove_command);
546 add_debug_flag(avm_prove_command);
547 add_crs_path_option(avm_prove_command);
548 std::filesystem::path avm_prove_output_path{
"./proofs" };
549 add_output_path_option(avm_prove_command, avm_prove_output_path);
550 add_avm_inputs_option(avm_prove_command);
555 CLI::App* avm_write_vk_command = app.add_subcommand(
"avm_write_vk",
"Write AVM verification key.");
556 avm_write_vk_command->group(aztec_internal_group);
557 add_verbose_flag(avm_write_vk_command);
558 add_debug_flag(avm_write_vk_command);
559 add_crs_path_option(avm_write_vk_command);
560 std::filesystem::path avm_write_vk_output_path{
"./keys" };
561 add_output_path_option(avm_write_vk_command, avm_write_vk_output_path);
566 CLI::App* avm_check_circuit_command = app.add_subcommand(
"avm_check_circuit",
"Check AVM circuit satisfiability.");
567 avm_check_circuit_command->group(aztec_internal_group);
568 add_verbose_flag(avm_check_circuit_command);
569 add_debug_flag(avm_check_circuit_command);
570 add_crs_path_option(avm_check_circuit_command);
571 add_avm_inputs_option(avm_check_circuit_command);
576 CLI::App* avm_verify_command = app.add_subcommand(
"avm_verify",
"Verify an AVM proof.");
577 avm_verify_command->group(aztec_internal_group);
578 add_verbose_flag(avm_verify_command);
579 add_debug_flag(avm_verify_command);
580 add_crs_path_option(avm_verify_command);
581 add_avm_public_inputs_option(avm_verify_command);
582 add_proof_path_option(avm_verify_command);
587 CLI::App* aztec_process = app.add_subcommand(
589 "Process Aztec contract artifacts: transpile and generate verification keys for all private functions.\n"
590 "If input is a directory (and no output specified), recursively processes all artifacts found in the "
592 "Multiple -i flags can be specified when no -o flag is present for parallel processing.");
593 aztec_process->group(aztec_internal_group);
595 std::vector<std::string> artifact_input_paths;
596 std::string artifact_output_path;
597 bool force_regenerate =
false;
599 aztec_process->add_option(
"-i,--input",
600 artifact_input_paths,
601 "Input artifact JSON path or directory to search (optional, defaults to current "
602 "directory). Can be specified multiple times when no -o flag is present.");
603 aztec_process->add_option(
605 artifact_output_path,
606 "Output artifact JSON path (optional, same as input if not specified). Cannot be used with multiple -i flags.");
607 aztec_process->add_flag(
"-f,--force", force_regenerate,
"Force regeneration of verification keys");
608 add_verbose_flag(aztec_process);
609 add_debug_flag(aztec_process);
614 CLI::App* cache_paths_command =
615 aztec_process->add_subcommand(
"cache_paths",
616 "Output cache paths for verification keys in an artifact.\n"
617 "Format: <hash>:<cache_path>:<function_name> (one per line).");
619 std::string cache_paths_input;
620 cache_paths_command->add_option(
"input", cache_paths_input,
"Input artifact JSON path (required).")->required();
621 add_verbose_flag(cache_paths_command);
622 add_debug_flag(cache_paths_command);
627 CLI::App* msgpack_command = app.add_subcommand(
"msgpack",
"Msgpack API interface.");
630 CLI::App* msgpack_schema_command =
631 msgpack_command->add_subcommand(
"schema",
"Output a msgpack schema encoded as JSON to stdout.");
632 add_verbose_flag(msgpack_schema_command);
635 CLI::App* msgpack_curve_constants_command =
636 msgpack_command->add_subcommand(
"curve_constants",
"Output curve constants as msgpack to stdout.");
637 add_verbose_flag(msgpack_curve_constants_command);
640 CLI::App* msgpack_run_command =
641 msgpack_command->add_subcommand(
"run",
"Execute msgpack API commands from stdin or file.");
642 add_verbose_flag(msgpack_run_command);
643 std::string msgpack_input_file;
644 msgpack_run_command->add_option(
645 "-i,--input", msgpack_input_file,
"Input file containing msgpack buffers (defaults to stdin)");
646 size_t request_ring_size = 1024 * 1024;
649 "--request-ring-size", request_ring_size,
"Request ring buffer size for shared memory IPC (default: 1MB)")
650 ->check(CLI::PositiveNumber);
651 size_t response_ring_size = 1024 * 1024;
653 ->add_option(
"--response-ring-size",
655 "Response ring buffer size for shared memory IPC (default: 1MB)")
656 ->check(CLI::PositiveNumber);
659 ->add_option(
"--max-clients",
661 "Maximum concurrent clients for socket IPC servers (default: 1, only used for .sock files)")
662 ->check(CLI::PositiveNumber);
671 if (show_extended_help) {
678 if (!flags.verifier_target.empty()) {
682 if (active_sub !=
nullptr) {
684 auto get_option_count = [](CLI::App* sub,
const std::string& name) ->
size_t {
686 return sub->get_option(name)->count();
687 }
catch (
const CLI::OptionNotFound&) {
692 if (get_option_count(active_sub,
"--oracle_hash") > 0) {
693 throw_or_abort(
"Cannot use --verifier_target with --oracle_hash. "
694 "The --verifier_target flag sets oracle_hash automatically.");
696 if (get_option_count(active_sub,
"--disable_zk") > 0) {
698 "Use a '-no-zk' variant of --verifier_target instead (e.g., 'evm-no-zk').");
700 if (get_option_count(active_sub,
"--ipa_accumulation") > 0) {
701 throw_or_abort(
"Cannot use --verifier_target with --ipa_accumulation. "
702 "Use '--verifier_target noir-rollup' for IPA accumulation.");
707 if (flags.verifier_target ==
"evm") {
708 flags.oracle_hash_type =
"keccak";
709 }
else if (flags.verifier_target ==
"evm-no-zk") {
710 flags.oracle_hash_type =
"keccak";
711 flags.disable_zk =
true;
712 }
else if (flags.verifier_target ==
"noir-recursive") {
713 flags.oracle_hash_type =
"poseidon2";
714 }
else if (flags.verifier_target ==
"noir-recursive-no-zk") {
715 flags.oracle_hash_type =
"poseidon2";
716 flags.disable_zk =
true;
717 }
else if (flags.verifier_target ==
"noir-rollup") {
718 flags.oracle_hash_type =
"poseidon2";
719 flags.ipa_accumulation =
true;
720 }
else if (flags.verifier_target ==
"noir-rollup-no-zk") {
721 flags.oracle_hash_type =
"poseidon2";
722 flags.ipa_accumulation =
true;
723 flags.disable_zk =
true;
724 }
else if (flags.verifier_target ==
"starknet") {
725 flags.oracle_hash_type =
"starknet";
726 }
else if (flags.verifier_target ==
"starknet-no-zk") {
727 flags.oracle_hash_type =
"starknet";
728 flags.disable_zk =
true;
730 vinfo(
"verifier_target '",
731 flags.verifier_target,
732 "' -> oracle_hash_type='",
733 flags.oracle_hash_type,
736 ", ipa_accumulation=",
737 flags.ipa_accumulation);
743 if ((prove->parsed() || write_vk->parsed()) && output_path !=
"-") {
745 std::filesystem::create_directories(output_path);
749 }
else if (flags.verbose) {
753#if !defined(__wasm__) || defined(ENABLE_WASM_BENCH)
754 if (!flags.storage_budget.empty()) {
757 if (print_bench || !bench_out.empty() || !bench_out_hierarchical.empty()) {
759 vinfo(
"BB_BENCH enabled via --print_bench or --bench_out");
771 const auto execute_non_prove_command = [&](
API& api) {
772 if (check->parsed()) {
773 api.check(flags, bytecode_path, witness_path);
776 if (gates->parsed()) {
777 api.gates(flags, bytecode_path);
780 if (write_vk->parsed()) {
781 api.write_vk(flags, bytecode_path, output_path);
784 if (verify->parsed()) {
785 const bool verified = api.verify(flags, public_inputs_path, proof_path, vk_path);
786 vinfo(
"verified: ", verified);
787 return verified ? 0 : 1;
789 if (write_solidity_verifier->parsed()) {
791 if (!flags.verifier_target.empty() && flags.verifier_target !=
"evm" &&
792 flags.verifier_target !=
"evm-no-zk") {
793 throw_or_abort(
"write_solidity_verifier requires --verifier_target to be 'evm' or 'evm-no-zk', got '" +
794 flags.verifier_target +
"'");
796 api.write_solidity_verifier(flags, output_path, vk_path);
799 auto subcommands = app.get_subcommands();
800 const std::string message = std::string(
"No handler for subcommand ") + subcommands[0]->get_name();
807 if (msgpack_schema_command->parsed()) {
811 if (msgpack_curve_constants_command->parsed()) {
815 if (msgpack_run_command->parsed()) {
816 return execute_msgpack_run(msgpack_input_file, max_clients, request_ring_size, response_ring_size);
818 if (aztec_process->parsed()) {
820 throw_or_abort(
"Aztec artifact processing is not supported in WASM builds.");
823 if (cache_paths_command->parsed()) {
828 if (!artifact_output_path.empty() && artifact_input_paths.size() > 1) {
829 throw_or_abort(
"Cannot specify --output when multiple --input flags are provided.");
833 if (artifact_input_paths.empty()) {
834 artifact_input_paths.push_back(
".");
838 if (artifact_input_paths.size() > 1) {
840 for (
const auto& input : artifact_input_paths) {
841 if (std::filesystem::is_directory(input)) {
842 throw_or_abort(
"When using multiple --input flags, all inputs must be files, not directories.");
847 std::atomic<bool> all_success =
true;
848 std::vector<std::string> failures;
849 std::mutex failures_mutex;
851 parallel_for(artifact_input_paths.size(), [&](
size_t i) {
852 const auto& input = artifact_input_paths[i];
853 if (!process_aztec_artifact(input, input, force_regenerate)) {
855 std::lock_guard<std::mutex> lock(failures_mutex);
856 failures.push_back(input);
861 info(
"Failed to process ", failures.size(),
" artifact(s)");
864 info(
"Successfully processed ", artifact_input_paths.size(),
" artifact(s)");
869 std::string input = artifact_input_paths[0];
872 if (std::filesystem::is_directory(input)) {
874 if (!artifact_output_path.empty()) {
876 "Cannot specify --output when input is a directory. Artifacts are updated in-place.");
883 std::string output = artifact_output_path.empty() ? input : artifact_output_path;
888 else if (avm_prove_command->parsed()) {
890 avm_prove(avm_inputs_path, avm_prove_output_path);
891 }
else if (avm_check_circuit_command->parsed()) {
893 }
else if (avm_verify_command->parsed()) {
894 return avm_verify(proof_path, avm_public_inputs_path) ? 0 : 1;
895 }
else if (avm_simulate_command->parsed()) {
897 }
else if (avm_write_vk_command->parsed()) {
899 }
else if (flags.scheme ==
"chonk") {
901 if (prove->parsed()) {
902 if (!std::filesystem::exists(ivc_inputs_path)) {
903 throw_or_abort(
"The prove command for Chonk expect a valid file passed with --ivc_inputs_path "
904 "<ivc-inputs.msgpack> (default ./ivc-inputs.msgpack)");
906 api.
prove(flags, ivc_inputs_path, output_path);
907#if !defined(__wasm__) || defined(ENABLE_WASM_BENCH)
909 vinfo(
"Printing BB_BENCH results...");
913 if (!bench_out.empty()) {
914 std::ofstream file(bench_out);
917 if (!bench_out_hierarchical.empty()) {
918 std::ofstream file(bench_out_hierarchical);
924 if (check->parsed()) {
925 if (!std::filesystem::exists(ivc_inputs_path)) {
926 throw_or_abort(
"The check command for Chonk expect a valid file passed with --ivc_inputs_path "
927 "<ivc-inputs.msgpack> (default ./ivc-inputs.msgpack)");
931 return execute_non_prove_command(api);
932 }
else if (flags.scheme ==
"ultra_honk") {
934 if (prove->parsed()) {
935 api.
prove(flags, bytecode_path, witness_path, vk_path, output_path);
936#if !defined(__wasm__) || defined(ENABLE_WASM_BENCH)
940 if (!bench_out.empty()) {
941 std::ofstream file(bench_out);
944 if (!bench_out_hierarchical.empty()) {
945 std::ofstream file(bench_out_hierarchical);
951 return execute_non_prove_command(api);
956 }
catch (std::runtime_error
const& err) {
957#ifndef BB_NO_EXCEPTIONS