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 static constexpr size_t TRACE_OFFSET = 0;
44 // Indicates that this flavor runs with Multilinear Batching.
45 static constexpr bool IS_MULTILINEAR_BATCHING = true;
46 // To achieve fixed proof size and that the recursive verifier circuit is constant, we are using padding in Sumcheck
47 // and Shplemini
48 static constexpr bool USE_PADDING = true;
49
50 // ============ PROOF STRUCTURE CONSTANTS ============
51 // Number of accumulator commitments sent in proof (non_shifted + shifted).
52 // Note: instance commitments are computed by verifier from Oink witness commitments.
53 // Note: eq polynomials are computed from challenges, not committed.
54 static constexpr size_t NUM_ACCUMULATOR_COMMITMENTS = 2;
55 // Number of accumulator evaluations sent in proof (non_shifted + shifted).
56 static constexpr size_t NUM_ACCUMULATOR_EVALUATIONS = 2;
57
58 // ============ SUMCHECK CONSTANTS ============
59 // Total polynomials in sumcheck: 4 unshifted + 2 shifted views.
60 static constexpr size_t NUM_ALL_ENTITIES = 6;
61 static constexpr size_t NUM_SHIFTED_ENTITIES = 2;
62
63 // define the tuple of Relations that comprise the Sumcheck relation
64 // Note: made generic for use in MegaRecursive.
65 template <typename FF>
66 using Relations_ =
69
70 static constexpr size_t MAX_PARTIAL_RELATION_LENGTH = compute_max_partial_relation_length<Relations>();
71 // BATCHED_RELATION_PARTIAL_LENGTH = algebraic degree of sumcheck relation *after* multiplying by the `pow_zeta`
72 // random polynomial e.g. For \sum(x) [A(x) * B(x) + C(x)] * PowZeta(X), relation length = 2 and random relation
73 // length = 3
76
77 // A challenge whose powers are used to batch subrelation contributions during Sumcheck
78 static constexpr size_t NUM_SUBRELATIONS = compute_number_of_subrelations<Relations>();
80
92 template <typename DataType> class AllEntities {
93 public:
95 batched_unshifted_accumulator, // Accumulator's batched unshifted poly (committed)
96 batched_unshifted_instance, // Instance's batched unshifted poly (verifier computes)
97 eq_accumulator, // eq(u, r_acc) selector (derived from challenges)
98 eq_instance, // eq(u, r_inst) selector (derived from challenges)
99 batched_shifted_accumulator, // Accumulator's batched shifted poly
100 batched_shifted_instance); // Instance's batched shifted poly
101
103 {
104 return RefArray{ batched_unshifted_accumulator, batched_unshifted_instance, eq_accumulator, eq_instance };
105 };
106 auto get_shifted() { return RefArray{ batched_shifted_accumulator, batched_shifted_instance }; };
107 };
108
113 class AllValues : public AllEntities<FF> {
114 public:
116 using Base::Base;
117 };
118
122 class ProverPolynomials : public AllEntities<Polynomial> {
123 public:
124 [[nodiscard]] size_t get_polynomial_size() const { return batched_unshifted_accumulator.size(); }
125 void increase_polynomials_virtual_size(const size_t size_in)
126 {
127 for (auto& polynomial : this->get_all()) {
128 polynomial.increase_virtual_size(size_in);
129 }
130 }
131 };
132
138 struct ProverClaim {
139 std::vector<FF> challenge; // Evaluation point r
140 FF non_shifted_evaluation; // Claimed value P(r)
141 FF shifted_evaluation; // Claimed value P_shifted(r)
143 Polynomial shifted_polynomial; // The shiftable polynomial (pre-shift form)
145 Commitment shifted_commitment; // Commitment [P_shifted]
146 size_t dyadic_size; // Size of the polynomial domain
147
148#ifndef NDEBUG
154#endif
155 };
156
184 public:
185 // Polynomials for sumcheck: batched witnesses + eq selectors
187
188 // Evaluation points r_acc and r_inst (sent to verifier for eq polynomial construction)
189 std::vector<FF> accumulator_challenge;
190 std::vector<FF> instance_challenge;
191
192 // Claimed evaluations v_acc = P_acc(r_acc) and v_inst = P_inst(r_inst)
193 std::vector<FF> accumulator_evaluations;
194 std::vector<FF> instance_evaluations;
195
197
198 // Commitments [P_acc] and [P_inst] - combined into output claim's commitment
203
204 // Pre-shifted polynomials for computing new claim's shifted polynomial
207
208 ProvingKey() = default;
209
214 ProvingKey(ProverClaim&& accumulator_claim, ProverClaim&& instance_claim);
215 };
216
222
228
233};
234
235// Type alias for external usage
237
238} // 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.