73 eval_domain.push_back(
FF(idx));
85 transcript->send_to_verifier(
"Sumcheck:univariate_comm_" + idx,
ck.commit(round_poly_monomial));
88 round_univariates.push_back(
std::move(round_poly_monomial));
91 transcript->send_to_verifier(
"Sumcheck:univariate_" + idx +
"_eval_0", round_univariate.
value_at(0));
92 transcript->send_to_verifier(
"Sumcheck:univariate_" + idx +
"_eval_1", round_univariate.
value_at(1));
95 round_evaluations.push_back({ round_univariate.
value_at(0), round_univariate.
value_at(1),
FF(0) });
97 round_evaluations[round_idx - 1][2] = round_univariate.
value_at(0) + round_univariate.
value_at(1);
103 const FF& last_challenge)
105 round_evaluations[multivariate_d - 1][2] = round_univariate.
evaluate(last_challenge);
133 const std::vector<FF>& ,
134 const std::vector<FF>& )
157 , libra_total_sum(this->
transcript->template receive_from_prover<
FF>(
"Libra:Sum"))
164 std::vector<FF>& multivariate_challenge,
165 const std::vector<FF>& padding_indicator_array)
171 full_honk_purported_value *=
359 const FF& relation_separator,
400 vinfo(
"starting sumcheck rounds...");
410 auto round_univariate =
420 transcript->send_to_verifier(
"Sumcheck:univariate_0", round_univariate);
421 FF round_challenge =
transcript->template get_challenge<FF>(
"Sumcheck:u_0");
431 for (
size_t round_idx = 1; round_idx <
multivariate_d; round_idx++) {
455 for (
size_t i = 0; i < k; i++) {
458 index_1_challenge[k] =
FF(1);
462 auto new_polynomial =
469 auto new_polynomial =
478 index_1_challenge[k] =
FF(0);
482 const auto virtual_round_univariate =
round.compute_virtual_contribution(
493 if (poly.size() > 0) {
494 if (poly.size() == 1) {
495 poly.at(0) *= (
FF(1) - round_challenge);
496 }
else if (poly.size() == 2) {
498 poly.at(0) = poly.at(0) * (
FF(1) - round_challenge) + poly.at(1) * round_challenge;
501 BB_ASSERT_EQ(
true,
false,
"Polynomial size is not 1 or 2");
509 transcript->send_to_verifier(
"Sumcheck:evaluations", multivariate_evaluations.get_all());
513 .claimed_evaluations = multivariate_evaluations };
514 vinfo(
"finished sumcheck");
528 vinfo(
"starting sumcheck rounds...");
535 size_t round_idx = 0;
540 auto round_univariate =
544 auto hiding_univariate =
round.compute_libra_univariate(zk_sumcheck_data, round_idx);
545 round_univariate += hiding_univariate;
549 round_univariate -=
round.compute_disabled_contribution(
560 handler.process_round_univariate(round_idx, round_univariate);
562 const FF round_challenge =
transcript->template get_challenge<FF>(
"Sumcheck:u_0");
568 zk_sumcheck_data.update_zk_sumcheck_data(round_challenge, round_idx);
570 gate_separators.partially_evaluate(round_challenge);
575 for (
size_t round_idx = 1; round_idx <
multivariate_d; round_idx++) {
584 hiding_univariate =
round.compute_libra_univariate(zk_sumcheck_data, round_idx);
586 round_univariate += hiding_univariate;
588 if constexpr (UseRowDisablingPolynomial<Flavor>) {
597 handler.process_round_univariate(round_idx, round_univariate);
599 const FF round_challenge =
605 zk_sumcheck_data.update_zk_sumcheck_data(round_challenge, round_idx);
608 gate_separators.partially_evaluate(round_challenge);
628 transcript->send_to_verifier(
"Sumcheck:evaluations", multivariate_evaluations.get_all());
633 for (
const auto& libra_eval : zk_sumcheck_data.libra_evaluations) {
641 .claimed_evaluations = multivariate_evaluations,
643 .round_univariates = handler.get_univariates(),
644 .round_univariate_evaluations = handler.get_evaluations() };
645 vinfo(
"finished sumcheck");
685 auto poly_view = polynomials.get_all();
688 const auto& poly = poly_view[j];
690 size_t limit = poly.end_index();
691 for (size_t i = 0; i < limit; i += 2) {
692 pep_view[j].at(i >> 1) = poly[i] + round_challenge * (poly[i + 1] - poly[i]);
700 pep_view[j].shrink_end_index((limit / 2) + (limit % 2));
707 template <
typename PolynomialT, std::
size_t N>
710 auto pep_view = partially_evaluated_polynomials.get_all();
713 const auto& poly = polynomials[j];
715 size_t limit = poly.end_index();
716 for (size_t i = 0; i < limit; i += 2) {
717 pep_view[j].at(i >> 1) = poly[i] + round_challenge * (poly[i + 1] - poly[i]);
725 pep_view[j].shrink_end_index((limit / 2) + (limit % 2));
743 for (
auto [eval, poly] :
744 zip_view(multivariate_evaluations.get_all(), partially_evaluated_polynomials.get_all())) {
747 return multivariate_evaluations;
827 size_t virtual_log_n,
829 : transcript(
std::move(transcript))
831 , virtual_log_n(virtual_log_n)
845 const std::vector<FF>& gate_challenges,
846 const std::vector<FF>& padding_indicator_array)
855 std::vector<FF> multivariate_challenge;
856 multivariate_challenge.reserve(virtual_log_n);
863 bool verified =
true;
864 for (
size_t round_idx = 0; round_idx < virtual_log_n; round_idx++) {
866 transcript, multivariate_challenge, gate_separators, padding_indicator_array[round_idx], round_idx);
872 auto transcript_evaluations =
873 transcript->template receive_from_prover<std::array<FF, NUM_POLYNOMIALS>>(
"Sumcheck:evaluations");
874 for (
auto [eval, transcript_eval] :
zip_view(purported_evaluations.get_all(), transcript_evaluations)) {
875 eval = transcript_eval;
881 purported_evaluations, relation_parameters, gate_separators, alphas);
886 full_honk_purported_value, multivariate_challenge, padding_indicator_array);
893 .claimed_evaluations = purported_evaluations,
894 .verified = verified,
905 for (
size_t i = 1; i < N; ++i) {
906 alphas[i] = alphas[i - 1] * alpha;
#define BB_ASSERT_EQ(actual, expected,...)
bb::field< bb::Bn254FrParams > FF
#define BB_BENCH_NAME(name)
A field element for each entity of the flavor. These entities represent the prover polynomials evalua...
A container for storing the partially evaluated multivariates produced by sumcheck.
A container for the prover polynomials.
static constexpr bool HasZK
typename Curve::ScalarField FF
static constexpr size_t NUM_SUBRELATIONS
static constexpr size_t NUM_ALL_ENTITIES
static constexpr size_t MAX_PARTIAL_RELATION_LENGTH
typename G1::affine_element Commitment
bb::CommitmentKey< Curve > CommitmentKey
NativeTranscript Transcript
static constexpr size_t BATCHED_RELATION_PARTIAL_LENGTH
Structured polynomial class that represents the coefficients 'a' of a_0 + a_1 x .....
The implementation of the sumcheck Prover for statements of the form for multilinear polynomials .
static constexpr size_t BATCHED_RELATION_PARTIAL_LENGTH
ProverPolynomials & full_polynomials
const size_t multivariate_n
bb::RelationParameters< FF > relation_parameters
typename Flavor::Transcript Transcript
std::vector< FF > accumulator_challenge
std::vector< FF > instance_challenge
void partially_evaluate(std::array< PolynomialT, N > &polynomials, const FF &round_challenge)
Evaluate at the round challenge and prepare class for next round. Specialization for array,...
static constexpr bool isMultilinearBatchingFlavor
typename Flavor::ProverPolynomials ProverPolynomials
static constexpr size_t MAX_PARTIAL_RELATION_LENGTH
The total algebraic degree of the Sumcheck relation as a polynomial in Prover Polynomials .
std::array< FF, Flavor::NUM_SUBRELATIONS - 1 > SubrelationSeparators
const size_t multivariate_d
ClaimedEvaluations extract_claimed_evaluations(PartiallyEvaluatedMultivariates &partially_evaluated_polynomials)
This method takes the book-keeping table containing partially evaluated prover polynomials and create...
typename Flavor::AllValues ClaimedEvaluations
typename bb::Univariate< FF, BATCHED_RELATION_PARTIAL_LENGTH > SumcheckRoundUnivariate
std::vector< FF > multivariate_challenge
SumcheckOutput< Flavor > prove(ZKData &zk_sumcheck_data) void partially_evaluate(auto &polynomials, const FF &round_challenge)
ZK-version of prove that runs Sumcheck with disabled rows and masking of Round Univariates....
typename Flavor::PartiallyEvaluatedMultivariates PartiallyEvaluatedMultivariates
SumcheckProver(size_t multivariate_n, ProverPolynomials &prover_polynomials, std::shared_ptr< Transcript > transcript, const FF &alpha, const std::vector< FF > &gate_challenges, const RelationParameters< FF > &relation_parameters, const size_t virtual_log_n)
RowDisablingPolynomial< FF > row_disabling_polynomial
typename Flavor::CommitmentKey CommitmentKey
SumcheckProver(size_t multivariate_n, ProverPolynomials &prover_polynomials, std::shared_ptr< Transcript > transcript, const FF &relation_separator, const size_t virtual_log_n, const std::vector< FF > &accumulator_challenge, const std::vector< FF > &instance_challenge)
std::vector< FF > gate_challenges
SumcheckProverRound< Flavor > round
PartiallyEvaluatedMultivariates partially_evaluated_polynomials
Container for partially evaluated Prover Polynomials at a current challenge. Upon computing challenge...
std::shared_ptr< Transcript > transcript
SumcheckOutput< Flavor > prove()
Non-ZK version: Compute round univariate, place it in transcript, compute challenge,...
ZKSumcheckData< Flavor > ZKData
SubrelationSeparators alphas
Imlementation of the Sumcheck prover round.
Implementation of the sumcheck Verifier for statements of the form for multilinear polynomials .
typename std::vector< FF > ClaimedLibraEvaluations
std::array< FF, Flavor::NUM_SUBRELATIONS - 1 > SubrelationSeparators
typename Flavor::Commitment Commitment
SumcheckVerifierRound< Flavor > round
SumcheckVerifier(std::shared_ptr< Transcript > transcript, const FF &alpha, size_t virtual_log_n, FF target_sum=0)
std::shared_ptr< Transcript > transcript
typename Flavor::AllValues ClaimedEvaluations
Container type for the evaluations of Prover Polynomials at the challenge point .
SubrelationSeparators alphas
typename Flavor::Transcript Transcript
SumcheckOutput< Flavor > verify(const bb::RelationParameters< FF > &relation_parameters, const std::vector< FF > &gate_challenges, const std::vector< FF > &padding_indicator_array)
The Sumcheck verification method. First it extracts round univariate, checks sum (the sumcheck univar...
Implementation of the Sumcheck Verifier Round.
std::vector< Commitment > get_round_univariate_commitments()
Get round univariate commitments (only used for Grumpkin flavors).
void process_round(const std::shared_ptr< Transcript > &transcript, std::vector< FF > &multivariate_challenge, bb::GateSeparatorPolynomial< FF > &gate_separators, const FF &padding_indicator, size_t round_idx)
Process a single sumcheck round: receive univariate from transcript, verify sum, generate challenge.
bool perform_final_verification(const FF &full_honk_purported_value)
Perform final verification: check that the computed target sum matches the full relation evaluation....
std::vector< std::array< FF, 3 > > get_round_univariate_evaluations()
Get round univariate evaluations (only used for Grumpkin flavors).
FF compute_full_relation_purported_value(const ClaimedEvaluations &purported_evaluations, const bb::RelationParameters< FF > &relation_parameters, const bb::GateSeparatorPolynomial< FF > &gate_separators, const SubrelationSeparators &alphas)
Compute the full relation purported value.
A univariate polynomial represented by its values on {0, 1,..., domain_end - 1}.
std::array< Fr, LENGTH > evaluations
Fr evaluate(const Fr &u) const
Evaluate a univariate at a point u not known at compile time and assumed not to be in the domain (els...
constexpr T get_msb(const T in)
Entry point for Barretenberg command-line interface.
CommitmentKey< Curve > ck
std::array< FF, N > initialize_relation_separator(const FF &alpha)
void parallel_for(size_t num_iterations, const std::function< void(size_t)> &func)
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
std::string to_string(bb::avm2::ValueTag tag)
Implementation of the methods for the -polynomials used in in Sumcheck.
void partially_evaluate(FF challenge)
Partially evaluate the -polynomial at the new challenge and update .
Container for parameters used by the grand product (permutation, lookup) Honk relations.
std::vector< FF > eval_domain
std::vector< std::array< FF, 3 > > round_evaluations
void process_round_univariate(size_t round_idx, bb::Univariate< FF, BATCHED_RELATION_PARTIAL_LENGTH > &round_univariate)
typename Flavor::CommitmentKey CommitmentKey
std::vector< Polynomial< FF > > round_univariates
void finalize_last_round(size_t multivariate_d, const bb::Univariate< FF, BATCHED_RELATION_PARTIAL_LENGTH > &round_univariate, const FF &last_challenge)
std::vector< Polynomial< FF > > get_univariates()
std::shared_ptr< Transcript > transcript
typename Flavor::Transcript Transcript
std::vector< std::array< FF, 3 > > get_evaluations()
RoundUnivariateHandler(std::shared_ptr< Transcript > transcript)
Handler for processing round univariates in sumcheck. Default implementation: send evaluations direct...
std::vector< Polynomial< FF > > get_univariates()
static constexpr size_t BATCHED_RELATION_PARTIAL_LENGTH
typename Flavor::CommitmentKey CommitmentKey
void process_round_univariate(size_t round_idx, bb::Univariate< FF, BATCHED_RELATION_PARTIAL_LENGTH > &round_univariate)
RoundUnivariateHandler(std::shared_ptr< Transcript > transcript)
std::shared_ptr< Transcript > transcript
std::vector< std::array< FF, 3 > > get_evaluations()
void finalize_last_round(size_t, const bb::Univariate< FF, BATCHED_RELATION_PARTIAL_LENGTH > &, const FF &)
typename Flavor::Transcript Transcript
Polynomial for Sumcheck with disabled Rows.
static FF evaluate_at_challenge(std::vector< FF > multivariate_challenge, const size_t log_circuit_size)
Compute the evaluation of at the sumcheck challenge.
Contains the evaluations of multilinear polynomials at the challenge point . These are computed by S...
std::vector< FF > challenge
static FF eval(std::span< const FF > r_in, std::span< const FF > u)
VerifierZKCorrectionHandler(std::shared_ptr< Transcript > transcript)
FF get_libra_evaluation() const
void initialize_target_sum(SumcheckRound &round)
typename Flavor::Transcript Transcript
std::shared_ptr< Transcript > transcript
void apply_zk_corrections(FF &full_honk_purported_value, std::vector< FF > &multivariate_challenge, const std::vector< FF > &padding_indicator_array)
Handler for ZK-related verification adjustments in sumcheck. Default implementation: no ZK adjustment...
void apply_zk_corrections(FF &, const std::vector< FF > &, const std::vector< FF > &)
typename Flavor::Transcript Transcript
void initialize_target_sum(SumcheckRound &)
FF get_libra_evaluation() const
std::shared_ptr< Transcript > transcript
VerifierZKCorrectionHandler(std::shared_ptr< Transcript > transcript)
This structure is created to contain various polynomials and constants required by ZK Sumcheck.