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: Complete, 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
17
18namespace bb {
19
20// Forward declaration for debug comparison method
21template <typename Curve> struct MultilinearBatchingVerifierClaim;
22
24 public:
29 using PCS = KZG<Curve>;
34
35 // An upper bound on the size of the MultilinearBatching-circuits. `CONST_FOLDING_LOG_N` bounds the log circuit
36 // sizes in the Chonk context.
37 static constexpr size_t VIRTUAL_LOG_N = CONST_FOLDING_LOG_N;
38 static constexpr bool USE_SHORT_MONOMIALS = false;
39 // Indicates that this flavor runs with non-ZK Sumcheck.
40 static constexpr bool HasZK = false;
41 // Indicates that this flavor runs with Multilinear Batching.
42 static constexpr bool IS_MULTILINEAR_BATCHING = true;
43 // To achieve fixed proof size and that the recursive verifier circuit is constant, we are using padding in Sumcheck
44 // and Shplemini
45 static constexpr bool USE_PADDING = true;
46 // The number of multivariate polynomials on which a sumcheck prover sumcheck operates (including shifts). We often
47 // need containers of this size to hold related data, so we choose a name more agnostic than `NUM_POLYNOMIALS`.
48 static constexpr size_t NUM_ALL_ENTITIES = 6;
49 // The total number of witness entities not including shifts.
50 static constexpr size_t NUM_WITNESS_ENTITIES = 4;
51 // The number of shifted witness entities including derived witness entities
52 static constexpr size_t NUM_SHIFTED_ENTITIES = 2;
53 // Number of accumulator evaluations sent in the proof (non_shifted + shifted)
54 static constexpr size_t NUM_ACCUMULATOR_EVALUATIONS = 2;
55
56 // define the tuple of Relations that comprise the Sumcheck relation
57 // Note: made generic for use in MegaRecursive.
58 template <typename FF>
59 using Relations_ =
62
63 static constexpr size_t MAX_PARTIAL_RELATION_LENGTH = compute_max_partial_relation_length<Relations>();
64 // BATCHED_RELATION_PARTIAL_LENGTH = algebraic degree of sumcheck relation *after* multiplying by the `pow_zeta`
65 // random polynomial e.g. For \sum(x) [A(x) * B(x) + C(x)] * PowZeta(X), relation length = 2 and random relation
66 // length = 3
69
70 // A challenge whose powers are used to batch subrelation contributions during Sumcheck
71 static constexpr size_t NUM_SUBRELATIONS = compute_number_of_subrelations<Relations>();
73
74 static constexpr size_t num_frs_comm = FrCodec::calc_num_fields<Commitment>();
75 static constexpr size_t num_frs_fr = FrCodec::calc_num_fields<FF>();
76
77 static constexpr size_t PROOF_LENGTH_WITHOUT_PUB_INPUTS()
78 {
79 return /*accumulator commitments*/ (NUM_WITNESS_ENTITIES / 2 * num_frs_comm) +
80 /*multivariate challenges*/ (VIRTUAL_LOG_N * num_frs_fr) +
81 /*witness evaluations*/ (NUM_WITNESS_ENTITIES / 2 * num_frs_fr) +
82 /*sumcheck univariates*/ (VIRTUAL_LOG_N * BATCHED_RELATION_PARTIAL_LENGTH * num_frs_fr) +
83 /*sumcheck evaluations*/ (NUM_ALL_ENTITIES * num_frs_fr);
84 }
85
90 template <typename DataType> class WitnessEntities {
91 public:
93 batched_unshifted_accumulator, // column 0: batched unshifted poly for accumulator
94 batched_unshifted_instance, // column 1: batched unshifted poly for instance
95 eq_accumulator, // column 2: eq(u, r_acc) - selects accumulator eval point
96 eq_instance); // column 3: eq(u, r_inst) - selects instance eval point
97 };
98
102 template <typename DataType> class ShiftedEntities {
103 public:
105 batched_shifted_accumulator, // column 0: batched shifted poly for accumulator
106 batched_shifted_instance // column 1: batched shifted poly for instance
107 );
108 };
109
118 template <typename DataType>
126
131 class AllValues : public AllEntities<FF> {
132 public:
134 using Base::Base;
135 };
136
140 class ProverPolynomials : public AllEntities<Polynomial> {
141 public:
142 [[nodiscard]] size_t get_polynomial_size() const { return batched_unshifted_accumulator.size(); }
143 void increase_polynomials_virtual_size(const size_t size_in)
144 {
145 for (auto& polynomial : this->get_all()) {
146 polynomial.increase_virtual_size(size_in);
147 }
148 }
149 };
150
156 struct ProverClaim {
157 std::vector<FF> challenge; // Evaluation point r
158 FF non_shifted_evaluation; // Claimed value P(r)
159 FF shifted_evaluation; // Claimed value P_shifted(r)
161 Polynomial shifted_polynomial; // The shiftable polynomial (pre-shift form)
163 Commitment shifted_commitment; // Commitment [P_shifted]
164 size_t dyadic_size; // Size of the polynomial domain
165
166#ifndef NDEBUG
172#endif
173 };
174
202 public:
203 // Polynomials for sumcheck: batched witnesses + eq selectors
205
206 // Evaluation points r_acc and r_inst (sent to verifier for eq polynomial construction)
207 std::vector<FF> accumulator_challenge;
208 std::vector<FF> instance_challenge;
209
210 // Claimed evaluations v_acc = P_acc(r_acc) and v_inst = P_inst(r_inst)
211 std::vector<FF> accumulator_evaluations;
212 std::vector<FF> instance_evaluations;
213
215
216 // Commitments [P_acc] and [P_inst] - combined into output claim's commitment
221
222 // Pre-shifted polynomials for computing new claim's shifted polynomial
225
226 ProvingKey() = default;
227
232 ProvingKey(ProverClaim&& accumulator_claim, ProverClaim&& instance_claim);
233 };
234
240
246
251
256
263 class CommitmentLabels : public AllEntities<std::string> {
264 public:
266 {
267 batched_unshifted_accumulator = "BATCHED_UNSHIFTED_ACCUMULATOR";
268 batched_unshifted_instance = "BATCHED_UNSHIFTED_INSTANCE";
269 batched_shifted_accumulator = "BATCHED_SHIFTED_ACCUMULATOR";
270 batched_shifted_instance = "BATCHED_SHIFTED_INSTANCE";
271 };
272 };
273};
274
275// Type alias for external usage
277
278} // 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 𝔾₁.
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 the prover polynomials handles.
The proving key for multilinear batching sumcheck.
Class for ShiftedEntities, containing the shifted witness polynomials.
DEFINE_FLAVOR_MEMBERS(DataType, batched_shifted_accumulator, batched_shifted_instance)
Container for all witness polynomials used/constructed by the prover.
DEFINE_FLAVOR_MEMBERS(DataType, batched_unshifted_accumulator, batched_unshifted_instance, eq_accumulator, eq_instance)
static constexpr size_t NUM_ACCUMULATOR_EVALUATIONS
static constexpr size_t BATCHED_RELATION_PARTIAL_LENGTH
static constexpr size_t MAX_PARTIAL_RELATION_LENGTH
static constexpr size_t PROOF_LENGTH_WITHOUT_PUB_INPUTS()
std::tuple< bb::MultilinearBatchingAccumulatorRelation< FF >, bb::MultilinearBatchingInstanceRelation< FF > > Relations_
A container for storing the partially evaluated multivariates produced by sumcheck.
A wrapper for Relations to expose methods used by the Sumcheck prover or verifier to add the contribu...
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 for structures that contain data parameterized by the fundamental polynomials of...
#define DEFINE_COMPOUND_GET_ALL(...)
Entry point for Barretenberg command-line interface.
Definition api.hpp:5
BaseTranscript< FrCodec, bb::crypto::Poseidon2< bb::crypto::Poseidon2Bn254ScalarFieldParams > > NativeTranscript
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
Prover's claim for multilinear batching - contains polynomials and their evaluation claims.
bool compare_with_verifier_claim(const MultilinearBatchingVerifierClaim< curve::BN254 > &verifier_claim)
Debug helper to compare prover claim against verifier claim.
Verifier's claim for multilinear batching - contains commitments and evaluation claims.