Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
bbapi_chonk.hpp
Go to the documentation of this file.
1#pragma once
14#include <vector>
15
16namespace bb::bbapi {
17
24struct ChonkStart {
25 static constexpr const char MSGPACK_SCHEMA_NAME[] = "ChonkStart";
26
31 struct Response {
32 static constexpr const char MSGPACK_SCHEMA_NAME[] = "ChonkStartResponse";
33 // Empty response - success indicated by no exception
34 void msgpack(auto&& pack_fn) { pack_fn(); }
35 bool operator==(const Response&) const = default;
36 };
37 // Number of circuits to be accumulated.
39 Response execute(BBApiRequest& request) &&;
41 bool operator==(const ChonkStart&) const = default;
42};
43
48struct ChonkLoad {
49 static constexpr const char MSGPACK_SCHEMA_NAME[] = "ChonkLoad";
50
55 struct Response {
56 static constexpr const char MSGPACK_SCHEMA_NAME[] = "ChonkLoadResponse";
57 // Empty response - success indicated by no exception
58 void msgpack(auto&& pack_fn) { pack_fn(); }
59 bool operator==(const Response&) const = default;
60 };
61
64 Response execute(BBApiRequest& request) &&;
66 bool operator==(const ChonkLoad&) const = default;
67};
68
74 static constexpr const char MSGPACK_SCHEMA_NAME[] = "ChonkAccumulate";
75
80 struct Response {
81 static constexpr const char MSGPACK_SCHEMA_NAME[] = "ChonkAccumulateResponse";
82 // Empty response - success indicated by no exception
83 void msgpack(auto&& pack_fn) { pack_fn(); }
84 bool operator==(const Response&) const = default;
85 };
86
88 std::vector<uint8_t> witness;
89 Response execute(BBApiRequest& request) &&;
91 bool operator==(const ChonkAccumulate&) const = default;
92};
93
98struct ChonkProve {
99 static constexpr const char MSGPACK_SCHEMA_NAME[] = "ChonkProve";
100
105 struct Response {
106 static constexpr const char MSGPACK_SCHEMA_NAME[] = "ChonkProveResponse";
107
111 bool operator==(const Response&) const = default;
112 };
113 Response execute(BBApiRequest& request) &&;
114 void msgpack(auto&& pack_fn) { pack_fn(); }
115 bool operator==(const ChonkProve&) const = default;
116};
117
123 static constexpr const char MSGPACK_SCHEMA_NAME[] = "ChonkVerify";
124
129 struct Response {
130 static constexpr const char MSGPACK_SCHEMA_NAME[] = "ChonkVerifyResponse";
131
133 bool valid;
135 bool operator==(const Response&) const = default;
136 };
137
141 std::vector<uint8_t> vk;
142 Response execute(const BBApiRequest& request = {}) &&;
144 bool operator==(const ChonkVerify&) const = default;
145};
146
156 static constexpr const char MSGPACK_SCHEMA_NAME[] = "ChonkComputeVk";
157
162 struct Response {
163 static constexpr const char MSGPACK_SCHEMA_NAME[] = "ChonkComputeVkResponse";
164
166 std::vector<uint8_t> bytes;
168 std::vector<bb::fr> fields;
170 bool operator==(const Response&) const = default;
171 };
172
174 Response execute([[maybe_unused]] const BBApiRequest& request = {}) &&;
176 bool operator==(const ChonkComputeVk&) const = default;
177};
178
184 static constexpr const char MSGPACK_SCHEMA_NAME[] = "ChonkCheckPrecomputedVk";
185
190 struct Response {
191 static constexpr const char MSGPACK_SCHEMA_NAME[] = "ChonkCheckPrecomputedVkResponse";
192
194 bool valid;
196 std::vector<uint8_t> actual_vk;
198 bool operator==(const Response&) const = default;
199 };
200
203
204 Response execute(const BBApiRequest& request = {}) &&;
206 bool operator==(const ChonkCheckPrecomputedVk&) const = default;
207};
208
214 static constexpr const char MSGPACK_SCHEMA_NAME[] = "ChonkStats";
215
220 struct Response {
221 static constexpr const char MSGPACK_SCHEMA_NAME[] = "ChonkStatsResponse";
222
224 uint32_t acir_opcodes;
226 uint32_t circuit_size;
228 std::vector<uint32_t> gates_per_opcode;
230 bool operator==(const Response&) const = default;
231 };
232
237 Response execute(BBApiRequest& request) &&;
239 bool operator==(const ChonkStats&) const = default;
240};
241
242} // namespace bb::bbapi
Shared type definitions for the Barretenberg RPC API.
Empty response indicating successful circuit accumulation.
bool operator==(const Response &) const =default
static constexpr const char MSGPACK_SCHEMA_NAME[]
Accumulate the previously loaded circuit into the IVC proof.
static constexpr const char MSGPACK_SCHEMA_NAME[]
std::vector< uint8_t > witness
Serialized witness data for the last loaded circuit.
Response execute(BBApiRequest &request) &&
bool operator==(const ChonkAccumulate &) const =default
Contains the validation result.
std::vector< uint8_t > actual_vk
The actual VK it should be.
bool valid
True if the precomputed VK matches the circuit.
bool operator==(const Response &) const =default
static constexpr const char MSGPACK_SCHEMA_NAME[]
Verify that a precomputed verification key matches the circuit.
bool operator==(const ChonkCheckPrecomputedVk &) const =default
Response execute(const BBApiRequest &request={}) &&
CircuitInput circuit
Circuit with its precomputed verification key.
static constexpr const char MSGPACK_SCHEMA_NAME[]
Contains the computed verification key in multiple formats.
static constexpr const char MSGPACK_SCHEMA_NAME[]
std::vector< uint8_t > bytes
Serialized MegaVerificationKey in binary format.
std::vector< bb::fr > fields
Verification key as array of field elements.
bool operator==(const Response &) const =default
Compute MegaHonk verification key for a circuit to be accumulated in Chonk.
static constexpr const char MSGPACK_SCHEMA_NAME[]
Response execute(const BBApiRequest &request={}) &&
bool operator==(const ChonkComputeVk &) const =default
Empty response indicating successful circuit loading.
void msgpack(auto &&pack_fn)
static constexpr const char MSGPACK_SCHEMA_NAME[]
bool operator==(const Response &) const =default
Load a circuit into the Chonk instance for accumulation.
static constexpr const char MSGPACK_SCHEMA_NAME[]
bool operator==(const ChonkLoad &) const =default
Response execute(BBApiRequest &request) &&
CircuitInput circuit
Circuit to be loaded with its bytecode and verification key.
Contains the generated IVC proof.
bool operator==(const Response &) const =default
static constexpr const char MSGPACK_SCHEMA_NAME[]
ChonkProof proof
Complete IVC proof for all accumulated circuits.
Generate a proof for all accumulated circuits.
static constexpr const char MSGPACK_SCHEMA_NAME[]
void msgpack(auto &&pack_fn)
bool operator==(const ChonkProve &) const =default
Response execute(BBApiRequest &request) &&
Empty response indicating successful initialization.
bool operator==(const Response &) const =default
void msgpack(auto &&pack_fn)
static constexpr const char MSGPACK_SCHEMA_NAME[]
Initialize a new Chonk instance for incremental proof accumulation.
Response execute(BBApiRequest &request) &&
bool operator==(const ChonkStart &) const =default
static constexpr const char MSGPACK_SCHEMA_NAME[]
MSGPACK_FIELDS(num_circuits)
Contains gate count information.
MSGPACK_FIELDS(acir_opcodes, circuit_size, gates_per_opcode)
uint32_t circuit_size
Circuit size (total number of gates)
static constexpr const char MSGPACK_SCHEMA_NAME[]
uint32_t acir_opcodes
Number of ACIR opcodes.
std::vector< uint32_t > gates_per_opcode
Optional: gate counts per opcode.
bool operator==(const Response &) const =default
Get gate counts for a circuit.
bool include_gates_per_opcode
Whether to include detailed gate counts per opcode.
static constexpr const char MSGPACK_SCHEMA_NAME[]
bool operator==(const ChonkStats &) const =default
CircuitInputNoVK circuit
The circuit to analyze.
MSGPACK_FIELDS(circuit, include_gates_per_opcode)
Response execute(BBApiRequest &request) &&
Contains the verification result.
bool valid
True if the proof is valid.
static constexpr const char MSGPACK_SCHEMA_NAME[]
bool operator==(const Response &) const =default
Verify a Chonk proof with its verification key.
static constexpr const char MSGPACK_SCHEMA_NAME[]
std::vector< uint8_t > vk
The verification key.
Response execute(const BBApiRequest &request={}) &&
bool operator==(const ChonkVerify &) const =default
ChonkProof proof
The Chonk proof to verify.
A circuit to be used in either ultrahonk or Chonk proving.
A circuit to be used in either ultrahonk or chonk verification key derivation.