24 request.ivc_stack_depth = 0;
31 if (!request.ivc_in_progress) {
32 throw_or_abort(
"ClientIVC not started. Call ClientIvcStart first.");
35 request.loaded_circuit_name = circuit.name;
37 request.loaded_circuit_vk = circuit.verification_key;
39 info(
"ClientIvcLoad - loaded circuit '", request.loaded_circuit_name,
"'");
47 if (!request.ivc_in_progress) {
48 throw_or_abort(
"ClientIVC not started. Call ClientIvcStart first.");
51 if (!request.loaded_circuit_constraints.has_value()) {
59 auto circuit = acir_format::create_circuit<IVCBase::ClientCircuit>(program, metadata);
62 if (!request.loaded_circuit_vk.empty()) {
64 precomputed_vk = from_buffer<std::shared_ptr<ClientIVC::MegaVerificationKey>>(request.loaded_circuit_vk);
67 info(
"ClientIvcAccumulate - accumulating circuit '", request.loaded_circuit_name,
"'");
68 request.ivc_in_progress->accumulate(circuit, precomputed_vk);
69 request.ivc_stack_depth++;
71 request.loaded_circuit_constraints.reset();
72 request.loaded_circuit_vk.clear();
80 if (!request.ivc_in_progress) {
81 throw_or_abort(
"ClientIVC not started. Call ClientIvcStart first.");
84 if (request.ivc_stack_depth == 0) {
85 throw_or_abort(
"No circuits accumulated. Call ClientIvcAccumulate first.");
88 info(
"ClientIvcProve - generating proof for ", request.ivc_stack_depth,
" accumulated circuits");
92 bool verification_passed =
false;
95 info(
"ClientIvcProve - using SumcheckClientIVC");
96 auto proof = sumcheck_ivc->prove();
97 auto vk = sumcheck_ivc->get_vk();
101 info(
"ClientIvcProve - verifying the generated proof as a sanity check");
104 if (!verification_passed) {
109 .goblin_proof =
std::move(proof.goblin_proof) };
111 info(
"ClientIvcProve - using ClientIVC");
112 auto proof = client_ivc->prove();
113 auto vk = client_ivc->get_vk();
117 info(
"ClientIvcProve - verifying the generated proof as a sanity check");
120 if (!verification_passed) {
129 request.ivc_in_progress.reset();
130 request.ivc_stack_depth = 0;
144 return { .valid = verified };
159 info(
"ClientIvcComputeStandaloneVk - deriving VK for circuit '", circuit.name,
"'");
167 return { .bytes =
to_buffer(*verification_key), .fields = verification_key->to_field_elements() };
173 info(
"ClientIvcComputeIvcVk - deriving IVC VK for circuit '", circuit.name,
"'");
177 }.execute({ .trace_settings = {} });
179 auto mega_vk = from_buffer<ClientIVC::MegaVerificationKey>(standalone_vk_response.bytes);
188 info(
"ClientIvcComputeIvcVk - IVC VK derived, size: ", response.
bytes.size(),
" bytes");
202 if (circuit.verification_key.empty()) {
203 info(
"FAIL: Expected precomputed vk for function ", circuit.name);
208 auto precomputed_vk = from_buffer<std::shared_ptr<ClientIVC::MegaVerificationKey>>(circuit.verification_key);
211 response.
valid =
true;
212 if (*computed_vk != *precomputed_vk) {
213 response.valid =
false;
214 response.actual_vk =
to_buffer(computed_vk);
228 const auto& ivc_constraints = constraint_system.pg_recursion_constraints;
232 .
ivc = ivc_constraints.empty() ? nullptr
233 : create_mock_ivc_from_constraints(ivc_constraints, request.trace_settings),
234 .collect_gates_per_opcode = include_gates_per_opcode
238 auto builder = acir_format::create_circuit<MegaCircuitBuilder>(program, metadata);
239 builder.finalize_circuit(
true);
242 response.
acir_opcodes = program.constraints.num_acir_opcodes;
246 if (include_gates_per_opcode) {
247 response.
gates_per_opcode = std::vector<uint32_t>(program.constraints.gates_per_opcode.begin(),
248 program.constraints.gates_per_opcode.end());
252 info(
"ClientIvcStats - circuit: ",
260 builder.blocks.set_fixed_block_sizes(request.trace_settings);
#define BB_BENCH_NAME(name)
ClientIVC-specific command definitions for the Barretenberg RPC API.
static bool verify(const Proof &proof, const VerificationKey &vk)
static bool verify(const Proof &proof, const VerificationKey &vk)
bool USE_SUMCHECK_IVC
Global flag to control whether to use SumcheckClientIVC instead of ClientIVC.
VerifierCommitmentKey< Curve > vk
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)