Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
shplemini.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
19
20namespace bb {
21
22template <typename Curve> class ShpleminiProver_ {
23 public:
24 using FF = typename Curve::ScalarField;
25 using GroupElement = typename Curve::Element;
29
34
35 template <typename Transcript>
36 static OpeningClaim prove(size_t circuit_size,
37 PolynomialBatcher& polynomial_batcher,
38 std::span<FF> multilinear_challenge,
39 const CommitmentKey<Curve>& commitment_key,
40 const std::shared_ptr<Transcript>& transcript,
41 const std::array<Polynomial, NUM_SMALL_IPA_EVALUATIONS>& libra_polynomials = {},
42 const std::vector<Polynomial>& sumcheck_round_univariates = {},
43 const std::vector<std::array<FF, 3>>& sumcheck_round_evaluations = {})
44 {
45 // While Shplemini is not templated on Flavor, we derive ZK flag this way
46 const bool has_zk = (libra_polynomials[0].size() > 0);
47
48 // When padding is enabled, the size of the multilinear challenge may be bigger than the log of `circuit_size`.
49 const size_t virtual_log_n = multilinear_challenge.size();
50
52 circuit_size, polynomial_batcher, multilinear_challenge, commitment_key, transcript, has_zk);
53 // Create opening claims for Libra masking univariates and Sumcheck Round Univariates
54 std::vector<OpeningClaim> libra_opening_claims;
55
56 if (has_zk) {
57 const auto gemini_r = opening_claims[0].opening_pair.challenge;
58 libra_opening_claims = compute_libra_opening_claims(gemini_r, libra_polynomials, transcript);
59 }
60
61 // Currently, only used in ECCVM.
62 std::vector<OpeningClaim> sumcheck_round_claims;
63
64 if (!sumcheck_round_univariates.empty()) {
65 sumcheck_round_claims = compute_sumcheck_round_claims(
66 circuit_size, multilinear_challenge, sumcheck_round_univariates, sumcheck_round_evaluations);
67 }
68
70 commitment_key, opening_claims, transcript, libra_opening_claims, sumcheck_round_claims, virtual_log_n);
71 };
72
78 template <typename Transcript>
80 const FF gemini_r,
82 const std::shared_ptr<Transcript>& transcript)
83 {
84 OpeningClaim new_claim;
85
86 std::vector<OpeningClaim> libra_opening_claims = {};
87
88 static constexpr FF subgroup_generator = Curve::subgroup_generator;
89
91 "Libra:concatenation_eval", "Libra:shifted_grand_sum_eval", "Libra:grand_sum_eval", "Libra:quotient_eval"
92 };
93 const std::array<FF, NUM_SMALL_IPA_EVALUATIONS> evaluation_points = {
94 gemini_r, gemini_r * subgroup_generator, gemini_r, gemini_r
95 };
96 for (size_t idx = 0; idx < NUM_SMALL_IPA_EVALUATIONS; idx++) {
97 new_claim.polynomial = std::move(libra_polynomials[idx]);
98 new_claim.opening_pair.challenge = evaluation_points[idx];
99 new_claim.opening_pair.evaluation = new_claim.polynomial.evaluate(evaluation_points[idx]);
100 transcript->send_to_verifier(libra_eval_labels[idx], new_claim.opening_pair.evaluation);
101 libra_opening_claims.push_back(new_claim);
102 }
103
104 return libra_opening_claims;
105 }
106
113 size_t circuit_size,
114 std::span<FF> multilinear_challenge,
115 const std::vector<Polynomial>& sumcheck_round_univariates,
116 const std::vector<std::array<FF, 3>>& sumcheck_round_evaluations)
117 {
118 OpeningClaim new_claim;
119 std::vector<OpeningClaim> sumcheck_round_claims = {};
120
121 const size_t log_n = numeric::get_msb(circuit_size);
122 for (size_t idx = 0; idx < log_n; idx++) {
123 const std::vector<FF> evaluation_points = { FF(0), FF(1), multilinear_challenge[idx] };
124 size_t eval_idx = 0;
125 new_claim.polynomial = std::move(sumcheck_round_univariates[idx]);
126
127 for (auto& eval_point : evaluation_points) {
128 new_claim.opening_pair.challenge = eval_point;
129 new_claim.opening_pair.evaluation = sumcheck_round_evaluations[idx][eval_idx];
130 sumcheck_round_claims.push_back(new_claim);
131 eval_idx++;
132 }
133 }
134
135 return sumcheck_round_claims;
136 }
137};
138
167template <typename Curve, bool HasZK> struct ShpleminiVerifierOutput_ {
169};
174
175template <typename Curve, bool HasZK = false> class ShpleminiVerifier_ {
176 using Fr = typename Curve::ScalarField;
177 using GroupElement = typename Curve::Element;
184
185 public:
213 template <typename Transcript>
215 std::span<const Fr> padding_indicator_array,
216 ClaimBatcher& claim_batcher,
217 const std::vector<Fr>& multivariate_challenge,
218 const Commitment& g1_identity,
219 const std::shared_ptr<Transcript>& transcript,
220 const RepeatedCommitmentsData& repeated_commitments = {},
221 const std::array<Commitment, NUM_LIBRA_COMMITMENTS>& libra_commitments = {},
222 const Fr& libra_univariate_evaluation = Fr{ 0 },
223 const std::vector<Commitment>& sumcheck_round_commitments = {},
224 const std::vector<std::array<Fr, 3>>& sumcheck_round_evaluations = {})
225
226 {
227 const size_t virtual_log_n = multivariate_challenge.size();
228
229 const bool committed_sumcheck = !sumcheck_round_evaluations.empty();
230
231 Fr batched_evaluation = Fr{ 0 };
232
233 // Get the challenge ρ to batch commitments to multilinear polynomials and their shifts
234 const Fr gemini_batching_challenge = transcript->template get_challenge<Fr>("rho");
235
236 // Process Gemini transcript data:
237 // - Get Gemini commitments (com(A₁), com(A₂), … , com(Aₙ₋₁))
238 const std::vector<Commitment> fold_commitments =
239 GeminiVerifier::get_fold_commitments(virtual_log_n, transcript);
240 // - Get Gemini evaluation challenge r, that is used to open the Gemini fold polynomials Aᵢ, i = 0, … , d−1 on
241 // r^{2^i}
242 const Fr gemini_evaluation_challenge = transcript->template get_challenge<Fr>("Gemini:r");
243
244 // - Get negative fold evaluations (A₀(−r), A₁(−r²), ... , Aₙ₋₁(−r²⁽ⁿ⁻¹⁾))
245 const std::vector<Fr> gemini_fold_neg_evaluations =
246 GeminiVerifier::get_gemini_evaluations(virtual_log_n, transcript);
247
248 // - Compute vector (r, r², ... , r^{2^{d-1}}), where d = log_n
249 const std::vector<Fr> gemini_eval_challenge_powers =
250 gemini::powers_of_evaluation_challenge(gemini_evaluation_challenge, virtual_log_n);
251
253 // In case of ZK, get the evaluations of Libra univariates from the transcript
254 if constexpr (HasZK) {
255 libra_evaluations[0] = transcript->template receive_from_prover<Fr>("Libra:concatenation_eval");
256 libra_evaluations[1] = transcript->template receive_from_prover<Fr>("Libra:shifted_grand_sum_eval");
257 libra_evaluations[2] = transcript->template receive_from_prover<Fr>("Libra:grand_sum_eval");
258 libra_evaluations[3] = transcript->template receive_from_prover<Fr>("Libra:quotient_eval");
259
260 // OriginTag false positive: Libra evaluations need to satisfy an identity where they
261 // are mixing without challenge, it is safe because these evaluations are opened in Shplonk.
262 if constexpr (Curve::is_stdlib_type) {
263 for (auto& eval : libra_evaluations) {
264 eval.clear_round_provenance();
265 }
266 }
267 }
268
269 // Process Shplonk transcript data:
270 // - Get Shplonk batching challenge
271 const Fr shplonk_batching_challenge = transcript->template get_challenge<Fr>("Shplonk:nu");
272
273 // Compute the powers of ν that are required for batching Gemini, SmallSubgroupIPA, and committed sumcheck
274 // univariate opening claims.
275 const std::vector<Fr> shplonk_batching_challenge_powers = compute_shplonk_batching_challenge_powers(
276 shplonk_batching_challenge, virtual_log_n, HasZK, committed_sumcheck);
277 // - Get the quotient commitment for the Shplonk batching of Gemini opening claims
278 const auto Q_commitment = transcript->template receive_from_prover<Commitment>("Shplonk:Q");
279
280 // Start populating the vector (Q, f₀, ... , fₖ₋₁, g₀, ... , gₘ₋₁, com(A₁), ... , com(A_{d-1}), [1]₁) where fᵢ
281 // are the k commitments to unshifted polynomials and gⱼ are the m commitments to shifted polynomials
282 std::vector<Commitment> commitments{ Q_commitment };
283
284 // Get Shplonk opening point z
285 const Fr shplonk_evaluation_challenge = transcript->template get_challenge<Fr>("Shplonk:z");
286
287 // OriginTag false positive: All evaluations received above are PCS-bound.
288 // The prover cannot choose them freely because they must satisfy the batched opening equation
289 // verified by the pairing check. Tag them with the shplonk evaluation challenge.
290 if constexpr (Curve::is_stdlib_type) {
291 const auto challenge_tag = shplonk_evaluation_challenge.get_origin_tag();
292 // Tag the Gemini fold evaluations
293 for (auto& eval : const_cast<std::vector<Fr>&>(gemini_fold_neg_evaluations)) {
294 eval.set_origin_tag(challenge_tag);
295 }
296 }
297
298 // Start computing the scalar to be multiplied by [1]₁
299 Fr constant_term_accumulator = Fr(0);
300
301 // Initialize the vector of scalars placing the scalar 1 corresponding to Q_commitment
302 std::vector<Fr> scalars;
303
304 scalars.emplace_back(Fr(1));
305
306 // Compute 1/(z − r), 1/(z + r), 1/(z - r²), 1/(z + r²), … , 1/(z - r^{2^{d-1}}), 1/(z + r^{2^{d-1}})
307 // These represent the denominators of the summand terms in Shplonk partially evaluated polynomial Q_z
308 const std::vector<Fr> inverse_vanishing_evals = ShplonkVerifier::compute_inverted_gemini_denominators(
309 shplonk_evaluation_challenge, gemini_eval_challenge_powers);
310
311 // Compute the additional factors to be multiplied with unshifted and shifted commitments when lazily
312 // reconstructing the commitment of Q_z
313 // For unshifted values, the scalar is computed as (1/(z−r) + ν/(z+r))
314 // For shifted values, the scalar is computed as r⁻¹ ⋅ (1/(z−r) − ν/(z+r))
315 claim_batcher.compute_scalars_for_each_batch(
316 inverse_vanishing_evals, shplonk_batching_challenge, gemini_evaluation_challenge);
317
318 // Place the commitments to prover polynomials in the commitments vector. Compute the evaluation of the
319 // batched multilinear polynomial. Populate the vector of scalars for the final batch mul
321 commitments, scalars, batched_evaluation, gemini_batching_challenge);
322
323 // Reconstruct Aᵢ(r²ⁱ) for i=0, ..., d - 1 from the batched evaluation of the multilinear polynomials and
324 // Aᵢ(−r²ⁱ) for i = 0, ..., d - 1.
325 const std::vector<Fr> gemini_fold_pos_evaluations =
327 batched_evaluation,
328 multivariate_challenge,
329 gemini_eval_challenge_powers,
330 gemini_fold_neg_evaluations);
331
332 // Place the commitments to Gemini fold polynomials Aᵢ in the vector of batch_mul commitments, compute the
333 // contributions from Aᵢ(−r²ⁱ) for i=1, … , d − 1 to the constant term accumulator, add corresponding scalars
334 // for the batch mul
335 batch_gemini_claims_received_from_prover(padding_indicator_array,
336 fold_commitments,
337 gemini_fold_neg_evaluations,
338 gemini_fold_pos_evaluations,
339 inverse_vanishing_evals,
340 shplonk_batching_challenge_powers,
341 commitments,
342 scalars,
343 constant_term_accumulator);
344 const Fr a_0_pos = gemini_fold_pos_evaluations[0];
345 // Add contributions from A₀₊(r) and A₀₋(-r) to constant_term_accumulator:
346 // Add A₀₊(r)/(z−r) to the constant term accumulator
347 constant_term_accumulator += a_0_pos * inverse_vanishing_evals[0];
348 // Add A₀₋(-r)/(z+r) to the constant term accumulator
349 constant_term_accumulator +=
350 gemini_fold_neg_evaluations[0] * shplonk_batching_challenge * inverse_vanishing_evals[1];
351
352 remove_repeated_commitments(commitments, scalars, repeated_commitments, HasZK);
353 // An optional boolean flag for SmallSubgroupIPAVerifier to check the consistency of the Libra evaluations
354 bool consistency_checked = true;
355 // For ZK flavors, the sumcheck output contains the evaluations of Libra univariates that submitted to the
356 // ShpleminiVerifier, otherwise this argument is set to be empty
357 if constexpr (HasZK) {
358 add_zk_data(virtual_log_n,
359 commitments,
360 scalars,
361 constant_term_accumulator,
362 libra_commitments,
363 libra_evaluations,
364 gemini_evaluation_challenge,
365 shplonk_batching_challenge_powers,
366 shplonk_evaluation_challenge);
367
369 libra_evaluations, gemini_evaluation_challenge, multivariate_challenge, libra_univariate_evaluation);
370 }
371
372 // Currently, only used in ECCVM
373 if (committed_sumcheck) {
374 batch_sumcheck_round_claims(commitments,
375 scalars,
376 constant_term_accumulator,
377 multivariate_challenge,
378 shplonk_batching_challenge_powers,
379 shplonk_evaluation_challenge,
380 sumcheck_round_commitments,
381 sumcheck_round_evaluations);
382 }
383
384 // Finalize the batch opening claim
385 commitments.emplace_back(g1_identity);
386 scalars.emplace_back(constant_term_accumulator);
387
388 BatchOpeningClaim<Curve> batch_opening_claim{ commitments, scalars, shplonk_evaluation_challenge };
389 ShpleminiVerifierOutput output = [&]() {
390 if constexpr (HasZK) {
391 return ShpleminiVerifierOutput{ batch_opening_claim, consistency_checked };
392 } else {
393 return ShpleminiVerifierOutput{ batch_opening_claim };
394 }
395 }();
396 return output;
397 };
398
444 const std::vector<Commitment>& fold_commitments,
445 std::span<const Fr> gemini_neg_evaluations,
446 std::span<const Fr> gemini_pos_evaluations,
447 std::span<const Fr> inverse_vanishing_evals,
448 std::span<const Fr> shplonk_batching_challenge_powers,
449 std::vector<Commitment>& commitments,
450 std::vector<Fr>& scalars,
451 Fr& constant_term_accumulator)
452 {
453 const size_t virtual_log_n = gemini_neg_evaluations.size();
454 // Start from 1, because the commitment to A_0 is reconstructed from the commitments to the multilinear
455 // polynomials. The corresponding evaluations are also handled separately.
456 for (size_t j = 1; j < virtual_log_n; ++j) {
457 // The index of 1/ (z - r^{2^{j}}) in the vector of inverted Gemini denominators
458 const size_t pos_index = 2 * j;
459 // The index of 1/ (z + r^{2^{j}}) in the vector of inverted Gemini denominators
460 const size_t neg_index = (2 * j) + 1;
461
462 // Compute the "positive" scaling factor (ν^{2j}) / (z - r^{2^{j}})
463 Fr scaling_factor_pos = shplonk_batching_challenge_powers[pos_index] * inverse_vanishing_evals[pos_index];
464 // Compute the "negative" scaling factor (ν^{2j+1}) / (z + r^{2^{j}})
465 Fr scaling_factor_neg = shplonk_batching_challenge_powers[neg_index] * inverse_vanishing_evals[neg_index];
466
467 // Accumulate the const term contribution given by
468 // v^{2j} * A_j(r^{2^j}) /(z - r^{2^j}) + v^{2j+1} * A_j(-r^{2^j}) /(z+ r^{2^j})
469 constant_term_accumulator +=
470 scaling_factor_neg * gemini_neg_evaluations[j] + scaling_factor_pos * gemini_pos_evaluations[j];
471
472 // Place the scaling factor to the 'scalars' vector
473 scalars.emplace_back(-padding_indicator_array[j] * (scaling_factor_neg + scaling_factor_pos));
474 // Move com(Aᵢ) to the 'commitments' vector
475 commitments.emplace_back(std::move(fold_commitments[j - 1]));
476 }
477 }
478
489 static void remove_repeated_commitments(std::vector<Commitment>& commitments,
490 std::vector<Fr>& scalars,
491 const RepeatedCommitmentsData& repeated_commitments,
492 bool has_zk)
493 {
494 // The commitments/scalars vectors start with Shplonk:Q (and Gemini:masking_poly_comm if ZK)
495 // before the prover polynomial commitments, so offset the AllEntities indices accordingly.
496 const size_t offset = has_zk ? 2 : 1;
497
498 const auto& r1 = repeated_commitments.first;
499 const auto& r2 = repeated_commitments.second;
500 const size_t first_original_start = r1.original_start + offset;
501 const size_t first_duplicate_start = r1.duplicate_start + offset;
502 const size_t second_original_start = r2.original_start + offset;
503 const size_t second_duplicate_start = r2.duplicate_start + offset;
504
505 // Fold duplicate scalars into their originals
506 for (size_t i = 0; i < r1.count; i++) {
507 scalars[i + first_original_start] = scalars[i + first_original_start] + scalars[i + first_duplicate_start];
508 }
509 for (size_t i = 0; i < r2.count; i++) {
510 scalars[i + second_original_start] =
511 scalars[i + second_original_start] + scalars[i + second_duplicate_start];
512 }
513
514 // Erase the duplicate entries (higher-index range first to preserve lower indices)
515 auto erase_range = [&](size_t start, size_t count) {
516 for (size_t i = 0; i < count; ++i) {
517 scalars.erase(scalars.begin() + static_cast<std::ptrdiff_t>(start));
518 commitments.erase(commitments.begin() + static_cast<std::ptrdiff_t>(start));
519 }
520 };
521 if (second_duplicate_start > first_duplicate_start) {
522 erase_range(second_duplicate_start, r2.count);
523 erase_range(first_duplicate_start, r1.count);
524 } else {
525 erase_range(first_duplicate_start, r1.count);
526 erase_range(second_duplicate_start, r2.count);
527 }
528 }
529
547 static void add_zk_data(const size_t virtual_log_n,
548 std::vector<Commitment>& commitments,
549 std::vector<Fr>& scalars,
550 Fr& constant_term_accumulator,
551 const std::array<Commitment, NUM_LIBRA_COMMITMENTS>& libra_commitments,
552 const std::array<Fr, NUM_SMALL_IPA_EVALUATIONS>& libra_evaluations,
553 const Fr& gemini_evaluation_challenge,
554 const std::vector<Fr>& shplonk_batching_challenge_powers,
555 const Fr& shplonk_evaluation_challenge)
556
557 {
558 // add Libra commitments to the vector of commitments
559 for (size_t idx = 0; idx < libra_commitments.size(); idx++) {
560 commitments.push_back(libra_commitments[idx]);
561 }
562
563 // compute corresponding scalars and the correction to the constant term
566 // compute Shplonk denominators and invert them
567 denominators[0] = Fr(1) / (shplonk_evaluation_challenge - gemini_evaluation_challenge);
568 denominators[1] =
569 Fr(1) / (shplonk_evaluation_challenge - Fr(Curve::subgroup_generator) * gemini_evaluation_challenge);
570 denominators[2] = denominators[0];
571 denominators[3] = denominators[0];
572
573 // compute the scalars to be multiplied against the commitments [libra_concatenated], [grand_sum], [grand_sum],
574 // and [libra_quotient]
575 for (size_t idx = 0; idx < NUM_SMALL_IPA_EVALUATIONS; idx++) {
576 Fr scaling_factor = denominators[idx] * shplonk_batching_challenge_powers[2 * virtual_log_n + idx];
577 batching_scalars[idx] = -scaling_factor;
578 constant_term_accumulator += scaling_factor * libra_evaluations[idx];
579 }
580
581 // to save a scalar mul, add the sum of the batching scalars corresponding to the big sum evaluations
582 scalars.push_back(batching_scalars[0]);
583 scalars.push_back(batching_scalars[1] + batching_scalars[2]);
584 scalars.push_back(batching_scalars[3]);
585 }
586
630 static void batch_sumcheck_round_claims(std::vector<Commitment>& commitments,
631 std::vector<Fr>& scalars,
632 Fr& constant_term_accumulator,
633 const std::vector<Fr>& multilinear_challenge,
634 const std::vector<Fr>& shplonk_batching_challenge_powers,
635 const Fr& shplonk_evaluation_challenge,
636 const std::vector<Commitment>& sumcheck_round_commitments,
637 const std::vector<std::array<Fr, 3>>& sumcheck_round_evaluations)
638 {
639
640 std::vector<Fr> denominators = {};
641
642 // The number of Gemini claims is equal to `2 * log_n` and `log_n` is equal to the size of
643 // `multilinear_challenge`, as this method is never used with padding.
644 const size_t num_gemini_claims = 2 * multilinear_challenge.size();
645 // Denominators for the opening claims at 0 and 1. Need to be computed only once as opposed to the claims at the
646 // sumcheck round challenges.
647 std::array<Fr, 2> const_denominators;
648
649 const_denominators[0] = Fr(1) / (shplonk_evaluation_challenge);
650 const_denominators[1] = Fr(1) / (shplonk_evaluation_challenge - Fr{ 1 });
651
652 // Compute the denominators corresponding to the evaluation claims at the round challenges and add the
653 // commitments to the sumcheck round univariates to the vector of commitments
654 for (const auto& [challenge, comm] : zip_view(multilinear_challenge, sumcheck_round_commitments)) {
655 denominators.push_back(shplonk_evaluation_challenge - challenge);
656 commitments.push_back(comm);
657 }
658
659 // Invert denominators
660 if constexpr (!Curve::is_stdlib_type) {
661 Fr::batch_invert(denominators);
662 } else {
663 for (auto& denominator : denominators) {
664 denominator = Fr{ 1 } / denominator;
665 }
666 }
667
668 // Each commitment to a sumcheck round univariate [S_i] is multiplied by the sum of three scalars corresponding
669 // to the evaluations at 0, 1, and the round challenge u_i.
670 // Compute the power of `shplonk_batching_challenge` to add sumcheck univariate commitments and evaluations to
671 // the batch.
672 size_t power = num_gemini_claims + NUM_SMALL_IPA_EVALUATIONS;
673 for (const auto& [eval_array, denominator] : zip_view(sumcheck_round_evaluations, denominators)) {
674 // Initialize batched_scalar corresponding to 3 evaluations claims
675 Fr batched_scalar = Fr(0);
676 Fr const_term_contribution = Fr(0);
677 // Compute the contribution from the evaluations at 0 and 1
678 for (size_t idx = 0; idx < 2; idx++) {
679 Fr current_scaling_factor = const_denominators[idx] * shplonk_batching_challenge_powers[power++];
680 batched_scalar -= current_scaling_factor;
681 const_term_contribution += current_scaling_factor * eval_array[idx];
682 }
683
684 // Compute the contribution from the evaluation at the challenge u_i
685 Fr current_scaling_factor = denominator * shplonk_batching_challenge_powers[power++];
686 batched_scalar -= current_scaling_factor;
687 const_term_contribution += current_scaling_factor * eval_array[2];
688
689 // Update Shplonk constant term accumulator
690 constant_term_accumulator += const_term_contribution;
691 scalars.push_back(batched_scalar);
692 }
693 };
694};
695} // namespace bb
CommitmentKey object over a pairing group 𝔾₁.
Class responsible for computation of the batched multilinear polynomials required by the Gemini proto...
Definition gemini.hpp:125
static std::vector< Claim > prove(size_t circuit_size, PolynomialBatcher &polynomial_batcher, std::span< Fr > multilinear_challenge, const CommitmentKey< Curve > &commitment_key, const std::shared_ptr< Transcript > &transcript, bool has_zk=false)
Gemini Verifier utility methods used by ShpleminiVerifier.
Definition gemini.hpp:241
static std::vector< Fr > compute_fold_pos_evaluations(std::span< const Fr > padding_indicator_array, const Fr &batched_evaluation, std::span< const Fr > evaluation_point, std::span< const Fr > challenge_powers, std::span< const Fr > fold_neg_evals)
Compute .
Definition gemini.hpp:319
static std::vector< Commitment > get_fold_commitments(const size_t virtual_log_n, auto &transcript)
Receive the fold commitments from the prover. This method is used by Shplemini where padding may be e...
Definition gemini.hpp:254
static std::vector< Fr > get_gemini_evaluations(const size_t virtual_log_n, auto &transcript)
Receive the fold evaluations from the prover. This method is used by Shplemini where padding may be e...
Definition gemini.hpp:275
Fr evaluate(const Fr &z) const
Polynomial p and an opening pair (r,v) such that p(r) = v.
Definition claim.hpp:36
Polynomial polynomial
Definition claim.hpp:41
OpeningPair< Curve > opening_pair
Definition claim.hpp:42
static OpeningClaim prove(size_t circuit_size, PolynomialBatcher &polynomial_batcher, std::span< FF > multilinear_challenge, const CommitmentKey< Curve > &commitment_key, const std::shared_ptr< Transcript > &transcript, const std::array< Polynomial, NUM_SMALL_IPA_EVALUATIONS > &libra_polynomials={}, const std::vector< Polynomial > &sumcheck_round_univariates={}, const std::vector< std::array< FF, 3 > > &sumcheck_round_evaluations={})
Definition shplemini.hpp:36
typename Curve::Element GroupElement
Definition shplemini.hpp:25
typename Curve::AffineElement Commitment
Definition shplemini.hpp:26
static std::vector< OpeningClaim > compute_libra_opening_claims(const FF gemini_r, const std::array< Polynomial, NUM_SMALL_IPA_EVALUATIONS > &libra_polynomials, const std::shared_ptr< Transcript > &transcript)
For ZK Flavors: Evaluate the polynomials used in SmallSubgroupIPA argument, send the evaluations to t...
Definition shplemini.hpp:79
typename Curve::ScalarField FF
Definition shplemini.hpp:24
static std::vector< OpeningClaim > compute_sumcheck_round_claims(size_t circuit_size, std::span< FF > multilinear_challenge, const std::vector< Polynomial > &sumcheck_round_univariates, const std::vector< std::array< FF, 3 > > &sumcheck_round_evaluations)
Create a vector of 3*log_n opening claims for the evaluations of Sumcheck Round Univariates at 0,...
static void batch_gemini_claims_received_from_prover(std::span< const Fr > padding_indicator_array, const std::vector< Commitment > &fold_commitments, std::span< const Fr > gemini_neg_evaluations, std::span< const Fr > gemini_pos_evaluations, std::span< const Fr > inverse_vanishing_evals, std::span< const Fr > shplonk_batching_challenge_powers, std::vector< Commitment > &commitments, std::vector< Fr > &scalars, Fr &constant_term_accumulator)
Place fold polynomial commitments to commitments and compute the corresponding scalar multipliers.
static void batch_sumcheck_round_claims(std::vector< Commitment > &commitments, std::vector< Fr > &scalars, Fr &constant_term_accumulator, const std::vector< Fr > &multilinear_challenge, const std::vector< Fr > &shplonk_batching_challenge_powers, const Fr &shplonk_evaluation_challenge, const std::vector< Commitment > &sumcheck_round_commitments, const std::vector< std::array< Fr, 3 > > &sumcheck_round_evaluations)
Adds the Sumcheck data into the Shplemini BatchOpeningClaim.
typename Curve::AffineElement Commitment
typename Curve::ScalarField Fr
static ShpleminiVerifierOutput compute_batch_opening_claim(std::span< const Fr > padding_indicator_array, ClaimBatcher &claim_batcher, const std::vector< Fr > &multivariate_challenge, const Commitment &g1_identity, const std::shared_ptr< Transcript > &transcript, const RepeatedCommitmentsData &repeated_commitments={}, const std::array< Commitment, NUM_LIBRA_COMMITMENTS > &libra_commitments={}, const Fr &libra_univariate_evaluation=Fr{ 0 }, const std::vector< Commitment > &sumcheck_round_commitments={}, const std::vector< std::array< Fr, 3 > > &sumcheck_round_evaluations={})
This method receives commitments to all prover polynomials, their claimed evaluations,...
typename Curve::Element GroupElement
static void remove_repeated_commitments(std::vector< Commitment > &commitments, std::vector< Fr > &scalars, const RepeatedCommitmentsData &repeated_commitments, bool has_zk)
Combines scalars of repeating commitments to reduce the number of scalar multiplications performed by...
ShpleminiVerifierOutput_< Curve, HasZK > ShpleminiVerifierOutput
static void add_zk_data(const size_t virtual_log_n, std::vector< Commitment > &commitments, std::vector< Fr > &scalars, Fr &constant_term_accumulator, const std::array< Commitment, NUM_LIBRA_COMMITMENTS > &libra_commitments, const std::array< Fr, NUM_SMALL_IPA_EVALUATIONS > &libra_evaluations, const Fr &gemini_evaluation_challenge, const std::vector< Fr > &shplonk_batching_challenge_powers, const Fr &shplonk_evaluation_challenge)
Add the opening data corresponding to Libra masking univariates to the batched opening claim.
Shplonk Prover.
Definition shplonk.hpp:36
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)
Returns a batched opening claim equivalent to a set of opening claims consisting of polynomials,...
Definition shplonk.hpp:262
Shplonk Verifier.
Definition shplonk.hpp:338
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:506
static bool check_libra_evaluations_consistency(const std::array< FF, NUM_SMALL_IPA_EVALUATIONS > &libra_evaluations, const FF &gemini_evaluation_challenge, const std::vector< FF > &multilinear_challenge, const FF &inner_product_eval_claim)
A method required by ZKSumcheck. The challenge polynomial is concatenated from the powers of the sumc...
Representation of the Grumpkin Verifier Commitment Key inside a bn254 circuit.
typename Group::element Element
Definition grumpkin.hpp:64
static constexpr bool is_stdlib_type
Definition grumpkin.hpp:68
typename Group::affine_element AffineElement
Definition grumpkin.hpp:65
static constexpr ScalarField subgroup_generator
Definition grumpkin.hpp:78
ssize_t offset
Definition engine.cpp:52
std::vector< Fr > powers_of_evaluation_challenge(const Fr &r, const size_t num_squares)
Compute squares of folding challenge r.
Definition gemini.hpp:93
constexpr T get_msb(const T in)
Definition get_msb.hpp:49
Entry point for Barretenberg command-line interface.
Definition api.hpp:5
STL namespace.
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
This file contains part of the logic for the Origin Tag mechanism that tracks the use of in-circuit p...
An accumulator consisting of the Shplonk evaluation challenge and vectors of commitments and scalars.
Definition claim.hpp:155
Logic to support batching opening claims for unshifted and shifted polynomials in Shplemini.
void update_batch_mul_inputs_and_batched_evaluation(std::vector< Commitment > &commitments, std::vector< Fr > &scalars, Fr &batched_evaluation, const Fr &rho)
Append the commitments and scalars from each batch of claims to the Shplemini vectors which subsequen...
void compute_scalars_for_each_batch(std::span< const Fr > inverted_vanishing_evals, const Fr &nu_challenge, const Fr &r_challenge)
Compute scalars used to batch each set of claims, excluding contribution from batching challenge \rho...
BatchOpeningClaim< Curve > batch_opening_claim
An efficient verifier for the evaluation proofs of multilinear polynomials and their shifts.
BatchOpeningClaim< Curve > batch_opening_claim
static void batch_invert(C &coeffs) noexcept
Batch invert a collection of field elements using Montgomery's trick.