32void write_standalone_vk(std::vector<uint8_t> bytecode,
33 const std::filesystem::path& output_path,
34 bool use_structured_trace =
true)
39 }.execute({ .trace_settings = trace_settings });
41 bool is_stdout = output_path ==
"-";
45 write_file(output_path /
"vk", response.bytes);
48void write_civc_vk(std::vector<uint8_t> bytecode,
const std::filesystem::path& output_dir)
51 info(
"ClientIVC: computing IVC vk for hiding kernel circuit");
54 const bool output_to_stdout = output_dir ==
"-";
55 if (output_to_stdout) {
64 const std::filesystem::path& input_path,
65 const std::filesystem::path& output_dir)
72 info(
"ClientIVC: starting with ",
76 for (
const auto& step : raw_steps) {
78 .
circuit = { .
name = step.function_name, .bytecode = step.bytecode, .verification_key = step.vk }
82 info(
"ClientIVC: accumulating " + step.function_name);
90 const bool output_to_stdout = output_dir ==
"-";
92 const auto write_proof = [&]() {
94 if (output_to_stdout) {
95 vinfo(
"writing ClientIVC proof to stdout");
98 vinfo(
"writing ClientIVC proof in directory ", output_dir);
106 vinfo(
"writing ClientIVC vk in directory ", output_dir);
108 write_civc_vk(raw_steps[raw_steps.size() - 1].bytecode, output_dir);
113 [[maybe_unused]]
const std::filesystem::path& public_inputs_path,
114 const std::filesystem::path& proof_path,
115 const std::filesystem::path& vk_path)
118 auto proof_fields = many_from_buffer<fr>(
read_file(proof_path));
124 return response.valid;
136 auto proof = ivc->prove();
148 [[maybe_unused]]
const std::filesystem::path& output_path,
149 [[maybe_unused]]
const std::filesystem::path& vk_path)
161 bool check_failed =
false;
162 for (
auto& step : raw_steps) {
163 if (step.vk.empty()) {
164 info(
"FAIL: Expected precomputed vk for function ", step.function_name);
168 .
circuit = { .
name = step.function_name, .bytecode = step.bytecode, .verification_key = step.vk }
171 if (!response.valid) {
175 step.vk = response.actual_vk;
187 const std::filesystem::path& bytecode_path,
188 const std::filesystem::path& output_path)
193 write_civc_vk(bytecode, output_path);
195 write_standalone_vk(bytecode, output_path);
198 write_standalone_vk(bytecode, output_path,
false);
200 const std::string msg = std::string(
"Can't write vk for verifier type ") + flags.
verifier_type;
206 [[maybe_unused]]
const std::filesystem::path& bytecode_path,
207 [[maybe_unused]]
const std::filesystem::path& witness_path)
217 std::string functions_string =
"{\"functions\": [\n ";
223 .include_gates_per_opcode = include_gates_per_opcode }
228 std::string gates_per_opcode_str;
229 if (include_gates_per_opcode && !response.gates_per_opcode.empty()) {
230 for (
size_t j = 0; j < response.gates_per_opcode.size(); j++) {
231 gates_per_opcode_str +=
std::to_string(response.gates_per_opcode[j]);
232 if (j != response.gates_per_opcode.size() - 1) {
233 gates_per_opcode_str +=
",";
237 auto result_string =
format(
238 "{\n \"acir_opcodes\": ",
239 response.acir_opcodes,
240 ",\n \"circuit_size\": ",
241 response.circuit_size,
242 (include_gates_per_opcode ?
format(
",\n \"gates_per_opcode\": [", gates_per_opcode_str,
"]") :
""),
244 functions_string =
format(functions_string, result_string);
void write_bytes_to_stdout(const std::vector< uint8_t > &data)
Writes raw bytes of the vector to stdout.
#define BB_BENCH_NAME(name)
void gates(const Flags &flags, const std::filesystem::path &bytecode_path) override
bool check(const Flags &flags, const std::filesystem::path &bytecode_path, const std::filesystem::path &witness_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_precomputed_vks(const Flags &flags, const std::filesystem::path &input_path)
bool prove_and_verify(const std::filesystem::path &input_path)
void write_solidity_verifier(const Flags &flags, const std::filesystem::path &output_path, const std::filesystem::path &vk_path) override
void prove(const Flags &flags, const std::filesystem::path &input_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
static bool verify(const Proof &proof, const VerificationKey &vk)
std::string format(Args... args)
std::vector< uint8_t > get_bytecode(const std::string &bytecodePath)
bool USE_SUMCHECK_IVC
Global flag to control whether to use SumcheckClientIVC instead of ClientIVC.
Entry point for Barretenberg command-line interface.
void gate_count_for_ivc(const std::string &bytecode_path, bool include_gates_per_opcode)
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 include_gates_per_opcode
std::string verifier_type
static Proof from_field_elements(const std::vector< ClientIVC::FF > &fields)
static void compress_and_save(std::vector< PrivateExecutionStepRaw > &&steps, const std::filesystem::path &output_path)
static std::vector< PrivateExecutionStepRaw > load_and_decompress(const std::filesystem::path &input_path)
std::shared_ptr< ClientIVC > accumulate()
void parse(std::vector< PrivateExecutionStepRaw > &&steps)
TraceSettings trace_settings
Accumulate the previously loaded circuit into the IVC proof.
std::vector< uint8_t > witness
Serialized witness data for the last loaded circuit.
Verify that a precomputed verification key matches the circuit.
CircuitInput circuit
Circuit with its precomputed verification key.
Compute IVC verification key for the complete proof.
Compute standalone verification key for a circuit.
Load a circuit into the ClientIVC instance for accumulation.
CircuitInput circuit
Circuit to be loaded with its bytecode and verification key.
ClientIVC::Proof proof
Complete IVC proof for all accumulated circuits.
Generate a proof for all accumulated circuits.
Response execute(BBApiRequest &request) &&
Initialize a new ClientIVC instance for incremental proof accumulation.
Get gate counts for a circuit.
CircuitInputNoVK circuit
The circuit to analyze.
Verify a ClientIVC proof with its verification key.
ClientIVC::Proof proof
The ClientIVC proof to verify.
void throw_or_abort(std::string const &err)