20#include <condition_variable>
47 void msgpack(
auto&& pack_fn) { pack_fn(); }
71 void msgpack(
auto&& pack_fn) { pack_fn(); }
96 void msgpack(
auto&& pack_fn) { pack_fn(); }
154 std::vector<uint8_t>
vk;
184 std::vector<uint8_t>
vk;
376 const std::string& fifo_path);
Shared type definitions for the Barretenberg RPC API.
Asynchronous batch verifier for Chonk IVC proofs.
FIFO-streaming batch verification service for Chonk proofs.
void enqueue(VerifyRequest request)
~ChonkBatchVerifierService()
ChonkBatchVerifierService(const ChonkBatchVerifierService &)=delete
ChonkBatchVerifier verifier_
void writer_loop(const std::string &fifo_path)
ChonkBatchVerifierService()=default
std::queue< VerifyResult > result_queue_
std::condition_variable result_cv_
std::thread writer_thread_
void start(std::vector< std::shared_ptr< MegaZKFlavor::VKAndHash > > vks, uint32_t num_cores, uint32_t batch_size, const std::string &fifo_path)
ChonkBatchVerifierService & operator=(const ChonkBatchVerifierService &)=delete
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
A request to verify a single Chonk proof.
Empty response indicating successful circuit accumulation.
void msgpack(auto &&pack_fn)
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
SERIALIZATION_FIELDS(witness)
bool operator==(const Response &) const =default
static constexpr const char MSGPACK_SCHEMA_NAME[]
void msgpack(auto &&pack_fn)
Enqueue a proof for batch verification.
Response execute(BBApiRequest &request) &&
std::vector< bb::fr > proof_fields
static constexpr const char MSGPACK_SCHEMA_NAME[]
bool operator==(const ChonkBatchVerifierQueue &) const =default
SERIALIZATION_FIELDS(request_id, vk_index, proof_fields)
void msgpack(auto &&pack_fn)
static constexpr const char MSGPACK_SCHEMA_NAME[]
bool operator==(const Response &) const =default
Start the batch verifier service.
SERIALIZATION_FIELDS(vks, num_cores, batch_size, fifo_path)
Response execute(BBApiRequest &request) &&
bool operator==(const ChonkBatchVerifierStart &) const =default
std::vector< std::vector< uint8_t > > vks
static constexpr const char MSGPACK_SCHEMA_NAME[]
bool operator==(const Response &) const =default
void msgpack(auto &&pack_fn)
static constexpr const char MSGPACK_SCHEMA_NAME[]
Stop the batch verifier service.
void msgpack(auto &&pack_fn)
bool operator==(const ChonkBatchVerifierStop &) const =default
static constexpr const char MSGPACK_SCHEMA_NAME[]
Response execute(BBApiRequest &request) &&
bool operator==(const Response &) const =default
SERIALIZATION_FIELDS(valid)
static constexpr const char MSGPACK_SCHEMA_NAME[]
Batch-verify multiple Chonk proofs with a single IPA SRS MSM.
std::vector< std::vector< uint8_t > > vks
bool operator==(const ChonkBatchVerify &) const =default
SERIALIZATION_FIELDS(proofs, vks)
Response execute(const BBApiRequest &request={}) &&
static constexpr const char MSGPACK_SCHEMA_NAME[]
std::vector< ChonkProof > proofs
Contains the validation result.
std::vector< uint8_t > actual_vk
The actual VK it should be.
SERIALIZATION_FIELDS(valid, actual_vk)
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={}) &&
SERIALIZATION_FIELDS(circuit, use_zk_flavor)
bool use_zk_flavor
When true, derive VK using MegaZKFlavor; otherwise MegaFlavor. The caller sets this to true for the h...
CircuitInput circuit
Circuit with its precomputed verification key.
static constexpr const char MSGPACK_SCHEMA_NAME[]
static constexpr const char MSGPACK_SCHEMA_NAME[]
SERIALIZATION_FIELDS(compressed_proof)
std::vector< uint8_t > compressed_proof
bool operator==(const Response &) const =default
Compress a Chonk proof to a compact byte representation.
bool operator==(const ChonkCompressProof &) const =default
static constexpr const char MSGPACK_SCHEMA_NAME[]
Response execute(const BBApiRequest &request={}) &&
SERIALIZATION_FIELDS(proof)
Contains the computed verification key in multiple formats.
static constexpr const char MSGPACK_SCHEMA_NAME[]
SERIALIZATION_FIELDS(bytes, fields)
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[]
SERIALIZATION_FIELDS(circuit, use_zk_flavor)
Response execute(const BBApiRequest &request={}) &&
bool operator==(const ChonkComputeVk &) const =default
bool use_zk_flavor
When true, derive VK using MegaZKFlavor; otherwise MegaFlavor. The caller sets this to true for the h...
bool operator==(const Response &) const =default
static constexpr const char MSGPACK_SCHEMA_NAME[]
SERIALIZATION_FIELDS(proof)
Decompress a compressed Chonk proof back to field elements.
std::vector< uint8_t > compressed_proof
SERIALIZATION_FIELDS(compressed_proof)
bool operator==(const ChonkDecompressProof &) const =default
static constexpr const char MSGPACK_SCHEMA_NAME[]
Response execute(const BBApiRequest &request={}) &&
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
SERIALIZATION_FIELDS(circuit)
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.
SERIALIZATION_FIELDS(proof)
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[]
SERIALIZATION_FIELDS(num_circuits)
Contains gate count information.
SERIALIZATION_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.
SERIALIZATION_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[]
SERIALIZATION_FIELDS(valid)
bool operator==(const Response &) const =default
SERIALIZATION_FIELDS(valid)
static constexpr const char MSGPACK_SCHEMA_NAME[]
bool valid
True if the proof is valid.
bool operator==(const Response &) const =default
Verify a Chonk proof passed as a flat field-element array (with public inputs prepended).
SERIALIZATION_FIELDS(proof, vk)
std::vector< uint8_t > vk
The verification key.
bool operator==(const ChonkVerifyFromFields &) const =default
std::vector< bb::fr > proof
Flat proof field elements with public inputs prepended.
static constexpr const char MSGPACK_SCHEMA_NAME[]
Response execute(const BBApiRequest &request={}) &&
Verify a Chonk proof with its verification key.
static constexpr const char MSGPACK_SCHEMA_NAME[]
std::vector< uint8_t > vk
The verification key.
SERIALIZATION_FIELDS(proof, vk)
Response execute(const BBApiRequest &request={}) &&
bool operator==(const ChonkVerify &) const =default
ChonkProof proof
The Chonk proof to verify.