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