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: [], date: YYYY-MM-DD }
3// external_1: { status: not started, auditors: [], date: YYYY-MM-DD }
4// external_2: { status: not started, auditors: [], date: YYYY-MM-DD }
5// =====================
6
7#pragma once
8#include <utility>
9
17
18namespace bb {
19
21 public:
26 using PCS = KZG<Curve>;
31
32 // An upper bound on the size of the MultilinearBatching-circuits. `CONST_PG_LOG_N` bounds the log circuit sizes in
33 // the CIVC context. `MEGA_AVM_LOG_N` is determined by the size of the AVMRecursiveVerifier.
34 static constexpr size_t VIRTUAL_LOG_N = std::max(CONST_PG_LOG_N, MEGA_AVM_LOG_N);
35 static constexpr bool USE_SHORT_MONOMIALS = false;
36 // Indicates that this flavor runs with non-ZK Sumcheck.
37 static constexpr bool HasZK = false;
38 // Indicates that this flavor runs with Multilinear Batching.
39 static constexpr bool IS_MULTILINEAR_BATCHING = true;
40 // To achieve fixed proof size and that the recursive verifier circuit is constant, we are using padding in Sumcheck
41 // and Shplemini
42 static constexpr bool USE_PADDING = true;
43 static constexpr size_t NUM_WIRES = 4;
44 // The number of multivariate polynomials on which a sumcheck prover sumcheck operates (including shifts). We often
45 // need containers of this size to hold related data, so we choose a name more agnostic than `NUM_POLYNOMIALS`.
46 static constexpr size_t NUM_ALL_ENTITIES = 6;
47 // The total number of witness entities not including shifts.
48 static constexpr size_t NUM_WITNESS_ENTITIES = 4;
49 // The number of shifted witness entities including derived witness entities
50 static constexpr size_t NUM_SHIFTED_ENTITIES = 2;
51
52 // define the tuple of Relations that comprise the Sumcheck relation
53 // Note: made generic for use in MegaRecursive.
54 template <typename FF>
55 using Relations_ =
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 // For instances of this flavour, used in folding, we need a unique sumcheck batching challenges for each
67 // subrelation. This is because using powers of alpha would increase the degree of Protogalaxy polynomial $G$ (the
68 // combiner) too much.
69 static constexpr size_t NUM_SUBRELATIONS = compute_number_of_subrelations<Relations>();
70 using SubrelationSeparators = std::array<FF, NUM_SUBRELATIONS - 1>;
71
72 // Whether or not the first row of the execution trace is reserved for 0s to enable shifts
73 static constexpr bool has_zero_row = false;
74
75 // WireEntities for basic witness entities
76 template <typename DataType> class WireEntities {
77 public:
79 w_non_shifted_accumulator, // column 0
80 w_non_shifted_instance, // column 1
81 w_evaluations_accumulator, // column 2
82 w_evaluations_instance); // column 3
83 };
84
90 template <typename DataType> class WitnessEntities : public WireEntities<DataType> {
91 public:
93 w_non_shifted_accumulator, // column 0
94 w_non_shifted_instance, // column 1
95 w_evaluations_accumulator, // column 2
96 w_evaluations_instance); // column 3
97
98 MSGPACK_FIELDS(this->w_non_shifted_accumulator,
99 this->w_non_shifted_instance,
100 this->w_evaluations_accumulator,
101 this->w_evaluations_instance);
102 };
103
107 template <typename DataType> class ShiftedEntities {
108 public:
110 w_shifted_accumulator, // column 0
111 w_shifted_instance // column 1
112 );
113 auto get_shifted() { return RefArray{ w_shifted_accumulator, w_shifted_instance }; };
114 };
115
125 template <typename DataType>
133
138 class AllValues : public AllEntities<FF> {
139 public:
141 using Base::Base;
142 };
143
147 class ProverPolynomials : public AllEntities<Polynomial> {
148 public:
149 // Define all operations as default, except copy construction/assignment
150 ProverPolynomials() = default;
151 // fully-formed constructor
152 ProverPolynomials(size_t circuit_size)
153 {
154 BB_BENCH_NAME("ProverPolynomials(size_t)");
155
156 // catch-all with fully formed polynomials
157 for (auto& poly : get_unshifted()) {
158 if (poly.is_empty()) {
159 // Not set above
160 poly = Polynomial{ /*memory size*/ circuit_size, /*largest possible index*/ 1 << VIRTUAL_LOG_N };
161 }
162 }
163
164 for (auto& poly : get_shifted()) {
165 poly = Polynomial{ /*memory size*/ circuit_size, /*largest possible index*/ 1 << VIRTUAL_LOG_N };
166 }
167 }
168 [[nodiscard]] size_t get_polynomial_size() const { return w_non_shifted_accumulator.size(); }
169 void increase_polynomials_virtual_size(const size_t size_in)
170 {
171 for (auto& polynomial : this->get_all()) {
172 polynomial.increase_virtual_size(size_in);
173 }
174 }
175 };
176
182 public:
183 ProverPolynomials polynomials; // storage for all polynomials evaluated by the prover
184 std::vector<FF> accumulator_challenge;
185 std::vector<FF> instance_challenge;
186 std::vector<FF> accumulator_evaluations;
187 std::vector<FF> instance_evaluations;
201 };
202
206 class PartiallyEvaluatedMultivariates : public AllEntities<Polynomial> {
207
208 public:
210 PartiallyEvaluatedMultivariates(const ProverPolynomials& full_polynomials, size_t circuit_size)
211 {
212 for (auto [poly, full_poly] : zip_view(get_all(), full_polynomials.get_all())) {
213 // After the initial sumcheck round, the new size is CEIL(size/2).
214 size_t desired_size = full_poly.end_index() / 2 + full_poly.end_index() % 2;
215 poly = Polynomial(desired_size, circuit_size / 2);
216 }
217 }
218 };
219
225
230
235
242 class CommitmentLabels : public AllEntities<std::string> {
243 public:
245 {
246 w_non_shifted_accumulator = "W_NON_SHIFTED_ACCUMULATOR";
247 w_non_shifted_instance = "W_NON_SHIFTED_INSTANCE";
248 w_evaluations_accumulator = "W_EVALUATIONS_ACCUMULATOR";
249 w_evaluations_instance = "W_EVALUATIONS_INSTANCE";
250 w_shifted_accumulator = "W_SHIFTED_ACCUMULATOR";
251 w_shifted_instance = "W_SHIFTED_INSTANCE";
252 };
253 };
254};
255
256} // namespace bb
#define BB_BENCH_NAME(name)
Definition bb_bench.hpp:218
Common transcript class for both parties. Stores the data for the current round, as well as the manif...
CommitmentKey object over a pairing group 𝔾₁.
A base class labelling all entities (for instance, all of the polynomials used by the prover during s...
A field element for each entity of the flavor. These entities represent the prover polynomials evalua...
A container for storing the partially evaluated multivariates produced by sumcheck.
PartiallyEvaluatedMultivariates(const ProverPolynomials &full_polynomials, size_t circuit_size)
A container for the prover polynomials handles.
The proving key is responsible for storing the polynomials used by the prover.
ProvingKey(ProverPolynomials &&polynomials, std::vector< FF > accumulator_challenge, std::vector< FF > instance_challenge, std::vector< FF > accumulator_evaluations, std::vector< FF > instance_evaluations)
Class for ShiftedEntities, containing the shifted witness polynomials.
DEFINE_FLAVOR_MEMBERS(DataType, w_shifted_accumulator, w_shifted_instance)
DEFINE_FLAVOR_MEMBERS(DataType, w_non_shifted_accumulator, w_non_shifted_instance, w_evaluations_accumulator, w_evaluations_instance)
Container for all witness polynomials used/constructed by the prover.
DEFINE_FLAVOR_MEMBERS(DataType, w_non_shifted_accumulator, w_non_shifted_instance, w_evaluations_accumulator, w_evaluations_instance)
MSGPACK_FIELDS(this->w_non_shifted_accumulator, this->w_non_shifted_instance, this->w_evaluations_accumulator, this->w_evaluations_instance)
std::array< FF, NUM_SUBRELATIONS - 1 > SubrelationSeparators
static constexpr size_t BATCHED_RELATION_PARTIAL_LENGTH
static constexpr size_t MAX_PARTIAL_RELATION_LENGTH
std::tuple< bb::MultilinearBatchingAccumulatorRelation< FF >, bb::MultilinearBatchingInstanceRelation< FF > > Relations_
A template class for a reference array. Behaves as if std::array<T&, N> was possible.
Definition ref_array.hpp:22
A wrapper for Relations to expose methods used by the Sumcheck prover or verifier to add the contribu...
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 for structures that contain data parameterized by the fundamental polynomials of...
#define DEFINE_COMPOUND_GET_ALL(...)
Entry point for Barretenberg command-line interface.
BaseTranscript< FrCodec, bb::crypto::Poseidon2< bb::crypto::Poseidon2Bn254ScalarFieldParams > > NativeTranscript
STL namespace.
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13