153 const std::vector<FF>& multivariate_challenge,
160 const FF evaluation_challenge_x,
161 const FF batching_challenge_v,
175 const std::vector<FF>& multivariate_challenge,
176 const size_t& log_circuit_size);
251 const FF& small_ipa_eval_challenge,
252 const std::vector<FF>& challenge_polynomial,
253 const FF& inner_product_eval_claim,
254 const FF& vanishing_poly_eval)
260 challenge_polynomial, small_ipa_eval_challenge, vanishing_poly_eval);
262 const FF& concatenated_at_r = small_ipa_evaluations[0];
263 const FF& grand_sum_shifted_eval = small_ipa_evaluations[1];
264 const FF& grand_sum_eval = small_ipa_evaluations[2];
266 const FF& quotient_eval = small_ipa_evaluations[4];
270 FF diff = lagrange_first * grand_sum_eval;
272 (grand_sum_shifted_eval - grand_sum_eval - concatenated_at_r * challenge_poly);
273 diff += lagrange_last * (grand_sum_eval - inner_product_eval_claim) - vanishing_poly_eval * quotient_eval;
279 bool out = (diff.get_value() ==
FF(0).get_value());
280 diff.assert_equal(
FF(0));
283 return (diff ==
FF(0));
301 const FF& gemini_evaluation_challenge,
302 const std::vector<FF>& multilinear_challenge,
303 const FF& inner_product_eval_claim)
307 const FF vanishing_poly_eval = gemini_evaluation_challenge.pow(
SUBGROUP_SIZE) -
FF(1);
310 gemini_evaluation_challenge,
311 compute_challenge_polynomial_coeffs<Curve>(multilinear_challenge),
312 inner_product_eval_claim,
313 vanishing_poly_eval);
328 const FF& evaluation_challenge,
329 const FF& evaluation_challenge_x,
330 const FF& batching_challenge_v,
331 const FF& inner_product_eval_claim)
338 evaluation_challenge,
339 compute_eccvm_challenge_coeffs<Curve>(evaluation_challenge_x,
340 batching_challenge_v,
341 NUM_TRANSLATION_EVALUATIONS,
342 NUM_DISABLED_ROWS_IN_SUMCHECK),
343 inner_product_eval_claim,
344 vanishing_poly_eval);
354 bool evaluation_challenge_in_small_subgroup =
false;
356 evaluation_challenge_in_small_subgroup = (vanishing_poly_eval.get_value() ==
FF(0).get_value());
358 evaluation_challenge_in_small_subgroup = (vanishing_poly_eval ==
FF(0));
361 if (evaluation_challenge_in_small_subgroup) {
362 throw_or_abort(
"SmallSubgroupIPA: Evaluation challenge is in the SmallSubgroup. This would cancel out the "
363 "hiding property of the commitment.");
378 const std::vector<FF>& coeffs,
const FF& r,
const FF& vanishing_poly_eval)
383 auto builder = r.get_context();
384 one.convert_constant_to_fixed_witness(
builder);
385 zero.convert_constant_to_fixed_witness(
builder);
390 std::array<FF, SUBGROUP_SIZE> denominators;
391 FF running_power = one;
393 denominators[i] = running_power * r - one;
400 denominators.begin(), denominators.end(), denominators.begin(), [](
FF& d) { return d.invert(); });
414 result.begin(),
result.end(),
result.begin(), [&](
FF& denominator) { return denominator * numerator; });
428template <
typename Curve>
437 if (multivariate_challenge.empty()) {
438 throw_or_abort(
"SmallSubgroupIPA: multivariate_challenge must be non-empty");
444 const size_t challenge_poly_length = libra_univariates_length * multivariate_challenge.size() + 1;
450 auto builder = multivariate_challenge[0].get_context();
451 one.convert_constant_to_fixed_witness(
builder);
452 zero.convert_constant_to_fixed_witness(
builder);
455 challenge_polynomial_lagrange[0] = one;
458 size_t round_idx = 0;
459 for (
auto challenge : multivariate_challenge) {
460 size_t current_idx = 1 + libra_univariates_length * round_idx;
461 challenge_polynomial_lagrange[current_idx] = one;
462 for (
size_t idx = current_idx + 1; idx < current_idx + libra_univariates_length; idx++) {
464 challenge_polynomial_lagrange[idx] = challenge_polynomial_lagrange[idx - 1] * challenge;
471 challenge_polynomial_lagrange[idx] = zero;
474 return challenge_polynomial_lagrange;
484template <
typename Curve>
489 size_t num_coeffs_per_poly)
496 auto builder = evaluation_challenge_x.get_context();
497 one.convert_constant_to_fixed_witness(
builder);
498 zero.convert_constant_to_fixed_witness(
builder);
501 for (
size_t poly_idx = 0; poly_idx < num_polys; poly_idx++) {
502 const size_t start = num_coeffs_per_poly * poly_idx;
503 coeffs_lagrange_basis[start] = v_power;
505 for (
size_t idx = start + 1; idx < start + num_coeffs_per_poly; idx++) {
506 coeffs_lagrange_basis[idx] = coeffs_lagrange_basis[idx - 1] * evaluation_challenge_x;
509 v_power *= batching_challenge_v;
512 const size_t challenge_poly_length = num_polys * num_coeffs_per_poly;
517 coeffs_lagrange_basis[idx] = zero;
520 return coeffs_lagrange_basis;
#define BB_ASSERT_LT(left, right,...)
CommitmentKey object over a pairing group 𝔾₁.
A Curve-agnostic ZK protocol to prove inner products of small vectors.
typename Curve::AffineElement Commitment
std::shared_ptr< typename Flavor::Transcript > transcript
void compute_eccvm_challenge_polynomial(const FF evaluation_challenge_x, const FF batching_challenge_v)
Compute a (public) challenge polynomial from the evaluation and batching challenges.
const Polynomial< FF > & get_batched_polynomial() const
std::array< bb::Polynomial< FF >, NUM_SMALL_IPA_COMMITMENTS > get_witness_polynomials() const
typename Curve::ScalarField FF
void compute_challenge_polynomial(const std::vector< FF > &multivariate_challenge)
Computes the challenge polynomial F(X) based on the provided multivariate challenges.
static constexpr size_t MASKED_CONCATENATED_WITNESS_LENGTH
Polynomial< FF > concatenated_polynomial
static constexpr size_t QUOTIENT_LENGTH
static Polynomial< FF > compute_monomial_coefficients(std::span< FF > lagrange_coeffs, const std::array< FF, SUBGROUP_SIZE > &interpolation_domain, const EvaluationDomain< FF > &bn_evaluation_domain)
Given a vector of coefficients of a polynomial in the Lagrange basis over , compute its coefficients ...
static constexpr FF subgroup_generator
std::array< FF, SUBGROUP_SIZE > interpolation_domain
void compute_grand_sum_polynomial()
Computes the grand sum polynomial .
static constexpr size_t MASKED_GRAND_SUM_LENGTH
static std::array< Polynomial< FF >, 2 > compute_lagrange_first_and_last(const std::array< FF, SUBGROUP_SIZE > &interpolation_domain, const EvaluationDomain< FF > &bn_evaluation_domain)
Compute monomial coefficients of the first and last Lagrange polynomials over the subgroup .
typename Flavor::Curve Curve
void compute_grand_sum_identity_quotient()
Efficiently compute the quotient of the grand sum identity polynomial by .
Polynomial< FF > grand_sum_polynomial_unmasked
static FF compute_claimed_inner_product(ZKSumcheckData< Flavor > &zk_sumcheck_data, const std::vector< FF > &multivariate_challenge, const size_t &log_circuit_size)
For test purposes: Compute the sum of the Libra constant term and Libra univariates evaluated at Sumc...
const Polynomial< FF > & get_challenge_polynomial() const
static constexpr size_t GRAND_SUM_MASKING_TERM_LENGTH
static constexpr size_t LIBRA_UNIVARIATES_LENGTH
void compute_grand_sum_identity_polynomial()
Compute , where is the fixed generator of .
std::array< Commitment, NUM_SMALL_IPA_COMMITMENTS > witness_commitments
Polynomial< FF > concatenated_lagrange_form
Polynomial< FF > grand_sum_identity_polynomial
Flavor::CommitmentKey commitment_key
std::array< Commitment, NUM_SMALL_IPA_COMMITMENTS > get_witness_commitments() const
Polynomial< FF > challenge_polynomial_lagrange
EvaluationDomain< FF > bn_evaluation_domain
Polynomial< FF > challenge_polynomial
void prove()
Compute the derived witnesses and and commit to them.
static constexpr size_t GRAND_SUM_IDENTITY_LENGTH
Polynomial< FF > grand_sum_polynomial
Polynomial< FF > grand_sum_identity_quotient
static constexpr size_t SUBGROUP_SIZE
FF compute_claimed_translation_inner_product(TranslationData< typename Flavor::Transcript > &translation_data)
Compute the batched evaluation of the last NUM_DISABLED_ROWS_IN_SUMCHECK rows of the ECCVM transcript...
std::array< FF, SUBGROUP_SIZE > grand_sum_lagrange_coeffs
Verifies the consistency of polynomial evaluations provided by the the prover.
static std::array< FF, NUM_BARYCENTRIC_EVALUATIONS > compute_batched_barycentric_evaluations(const std::vector< FF > &coeffs, const FF &r, const FF &vanishing_poly_eval)
Efficient batch evaluation of the challenge polynomial, Lagrange first, and Lagrange last.
typename Curve::ScalarField FF
static bool check_consistency(const std::array< FF, NUM_SMALL_IPA_OPENING_CLAIMS > &small_ipa_evaluations, const FF &small_ipa_eval_challenge, const std::vector< FF > &challenge_polynomial, const FF &inner_product_eval_claim, const FF &vanishing_poly_eval)
Generic consistency check agnostic to challenge polynomial .
static constexpr size_t NUM_BARYCENTRIC_EVALUATIONS
static bool check_libra_evaluations_consistency(const std::array< FF, NUM_SMALL_IPA_OPENING_CLAIMS > &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...
static void handle_edge_cases(const FF &vanishing_poly_eval)
Check if the random evaluation challenge is in the SmallSubgroup.
static constexpr size_t LIBRA_UNIVARIATES_LENGTH
static bool check_eccvm_evaluations_consistency(const std::array< FF, NUM_SMALL_IPA_OPENING_CLAIMS > &small_ipa_evaluations, const FF &evaluation_challenge, const FF &evaluation_challenge_x, const FF &batching_challenge_v, const FF &inner_product_eval_claim)
A method required for the verification Translation Evaluations in the ECCVMVerifier....
static constexpr size_t SUBGROUP_SIZE
A class designed to accept the ECCVM Transcript Polynomials, concatenate their masking terms in Lagra...
static constexpr size_t SUBGROUP_SIZE
static constexpr uint32_t LIBRA_UNIVARIATES_LENGTH
static constexpr bool is_stdlib_type
static constexpr ScalarField subgroup_generator_inverse
typename Group::affine_element AffineElement
static constexpr ScalarField subgroup_generator
Entry point for Barretenberg command-line interface.
constexpr size_t NUM_SMALL_IPA_COMMITMENTS
std::vector< typename Curve::ScalarField > compute_eccvm_challenge_coeffs(const typename Curve::ScalarField &evaluation_challenge_x, const typename Curve::ScalarField &batching_challenge_v, size_t num_polys, size_t num_coeffs_per_poly)
Given num_polys polynomials each contributing num_coeffs_per_poly masking coefficients,...
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
bb::VectorAffineElementPushSpan< BaseParams > out
This structure is created to contain various polynomials and constants required by ZK Sumcheck.
constexpr field invert() const noexcept
static void batch_invert(C &coeffs) noexcept
Batch invert a collection of field elements using Montgomery's trick.
void throw_or_abort(std::string const &err)