Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
shplonk.hpp
Go to the documentation of this file.
1// === AUDIT STATUS ===
2// internal: { status: Complete, auditors: [Khashayar], commit: }
3// external_1: { status: not started, auditors: [], commit: }
4// external_2: { status: not started, auditors: [], commit: }
5// =====================
6
7#pragma once
16
31namespace bb {
32
38template <typename Curve> class ShplonkProver_ {
39 using Fr = typename Curve::ScalarField;
42
43 public:
49
58 static Polynomial compute_batched_quotient(const size_t virtual_log_n,
59 std::span<const ProverOpeningClaim<Curve>> opening_claims,
60 const Fr& nu,
61 std::span<Fr> gemini_fold_pos_evaluations,
62 std::span<const ProverOpeningClaim<Curve>> libra_opening_claims,
63 std::span<const ProverOpeningClaim<Curve>> sumcheck_round_claims)
64 {
65 // Find the maximum polynomial size among all claims to determine the dyadic size of the batched polynomial.
66 size_t max_poly_size{ 0 };
67
68 for (const auto& claim_set : { opening_claims, libra_opening_claims, sumcheck_round_claims }) {
69 for (const auto& claim : claim_set) {
70 max_poly_size = std::max(max_poly_size, claim.polynomial.size());
71 }
72 }
73 // Q(X) = ∑ⱼ νʲ ⋅ ( fⱼ(X) − vⱼ) / ( X − xⱼ )
74 Polynomial Q(max_poly_size);
75 Polynomial tmp(max_poly_size);
76
77 Fr current_nu = Fr::one();
78
79 size_t fold_idx = 0;
80 for (const auto& claim : opening_claims) {
81
82 // Gemini Fold Polynomials have to be opened at -r^{2^j} and r^{2^j}.
83 if (claim.gemini_fold) {
84 tmp = claim.polynomial;
85 tmp.at(0) = tmp[0] - gemini_fold_pos_evaluations[fold_idx++];
86 tmp.factor_roots(-claim.opening_pair.challenge);
87 // Add the claim quotient to the batched quotient polynomial
88 Q.add_scaled(tmp, current_nu);
89 current_nu *= nu;
90 }
91
92 // Compute individual claim quotient tmp = ( fⱼ(X) − vⱼ) / ( X − xⱼ )
93 tmp = claim.polynomial;
94 tmp.at(0) = tmp[0] - claim.opening_pair.evaluation;
95 tmp.factor_roots(claim.opening_pair.challenge);
96 // Add the claim quotient to the batched quotient polynomial
97 Q.add_scaled(tmp, current_nu);
98 current_nu *= nu;
99 }
100 // Libra and sumcheck opening claims are batched immediately after the Gemini fold claims, reusing the same
101 // batching challenge nu. They start at nu^{2 * virtual_log_n}. Guard on either Libra or sumcheck claims being
102 // present (not just Libra): a sumcheck-only claim set must still skip past the (dummy-padded) fold claims.
103 if (!libra_opening_claims.empty() || !sumcheck_round_claims.empty()) {
104 // The offset 2 * virtual_log_n offset is a property of the *Gemini* claim layout — virtual_log_n fold
105 // rounds, each opened at two points (±r^{2^i}), including the dummy padding folds.
106 current_nu = nu.pow(2 * virtual_log_n);
107 }
108
109 for (const auto& claim : libra_opening_claims) {
110 // Compute individual claim quotient tmp = ( fⱼ(X) − vⱼ) / ( X − xⱼ )
111 tmp = claim.polynomial;
112 tmp.at(0) = tmp[0] - claim.opening_pair.evaluation;
113 tmp.factor_roots(claim.opening_pair.challenge);
114
115 // Add the claim quotient to the batched quotient polynomial
116 Q.add_scaled(tmp, current_nu);
117 current_nu *= nu;
118 }
119
120 for (const auto& claim : sumcheck_round_claims) {
121
122 // Compute individual claim quotient tmp = ( fⱼ(X) − vⱼ) / ( X − xⱼ )
123 tmp = claim.polynomial;
124 tmp.at(0) = tmp[0] - claim.opening_pair.evaluation;
125 tmp.factor_roots(claim.opening_pair.challenge);
126
127 // Add the claim quotient to the batched quotient polynomial
128 Q.add_scaled(tmp, current_nu);
129 current_nu *= nu;
130 }
131 // Return batched quotient polynomial Q(X)
132 return Q;
133 };
134
146 const size_t virtual_log_n,
147 std::span<ProverOpeningClaim<Curve>> opening_claims,
148 Polynomial& batched_quotient_Q,
149 const Fr& nu_challenge,
150 const Fr& z_challenge,
151 std::span<Fr> gemini_fold_pos_evaluations,
152 std::span<ProverOpeningClaim<Curve>> libra_opening_claims = {},
153 std::span<ProverOpeningClaim<Curve>> sumcheck_opening_claims = {})
154 {
155 // Our main use case is the opening of Gemini fold polynomials and each Gemini fold is opened at 2 points.
156 const size_t num_gemini_opening_claims = 2 * opening_claims.size();
157 const size_t num_opening_claims =
158 num_gemini_opening_claims + libra_opening_claims.size() + sumcheck_opening_claims.size();
159
160 // {ẑⱼ(z)}ⱼ , where ẑⱼ(r) = 1/zⱼ(z) = 1/(z - xⱼ)
161 std::vector<Fr> inverse_vanishing_evals;
162 inverse_vanishing_evals.reserve(num_opening_claims);
163 for (const auto& claim : opening_claims) {
164 if (claim.gemini_fold) {
165 inverse_vanishing_evals.emplace_back(z_challenge + claim.opening_pair.challenge);
166 }
167 inverse_vanishing_evals.emplace_back(z_challenge - claim.opening_pair.challenge);
168 }
169
170 // Add the terms (z - uₖ) for k = 0, …, d−1 where d is the number of rounds in Sumcheck
171 for (const auto& claim : libra_opening_claims) {
172 inverse_vanishing_evals.emplace_back(z_challenge - claim.opening_pair.challenge);
173 }
174
175 for (const auto& claim : sumcheck_opening_claims) {
176 inverse_vanishing_evals.emplace_back(z_challenge - claim.opening_pair.challenge);
177 }
178
179 Fr::batch_invert(inverse_vanishing_evals);
180
181 // G(X) = Q(X) - Q_z(X) = Q(X) - ∑ⱼ νʲ ⋅ ( fⱼ(X) − vⱼ) / ( z − xⱼ ),
182 // s.t. G(r) = 0
183 Polynomial G(std::move(batched_quotient_Q)); // G(X) = Q(X)
184
185 Fr current_nu = Fr::one();
186 size_t idx = 0;
187
188 size_t fold_idx = 0;
189 for (const auto& claim : opening_claims) {
190
191 if (claim.gemini_fold) {
192 // G -= νʲ ⋅ ( fⱼ(X) − vⱼ₊) / ( z + xⱼ ), where vⱼ₊ is the positive fold evaluation
193 Fr scaling_factor = current_nu * inverse_vanishing_evals[idx++]; // = νʲ / (z + xⱼ )
194 G.add_scaled(claim.polynomial, -scaling_factor);
195 G.at(0) = G[0] + scaling_factor * gemini_fold_pos_evaluations[fold_idx++];
196
197 current_nu *= nu_challenge;
198 }
199 // G -= νʲ ⋅ ( fⱼ(X) − vⱼ) / ( z − xⱼ )
200 Fr scaling_factor = current_nu * inverse_vanishing_evals[idx++]; // = νʲ / (z − xⱼ )
201 G.add_scaled(claim.polynomial, -scaling_factor);
202 G.at(0) = G[0] + scaling_factor * claim.opening_pair.evaluation;
203
204 current_nu *= nu_challenge;
205 }
206
207 // Libra and sumcheck opening claims are batched immediately after the Gemini fold claims, reusing the same
208 // batching challenge nu. They start at nu^{2 * virtual_log_n}. Guard on either Libra or sumcheck claims being
209 // present (not just Libra): a sumcheck-only claim set must still skip past the (dummy-padded) fold claims.
210 if (!libra_opening_claims.empty() || !sumcheck_opening_claims.empty()) {
211 // The offset 2 * virtual_log_n offset is a property of the *Gemini* claim layout — virtual_log_n fold
212 // rounds, each opened at two points (±r^{2^i}), including the dummy padding folds.
213 current_nu = nu_challenge.pow(2 * virtual_log_n);
214 }
215
216 for (const auto& claim : libra_opening_claims) {
217 // G -= νʲ ⋅ ( fⱼ(X) − vⱼ) / ( z − xⱼ )
218 Fr scaling_factor = current_nu * inverse_vanishing_evals[idx++]; // = νʲ / (z − xⱼ )
219 G.add_scaled(claim.polynomial, -scaling_factor);
220 G.at(0) = G[0] + scaling_factor * claim.opening_pair.evaluation;
221 current_nu *= nu_challenge;
222 }
223
224 for (const auto& claim : sumcheck_opening_claims) {
225 Fr scaling_factor = current_nu * inverse_vanishing_evals[idx++]; // = νʲ / (z − xⱼ )
226 G.add_scaled(claim.polynomial, -scaling_factor);
227 G.at(0) = G[0] + scaling_factor * claim.opening_pair.evaluation;
228 current_nu *= nu_challenge;
229 }
230 // Return opening pair (z, 0) and polynomial G(X) = Q(X) - Q_z(X)
231 return { .polynomial = G, .opening_pair = { .challenge = z_challenge, .evaluation = Fr::zero() } };
232 };
241 std::span<const ProverOpeningClaim<Curve>> opening_claims)
242 {
243 std::vector<Fr> gemini_fold_pos_evaluations;
244 gemini_fold_pos_evaluations.reserve(opening_claims.size());
245
246 for (const auto& claim : opening_claims) {
247 if (claim.gemini_fold) {
248 // -r^{2^i} is stored in the claim
249 const Fr evaluation_point = -claim.opening_pair.challenge;
250 // Compute Fold_i(r^{2^i})
251 const Fr evaluation = claim.polynomial.evaluate(evaluation_point);
252 gemini_fold_pos_evaluations.emplace_back(evaluation);
253 }
254 }
255 return gemini_fold_pos_evaluations;
256 }
257
267 template <typename Transcript>
269 const CommitmentKey<Curve>& commitment_key,
270 std::span<ProverOpeningClaim<Curve>> opening_claims,
271 const std::shared_ptr<Transcript>& transcript,
272 std::span<ProverOpeningClaim<Curve>> libra_opening_claims = {},
273 std::span<ProverOpeningClaim<Curve>> sumcheck_round_claims = {},
274 const size_t virtual_log_n = 0)
275 {
276 BB_BENCH_NAME("ShplonkProver::prove");
277 BB_ASSERT(virtual_log_n > 0 || (libra_opening_claims.empty() && sumcheck_round_claims.empty()),
278 "ShplonkProver::prove: virtual_log_n must be provided when batching Libra or sumcheck claims");
279 const Fr nu = transcript->template get_challenge<Fr>("Shplonk:nu");
280
281 // Compute the evaluations Fold_i(r^{2^i}) for i>0.
282 std::vector<Fr> gemini_fold_pos_evaluations = compute_gemini_fold_pos_evaluations(opening_claims);
283
284 auto batched_quotient = compute_batched_quotient(virtual_log_n,
285 opening_claims,
286 nu,
287 gemini_fold_pos_evaluations,
288 libra_opening_claims,
289 sumcheck_round_claims);
290 auto batched_quotient_commitment = commitment_key.commit(batched_quotient);
291 transcript->send_to_verifier("Shplonk:Q", batched_quotient_commitment);
292 const Fr z = transcript->template get_challenge<Fr>("Shplonk:z");
293
295 opening_claims,
296 batched_quotient,
297 nu,
298 z,
299 gemini_fold_pos_evaluations,
300 libra_opening_claims,
301 sumcheck_round_claims),
302 batched_quotient_commitment,
303 nu };
304 }
305
306 template <typename Transcript>
308 std::span<ProverOpeningClaim<Curve>> opening_claims,
309 const std::shared_ptr<Transcript>& transcript,
310 std::span<ProverOpeningClaim<Curve>> libra_opening_claims = {},
311 std::span<ProverOpeningClaim<Curve>> sumcheck_round_claims = {},
312 const size_t virtual_log_n = 0)
313 {
314 return compute_partially_evaluated_quotient(commitment_key,
315 opening_claims,
316 transcript,
317 libra_opening_claims,
318 sumcheck_round_claims,
319 virtual_log_n)
321 }
322};
323
367template <typename Curve> class ShplonkVerifier_ {
368 using Fr = typename Curve::ScalarField;
369 using GroupElement = typename Curve::Element;
372
373 // Random challenges
374 std::vector<Fr> pows_of_nu;
375 // Commitment to quotient polynomial
377 // Partial evaluation challenge
379 // Commitments in the batch-opening MSM. Index 0 holds the quotient commitment \f$[Q]\f$; indices 1..n hold the
380 // claim commitments \f$[f_1], \dots, [f_n]\f$. finalize() additionally appends the g1 identity \f$[1]\f$.
381 std::vector<Commitment> commitments;
382 // Scalar coefficients aligned index-for-index with `commitments`: `scalars[0] = 1` (for \f$[Q]\f$), and
383 // `scalars[i]` is the coefficient of \f$[f_i]\f$ in the MSM that forms the commitment to the partially
384 // evaluated quotient.
385 std::vector<Fr> scalars;
386 // Coefficient of the identity in partially evaluated quotient
388 // Target evaluation
390 // finalize() and export_batch_opening_claim() both append the g1 identity to `commitments`/`scalars`, so they
391 // are mutually exclusive and each may be called at most once; this guards against a double-append.
392 bool consumed_ = false;
393
394 public:
395 ShplonkVerifier_(const std::vector<Commitment>& polynomial_commitments,
396 const Commitment& quotient_commitment,
397 const Fr& nu_challenge,
398 const Fr& partial_evaluation_challenge)
399 : pows_of_nu({ Fr(1), nu_challenge })
400 , quotient(quotient_commitment)
401 , z_challenge(partial_evaluation_challenge)
402 , commitments({ quotient })
403 , scalars{ Fr{ 1 } }
404 {
405 initialize(polynomial_commitments);
406 }
407
408 template <typename Transcript>
409 ShplonkVerifier_(const std::vector<Commitment>& polynomial_commitments,
410 std::shared_ptr<Transcript>& transcript,
411 const size_t num_claims)
412 : pows_of_nu({ Fr(1), transcript->template get_challenge<Fr>("Shplonk:nu") })
413 , quotient(transcript->template receive_from_prover<Commitment>("Shplonk:Q"))
414 , z_challenge(transcript->template get_challenge<Fr>("Shplonk:z"))
415 , commitments({ quotient })
416 , scalars{ Fr{ 1 } }
417 {
418 BB_ASSERT_EQ(num_claims, polynomial_commitments.size());
419 initialize(polynomial_commitments);
420 }
421
422 private:
423 void initialize(const std::vector<Commitment>& polynomial_commitments)
424 {
425 const size_t num_claims = polynomial_commitments.size();
426 if (num_claims <= 1U) {
427 throw_or_abort("Using Shplonk with just one claim. Should use batch reduction.");
428 }
429 commitments.reserve(num_claims + 1);
430 scalars.reserve(num_claims + 1);
431 pows_of_nu.reserve(num_claims);
432
433 commitments.insert(commitments.end(), polynomial_commitments.begin(), polynomial_commitments.end());
434 scalars.insert(scalars.end(), commitments.size() - 1, Fr(0)); // Initialized as circuit constants
435 // The first two powers of nu have already been initialized, we need another `num_claims - 2` powers to batch
436 // all the claims
437 for (size_t idx = 0; idx < num_claims - 2; idx++) {
438 pows_of_nu.emplace_back(pows_of_nu.back() * pows_of_nu[1]);
439 }
440
441 if constexpr (Curve::is_stdlib_type) {
442 evaluation.convert_constant_to_fixed_witness(pows_of_nu[1].get_context());
443 }
444 }
445
446 void accumulate_claims(std::span<const OpeningClaim<Curve>> claims)
447 {
448 // Compute { 1 / (z - x_i) }
449 std::vector<Fr> inverse_vanishing_evals;
450 inverse_vanishing_evals.reserve(claims.size());
451 if constexpr (Curve::is_stdlib_type) {
452 for (const auto& claim : claims) {
453 inverse_vanishing_evals.emplace_back((z_challenge - claim.opening_pair.challenge).invert());
454 }
455 } else {
456 for (const auto& claim : claims) {
457 inverse_vanishing_evals.emplace_back(z_challenge - claim.opening_pair.challenge);
458 }
459 Fr::batch_invert(inverse_vanishing_evals);
460 }
461
462 // Update the Shplonk verifier state with each claim
463 // For each claim: s_i -= ν^i / (z - x_i) and θ += ν^i * v_i / (z - x_i)
464 for (size_t idx = 0; idx < claims.size(); idx++) {
465 // Compute ν^i / (z - x_i)
466 auto scalar_factor = pows_of_nu[idx] * inverse_vanishing_evals[idx];
467 // s_i -= ν^i / (z - x_i)
468 scalars[idx + 1] -= scalar_factor;
469 // θ += ν^i * v_i / (z - x_i)
470 identity_scalar_coefficient += scalar_factor * claims[idx].opening_pair.evaluation;
471 }
472 }
473
474 public:
484 {
486 "ShplonkVerifier: finalize()/export_batch_opening_claim() are mutually exclusive and may each be "
487 "called at most once");
488 consumed_ = true;
489 commitments.emplace_back(g1_identity);
491 GroupElement result = GroupElement::batch_mul(commitments, scalars);
492
493 return { { z_challenge, evaluation }, result };
494 }
495
510 // TODO(https://github.com/AztecProtocol/barretenberg/issues/1475): Compute g1_identity inside the function body
512 {
514 "ShplonkVerifier: finalize()/export_batch_opening_claim() are mutually exclusive and may each be "
515 "called at most once");
516 consumed_ = true;
517 commitments.emplace_back(g1_identity);
519
520 return { commitments, scalars, z_challenge };
521 }
522
530 template <typename Transcript>
532 std::shared_ptr<Transcript>& transcript)
533 {
534 // Initialize Shplonk verifier
535 const size_t num_claims = claims.size();
536 std::vector<Commitment> polynomial_commiments;
537 polynomial_commiments.reserve(num_claims);
538 for (const auto& claim : claims) {
539 polynomial_commiments.emplace_back(claim.commitment);
540 }
541 ShplonkVerifier_<Curve> verifier(polynomial_commiments, transcript, num_claims);
542
543 verifier.accumulate_claims(claims);
544 return verifier;
545 };
546
548 std::span<const OpeningClaim<Curve>> claims,
549 const Commitment& quotient_commitment,
550 const Fr& nu_challenge,
551 const Fr& partial_evaluation_challenge)
552 {
553 std::vector<Commitment> polynomial_commiments;
554 polynomial_commiments.reserve(claims.size());
555 for (const auto& claim : claims) {
556 polynomial_commiments.emplace_back(claim.commitment);
557 }
559 polynomial_commiments, quotient_commitment, nu_challenge, partial_evaluation_challenge);
560 verifier.accumulate_claims(claims);
561 return verifier.finalize(g1_identity);
562 }
563
574 template <typename Transcript>
576 std::span<const OpeningClaim<Curve>> claims,
577 std::shared_ptr<Transcript>& transcript)
578 {
579 auto verifier = ShplonkVerifier_::reduce_verification_no_finalize(claims, transcript);
580 return verifier.finalize(g1_identity);
581 };
582
592 static std::vector<Fr> compute_inverted_gemini_denominators(const Fr& shplonk_eval_challenge,
593 const std::vector<Fr>& gemini_eval_challenge_powers)
594 {
595 std::vector<Fr> denominators;
596 const size_t virtual_log_n = gemini_eval_challenge_powers.size();
597 const size_t num_gemini_claims = 2 * virtual_log_n;
598 denominators.reserve(num_gemini_claims);
599
600 for (const auto& gemini_eval_challenge_power : gemini_eval_challenge_powers) {
601 // Place 1/(z - r ^ {2^j})
602 denominators.emplace_back(shplonk_eval_challenge - gemini_eval_challenge_power);
603 // Place 1/(z + r ^ {2^j})
604 denominators.emplace_back(shplonk_eval_challenge + gemini_eval_challenge_power);
605 }
606
607 if constexpr (!Curve::is_stdlib_type) {
608 Fr::batch_invert(denominators);
609 } else {
610 for (auto& denominator : denominators) {
611 denominator = denominator.invert();
612 }
613 }
614 return denominators;
615 }
616};
617
623template <typename Fr>
624static std::vector<Fr> compute_shplonk_batching_challenge_powers(const Fr& shplonk_batching_challenge,
625 const size_t virtual_log_n,
626 bool has_zk = false,
627 bool committed_sumcheck = false)
628{
629 // Minimum number of powers: 2 * virtual_log_n for the Gemini fold claims
630 size_t num_powers = 2 * virtual_log_n;
631 // Each round univariate is opened at 0, 1, and a round challenge.
632 static constexpr size_t NUM_COMMITTED_SUMCHECK_CLAIMS_PER_ROUND = 3;
633
634 // Shplonk evaluation and batching challenges are re-used in SmallSubgroupIPA.
635 if (has_zk) {
636 num_powers += NUM_SMALL_IPA_OPENING_CLAIMS;
637 }
638
639 // Commited sumcheck adds 3 claims per round.
640 if (committed_sumcheck) {
641 num_powers += NUM_COMMITTED_SUMCHECK_CLAIMS_PER_ROUND * virtual_log_n;
642 }
643
644 std::vector<Fr> result;
645 result.reserve(num_powers);
646 result.emplace_back(Fr{ 1 });
647 for (size_t idx = 1; idx < num_powers; idx++) {
648 result.emplace_back(result[idx - 1] * shplonk_batching_challenge);
649 }
650 return result;
651}
652} // namespace bb
#define BB_ASSERT(expression,...)
Definition assert.hpp:70
#define BB_ASSERT_EQ(actual, expected,...)
Definition assert.hpp:83
#define BB_BENCH_NAME(name)
Definition bb_bench.hpp:264
CommitmentKey object over a pairing group 𝔾₁.
Commitment commit(PolynomialSpan< const Fr > polynomial, bool has_duplicates_hint=false) const
Uses the ProverSRS to create a commitment to p(X)
Unverified claim (C,r,v) for some witness polynomial p(X) such that.
Definition claim.hpp:55
void add_scaled(PolynomialSpan< const Fr > other, const Fr &scaling_factor)
adds the polynomial q(X) 'other', multiplied by a scaling factor.
Fr & at(size_t index)
Our mutable accessor, unlike operator[]. We abuse precedent a bit to differentiate at() and operator[...
void factor_roots(const Fr &root)
Divides p(X) by (X-r) in-place. Assumes that p(rⱼ)=0 for all j.
Polynomial p and an opening pair (r,v) such that p(r) = v.
Definition claim.hpp:36
Shplonk Prover.
Definition shplonk.hpp:38
static std::vector< Fr > compute_gemini_fold_pos_evaluations(std::span< const ProverOpeningClaim< Curve > > opening_claims)
Compute evaluations of fold polynomials Fold_i at r^{2^i} for i>0. TODO(https://github....
Definition shplonk.hpp:240
static PartiallyEvaluatedQuotient compute_partially_evaluated_quotient(const CommitmentKey< Curve > &commitment_key, std::span< ProverOpeningClaim< Curve > > opening_claims, const std::shared_ptr< Transcript > &transcript, std::span< ProverOpeningClaim< Curve > > libra_opening_claims={}, std::span< ProverOpeningClaim< Curve > > sumcheck_round_claims={}, const size_t virtual_log_n=0)
Returns a batched opening claim equivalent to a set of opening claims consisting of polynomials,...
Definition shplonk.hpp:268
static Polynomial compute_batched_quotient(const size_t virtual_log_n, std::span< const ProverOpeningClaim< Curve > > opening_claims, const Fr &nu, std::span< Fr > gemini_fold_pos_evaluations, std::span< const ProverOpeningClaim< Curve > > libra_opening_claims, std::span< const ProverOpeningClaim< Curve > > sumcheck_round_claims)
Compute batched quotient polynomial Q(X) = ∑ⱼ νʲ ⋅ ( fⱼ(X) − vⱼ) / ( X − xⱼ )
Definition shplonk.hpp:58
typename Curve::AffineElement Commitment
Definition shplonk.hpp:40
static ProverOpeningClaim< Curve > prove(const CommitmentKey< Curve > &commitment_key, std::span< ProverOpeningClaim< Curve > > opening_claims, const std::shared_ptr< Transcript > &transcript, std::span< ProverOpeningClaim< Curve > > libra_opening_claims={}, std::span< ProverOpeningClaim< Curve > > sumcheck_round_claims={}, const size_t virtual_log_n=0)
Definition shplonk.hpp:307
typename Curve::ScalarField Fr
Definition shplonk.hpp:39
static ProverOpeningClaim< Curve > compute_partially_evaluated_batched_quotient(const size_t virtual_log_n, std::span< ProverOpeningClaim< Curve > > opening_claims, Polynomial &batched_quotient_Q, const Fr &nu_challenge, const Fr &z_challenge, std::span< Fr > gemini_fold_pos_evaluations, std::span< ProverOpeningClaim< Curve > > libra_opening_claims={}, std::span< ProverOpeningClaim< Curve > > sumcheck_opening_claims={})
Compute partially evaluated batched quotient polynomial difference Q(X) - Q_z(X)
Definition shplonk.hpp:145
bb::Polynomial< Fr > Polynomial
Definition shplonk.hpp:41
Shplonk Verifier.
Definition shplonk.hpp:367
std::vector< Fr > pows_of_nu
Definition shplonk.hpp:374
typename Curve::ScalarField Fr
Definition shplonk.hpp:368
BatchOpeningClaim< Curve > export_batch_opening_claim(const Commitment &g1_identity)
Export a BatchOpeningClaim instead of performing final batch_mul.
Definition shplonk.hpp:511
ShplonkVerifier_(const std::vector< Commitment > &polynomial_commitments, const Commitment &quotient_commitment, const Fr &nu_challenge, const Fr &partial_evaluation_challenge)
Definition shplonk.hpp:395
void accumulate_claims(std::span< const OpeningClaim< Curve > > claims)
Definition shplonk.hpp:446
static OpeningClaim< Curve > reduce_verification(Commitment g1_identity, std::span< const OpeningClaim< Curve > > claims, std::shared_ptr< Transcript > &transcript)
Recomputes the new claim commitment [G] given the proof and the challenge r. No verification happens ...
Definition shplonk.hpp:575
static OpeningClaim< Curve > compute_partially_evaluated_quotient_claim(const Commitment &g1_identity, std::span< const OpeningClaim< Curve > > claims, const Commitment &quotient_commitment, const Fr &nu_challenge, const Fr &partial_evaluation_challenge)
Definition shplonk.hpp:547
void initialize(const std::vector< Commitment > &polynomial_commitments)
Definition shplonk.hpp:423
std::vector< Commitment > commitments
Definition shplonk.hpp:381
ShplonkVerifier_(const std::vector< Commitment > &polynomial_commitments, std::shared_ptr< Transcript > &transcript, const size_t num_claims)
Definition shplonk.hpp:409
typename Curve::AffineElement Commitment
Definition shplonk.hpp:370
static std::vector< Fr > compute_inverted_gemini_denominators(const Fr &shplonk_eval_challenge, const std::vector< Fr > &gemini_eval_challenge_powers)
Computes .
Definition shplonk.hpp:592
static ShplonkVerifier_< Curve > reduce_verification_no_finalize(std::span< const OpeningClaim< Curve > > claims, std::shared_ptr< Transcript > &transcript)
Instantiate a Shplonk verifier and update its state with the provided claims.
Definition shplonk.hpp:531
typename Curve::Element GroupElement
Definition shplonk.hpp:369
OpeningClaim< Curve > finalize(const Commitment &g1_identity)
Finalize the Shplonk verification and return the KZG opening claim.
Definition shplonk.hpp:483
std::vector< Fr > scalars
Definition shplonk.hpp:385
Commitment quotient
Definition shplonk.hpp:376
Representation of the Grumpkin Verifier Commitment Key inside a bn254 circuit.
typename Group::element Element
Definition grumpkin.hpp:63
static constexpr bool is_stdlib_type
Definition grumpkin.hpp:67
typename Group::affine_element AffineElement
Definition grumpkin.hpp:64
#define G(r, i, a, b, c, d)
Definition blake2s.cpp:116
Entry point for Barretenberg command-line interface.
Definition api.hpp:5
constexpr size_t NUM_SMALL_IPA_OPENING_CLAIMS
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
An accumulator consisting of the Shplonk evaluation challenge and vectors of commitments and scalars.
Definition claim.hpp:156
ProverOpeningClaim< Curve > opening_claim
Definition shplonk.hpp:45
static constexpr field one()
BB_INLINE constexpr field pow(const uint256_t &exponent) const noexcept
static void batch_invert(C &coeffs) noexcept
Batch invert a collection of field elements using Montgomery's trick.
static constexpr field zero()
void throw_or_abort(std::string const &err)
VectorField result