12template <
typename VK>
void validate_vk_size(
const std::vector<uint8_t>& vk_bytes)
14 const size_t expected_size = VK::calc_num_data_types() *
sizeof(
bb::fr);
15 if (vk_bytes.size() != expected_size) {
21template <
typename VK>
std::shared_ptr<VK> deserialize_vk(
const std::vector<uint8_t>& vk_bytes)
23 validate_vk_size<VK>(vk_bytes);
24 return from_buffer<std::shared_ptr<VK>>(vk_bytes);
29 auto builder = acir_format::create_circuit<Chonk::ClientCircuit>(program);
35 auto vk = compute_vk_from_program<VK, Instance>(program);
36 return { .bytes =
to_buffer(*
vk), .fields =
vk->to_field_elements() };
39template <
typename VK,
typename Instance>
42 auto computed_vk = compute_vk_from_program<VK, Instance>(program);
43 auto precomputed_vk = deserialize_vk<VK>(precomputed_vk_bytes);
44 if (*computed_vk == *precomputed_vk) {
47 return { .valid =
false, .actual_vk =
to_buffer(*computed_vk) };
50void accumulate_next_chonk_circuit(Chonk& ivc,
53 const std::vector<uint8_t>& precomputed_vk,
58 if (kind != ivc.current_kind()) {
59 throw_or_abort(
"ChonkStepProcessor: supplied CircuitKind disagrees with the kinds the IVC was started with");
63 using FlavorT = flavor_for<K>;
64 using VK =
typename FlavorT::VerificationKey;
69 if (precomputed_vk.empty()) {
72 vk = deserialize_vk<VK>(precomputed_vk);
75 if (*
vk != *computed_vk) {
76 throw_or_abort(
"Chonk: precomputed VK does not match computed VK");
87 : ivc(
std::make_shared<
Chonk>(
std::move(circuit_kinds)))
93 auto circuit = acir_format::create_circuit<Chonk::ClientCircuit>(step.program, metadata);
95 info(
"Chonk: accumulating ", step.name);
99 accumulate_next_chonk_circuit(*
ivc, circuit, step.kind, step.precomputed_vk, policy);
109 return ivc->get_hiding_kernel_vk_and_hash();
116 return compute_vk_data<typename FlavorT::VerificationKey, ProverInstance_<FlavorT>>(program);
121 const std::vector<uint8_t>& precomputed_vk,
126 return check_vk<typename FlavorT::VerificationKey, ProverInstance_<FlavorT>>(program, precomputed_vk);
132 return deserialize_vk<Chonk::MegaZKVerificationKey>(
vk);
The IVC scheme used by the aztec client for private function execution.
bb::CircuitVerificationKey CircuitVerificationKey
bb::CircuitKind CircuitKind
MegaCircuitBuilder ClientCircuit
std::shared_ptr< MegaZKFlavor::VKAndHash > get_hiding_kernel_vk_and_hash() const
std::shared_ptr< Chonk > ivc
ChonkStepProcessor(std::vector< CircuitKind > circuit_kinds)
void process_step(ChonkExecutionStep &&step, ChonkPrecomputedVkPolicy policy=ChonkPrecomputedVkPolicy::DEFAULT)
void validate_vk_size(const std::vector< uint8_t > &vk_bytes)
Validate verification key size before deserialization.
MemoryProfile GLOBAL_MEMORY_PROFILE
Entry point for Barretenberg command-line interface.
field< Bn254FrParams > fr
std::shared_ptr< MegaZKFlavor::VKAndHash > deserialize_chonk_vk_and_hash(const std::vector< uint8_t > &vk)
typename flavor_for_impl< K >::type flavor_for
ChonkVkCheckResult check_precomputed_chonk_vk(acir_format::AcirProgram &program, const std::vector< uint8_t > &precomputed_vk, CircuitKind kind)
std::shared_ptr< Chonk::MegaZKVerificationKey > deserialize_chonk_vk(const std::vector< uint8_t > &vk)
ChonkVkData compute_chonk_vk(acir_format::AcirProgram &program, CircuitKind kind)
constexpr decltype(auto) dispatch_kind(CircuitKind kind, F &&f)
VerifierCommitmentKey< Curve > vk
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
std::string to_string(bb::avm2::ValueTag tag)
std::vector< uint8_t > to_buffer(T const &value)
void set_circuit_name(const std::string &name)
void throw_or_abort(std::string const &err)