Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
multilinear_batching_flavor.hpp
Go to the documentation of this file.
1// === AUDIT STATUS ===
2// internal: { status: not started, auditors: [], commit: }
3// external_1: { status: not started, auditors: [], commit: }
4// external_2: { status: not started, auditors: [], commit: }
5// =====================
6#pragma once
7
20
21#include <array>
22
23namespace bb {
24
25template <typename FF, typename Polynomial, size_t NumClaims> struct MultilinearBatchingProverPolynomials;
26
30template <size_t NumClaims> class MultilinearBatchingFlavor_ {
31 public:
36 using PCS = KZG<Curve>;
41 using Codec = FrCodec;
42
43 // The number of claims batched using this flavor
44 static constexpr size_t NUM_CLAIMS = NumClaims;
45 // An upper bound on the size of the MultilinearBatching-circuits. `CONST_FOLDING_LOG_N` bounds the log circuit
46 // sizes in the Chonk context.
47 static constexpr size_t VIRTUAL_LOG_N = CONST_FOLDING_LOG_N;
48 static constexpr bool USE_SHORT_MONOMIALS = false;
49 static constexpr bool HasZK = false;
50 static constexpr size_t TRACE_OFFSET = 0;
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
55 // Entities = Unshifted polys + Shifted polys + Eq polys
56 static constexpr size_t NUM_ALL_ENTITIES = 3 * NUM_CLAIMS;
57
60
61 static constexpr size_t MAX_PARTIAL_RELATION_LENGTH = compute_max_partial_relation_length<Relations>();
62 // There is no gate polynomial in the relation (the only relation is linearly dependent), so the batched relation
63 // partial length is equal to max partial relation length
66 static constexpr size_t NUM_SUBRELATIONS = compute_number_of_subrelations<Relations>();
68
72 template <typename DataType> class AllEntities {
73 public:
74 std::array<DataType, NUM_ALL_ENTITIES> values;
75
76 DataType& non_shifted(size_t idx) { return values[idx]; }
77 const DataType& non_shifted(size_t idx) const { return values[idx]; }
78 DataType& shifted(size_t idx) { return values[NUM_CLAIMS + idx]; }
79 const DataType& shifted(size_t idx) const { return values[NUM_CLAIMS + idx]; }
80 DataType& eq(size_t idx) { return values[(2 * NUM_CLAIMS) + idx]; }
81 const DataType& eq(size_t idx) const { return values[(2 * NUM_CLAIMS) + idx]; }
82
84 auto get_all() const
85 {
87 for (size_t idx = 0; idx < NUM_ALL_ENTITIES; ++idx) {
88 refs[idx] = &values[idx];
89 }
91 }
92 auto get_witness() { return get_all(); }
93 auto get_witness() const { return get_all(); }
94
95 static const std::vector<std::string>& get_labels()
96 {
97 static const std::vector<std::string> labels = [] {
98 std::vector<std::string> result;
99 result.reserve(NUM_ALL_ENTITIES);
100 for (size_t idx = 0; idx < NUM_CLAIMS; ++idx) {
101 result.emplace_back("non_shifted_" + std::to_string(idx));
102 }
103 for (size_t idx = 0; idx < NUM_CLAIMS; ++idx) {
104 result.emplace_back("shifted_" + std::to_string(idx));
105 }
106 for (size_t idx = 0; idx < NUM_CLAIMS; ++idx) {
107 result.emplace_back("eq_" + std::to_string(idx));
108 }
109 return result;
110 }();
111 return labels;
112 }
113
114 static constexpr std::size_t size() { return NUM_ALL_ENTITIES; }
115 };
116
117 class AllValues : public AllEntities<FF> {
118 public:
120 using Base::Base;
121 };
122
123 class ProverPolynomials : public AllEntities<Polynomial> {
124 public:
126
127 [[nodiscard]] size_t get_polynomial_size() const
128 {
129 size_t result = 0;
130 for (const auto& polynomial : this->get_all()) {
131 result = std::max(result, polynomial.virtual_size());
132 }
133 return result;
134 }
135
136 void increase_polynomials_virtual_size(const size_t size_in)
137 {
138 for (auto& polynomial : this->get_all()) {
139 if (!polynomial.is_empty()) {
140 polynomial.increase_virtual_size(size_in);
141 }
142 }
143 }
144 };
145
147
179
181 : public PartiallyEvaluatedMultivariatesBase<AllEntities<Polynomial>, ProverPolynomials, Polynomial> {
182 public:
185
186 PartiallyEvaluatedMultivariates(const ProverPolynomials& full_polynomials, size_t circuit_size)
187 : Base(full_polynomials, circuit_size)
188 , claim_challenges(full_polynomials.claim_challenges)
189 {}
190 };
191
194
206 template <typename PartiallyEvaluatedPolynomials>
207 static void extend_eq_polynomials_for_virtual_round(PartiallyEvaluatedPolynomials& partially_evaluated_polynomials,
208 const std::vector<FF>& multivariate_challenge,
209 const size_t round_idx)
210 {
211 std::vector<FF> round_challenge(VIRTUAL_LOG_N);
212 for (size_t i = 0; i < round_idx; i++) {
213 round_challenge[i] = multivariate_challenge[i];
214 }
215 round_challenge[round_idx] = FF(1);
216
217 for (size_t idx = 0; idx < NUM_CLAIMS; ++idx) {
218 auto& eq_polynomial = partially_evaluated_polynomials.eq(idx);
219 auto new_eq_polynomial = Polynomial(2, eq_polynomial.virtual_size());
220 new_eq_polynomial.at(0) = eq_polynomial.at(0);
221 new_eq_polynomial.at(1) =
222 VerifierEqPolynomial<FF>::eval(partially_evaluated_polynomials.claim_challenges[idx], round_challenge);
223 eq_polynomial = new_eq_polynomial;
224 }
225 }
226};
227
229
230template <size_t NumClaims> class MultilinearBatchingRecursiveFlavor_ {
231 public:
236 using FF = typename Curve::ScalarField;
237 using Commitment = typename Curve::Element;
240
241 static constexpr size_t NUM_CLAIMS = NativeFlavor::NUM_CLAIMS;
243 static constexpr bool HasZK = NativeFlavor::HasZK;
244 static constexpr bool USE_PADDING = NativeFlavor::USE_PADDING;
246
247 using Relations = typename NativeFlavor::template Relations_<FF>;
253
254 class AllValues : public NativeFlavor::template AllEntities<FF> {
255 public:
256 using Base = typename NativeFlavor::template AllEntities<FF>;
257 using Base::Base;
258 };
259};
260
262
263} // 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 𝔾₁.
Define a bespoke AllEntities holding all the values: [unshifted values, shifted values,...
std::array< DataType, NUM_ALL_ENTITIES > values
static const std::vector< std::string > & get_labels()
PartiallyEvaluatedMultivariates(const ProverPolynomials &full_polynomials, size_t circuit_size)
std::array< std::vector< FF >, NUM_CLAIMS > claim_challenges
The proving key for multilinear batching sumcheck.
std::array< Commitment, NUM_CLAIMS > shifted_commitments
std::array< Polynomial, NUM_CLAIMS > preshifted_polynomials
std::array< Commitment, NUM_CLAIMS > non_shifted_commitments
Native flavor for multilinear batching sumcheck with NumClaims polynomials.
std::tuple< bb::MultilinearBatchingRelation< FF_, NUM_CLAIMS > > Relations_
static constexpr size_t MAX_PARTIAL_RELATION_LENGTH
static void extend_eq_polynomials_for_virtual_round(PartiallyEvaluatedPolynomials &partially_evaluated_polynomials, const std::vector< FF > &multivariate_challenge, const size_t round_idx)
Given the eq polynomial at (u_1, .., u_N, 0, .., 0) compute its value at (u_1, ..,...
static constexpr size_t BATCHED_RELATION_PARTIAL_LENGTH
typename NativeFlavor::template AllEntities< FF > Base
typename NativeFlavor::template Relations_< FF > Relations
A container for storing the partially evaluated multivariates produced by sumcheck.
A template class for a reference array. Behaves as if std::array<T&, N> was possible.
Definition ref_array.hpp:23
Representation of the Grumpkin Verifier Commitment Key inside a bn254 circuit.
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
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
std::string to_string(bb::avm2::ValueTag tag)
Prover's claim for multilinear batching - contains polynomials and their evaluation claims.
static FF eval(std::span< const FF > r_in, std::span< const FF > u)
field_t< CircuitBuilder > ScalarField
Definition bn254.hpp:30
VectorField result