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
152 static constexpr const char MSGPACK_SCHEMA_NAME[] = "ChonkComputeStandaloneVk";
153
158 struct Response {
159 static constexpr const char MSGPACK_SCHEMA_NAME[] = "ChonkComputeStandaloneVkResponse";
160
162 std::vector<uint8_t> bytes;
164 std::vector<bb::fr> fields;
166 bool operator==(const Response&) const = default;
167 };
168
170 Response execute([[maybe_unused]] const BBApiRequest& request = {}) &&;
172 bool operator==(const ChonkComputeStandaloneVk&) const = default;
173};
174
180 static constexpr const char MSGPACK_SCHEMA_NAME[] = "ChonkComputeIvcVk";
181
186 struct Response {
187 static constexpr const char MSGPACK_SCHEMA_NAME[] = "ChonkComputeIvcVkResponse";
188
190 std::vector<uint8_t> bytes;
192 bool operator==(const Response&) const = default;
193 };
194
196 Response execute(const BBApiRequest& request = {}) &&;
198 bool operator==(const ChonkComputeIvcVk&) const = default;
199};
200
206 static constexpr const char MSGPACK_SCHEMA_NAME[] = "ChonkCheckPrecomputedVk";
207
212 struct Response {
213 static constexpr const char MSGPACK_SCHEMA_NAME[] = "ChonkCheckPrecomputedVkResponse";
214
216 bool valid;
218 std::vector<uint8_t> actual_vk;
220 bool operator==(const Response&) const = default;
221 };
222
225
226 Response execute(const BBApiRequest& request = {}) &&;
228 bool operator==(const ChonkCheckPrecomputedVk&) const = default;
229};
230
236 static constexpr const char MSGPACK_SCHEMA_NAME[] = "ChonkStats";
237
242 struct Response {
243 static constexpr const char MSGPACK_SCHEMA_NAME[] = "ChonkStatsResponse";
244
246 uint32_t acir_opcodes;
248 uint32_t circuit_size;
250 std::vector<uint32_t> gates_per_opcode;
252 bool operator==(const Response&) const = default;
253 };
254
259 Response execute(BBApiRequest& request) &&;
261 bool operator==(const ChonkStats&) const = default;
262};
263
264} // namespace bb::bbapi
Shared type definitions for the Barretenberg RPC API.
A full proof for the IVC scheme containing a Mega proof showing correctness of the Hiding kernel (whi...
Definition chonk.hpp:91
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 IVC verification key.
bool operator==(const Response &) const =default
static constexpr const char MSGPACK_SCHEMA_NAME[]
std::vector< uint8_t > bytes
Serialized IVC verification key in binary format.
Compute IVC verification key for the complete proof.
static constexpr const char MSGPACK_SCHEMA_NAME[]
Response execute(const BBApiRequest &request={}) &&
bool operator==(const ChonkComputeIvcVk &) const =default
Contains the computed verification key in multiple formats.
static constexpr const char MSGPACK_SCHEMA_NAME[]
std::vector< bb::fr > fields
Verification key as array of field elements.
std::vector< uint8_t > bytes
Serialized verification key in binary format.
bool operator==(const Response &) const =default
Compute standalone verification key for a circuit.
Response execute(const BBApiRequest &request={}) &&
static constexpr const char MSGPACK_SCHEMA_NAME[]
bool operator==(const ChonkComputeStandaloneVk &) 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[]
Chonk::Proof 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
Chonk::Proof 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.