Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
mega_flavor.hpp
Go to the documentation of this file.
1// === AUDIT STATUS ===
2// internal: { status: Completed, auditors: [Sergei], commit: }
3// external_1: { status: not started, auditors: [], commit: }
4// external_2: { status: not started, auditors: [], commit: }
5// =====================
6
7#pragma once
8
19
20namespace bb {
21
22// MegaFlavor inherits the generated layout: EntityId, NUM_*_ENTITIES, AllEntities / Precomputed /
23// WitnessEntities, Relations_<FF>, REPEATED_COMMITMENTS, capability bools, and challenge-usage
24// bools all come through public inheritance. The hand-written class adds curve / commitment /
25// transcript types, sumcheck-shape constants, the VK / ProverPolynomials wrappers, and the
26// CommitmentLabels singleton.
28 public:
30
36 using PCS = KZG<Curve>;
39 using Codec = FrCodec;
42
43 // An upper bound on the size of the Mega-circuits. `CONST_FOLDING_LOG_N` bounds the log circuit sizes in the Chonk
44 // context.
45 static constexpr size_t VIRTUAL_LOG_N = CONST_FOLDING_LOG_N;
46 // indicates when evaluating sumcheck, edges can be left as degree-1 monomials
47 static constexpr bool USE_SHORT_MONOMIALS = true;
48 // opt in to the row-parallel (SIMD) sumcheck path; see SupportsSimdSumcheck in flavor_concepts.hpp
49 static constexpr bool USE_SIMD_SUMCHECK = true;
50 // Indicates that this flavor runs with non-ZK Sumcheck.
51 static constexpr bool HasZK = false;
52 // To achieve fixed proof size and that the recursive verifier circuit is constant, we are using padding in Sumcheck
53 // and Shplemini
54 static constexpr bool USE_PADDING = true;
55 static constexpr size_t NUM_WIRES = CircuitBuilder::NUM_WIRES;
56
58
59 static constexpr size_t MAX_PARTIAL_RELATION_LENGTH = compute_max_partial_relation_length<Relations>();
60 // BATCHED_RELATION_PARTIAL_LENGTH = algebraic degree of sumcheck relation *after* multiplying by the `pow_zeta`
61 // random polynomial e.g. For \sum(x) [A(x) * B(x) + C(x)] * PowZeta(X), relation length = 2 and random relation
62 // length = 3
65
66 // A challenge whose powers are used to batch subrelation contributions during Sumcheck
67 static constexpr size_t NUM_SUBRELATIONS = compute_number_of_subrelations<Relations>();
69
70 static_assert(NUM_MASKING_ENTITIES == 0,
71 "MegaFlavor layout must not include masking columns (ZK masking is owned by the translator).");
72 static_assert(NUM_BUS_COLUMNS == bb::NUM_BUS_COLUMNS, "Generated Mega databus count must match builder databus");
73
74 // Rows reserved at the top of the trace for row-disabling / ZK masking.
75 static constexpr size_t TRACE_OFFSET = 0;
76
77 // Size of the final PCS MSM after KZG adds quotient commitment:
78 // 1 (Shplonk Q) + NUM_UNSHIFTED + (log_n - 1) Gemini folds + 1 (G1 identity) + 1 (KZG W)
79 // (shifted commitments are removed as duplicates)
80 static constexpr size_t FINAL_PCS_MSM_SIZE(size_t log_n = VIRTUAL_LOG_N)
81 {
82 return NUM_UNSHIFTED_ENTITIES + log_n + 2;
83 }
84
90
91 static_assert(gemini_masking_layout_consistent<MegaFlavor>(),
92 "MegaFlavor gemini masking flag must match its entity layout");
93
98
100
106
108
114
120
125
130
131 // Per-entity transcript labels (uppercase). The data is generator-emitted via
132 // `AllEntities<std::string>::get_labels()`; `commitment_labels()` returns a process-wide
133 // singleton populated from that list. Callers index by name (`commitment_labels().q_m()`)
134 // when building Fiat-Shamir transcript domain separators.
137 {
138 static const CommitmentLabels instance = []() {
140 const auto& src = AllEntities<std::string>::get_labels();
141 std::copy(src.begin(), src.end(), result.data.begin());
142 return result;
143 }();
144 return instance;
145 }
146};
147
148} // namespace bb
Common transcript class for both parties. Stores the data for the current round, as well as the manif...
CommitmentKey object over a pairing group 𝔾₁.
static const std::vector< std::string > & get_labels()
static constexpr size_t NUM_BUS_COLUMNS
std::tuple< bb::UltraPermutationRelation< FF >, bb::LogDerivLookupRelation< FF >, bb::ArithmeticRelation< FF >, bb::BilinearOrBatchedEqCheckRelation< FF >, bb::DeltaRangeConstraintRelation< FF >, bb::EllipticRelation< FF >, bb::MemoryRelation< FF >, bb::NonNativeFieldRelation< FF >, bb::EccOpQueueRelation< FF >, bb::SingleBusLookupRelation< FF, EntityId::kernel_calldata, EntityId::kernel_calldata_read_counts, EntityId::kernel_calldata_inverses, EntityId::kernel_calldata_indicator, EntityId::q_l >, bb::SingleBusLookupRelation< FF, EntityId::first_app_calldata, EntityId::first_app_calldata_read_counts, EntityId::first_app_calldata_inverses, EntityId::first_app_calldata_indicator, EntityId::q_r >, bb::SingleBusLookupRelation< FF, EntityId::second_app_calldata, EntityId::second_app_calldata_read_counts, EntityId::second_app_calldata_inverses, EntityId::second_app_calldata_indicator, EntityId::q_o >, bb::SingleBusLookupRelation< FF, EntityId::third_app_calldata, EntityId::third_app_calldata_read_counts, EntityId::third_app_calldata_inverses, EntityId::third_app_calldata_indicator, EntityId::q_4 >, bb::SingleBusLookupRelation< FF, EntityId::fourth_app_calldata, EntityId::fourth_app_calldata_read_counts, EntityId::fourth_app_calldata_inverses, EntityId::fourth_app_calldata_indicator, EntityId::q_5 >, bb::SingleBusLookupRelation< FF, EntityId::fifth_app_calldata, EntityId::fifth_app_calldata_read_counts, EntityId::fifth_app_calldata_inverses, EntityId::fifth_app_calldata_indicator, EntityId::q_c >, bb::SingleBusLookupRelation< FF, EntityId::return_data, EntityId::return_data_read_counts, EntityId::return_data_inverses, EntityId::return_data_indicator, EntityId::q_m >, bb::Poseidon2ExternalRelation< FF >, bb::Poseidon2InitialExternalRelation< FF >, bb::Poseidon2QuadInternalRelation< FF >, bb::Poseidon2QuadInternalTerminalRelation< FF >, bb::Poseidon2TransitionEntryRelation< FF > > Relations_
static constexpr size_t NUM_MASKING_ENTITIES
static constexpr size_t NUM_UNSHIFTED_ENTITIES
Curve::ScalarField FF
AllEntities< FF > AllValues
A field element for each entity of the flavor. These entities represent the prover polynomials evalua...
crypto::Poseidon2< crypto::Poseidon2Bn254ScalarFieldParams > HashFunction
static constexpr size_t NUM_WIRES
static const CommitmentLabels & commitment_labels()
static constexpr size_t NUM_SUBRELATIONS
Curve::Element GroupElement
static constexpr size_t NUM_RELATIONS
static constexpr bool HasZK
static constexpr size_t TRACE_OFFSET
static constexpr size_t MAX_PARTIAL_RELATION_LENGTH
static constexpr size_t VIRTUAL_LOG_N
static constexpr size_t FINAL_PCS_MSM_SIZE(size_t log_n=VIRTUAL_LOG_N)
static constexpr bool USE_SIMD_SUMCHECK
Relations_< FF > Relations
static constexpr bool USE_SHORT_MONOMIALS
ProverPolynomialsBase< AllEntities< Polynomial >, AllValues, Polynomial > ProverPolynomials
A container for the prover polynomials handles.
Curve::AffineElement Commitment
static constexpr bool USE_PADDING
static constexpr size_t BATCHED_RELATION_PARTIAL_LENGTH
AllEntities< std::string > CommitmentLabels
Base Native verification key class.
Definition flavor.hpp:138
A container for polynomials handles used by the prover.
Wrapper holding a verification key and its precomputed hash.
Definition flavor.hpp:551
typename Group::element Element
Definition bn254.hpp:21
typename Group::affine_element AffineElement
Definition bn254.hpp:22
bb::fr ScalarField
Definition bn254.hpp:18
Base class templates shared across Honk flavors.
Entry point for Barretenberg command-line interface.
Definition api.hpp:5
constexpr size_t NUM_BUS_COLUMNS
The DataBus; facilitates storage of public circuit input/output.
Definition databus.hpp:72
MegaCircuitBuilder_< field< Bn254FrParams > > MegaCircuitBuilder
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
The precomputed data needed to compute a Honk VK.
Definition flavor.hpp:87
VectorField result