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 using Codec = FrCodec;
35
36 // An upper bound on the size of the MultilinearBatching-circuits. `CONST_FOLDING_LOG_N` bounds the log circuit
37 // sizes in the Chonk context.
38 static constexpr size_t VIRTUAL_LOG_N = CONST_FOLDING_LOG_N;
39 static constexpr bool USE_SHORT_MONOMIALS = false;
40 // Indicates that this flavor runs with non-ZK Sumcheck.
41 static constexpr bool HasZK = false;
42 // Indicates that this flavor runs with Multilinear Batching.
43 static constexpr bool IS_MULTILINEAR_BATCHING = true;
44 // To achieve fixed proof size and that the recursive verifier circuit is constant, we are using padding in Sumcheck
45 // and Shplemini
46 static constexpr bool USE_PADDING = true;
47
48 // ============ PROOF STRUCTURE CONSTANTS ============
49 // Number of accumulator commitments sent in proof (non_shifted + shifted).
50 // Note: instance commitments are computed by verifier from Oink witness commitments.
51 // Note: eq polynomials are computed from challenges, not committed.
52 static constexpr size_t NUM_ACCUMULATOR_COMMITMENTS = 2;
53 // Number of accumulator evaluations sent in proof (non_shifted + shifted).
54 static constexpr size_t NUM_ACCUMULATOR_EVALUATIONS = 2;
55
56 // ============ SUMCHECK CONSTANTS ============
57 // Total polynomials in sumcheck: 4 unshifted + 2 shifted views.
58 static constexpr size_t NUM_ALL_ENTITIES = 6;
59 static constexpr size_t NUM_SHIFTED_ENTITIES = 2;
60
61 // define the tuple of Relations that comprise the Sumcheck relation
62 // Note: made generic for use in MegaRecursive.
63 template <typename FF>
64 using Relations_ =
67
68 static constexpr size_t MAX_PARTIAL_RELATION_LENGTH = compute_max_partial_relation_length<Relations>();
69 // BATCHED_RELATION_PARTIAL_LENGTH = algebraic degree of sumcheck relation *after* multiplying by the `pow_zeta`
70 // random polynomial e.g. For \sum(x) [A(x) * B(x) + C(x)] * PowZeta(X), relation length = 2 and random relation
71 // length = 3
74
75 // A challenge whose powers are used to batch subrelation contributions during Sumcheck
76 static constexpr size_t NUM_SUBRELATIONS = compute_number_of_subrelations<Relations>();
78
90 template <typename DataType> class AllEntities {
91 public:
93 batched_unshifted_accumulator, // Accumulator's batched unshifted poly (committed)
94 batched_unshifted_instance, // Instance's batched unshifted poly (verifier computes)
95 eq_accumulator, // eq(u, r_acc) selector (derived from challenges)
96 eq_instance, // eq(u, r_inst) selector (derived from challenges)
97 batched_shifted_accumulator, // Accumulator's batched shifted poly
98 batched_shifted_instance); // Instance's batched shifted poly
99
101 {
102 return RefArray{ batched_unshifted_accumulator, batched_unshifted_instance, eq_accumulator, eq_instance };
103 };
104 auto get_shifted() { return RefArray{ batched_shifted_accumulator, batched_shifted_instance }; };
105 };
106
111 class AllValues : public AllEntities<FF> {
112 public:
114 using Base::Base;
115 };
116
120 class ProverPolynomials : public AllEntities<Polynomial> {
121 public:
122 [[nodiscard]] size_t get_polynomial_size() const { return batched_unshifted_accumulator.size(); }
123 void increase_polynomials_virtual_size(const size_t size_in)
124 {
125 for (auto& polynomial : this->get_all()) {
126 polynomial.increase_virtual_size(size_in);
127 }
128 }
129 };
130
136 struct ProverClaim {
137 std::vector<FF> challenge; // Evaluation point r
138 FF non_shifted_evaluation; // Claimed value P(r)
139 FF shifted_evaluation; // Claimed value P_shifted(r)
141 Polynomial shifted_polynomial; // The shiftable polynomial (pre-shift form)
143 Commitment shifted_commitment; // Commitment [P_shifted]
144 size_t dyadic_size; // Size of the polynomial domain
145
146#ifndef NDEBUG
152#endif
153 };
154
182 public:
183 // Polynomials for sumcheck: batched witnesses + eq selectors
185
186 // Evaluation points r_acc and r_inst (sent to verifier for eq polynomial construction)
187 std::vector<FF> accumulator_challenge;
188 std::vector<FF> instance_challenge;
189
190 // Claimed evaluations v_acc = P_acc(r_acc) and v_inst = P_inst(r_inst)
191 std::vector<FF> accumulator_evaluations;
192 std::vector<FF> instance_evaluations;
193
195
196 // Commitments [P_acc] and [P_inst] - combined into output claim's commitment
201
202 // Pre-shifted polynomials for computing new claim's shifted polynomial
205
206 ProvingKey() = default;
207
212 ProvingKey(ProverClaim&& accumulator_claim, ProverClaim&& instance_claim);
213 };
214
220
226
231};
232
233// Type alias for external usage
235
236} // 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 𝔾₁.
All polynomials used in multilinear batching sumcheck.
DEFINE_FLAVOR_MEMBERS(DataType, batched_unshifted_accumulator, batched_unshifted_instance, eq_accumulator, eq_instance, batched_shifted_accumulator, batched_shifted_instance)
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.
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 NUM_ACCUMULATOR_COMMITMENTS
std::tuple< bb::MultilinearBatchingAccumulatorRelation< FF >, bb::MultilinearBatchingInstanceRelation< 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:22
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...
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.