26void write_vk_outputs(
const bbapi::CircuitComputeVk::Response& vk_response,
const std::filesystem::path& output_dir)
28 write_file(output_dir /
"vk", vk_response.bytes);
29 info(
"VK saved to ", output_dir /
"vk");
30 write_file(output_dir /
"vk_hash", vk_response.hash);
31 info(
"VK Hash saved to ", output_dir /
"vk_hash");
34void write_proof_outputs(
const bbapi::CircuitProve::Response& prove_response,
const std::filesystem::path& output_dir)
36 auto public_inputs_buf =
to_buffer(prove_response.public_inputs);
37 auto proof_buf =
to_buffer(prove_response.proof);
39 write_file(output_dir /
"public_inputs", public_inputs_buf);
41 info(
"Public inputs saved to ", output_dir /
"public_inputs");
42 info(
"Proof saved to ", output_dir /
"proof");
48 [[maybe_unused]]
const std::filesystem::path& bytecode_path,
49 [[maybe_unused]]
const std::filesystem::path& witness_path)
56 const std::filesystem::path& bytecode_path,
57 const std::filesystem::path& witness_path,
58 const std::filesystem::path& vk_path,
59 const std::filesystem::path& output_dir)
63 if (output_dir ==
"-") {
64 throw_or_abort(
"Stdout output is not supported. Please specify an output directory.");
77 std::vector<uint8_t> vk_bytes;
79 if (!vk_path.empty() && !flags.
write_vk) {
86 .verification_key =
std::move(vk_bytes) },
90 write_proof_outputs(response, output_dir);
92 write_vk_outputs(response.vk, output_dir);
97 const std::filesystem::path& public_inputs_path,
98 const std::filesystem::path& proof_path,
99 const std::filesystem::path& vk_path)
103 auto public_inputs = many_from_buffer<uint256_t>(
read_file(public_inputs_path));
104 auto proof = many_from_buffer<uint256_t>(
read_file(proof_path));
114 .public_inputs =
std::move(public_inputs),
116 .settings = settings }
119 return response.verified;
123 [[maybe_unused]]
const std::filesystem::path& bytecode_path,
124 [[maybe_unused]]
const std::filesystem::path& witness_path)
131 const std::filesystem::path& bytecode_path,
132 const std::filesystem::path& output_dir)
136 if (output_dir ==
"-") {
137 throw_or_abort(
"Stdout output is not supported. Please specify an output directory.");
149 .settings = settings }
152 write_vk_outputs(response, output_dir);
156 [[maybe_unused]]
const std::filesystem::path& bytecode_path)
163 std::string functions_string =
"{\"functions\": [\n ";
169 .oracle_hash_type = flags.oracle_hash_type,
170 .disable_zk = flags.disable_zk };
174 .include_gates_per_opcode = flags.include_gates_per_opcode,
175 .settings = settings }
178 vinfo(
"Calculated circuit size in gate_count: ", response.num_gates);
181 std::string gates_per_opcode_str;
182 if (flags.include_gates_per_opcode) {
184 for (
size_t count : response.gates_per_opcode) {
186 gates_per_opcode_str +=
",";
195 auto result_string =
format(
196 "{\n \"acir_opcodes\": ",
197 response.num_acir_opcodes,
198 ",\n \"circuit_size\": ",
200 (flags.include_gates_per_opcode ?
format(
",\n \"gates_per_opcode\": [", gates_per_opcode_str,
"]") :
""),
203 functions_string =
format(functions_string, result_string);
208 const std::filesystem::path& output_path,
209 const std::filesystem::path& vk_path)
225 if (output_path ==
"-") {
228 write_file(output_path, { response.solidity_code.begin(), response.solidity_code.end() });
230 info(
"Honk solidity verifier saved to ", output_path);
232 info(
"ZK Honk solidity verifier saved to ", output_path);
#define BB_BENCH_NAME(name)
UltraHonk-specific command definitions for the Barretenberg RPC API.
void prove(const Flags &flags, const std::filesystem::path &bytecode_path, const std::filesystem::path &witness_path, const std::filesystem::path &vk_path, const std::filesystem::path &output_dir)
void write_vk(const Flags &flags, const std::filesystem::path &bytecode_path, const std::filesystem::path &output_path) override
bool verify(const Flags &flags, const std::filesystem::path &public_inputs_path, const std::filesystem::path &proof_path, const std::filesystem::path &vk_path) override
bool check(const Flags &flags, const std::filesystem::path &bytecode_path, const std::filesystem::path &witness_path) override
bool prove_and_verify(const Flags &flags, const std::filesystem::path &bytecode_path, const std::filesystem::path &witness_path)
void gates(const Flags &flags, const std::filesystem::path &bytecode_path) override
void write_solidity_verifier(const Flags &flags, const std::filesystem::path &output_path, const std::filesystem::path &vk_path) override
std::string format(Args... args)
std::vector< uint8_t > get_bytecode(const std::string &bytecodePath)
Entry point for Barretenberg command-line interface.
std::vector< uint8_t > read_file(const std::string &filename, size_t bytes=0)
void write_file(const std::string &filename, std::vector< uint8_t > const &data)
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
std::string to_string(bb::avm2::ValueTag tag)
std::vector< uint8_t > to_buffer(T const &value)
bool optimized_solidity_verifier
std::string oracle_hash_type
Represents a request to generate a proof. Currently, UltraHonk is the only proving system supported b...
Consolidated command for retrieving circuit information. Combines gate count, circuit size,...
Verify a proof against a verification key and public inputs.
std::vector< uint8_t > verification_key
Command to generate Solidity verifier contract.
std::vector< uint8_t > verification_key
bool ipa_accumulation
Optional flag to indicate if the proof should be generated with IPA accumulation (i....
void throw_or_abort(std::string const &err)