Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
recursion_constraint.hpp
Go to the documentation of this file.
1// === AUDIT STATUS ===
2// internal: { status: Completed, auditors: [Federico], commit: }
3// external_1: { status: not started, auditors: [], commit: }
4// external_2: { status: not started, auditors: [], commit: }
5// =====================
6
7#pragma once
20#include <cstdint>
21#include <vector>
22
23namespace acir_format {
24
25using namespace bb;
26using namespace stdlib;
27
28// Used to specify the type of recursive verifier via the proof_type specified by the RecursiveAggregation opcode from
29// ACIR
30// Keep this enum values in sync with their noir counterpart constants defined in
31// noir-projects/fnd/noir-protocol-circuits/crates/types/src/constants.nr
33
34// Check if a PROOF_TYPE is a HyperNova variant (OINK, HN, HN_FINAL)
35constexpr bool is_hypernova_proof_type(uint32_t proof_type)
36{
37 return proof_type == PROOF_TYPE::OINK || proof_type == PROOF_TYPE::HN || proof_type == PROOF_TYPE::HN_FINAL;
38}
39
40// The ACIR proof_type expected for the group entry at `group_index` of the kernel currently being completed,
41// derived from the IVC's circuit-kinds-based state. The init kernel's first app is verified via an OINK proof,
42// the hiding kernel verifies the tail kernel via an HN_FINAL proof, and every other proof is a plain HN proof.
43// Used as a defense-in-depth cross-check that the ACIR proof_type agrees with the IVC state (the IVC's circuit
44// kinds, not the proof_type, drive the actual verification logic).
45inline PROOF_TYPE expected_proof_type(const Chonk& ivc, size_t group_index)
46{
47 if (ivc.is_hiding_kernel()) {
49 }
50 if (ivc.is_init_kernel() && group_index == 0) {
51 return PROOF_TYPE::OINK;
52 }
53 return PROOF_TYPE::HN;
54}
55
56// The circuit kind expected for the group entry at `group_index`: every kernel except the init kernel verifies
57// the carried previous kernel as its first proof; all other entries are apps.
58inline bb::CircuitKind expected_group_entry_kind(const Chonk& ivc, size_t group_index)
59{
60 return (group_index == 0 && !ivc.is_init_kernel()) ? bb::CircuitKind::Kernel : bb::CircuitKind::App;
61}
62
63// Static assertions to catch PROOF_TYPE desync with the Noir constants at compile time
64namespace detail {
65static_assert(PROOF_TYPE::OINK == 1);
66static_assert(PROOF_TYPE::HN == 2);
67static_assert(PROOF_TYPE::HN_FINAL == 7);
68static_assert(PROOF_TYPE::CHONK == 8);
69} // namespace detail
70
97 std::vector<uint32_t> key;
98 std::vector<uint32_t> proof;
99 std::vector<uint32_t> public_inputs;
100 uint32_t key_hash;
101 uint32_t proof_type;
103
104 friend bool operator==(RecursionConstraint const& lhs, RecursionConstraint const& rhs) = default;
105};
106
134template <typename Builder>
135[[nodiscard("pairing points and IPA claim must be accumulated")]] HonkRecursionConstraintsOutput<Builder>
138 GateCounter<Builder>& gate_counter,
139 std::vector<size_t>& gates_per_opcode,
140 [[maybe_unused]] const std::shared_ptr<Chonk>& ivc_base,
141 const std::pair<std::vector<RecursionConstraint>, std::vector<size_t>>& honk_recursion_data,
142 const std::pair<std::vector<RecursionConstraint>, std::vector<size_t>>& avm_recursion_data,
143 const std::pair<std::vector<RecursionConstraint>, std::vector<size_t>>& hn_recursion_data,
144 const std::pair<std::vector<RecursionConstraint>, std::vector<size_t>>& chonk_recursion_data);
145
158 std::vector<size_t>& gates_per_opcode,
159 const std::pair<std::vector<RecursionConstraint>, std::vector<size_t>>& hn_recursion_data,
160 const std::shared_ptr<Chonk>& ivc_base);
161
162} // namespace acir_format
Utility class for tracking the gate count of acir constraints.
The IVC scheme used by the aztec client for private function execution.
Definition chonk.hpp:42
bool is_hiding_kernel() const
Whether the circuit currently being accumulated/completed is the hiding kernel.
Definition chonk.hpp:268
bool is_init_kernel() const
Whether the kernel currently being completed is the init kernel (the first kernel,...
Definition chonk.cpp:622
AluTraceBuilder builder
Definition alu.test.cpp:124
bb::CircuitKind expected_group_entry_kind(const Chonk &ivc, size_t group_index)
PROOF_TYPE expected_proof_type(const Chonk &ivc, size_t group_index)
HonkRecursionConstraintsOutput< MegaCircuitBuilder > create_recursion_constraints(MegaCircuitBuilder &builder, GateCounter< MegaCircuitBuilder > &gate_counter, std::vector< size_t > &gates_per_opcode, const std::shared_ptr< Chonk > &ivc_base, const std::pair< std::vector< RecursionConstraint >, std::vector< size_t > > &honk_recursion_data, const std::pair< std::vector< RecursionConstraint >, std::vector< size_t > > &avm_recursion_data, const std::pair< std::vector< RecursionConstraint >, std::vector< size_t > > &hn_recursion_data, const std::pair< std::vector< RecursionConstraint >, std::vector< size_t > > &chonk_recursion_data)
void process_hn_recursion_constraints(MegaCircuitBuilder &builder, GateCounter< MegaCircuitBuilder > &gate_counter, std::vector< size_t > &gates_per_opcode, const std::pair< std::vector< RecursionConstraint >, std::vector< size_t > > &hn_recursion_data, const std::shared_ptr< Chonk > &ivc_base)
Process HyperNova recursion constraints and complete kernel logic.
constexpr bool is_hypernova_proof_type(uint32_t proof_type)
Entry point for Barretenberg command-line interface.
Definition api.hpp:5
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
bb::VectorAffineElementPushSpan< BaseParams > lhs
bb::VectorAffineElementPushSpan< BaseParams > rhs
Container for the output of multiple recursive verifications.
RecursionConstraint struct contains information required to recursively verify a proof.
WitnessOrConstant< bb::fr > predicate
friend bool operator==(RecursionConstraint const &lhs, RecursionConstraint const &rhs)=default