Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
ultra_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
20#include <type_traits>
21
22namespace bb {
23
24// UltraFlavor inherits the non-ZK generated layout. Relations_, REPEATED_COMMITMENTS, capability
25// bools, and challenge-usage bools all carry through. The hand-written class adds curve /
26// commitment types, sumcheck-shape constants, and a HasZK-parameterized `AllEntities_` that
27// switches between the non-ZK and ZK generated AllEntities — UltraFlavorWithZK reuses this same
28// surface with HasZK = true to pick up the masking column.
30 public:
36 using PCS = KZG<Curve>;
39 using Codec = FrCodec;
42
43 static constexpr size_t VIRTUAL_LOG_N = CONST_PROOF_SIZE_LOG_N;
44 // indicates when evaluating sumcheck, edges can be left as degree-1 monomials
45 static constexpr bool USE_SHORT_MONOMIALS = true;
46 // opt in to the row-parallel (SIMD) sumcheck path; see SupportsSimdSumcheck in flavor_concepts.hpp
47 static constexpr bool USE_SIMD_SUMCHECK = true;
48
49 // Indicates that this flavor runs with non-ZK Sumcheck.
50 static constexpr bool HasZK = false;
51 // To achieve fixed proof size and that the recursive verifier circuit is constant, we are using padding in Sumcheck
52 // and Shplemini
53 static constexpr bool USE_PADDING = true;
54 static constexpr size_t NUM_WIRES = CircuitBuilder::NUM_WIRES;
55
56 // WARNING: ordering of `Relations_<FF>` (inherited from UltraFlavor_Generated; defined in
57 // scripts/flavor-codegen/src/flavors/ultra.ts) is reflected in the smart-contract verifier —
58 // any reordering at the TS source must be matched in Solidity, or relation accumulation will
59 // drift. The Ultra and UltraZK generated classes share the same relation set (UltraZK only
60 // adds a masking column, no extra relations), so the non-ZK Generated is canonical for both.
62
64
65 static constexpr size_t MAX_PARTIAL_RELATION_LENGTH = compute_max_partial_relation_length<Relations>();
66 static_assert(MAX_PARTIAL_RELATION_LENGTH == 7);
67 static constexpr size_t NUM_SUBRELATIONS = compute_number_of_subrelations<Relations>();
68 // A challenge whose powers are used to batch subrelation contributions during Sumcheck
70
71 // BATCHED_RELATION_PARTIAL_LENGTH = algebraic degree of sumcheck relation *after* multiplying by the `pow_zeta`
72 // random polynomial e.g. For \sum(x) [A(x) * B(x) + C(x)] * PowZeta(X), relation length = 2 and random relation
73 // length = 3
76
77 // HasZK_-parameterized AllEntities — switches between the non-ZK and ZK generated
78 // AllEntities so UltraFlavorWithZK can reuse this surface (UltraZK only adds a masking column,
79 // not any new entity *shapes*). The base-class `AllEntities<DataType>` from
80 // UltraFlavor_Generated is the non-ZK case and remains directly accessible.
81 template <typename DataType, bool HasZK_ = HasZK>
85
86 // Pin the ZK / non-ZK generated counts to each other. UltraZK shares the precomputed /
87 // witness / shifted shape with the non-ZK side and only adds the masking column.
89 "UltraFlavor (non-ZK) layout must not include masking columns");
94 "UltraZK layout must include exactly one masking column (gemini_masking_poly)");
95
96 static constexpr size_t TRACE_OFFSET = NUM_DISABLED_ROWS_IN_SUMCHECK;
97
98 // Size of the final PCS MSM after KZG adds quotient commitment:
99 // 1 (Shplonk Q) + NUM_UNSHIFTED + (log_n - 1) Gemini folds + 1 (G1 identity) + 1 (KZG W)
100 // (shifted commitments are removed as duplicates)
101 static constexpr size_t FINAL_PCS_MSM_SIZE(size_t log_n = VIRTUAL_LOG_N)
102 {
103 return NUM_UNSHIFTED_ENTITIES + log_n + 2;
104 }
105
110 template <bool HasZK_ = HasZK> class AllValues_ : public AllEntities_<FF, HasZK_> {
111 public:
113 using Base::Base;
114 };
115
117
118 static_assert(gemini_masking_layout_consistent<UltraFlavor>(),
119 "UltraFlavor gemini masking flag must match its entity layout");
120
124 template <bool HasZK_ = HasZK>
126
128
130
136
138
142 template <bool HasZK_ = HasZK>
145
147
153
158
163
164 // Per-entity transcript labels (uppercase). The data is generator-emitted via
165 // `AllEntities<std::string>::get_labels()`; `commitment_labels()` returns a process-wide
166 // singleton populated from that list. Callers index by name (`commitment_labels().q_m()`)
167 // when building Fiat-Shamir transcript domain separators.
170 {
171 static const CommitmentLabels instance = []() {
173 const auto& src = AllEntities<std::string>::get_labels();
174 std::copy(src.begin(), src.end(), result.data.begin());
175 return result;
176 }();
177 return instance;
178 }
179};
180
181} // 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()
Base Native verification key class.
Definition flavor.hpp:138
A container for storing the partially evaluated multivariates produced by sumcheck.
A container for polynomials handles used by the prover.
static constexpr size_t NUM_WIRES
A field element for each entity of the flavor. These entities represent the prover polynomials evalua...
AllEntities_< FF, HasZK_ > Base
static constexpr size_t NUM_SHIFTED_ENTITIES
static constexpr size_t NUM_MASKING_ENTITIES
static constexpr size_t NUM_PRECOMPUTED_ENTITIES
std::tuple< bb::UltraPermutationRelation< FF >, bb::LogDerivLookupRelation< FF >, bb::ArithmeticRelation< FF >, bb::DeltaRangeConstraintRelation< FF >, bb::EllipticRelation< FF >, bb::MemoryRelation< FF >, bb::NonNativeFieldRelation< FF >, bb::Poseidon2ExternalRelation< FF >, bb::Poseidon2InternalRelation< FF > > Relations_
static constexpr size_t NUM_UNSHIFTED_ENTITIES
static constexpr size_t NUM_WITNESS_ENTITIES
static const CommitmentLabels & commitment_labels()
crypto::Poseidon2< crypto::Poseidon2Bn254ScalarFieldParams > HashFunction
static constexpr size_t BATCHED_RELATION_PARTIAL_LENGTH
static constexpr bool USE_PADDING
static constexpr size_t NUM_RELATIONS
static constexpr bool HasZK
static constexpr bool USE_SHORT_MONOMIALS
static constexpr size_t FINAL_PCS_MSM_SIZE(size_t log_n=VIRTUAL_LOG_N)
Curve::ScalarField FF
Curve::AffineElement Commitment
static constexpr size_t MAX_PARTIAL_RELATION_LENGTH
std::conditional_t< HasZK_, UltraZKFlavor_Generated::AllEntities< DataType >, UltraFlavor_Generated::AllEntities< DataType > > AllEntities_
static constexpr size_t NUM_SUBRELATIONS
static constexpr size_t TRACE_OFFSET
static constexpr size_t VIRTUAL_LOG_N
AllEntities< std::string > CommitmentLabels
static constexpr bool USE_SIMD_SUMCHECK
Curve::Element GroupElement
Relations_< FF > Relations
static constexpr size_t NUM_WIRES
static constexpr size_t NUM_PRECOMPUTED_ENTITIES
static constexpr size_t NUM_WITNESS_ENTITIES
static constexpr size_t NUM_SHIFTED_ENTITIES
static constexpr size_t NUM_MASKING_ENTITIES
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
UltraCircuitBuilder_< UltraExecutionTraceBlocks > UltraCircuitBuilder
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