19 request.ivc_stack_depth = 0;
25 if (!request.ivc_in_progress) {
26 throw_or_abort(
"ClientIVC not started. Call ClientIvcStart first.");
29 request.loaded_circuit_name = circuit.name;
31 request.loaded_circuit_vk = circuit.verification_key;
33 info(
"ClientIvcLoad - loaded circuit '", request.loaded_circuit_name,
"'");
40 if (!request.ivc_in_progress) {
41 throw_or_abort(
"ClientIVC not started. Call ClientIvcStart first.");
44 if (!request.loaded_circuit_constraints.has_value()) {
52 auto circuit = acir_format::create_circuit<ClientIVC::ClientCircuit>(program, metadata);
55 if (!request.loaded_circuit_vk.empty()) {
56 precomputed_vk = from_buffer<std::shared_ptr<ClientIVC::MegaVerificationKey>>(request.loaded_circuit_vk);
59 info(
"ClientIvcAccumulate - accumulating circuit '", request.loaded_circuit_name,
"'");
60 request.ivc_in_progress->accumulate(circuit, precomputed_vk);
61 request.ivc_stack_depth++;
63 request.loaded_circuit_constraints.reset();
64 request.loaded_circuit_vk.clear();
71 if (!request.ivc_in_progress) {
72 throw_or_abort(
"ClientIVC not started. Call ClientIvcStart first.");
75 if (request.ivc_stack_depth == 0) {
76 throw_or_abort(
"No circuits accumulated. Call ClientIvcAccumulate first.");
79 info(
"ClientIvcProve - generating proof for ", request.ivc_stack_depth,
" accumulated circuits");
83 info(
"ClientIvcProve - verifying the generated proof as a sanity check");
84 if (!request.ivc_in_progress->verify(proof)) {
88 request.ivc_in_progress.reset();
89 request.ivc_stack_depth = 0;
99 const auto verification_key = from_buffer<ClientIVC::VerificationKey>(
vk);
104 return { .valid = verified };
118 info(
"ClientIvcComputeStandaloneVk - deriving VK for circuit '", circuit.name,
"'");
126 return { .bytes =
to_buffer(*verification_key), .fields = verification_key->to_field_elements() };
131 info(
"ClientIvcComputeIvcVk - deriving IVC VK for circuit '", circuit.name,
"'");
135 }.execute({ .trace_settings = {} });
137 auto mega_vk = from_buffer<ClientIVC::MegaVerificationKey>(standalone_vk_response.bytes);
146 info(
"ClientIvcComputeIvcVk - IVC VK derived, size: ", response.
bytes.size(),
" bytes");
159 if (circuit.verification_key.empty()) {
160 info(
"FAIL: Expected precomputed vk for function ", circuit.name);
164 auto precomputed_vk = from_buffer<std::shared_ptr<ClientIVC::MegaVerificationKey>>(circuit.verification_key);
167 response.
valid =
true;
168 std::string error_message =
"Precomputed vk does not match computed vk for function " + circuit.name;
170 response.valid =
false;
171 response.actual_vk =
to_buffer(computed_vk);
184 const auto& ivc_constraints = constraint_system.pg_recursion_constraints;
188 .
ivc = ivc_constraints.empty() ? nullptr
189 : create_mock_ivc_from_constraints(ivc_constraints, request.trace_settings),
190 .collect_gates_per_opcode = include_gates_per_opcode
194 auto builder = acir_format::create_circuit<MegaCircuitBuilder>(program, metadata);
195 builder.finalize_circuit(
true);
198 response.
acir_opcodes =
static_cast<uint32_t
>(program.constraints.num_acir_opcodes);
202 if (include_gates_per_opcode) {
203 response.
gates_per_opcode = std::vector<uint32_t>(program.constraints.gates_per_opcode.begin(),
204 program.constraints.gates_per_opcode.end());
208 info(
"ClientIvcStats - circuit: ",
216 builder.blocks.set_fixed_block_sizes(request.trace_settings);
ClientIVC-specific command definitions for the Barretenberg RPC API.
static bool verify(const Proof &proof, const VerificationKey &vk)
VerifierCommitmentKey< Curve > vk
bool msgpack_check_eq(const T &v1, const T &v2, const std::string_view &error_message)
Ensures that two msgpack objects are equal by applying the msgpack method to both and comparing the r...
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
std::vector< uint8_t > to_buffer(T const &value)
A full proof for the IVC scheme containing a Mega proof showing correctness of the hiding circuit (wh...
std::shared_ptr< MegaVerificationKey > mega
TraceSettings trace_settings
Empty response indicating successful circuit accumulation.
Response execute(BBApiRequest &request) &&
Contains the validation result.
bool valid
True if the precomputed VK matches the circuit.
Response execute(const BBApiRequest &request={}) &&
Contains the computed IVC verification key.
std::vector< uint8_t > bytes
Serialized IVC verification key in binary format.
Response execute(const BBApiRequest &request={}) &&
Contains the computed verification key in multiple formats.
Compute standalone verification key for a circuit.
Response execute(const BBApiRequest &request={}) &&
Empty response indicating successful circuit loading.
Response execute(BBApiRequest &request) &&
Contains the generated IVC proof.
ClientIVC::Proof proof
Complete IVC proof for all accumulated circuits.
Response execute(BBApiRequest &request) &&
Empty response indicating successful initialization.
Response execute(BBApiRequest &request) &&
Contains gate count information.
uint32_t circuit_size
Circuit size (total number of gates)
std::vector< uint32_t > gates_per_opcode
Optional: gate counts per opcode.
uint32_t acir_opcodes
Number of ACIR opcodes.
Response execute(BBApiRequest &request) &&
Contains the verification result.
Response execute(const BBApiRequest &request={}) &&
void throw_or_abort(std::string const &err)