108 std::string name =
"Barretenberg\nYour favo(u)rite zkSNARK library written in C++, a perfectly good computer "
109 "programming language.";
113 name +=
"\nAztec Virtual Machine (AVM): enabled";
115 name +=
"\nAztec Virtual Machine (AVM): disabled";
117#ifdef ENABLE_AVM_TRANSPILER
118 name +=
"\nAVM Transpiler: enabled";
120 name +=
"\nAVM Transpiler: disabled";
122#ifdef STARKNET_GARAGA_FLAVORS
123 name +=
"\nStarknet Garaga Extensions: enabled";
125 name +=
"\nStarknet Garaga Extensions: disabled";
127 CLI::App app{ name };
128 argv = app.ensure_utf8(argv);
138 app.require_subcommand(0, 1);
142 std::filesystem::path bytecode_path{
"./target/program.json" };
143 std::filesystem::path witness_path{
"./target/witness.gz" };
144 std::filesystem::path ivc_inputs_path{
"./ivc-inputs.msgpack" };
145 std::filesystem::path output_path{
148 std::filesystem::path public_inputs_path{
"./target/public_inputs" };
149 std::filesystem::path proof_path{
"./target/proof" };
150 std::filesystem::path vk_path{
"./target/vk" };
152 flags.oracle_hash_type =
"poseidon2";
154 flags.include_gates_per_opcode =
false;
160 bool show_extended_help =
false;
161 for (
int i = 1; i < argc; ++i) {
162 if (std::string(argv[i]) ==
"--help-extended") {
163 show_extended_help =
true;
168 const std::string advanced_group = show_extended_help ?
"Advanced Options (Aztec/Power Users)" :
"";
169 const std::string aztec_internal_group = show_extended_help ?
"Aztec Internal Commands" :
"";
171 const auto add_output_path_option = [&](CLI::App* subcommand,
auto& _output_path) {
172 return subcommand->add_option(
"--output_path, -o",
174 "Directory to write files or path of file to write, depending on subcommand.");
178 const auto add_help_extended_flag = [&](CLI::App* subcommand) {
179 subcommand->add_flag(
"--help-extended",
"Show all options including advanced ones.");
186 const auto add_ipa_accumulation_flag = [&](CLI::App* subcommand) {
188 ->add_flag(
"--ipa_accumulation",
189 flags.ipa_accumulation,
190 "Accumulate/Aggregate IPA (Inner Product Argument) claims")
191 ->group(advanced_group);
194 const auto add_scheme_option = [&](CLI::App* subcommand) {
199 "The type of proof to be constructed. This can specify a proving system, an accumulation scheme, or a "
200 "particular type of circuit to be constructed and proven for some implicit scheme.")
201 ->envname(
"BB_SCHEME")
202 ->default_val(
"ultra_honk")
203 ->check(CLI::IsMember({
"chonk",
"avm",
"ultra_honk" }).name(
"is_member"))
204 ->
group(advanced_group);
207 const auto add_crs_path_option = [&](CLI::App* subcommand) {
209 ->add_option(
"--crs_path, -c",
211 "Path CRS directory. Missing CRS files will be retrieved from the internet.")
212 ->check(CLI::ExistingDirectory)
213 ->group(advanced_group);
216 const auto add_oracle_hash_option = [&](CLI::App* subcommand) {
220 flags.oracle_hash_type,
221 "The hash function used by the prover as random oracle standing in for a verifier's challenge "
222 "generation. Poseidon2 is to be used for proofs that are intended to be verified inside of a "
223 "circuit. Keccak is optimized for verification in an Ethereum smart contract, where Keccak "
224 "has a privileged position due to the existence of an EVM precompile. Starknet is optimized "
225 "for verification in a Starknet smart contract, which can be generated using the Garaga library. "
226 "Prefer using --verifier_target instead.")
227 ->check(CLI::IsMember({
"poseidon2",
"keccak",
"starknet" }).name(
"is_member"))
228 ->
group(advanced_group);
231 const auto add_verifier_target_option = [&](CLI::App* subcommand) {
233 ->add_option(
"--verifier_target, -t",
234 flags.verifier_target,
235 "Target verification environment. Determines hash function and ZK settings.\n"
238 " evm Ethereum/Solidity (keccak, ZK)\n"
239 " evm-no-zk Ethereum/Solidity without ZK\n"
240 " noir-recursive Noir circuits (poseidon2, ZK)\n"
241 " noir-recursive-no-zk Noir circuits without ZK\n"
242 " noir-rollup Rollup with IPA (poseidon2, ZK)\n"
243 " noir-rollup-no-zk Rollup without ZK\n"
244 " starknet Starknet via Garaga (ZK)\n"
245 " starknet-no-zk Starknet without ZK")
246 ->envname(
"BB_VERIFIER_TARGET")
247 ->check(CLI::IsMember({
"evm",
250 "noir-recursive-no-zk",
254 "starknet-no-zk" }));
257 const auto add_write_vk_flag = [&](CLI::App* subcommand) {
258 return subcommand->add_flag(
"--write_vk", flags.write_vk,
"Write the provided circuit's verification key");
261 const auto remove_zk_option = [&](CLI::App* subcommand) {
263 ->add_flag(
"--disable_zk",
265 "Use a non-zk version of --scheme. Prefer using --verifier_target *-no-zk variants instead.")
266 ->group(advanced_group);
269 const auto add_bytecode_path_option = [&](CLI::App* subcommand) {
270 subcommand->add_option(
"--bytecode_path, -b", bytecode_path,
"Path to ACIR bytecode generated by Noir.")
274 const auto add_witness_path_option = [&](CLI::App* subcommand) {
275 subcommand->add_option(
"--witness_path, -w", witness_path,
"Path to partial witness generated by Noir.")
279 const auto add_ivc_inputs_path_options = [&](CLI::App* subcommand) {
282 "--ivc_inputs_path", ivc_inputs_path,
"For IVC, path to input stack with bytecode and witnesses.")
283 ->group(advanced_group);
286 const auto add_public_inputs_path_option = [&](CLI::App* subcommand) {
287 return subcommand->add_option(
288 "--public_inputs_path, -i", public_inputs_path,
"Path to public inputs.") ;
291 const auto add_proof_path_option = [&](CLI::App* subcommand) {
292 return subcommand->add_option(
293 "--proof_path, -p", proof_path,
"Path to a proof.") ;
296 const auto add_vk_path_option = [&](CLI::App* subcommand) {
297 return subcommand->add_option(
"--vk_path, -k", vk_path,
"Path to a verification key.")
301 const auto add_verbose_flag = [&](CLI::App* subcommand) {
302 return subcommand->add_flag(
"--verbose, --verbose_logging, -v", flags.verbose,
"Output all logs to stderr.")
303 ->group(advanced_group);
306 const auto add_debug_flag = [&](CLI::App* subcommand) {
307 return subcommand->add_flag(
"--debug_logging, -d", flags.debug,
"Output debug logs to stderr.")
308 ->group(advanced_group);
311 const auto add_include_gates_per_opcode_flag = [&](CLI::App* subcommand) {
312 return subcommand->add_flag(
"--include_gates_per_opcode",
313 flags.include_gates_per_opcode,
314 "Include gates_per_opcode in the output of the gates command.");
317 const auto add_slow_low_memory_flag = [&](CLI::App* subcommand) {
319 ->add_flag(
"--slow_low_memory", flags.slow_low_memory,
"Enable low memory mode (can be 2x slower or more).")
320 ->group(advanced_group);
323 const auto add_storage_budget_option = [&](CLI::App* subcommand) {
325 ->add_option(
"--storage_budget",
326 flags.storage_budget,
327 "Storage budget for FileBackedMemory (e.g. '500m', '2g'). When exceeded, falls "
328 "back to RAM (requires --slow_low_memory).")
329 ->group(advanced_group);
332 const auto add_vk_policy_option = [&](CLI::App* subcommand) {
334 ->add_option(
"--vk_policy",
336 "Policy for handling verification keys. 'default' uses the provided VK as-is, 'check' "
337 "verifies the provided VK matches the computed VK (throws error on mismatch), 'recompute' "
338 "always ignores the provided VK and treats it as nullptr, 'rewrite' checks the VK and "
339 "rewrites the input file with the correct VK if there's a mismatch (for check command).")
340 ->check(CLI::IsMember({
"default",
"check",
"recompute",
"rewrite" }).name(
"is_member"))
341 ->
group(advanced_group);
344 const auto add_optimized_solidity_verifier_flag = [&](CLI::App* subcommand) {
345 return subcommand->add_flag(
346 "--optimized", flags.optimized_solidity_verifier,
"Use the optimized Solidity verifier.");
349 const auto add_output_format_option = [&](CLI::App* subcommand) {
351 ->add_option(
"--output_format",
353 "Output format for proofs and verification keys: 'binary' (default) or 'json'.\n"
354 "JSON format includes metadata like bb_version, scheme, and verifier_target.")
355 ->check(CLI::IsMember({
"binary",
"json" }).name(
"is_member"));
358 bool print_bench =
false;
359 const auto add_print_bench_flag = [&](CLI::App* subcommand) {
362 "--print_bench", print_bench,
"Pretty print op counts to standard error in a human-readable format.")
363 ->group(advanced_group);
366 std::string bench_out;
367 const auto add_bench_out_option = [&](CLI::App* subcommand) {
368 return subcommand->add_option(
"--bench_out", bench_out,
"Path to write the op counts in a json.")
369 ->group(advanced_group);
371 std::string bench_out_hierarchical;
372 const auto add_bench_out_hierarchical_option = [&](CLI::App* subcommand) {
374 ->add_option(
"--bench_out_hierarchical",
375 bench_out_hierarchical,
376 "Path to write the hierarchical benchmark data (op counts and timings with "
377 "parent-child relationships) as json.")
378 ->group(advanced_group);
384 add_verbose_flag(&app);
385 add_debug_flag(&app);
386 add_crs_path_option(&app);
391 app.set_version_flag(
"--version",
BB_VERSION,
"Print the version string.");
396 app.add_flag(
"--help-extended",
"Show all options including advanced and Aztec-specific commands.");
401 CLI::App* check = app.add_subcommand(
403 "A debugging tool to quickly check whether a witness satisfies a circuit The "
404 "function constructs the execution trace and iterates through it row by row, applying the "
405 "polynomial relations defining the gate types. For Chonk, we check the VKs in the folding stack.");
407 add_help_extended_flag(check);
408 add_scheme_option(check);
409 add_bytecode_path_option(check);
410 add_witness_path_option(check);
411 add_ivc_inputs_path_options(check);
412 add_vk_policy_option(check);
417 CLI::App* gates = app.add_subcommand(
"gates",
418 "Construct a circuit from the given bytecode (in particular, expand black box "
419 "functions) and return the gate count information.");
421 add_help_extended_flag(gates);
422 add_scheme_option(gates);
423 add_verbose_flag(gates);
424 add_bytecode_path_option(gates);
425 add_include_gates_per_opcode_flag(gates);
426 add_verifier_target_option(gates);
427 add_oracle_hash_option(gates);
428 add_ipa_accumulation_flag(gates);
433 CLI::App* prove = app.add_subcommand(
"prove",
"Generate a proof.");
435 add_help_extended_flag(prove);
436 add_scheme_option(prove);
437 add_bytecode_path_option(prove);
438 add_witness_path_option(prove);
439 add_output_path_option(prove, output_path);
440 add_ivc_inputs_path_options(prove);
441 add_vk_path_option(prove);
442 add_vk_policy_option(prove);
443 add_verbose_flag(prove);
444 add_debug_flag(prove);
445 add_crs_path_option(prove);
446 add_verifier_target_option(prove);
447 add_oracle_hash_option(prove);
448 add_write_vk_flag(prove);
449 add_ipa_accumulation_flag(prove);
450 remove_zk_option(prove);
451 add_slow_low_memory_flag(prove);
452 add_print_bench_flag(prove);
453 add_bench_out_option(prove);
454 add_bench_out_hierarchical_option(prove);
455 add_storage_budget_option(prove);
456 add_output_format_option(prove);
458 prove->add_flag(
"--verify",
"Verify the proof natively, resulting in a boolean output. Useful for testing.");
464 app.add_subcommand(
"write_vk",
465 "Write the verification key of a circuit. The circuit is constructed using "
466 "quickly generated but invalid witnesses (which must be supplied in Barretenberg in order "
467 "to expand ACIR black box opcodes), and no proof is constructed.");
469 add_help_extended_flag(write_vk);
470 add_scheme_option(write_vk);
471 add_bytecode_path_option(write_vk);
472 add_output_path_option(write_vk, output_path);
473 add_ivc_inputs_path_options(write_vk);
475 add_verbose_flag(write_vk);
476 add_debug_flag(write_vk);
477 add_crs_path_option(write_vk);
478 add_verifier_target_option(write_vk);
479 add_oracle_hash_option(write_vk);
480 add_ipa_accumulation_flag(write_vk);
481 remove_zk_option(write_vk);
482 add_output_format_option(write_vk);
487 CLI::App* verify = app.add_subcommand(
"verify",
"Verify a proof.");
489 add_help_extended_flag(verify);
490 add_public_inputs_path_option(verify);
491 add_proof_path_option(verify);
492 add_vk_path_option(verify);
494 add_verbose_flag(verify);
495 add_debug_flag(verify);
496 add_scheme_option(verify);
497 add_crs_path_option(verify);
498 add_verifier_target_option(verify);
499 add_oracle_hash_option(verify);
500 remove_zk_option(verify);
501 add_ipa_accumulation_flag(verify);
506 CLI::App* write_solidity_verifier =
507 app.add_subcommand(
"write_solidity_verifier",
508 "Write a Solidity smart contract suitable for verifying proofs of circuit "
509 "satisfiability for the circuit with verification key at vk_path. Not all "
510 "hash types are implemented due to efficiency concerns.");
512 add_help_extended_flag(write_solidity_verifier);
513 add_scheme_option(write_solidity_verifier);
514 add_vk_path_option(write_solidity_verifier);
515 add_output_path_option(write_solidity_verifier, output_path);
517 add_verbose_flag(write_solidity_verifier);
518 add_verifier_target_option(write_solidity_verifier);
519 remove_zk_option(write_solidity_verifier);
520 add_crs_path_option(write_solidity_verifier);
521 add_optimized_solidity_verifier_flag(write_solidity_verifier);
523 std::filesystem::path avm_inputs_path{
"./target/avm_inputs.bin" };
524 const auto add_avm_inputs_option = [&](CLI::App* subcommand) {
525 return subcommand->add_option(
"--avm-inputs", avm_inputs_path,
"");
527 std::filesystem::path avm_public_inputs_path{
"./target/avm_public_inputs.bin" };
528 const auto add_avm_public_inputs_option = [&](CLI::App* subcommand) {
529 return subcommand->add_option(
"--avm-public-inputs", avm_public_inputs_path,
"");
535 CLI::App* avm_simulate_command = app.add_subcommand(
"avm_simulate",
"Simulate AVM execution.");
536 avm_simulate_command->group(aztec_internal_group);
537 add_verbose_flag(avm_simulate_command);
538 add_debug_flag(avm_simulate_command);
539 add_avm_inputs_option(avm_simulate_command);
544 CLI::App* avm_prove_command = app.add_subcommand(
"avm_prove",
"Generate an AVM proof.");
545 avm_prove_command->group(aztec_internal_group);
546 add_verbose_flag(avm_prove_command);
547 add_debug_flag(avm_prove_command);
548 add_crs_path_option(avm_prove_command);
549 std::filesystem::path avm_prove_output_path{
"./proofs" };
550 add_output_path_option(avm_prove_command, avm_prove_output_path);
551 add_avm_inputs_option(avm_prove_command);
556 CLI::App* avm_write_vk_command = app.add_subcommand(
"avm_write_vk",
"Write AVM verification key.");
557 avm_write_vk_command->group(aztec_internal_group);
558 add_verbose_flag(avm_write_vk_command);
559 add_debug_flag(avm_write_vk_command);
560 add_crs_path_option(avm_write_vk_command);
561 std::filesystem::path avm_write_vk_output_path{
"./keys" };
562 add_output_path_option(avm_write_vk_command, avm_write_vk_output_path);
567 CLI::App* avm_check_circuit_command = app.add_subcommand(
"avm_check_circuit",
"Check AVM circuit satisfiability.");
568 avm_check_circuit_command->group(aztec_internal_group);
569 add_verbose_flag(avm_check_circuit_command);
570 add_debug_flag(avm_check_circuit_command);
571 add_crs_path_option(avm_check_circuit_command);
572 add_avm_inputs_option(avm_check_circuit_command);
577 CLI::App* avm_verify_command = app.add_subcommand(
"avm_verify",
"Verify an AVM proof.");
578 avm_verify_command->group(aztec_internal_group);
579 add_verbose_flag(avm_verify_command);
580 add_debug_flag(avm_verify_command);
581 add_crs_path_option(avm_verify_command);
582 add_avm_public_inputs_option(avm_verify_command);
583 add_proof_path_option(avm_verify_command);
588 CLI::App* aztec_process = app.add_subcommand(
590 "Process Aztec contract artifacts: transpile and generate verification keys for all private functions.\n"
591 "If input is a directory (and no output specified), recursively processes all artifacts found in the "
593 "Multiple -i flags can be specified when no -o flag is present for parallel processing.");
594 aztec_process->group(aztec_internal_group);
596 std::vector<std::string> artifact_input_paths;
597 std::string artifact_output_path;
598 bool force_regenerate =
false;
600 aztec_process->add_option(
"-i,--input",
601 artifact_input_paths,
602 "Input artifact JSON path or directory to search (optional, defaults to current "
603 "directory). Can be specified multiple times when no -o flag is present.");
604 aztec_process->add_option(
606 artifact_output_path,
607 "Output artifact JSON path (optional, same as input if not specified). Cannot be used with multiple -i flags.");
608 aztec_process->add_flag(
"-f,--force", force_regenerate,
"Force regeneration of verification keys");
609 add_verbose_flag(aztec_process);
610 add_debug_flag(aztec_process);
615 CLI::App* cache_paths_command =
616 aztec_process->add_subcommand(
"cache_paths",
617 "Output cache paths for verification keys in an artifact.\n"
618 "Format: <hash>:<cache_path>:<function_name> (one per line).");
620 std::string cache_paths_input;
621 cache_paths_command->add_option(
"input", cache_paths_input,
"Input artifact JSON path (required).")->required();
622 add_verbose_flag(cache_paths_command);
623 add_debug_flag(cache_paths_command);
628 CLI::App* msgpack_command = app.add_subcommand(
"msgpack",
"Msgpack API interface.");
631 CLI::App* msgpack_schema_command =
632 msgpack_command->add_subcommand(
"schema",
"Output a msgpack schema encoded as JSON to stdout.");
633 add_verbose_flag(msgpack_schema_command);
636 CLI::App* msgpack_curve_constants_command =
637 msgpack_command->add_subcommand(
"curve_constants",
"Output curve constants as msgpack to stdout.");
638 add_verbose_flag(msgpack_curve_constants_command);
641 CLI::App* msgpack_run_command =
642 msgpack_command->add_subcommand(
"run",
"Execute msgpack API commands from stdin or file.");
643 add_verbose_flag(msgpack_run_command);
644 std::string msgpack_input_file;
645 msgpack_run_command->add_option(
646 "-i,--input", msgpack_input_file,
"Input file containing msgpack buffers (defaults to stdin)");
647 size_t request_ring_size = 1024 * 1024;
650 "--request-ring-size", request_ring_size,
"Request ring buffer size for shared memory IPC (default: 1MB)")
651 ->check(CLI::PositiveNumber);
652 size_t response_ring_size = 1024 * 1024;
654 ->add_option(
"--response-ring-size",
656 "Response ring buffer size for shared memory IPC (default: 1MB)")
657 ->check(CLI::PositiveNumber);
660 ->add_option(
"--max-clients",
662 "Maximum concurrent clients for socket IPC servers (default: 1, only used for .sock files)")
663 ->check(CLI::PositiveNumber);
672 if (show_extended_help) {
679 if (!flags.verifier_target.empty()) {
683 if (active_sub !=
nullptr) {
685 auto get_option_count = [](CLI::App* sub,
const std::string& name) ->
size_t {
687 return sub->get_option(name)->count();
688 }
catch (
const CLI::OptionNotFound&) {
693 if (get_option_count(active_sub,
"--oracle_hash") > 0) {
694 throw_or_abort(
"Cannot use --verifier_target with --oracle_hash. "
695 "The --verifier_target flag sets oracle_hash automatically.");
697 if (get_option_count(active_sub,
"--disable_zk") > 0) {
699 "Use a '-no-zk' variant of --verifier_target instead (e.g., 'evm-no-zk').");
701 if (get_option_count(active_sub,
"--ipa_accumulation") > 0) {
702 throw_or_abort(
"Cannot use --verifier_target with --ipa_accumulation. "
703 "Use '--verifier_target noir-rollup' for IPA accumulation.");
708 if (flags.verifier_target ==
"evm") {
709 flags.oracle_hash_type =
"keccak";
710 }
else if (flags.verifier_target ==
"evm-no-zk") {
711 flags.oracle_hash_type =
"keccak";
712 flags.disable_zk =
true;
713 }
else if (flags.verifier_target ==
"noir-recursive") {
714 flags.oracle_hash_type =
"poseidon2";
715 }
else if (flags.verifier_target ==
"noir-recursive-no-zk") {
716 flags.oracle_hash_type =
"poseidon2";
717 flags.disable_zk =
true;
718 }
else if (flags.verifier_target ==
"noir-rollup") {
719 flags.oracle_hash_type =
"poseidon2";
720 flags.ipa_accumulation =
true;
721 }
else if (flags.verifier_target ==
"noir-rollup-no-zk") {
722 flags.oracle_hash_type =
"poseidon2";
723 flags.ipa_accumulation =
true;
724 flags.disable_zk =
true;
725 }
else if (flags.verifier_target ==
"starknet") {
726 flags.oracle_hash_type =
"starknet";
727 }
else if (flags.verifier_target ==
"starknet-no-zk") {
728 flags.oracle_hash_type =
"starknet";
729 flags.disable_zk =
true;
731 vinfo(
"verifier_target '",
732 flags.verifier_target,
733 "' -> oracle_hash_type='",
734 flags.oracle_hash_type,
737 ", ipa_accumulation=",
738 flags.ipa_accumulation);
744 if ((prove->parsed() || write_vk->parsed()) && output_path !=
"-") {
746 std::filesystem::create_directories(output_path);
750 }
else if (flags.verbose) {
754#if !defined(__wasm__) || defined(ENABLE_WASM_BENCH)
755 if (!flags.storage_budget.empty()) {
758 if (print_bench || !bench_out.empty() || !bench_out_hierarchical.empty()) {
760 vinfo(
"BB_BENCH enabled via --print_bench or --bench_out");
772 const auto execute_non_prove_command = [&](
API& api) {
773 if (check->parsed()) {
774 api.check(flags, bytecode_path, witness_path);
777 if (gates->parsed()) {
778 api.gates(flags, bytecode_path);
781 if (write_vk->parsed()) {
782 api.write_vk(flags, bytecode_path, output_path);
785 if (verify->parsed()) {
786 const bool verified = api.verify(flags, public_inputs_path, proof_path, vk_path);
787 vinfo(
"verified: ", verified);
788 return verified ? 0 : 1;
790 if (write_solidity_verifier->parsed()) {
792 if (!flags.verifier_target.empty() && flags.verifier_target !=
"evm" &&
793 flags.verifier_target !=
"evm-no-zk") {
794 throw_or_abort(
"write_solidity_verifier requires --verifier_target to be 'evm' or 'evm-no-zk', got '" +
795 flags.verifier_target +
"'");
797 api.write_solidity_verifier(flags, output_path, vk_path);
800 auto subcommands = app.get_subcommands();
801 const std::string message = std::string(
"No handler for subcommand ") + subcommands[0]->get_name();
808 if (msgpack_schema_command->parsed()) {
812 if (msgpack_curve_constants_command->parsed()) {
816 if (msgpack_run_command->parsed()) {
817 return execute_msgpack_run(msgpack_input_file, max_clients, request_ring_size, response_ring_size);
819 if (aztec_process->parsed()) {
821 throw_or_abort(
"Aztec artifact processing is not supported in WASM builds.");
824 if (cache_paths_command->parsed()) {
829 if (!artifact_output_path.empty() && artifact_input_paths.size() > 1) {
830 throw_or_abort(
"Cannot specify --output when multiple --input flags are provided.");
834 if (artifact_input_paths.empty()) {
835 artifact_input_paths.push_back(
".");
839 if (artifact_input_paths.size() > 1) {
841 for (
const auto& input : artifact_input_paths) {
842 if (std::filesystem::is_directory(input)) {
843 throw_or_abort(
"When using multiple --input flags, all inputs must be files, not directories.");
848 std::atomic<bool> all_success =
true;
849 std::vector<std::string> failures;
850 std::mutex failures_mutex;
852 parallel_for(artifact_input_paths.size(), [&](
size_t i) {
853 const auto& input = artifact_input_paths[i];
854 if (!process_aztec_artifact(input, input, force_regenerate)) {
856 std::lock_guard<std::mutex> lock(failures_mutex);
857 failures.push_back(input);
862 info(
"Failed to process ", failures.size(),
" artifact(s)");
865 info(
"Successfully processed ", artifact_input_paths.size(),
" artifact(s)");
870 std::string input = artifact_input_paths[0];
873 if (std::filesystem::is_directory(input)) {
875 if (!artifact_output_path.empty()) {
877 "Cannot specify --output when input is a directory. Artifacts are updated in-place.");
884 std::string output = artifact_output_path.empty() ? input : artifact_output_path;
889 else if (avm_prove_command->parsed()) {
891 avm_prove(avm_inputs_path, avm_prove_output_path);
892 }
else if (avm_check_circuit_command->parsed()) {
894 }
else if (avm_verify_command->parsed()) {
895 return avm_verify(proof_path, avm_public_inputs_path) ? 0 : 1;
896 }
else if (avm_simulate_command->parsed()) {
898 }
else if (avm_write_vk_command->parsed()) {
900 }
else if (flags.scheme ==
"chonk") {
902 if (prove->parsed()) {
903 if (!std::filesystem::exists(ivc_inputs_path)) {
904 throw_or_abort(
"The prove command for Chonk expect a valid file passed with --ivc_inputs_path "
905 "<ivc-inputs.msgpack> (default ./ivc-inputs.msgpack)");
907 api.
prove(flags, ivc_inputs_path, output_path);
908#if !defined(__wasm__) || defined(ENABLE_WASM_BENCH)
910 vinfo(
"Printing BB_BENCH results...");
914 if (!bench_out.empty()) {
915 std::ofstream file(bench_out);
918 if (!bench_out_hierarchical.empty()) {
919 std::ofstream file(bench_out_hierarchical);
925 if (check->parsed()) {
926 if (!std::filesystem::exists(ivc_inputs_path)) {
927 throw_or_abort(
"The check command for Chonk expect a valid file passed with --ivc_inputs_path "
928 "<ivc-inputs.msgpack> (default ./ivc-inputs.msgpack)");
932 return execute_non_prove_command(api);
933 }
else if (flags.scheme ==
"ultra_honk") {
935 if (prove->parsed()) {
936 api.
prove(flags, bytecode_path, witness_path, vk_path, output_path);
937#if !defined(__wasm__) || defined(ENABLE_WASM_BENCH)
941 if (!bench_out.empty()) {
942 std::ofstream file(bench_out);
945 if (!bench_out_hierarchical.empty()) {
946 std::ofstream file(bench_out_hierarchical);
952 return execute_non_prove_command(api);
957 }
catch (std::runtime_error
const& err) {
958#ifndef BB_NO_EXCEPTIONS