Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
mega_zk_flavor.hpp
Go to the documentation of this file.
1// === AUDIT STATUS ===
2// internal: { status: in progress, 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
21
22namespace bb {
23
38// MegaZKFlavor inherits the generated layout (EntityId, NUM_*_ENTITIES, AllEntities, Relations,
39// REPEATED_COMMITMENTS, capability + challenge-usage bools). The hand-written class adds the
40// curve / transcript types, sumcheck-shape constants, and the VK / ProverPolynomials wrappers.
42 public:
44
50 using PCS = KZG<Curve>;
53 using Codec = FrCodec;
56
57 // MegaZK is only used in production to prove the Hiding Kernel.
58 static constexpr size_t VIRTUAL_LOG_N = HIDING_KERNEL_LOG_N;
59 static constexpr bool USE_SHORT_MONOMIALS = true;
60 // opt in to the row-parallel (SIMD) sumcheck path; see SupportsSimdSumcheck in flavor_concepts.hpp
61 static constexpr bool USE_SIMD_SUMCHECK = true;
62 // Runs with ZK Sumcheck.
63 static constexpr bool HasZK = true;
64 static constexpr bool USE_PADDING = true;
65 static constexpr size_t NUM_WIRES = CircuitBuilder::NUM_WIRES;
66
67 // MegaZK does not include a Gemini masking polynomial in its entities; the Translator provides
68 // one at the correct joint circuit size in the batched Chonk flow.
69 static constexpr bool HasGeminiMasking = false;
70
72
73 static constexpr size_t MAX_PARTIAL_RELATION_LENGTH = compute_max_partial_relation_length<Relations>();
74 // BATCHED_RELATION_PARTIAL_LENGTH = algebraic degree of sumcheck relation *after* multiplying by the `pow_zeta`
75 // random polynomial e.g. For \sum(x) [A(x) * B(x) + C(x)] * PowZeta(X), relation length = 2 and random relation
76 // length = 3. ZK adds one for row-disabling.
79 "LIBRA_UNIVARIATES_LENGTH must be equal to MegaZKFlavor::BATCHED_RELATION_PARTIAL_LENGTH");
81
82 // A challenge whose powers are used to batch subrelation contributions during Sumcheck
83 static constexpr size_t NUM_SUBRELATIONS = compute_number_of_subrelations<Relations>();
85
86 static_assert(NUM_MASKING_ENTITIES == 0,
87 "MegaZKFlavor layout must not include masking columns; Translator provides Gemini masking in the "
88 "batched Chonk flow.");
89 // MegaZK includes only the kernel_calldata bus. The hiding kernel reads against the prior
90 // circuit's return_data, which is copy-constrained to kernel_calldata; the other Mega buses
91 // (first..fifth_app_calldata, return_data) don't apply here.
92 static_assert(NUM_BUS_COLUMNS == 1, "MegaZK flavor should declare exactly the kernel_calldata bus");
93
94 // ZK masking lives at rows [NUM_ZERO_ROWS, TRACE_OFFSET); Sumcheck disables rows [0, TRACE_OFFSET).
95 static constexpr size_t TRACE_OFFSET = NUM_DISABLED_ROWS_IN_SUMCHECK;
96
97 // Size of the final PCS MSM for ZK = non-ZK Mega-style size + NUM_LIBRA_COMMITMENTS (3):
98 // 1 (Shplonk Q) + NUM_UNSHIFTED + (log_n - 1) Gemini folds + 1 (G1 identity) + 1 (KZG W) + 3 (Libra)
99 // Shifted commitments are removed as duplicates via REPEATED_COMMITMENTS.
100 static constexpr size_t FINAL_PCS_MSM_SIZE(size_t log_n = VIRTUAL_LOG_N)
101 {
103 }
104
106
107 static_assert(gemini_masking_layout_consistent<MegaZKFlavor>(),
108 "MegaZKFlavor gemini masking flag must match its entity layout");
109
119
122 {
123 static const CommitmentLabels instance = []() {
125 const auto& src = AllEntities<std::string>::get_labels();
126 std::copy(src.begin(), src.end(), result.data.begin());
127 return result;
128 }();
129 return instance;
130 }
131};
132
133} // 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_MASKING_ENTITIES
static constexpr size_t NUM_BUS_COLUMNS
std::tuple< bb::ArithmeticRelation< FF >, bb::BilinearOrBatchedEqCheckRelation< FF >, bb::UltraPermutationRelation< FF >, bb::DeltaRangeConstraintRelation< FF >, bb::EccOpQueueRelation< FF >, bb::MegaEccOpBoundaryRelation< FF >, bb::SingleBusLookupRelation< FF, EntityId::kernel_calldata, EntityId::kernel_calldata_read_counts, EntityId::kernel_calldata_inverses, EntityId::kernel_calldata_indicator, EntityId::q_l >, bb::Poseidon2ExternalRelation< FF >, bb::Poseidon2InitialExternalRelation< FF >, bb::Poseidon2QuadInternalRelation< FF >, bb::Poseidon2QuadInternalTerminalRelation< FF >, bb::Poseidon2TransitionEntryRelation< FF > > Relations_
static constexpr size_t NUM_UNSHIFTED_ENTITIES
Hiding-kernel-only Mega variant: runs with ZK Sumcheck and a reduced relation set.
static constexpr bool USE_SIMD_SUMCHECK
static constexpr size_t TRACE_OFFSET
static constexpr bool HasZK
static constexpr size_t NUM_SUBRELATIONS
static constexpr bool USE_PADDING
AllEntities< FF > AllValues
ProverPolynomialsBase< AllEntities< Polynomial >, AllValues, Polynomial > ProverPolynomials
Curve::AffineElement Commitment
static constexpr size_t MAX_PARTIAL_RELATION_LENGTH
static constexpr size_t NUM_WIRES
crypto::Poseidon2< crypto::Poseidon2Bn254ScalarFieldParams > HashFunction
static constexpr bool USE_SHORT_MONOMIALS
Curve::Element GroupElement
AllEntities< std::string > CommitmentLabels
static constexpr size_t NUM_RELATIONS
static constexpr size_t BATCHED_RELATION_PARTIAL_LENGTH
static const CommitmentLabels & commitment_labels()
Relations_< FF > Relations
static constexpr size_t FINAL_PCS_MSM_SIZE(size_t log_n=VIRTUAL_LOG_N)
static constexpr bool HasGeminiMasking
static constexpr size_t VIRTUAL_LOG_N
Curve::ScalarField FF
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
static constexpr uint32_t LIBRA_UNIVARIATES_LENGTH
Definition bn254.hpp:44
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_SMALL_IPA_COMMITMENTS
BaseTranscript< FrCodec, bb::crypto::Poseidon2< bb::crypto::Poseidon2Bn254ScalarFieldParams > > NativeTranscript
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