22 request.ivc_stack_depth = 0;
29 if (!request.ivc_in_progress) {
33 request.loaded_circuit_name = circuit.name;
35 request.loaded_circuit_vk = circuit.verification_key;
37 info(
"ChonkLoad - loaded circuit '", request.loaded_circuit_name,
"'");
45 if (!request.ivc_in_progress) {
49 if (!request.loaded_circuit_constraints.has_value()) {
57 auto circuit = acir_format::create_circuit<IVCBase::ClientCircuit>(program, metadata);
62 precomputed_vk =
nullptr;
64 if (!request.loaded_circuit_vk.empty()) {
65 precomputed_vk = from_buffer<std::shared_ptr<Chonk::MegaVerificationKey>>(request.loaded_circuit_vk);
72 if (*precomputed_vk != *computed_vk) {
73 throw_or_abort(
"VK check failed for circuit '" + request.loaded_circuit_name +
74 "': provided VK does not match computed VK");
79 throw_or_abort(
"Invalid VK policy. Valid options: default, check, recompute");
82 info(
"ChonkAccumulate - accumulating circuit '", request.loaded_circuit_name,
"'");
83 request.ivc_in_progress->accumulate(circuit, precomputed_vk);
84 request.ivc_stack_depth++;
86 request.loaded_circuit_constraints.reset();
87 request.loaded_circuit_vk.clear();
95 if (!request.ivc_in_progress) {
99 if (request.ivc_stack_depth == 0) {
100 throw_or_abort(
"No circuits accumulated. Call ChonkAccumulate first.");
103 info(
"ChonkProve - generating proof for ", request.ivc_stack_depth,
" accumulated circuits");
107 bool verification_passed =
false;
109 info(
"ChonkProve - using Chonk");
111 auto proof = sumcheck_ivc->prove();
112 auto vk_and_hash = sumcheck_ivc->get_hiding_kernel_vk_and_hash();
116 info(
"ChonkProve - verifying the generated proof as a sanity check");
118 verification_passed = verifier.
verify(proof);
120 if (!verification_passed) {
126 request.ivc_in_progress.reset();
127 request.ivc_stack_depth = 0;
141 const bool verified = verifier.
verify(proof);
143 return { .valid = verified };
157 info(
"ChonkComputeStandaloneVk - deriving VK for circuit '", circuit.name,
"'");
165 return { .bytes =
to_buffer(*verification_key), .fields = verification_key->to_field_elements() };
171 info(
"ChonkComputeIvcVk - deriving IVC VK for circuit '", circuit.name,
"'");
178 auto hiding_kernel_vk = from_buffer<Chonk::MegaVerificationKey>(standalone_vk_response.bytes);
182 info(
"ChonkComputeIvcVk - hiding kernel VK derived, size: ", response.
bytes.size(),
" bytes");
196 if (circuit.verification_key.empty()) {
197 info(
"FAIL: Expected precomputed vk for function ", circuit.name);
202 auto precomputed_vk = from_buffer<std::shared_ptr<Chonk::MegaVerificationKey>>(circuit.verification_key);
205 response.
valid =
true;
206 if (*computed_vk != *precomputed_vk) {
207 response.valid =
false;
208 response.actual_vk =
to_buffer(computed_vk);
222 const auto& ivc_constraints = constraint_system.hn_recursion_constraints;
227 .collect_gates_per_opcode = include_gates_per_opcode
231 auto builder = acir_format::create_circuit<MegaCircuitBuilder>(program, metadata);
232 builder.finalize_circuit(
true);
235 response.
acir_opcodes = program.constraints.num_acir_opcodes;
239 if (include_gates_per_opcode) {
240 response.
gates_per_opcode = std::vector<uint32_t>(program.constraints.gates_per_opcode.begin(),
241 program.constraints.gates_per_opcode.end());
245 info(
"ChonkStats - circuit: ",
#define BB_BENCH_NAME(name)
Chonk-specific command definitions for the Barretenberg RPC API.
Verifier for Chonk IVC proofs (both native and recursive).
Output verify(const Proof &proof)
Verify a Chonk proof.
VerifierCommitmentKey< Curve > vk
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
std::vector< uint8_t > to_buffer(T const &value)
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.
ChonkProof 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)
uint32_t acir_opcodes
Number of ACIR opcodes.
std::vector< uint32_t > gates_per_opcode
Optional: gate counts per opcode.
Response execute(BBApiRequest &request) &&
Contains the verification result.
Response execute(const BBApiRequest &request={}) &&
void throw_or_abort(std::string const &err)