74 eval_domain.push_back(
FF(idx));
86 transcript->send_to_verifier(
"Sumcheck:univariate_comm_" + idx,
ck.commit(round_poly_monomial));
89 round_univariates.push_back(
std::move(round_poly_monomial));
92 transcript->send_to_verifier(
"Sumcheck:univariate_" + idx +
"_eval_0", round_univariate.
value_at(0));
93 transcript->send_to_verifier(
"Sumcheck:univariate_" + idx +
"_eval_1", round_univariate.
value_at(1));
96 round_evaluations.push_back({ round_univariate.
value_at(0), round_univariate.
value_at(1),
FF(0) });
98 round_evaluations[round_idx - 1][2] = round_univariate.
value_at(0) + round_univariate.
value_at(1);
104 const FF& last_challenge)
106 round_evaluations[multivariate_d - 1][2] = round_univariate.
evaluate(last_challenge);
134 const std::vector<FF>& ,
135 const std::vector<FF>& )
158 , libra_total_sum(this->
transcript->template receive_from_prover<
FF>(
"Libra:Sum"))
165 std::vector<FF>& multivariate_challenge,
166 const std::vector<FF>& padding_indicator_array)
172 full_honk_purported_value *=
182 const auto challenge_tag = multivariate_challenge.back().get_origin_tag();
357 const FF& relation_separator,
398 vinfo(
"starting sumcheck rounds...");
408 auto round_univariate =
412 transcript->send_to_verifier(
"Sumcheck:univariate_0", round_univariate);
413 FF round_challenge =
transcript->template get_challenge<FF>(
"Sumcheck:u_0");
422 for (
size_t round_idx = 1; round_idx <
multivariate_d; round_idx++) {
446 for (
size_t i = 0; i < k; i++) {
449 index_1_challenge[k] =
FF(1);
450 if (partially_evaluated_polynomials.eq_accumulator.size() == 1) {
453 auto new_polynomial =
454 Polynomial<FF>(2, partially_evaluated_polynomials.eq_accumulator.virtual_size());
455 new_polynomial.at(0) = partially_evaluated_polynomials.eq_accumulator.at(0);
456 partially_evaluated_polynomials.eq_accumulator = new_polynomial;
458 if (partially_evaluated_polynomials.eq_instance.size() == 1) {
460 auto new_polynomial =
Polynomial<FF>(2, partially_evaluated_polynomials.eq_instance.virtual_size());
461 new_polynomial.at(0) = partially_evaluated_polynomials.eq_instance.at(0);
462 partially_evaluated_polynomials.eq_instance = new_polynomial;
464 partially_evaluated_polynomials.eq_accumulator.at(1) =
466 partially_evaluated_polynomials.eq_instance.at(1) =
468 index_1_challenge[k] =
FF(0);
472 const auto virtual_round_univariate =
round.compute_virtual_contribution(
481 for (
auto& poly : partially_evaluated_polynomials.get_all()) {
483 if (poly.size() > 0) {
484 if (poly.size() == 1) {
485 poly.at(0) *= (
FF(1) - round_challenge);
486 }
else if (poly.size() == 2) {
488 poly.at(0) = poly.at(0) * (
FF(1) - round_challenge) + poly.at(1) * round_challenge;
491 BB_ASSERT_EQ(
true,
false,
"Polynomial size is not 1 or 2");
499 transcript->send_to_verifier(
"Sumcheck:evaluations", multivariate_evaluations.get_all());
503 .claimed_evaluations = multivariate_evaluations };
504 vinfo(
"finished sumcheck");
518 vinfo(
"starting sumcheck rounds...");
525 size_t round_idx = 0;
530 auto round_univariate =
534 auto hiding_univariate =
round.compute_libra_univariate(zk_sumcheck_data, round_idx);
535 round_univariate += hiding_univariate;
539 round_univariate -=
round.compute_disabled_contribution(
543 handler.process_round_univariate(round_idx, round_univariate);
544 const FF round_challenge =
transcript->template get_challenge<FF>(
"Sumcheck:u_0");
552 zk_sumcheck_data.update_zk_sumcheck_data(round_challenge, round_idx);
554 gate_separators.partially_evaluate(round_challenge);
556 for (
size_t round_idx = 1; round_idx <
multivariate_d; round_idx++) {
565 hiding_univariate =
round.compute_libra_univariate(zk_sumcheck_data, round_idx);
567 round_univariate += hiding_univariate;
569 if constexpr (UseRowDisablingPolynomial<Flavor>) {
570 round_univariate -=
round.compute_disabled_contribution(partially_evaluated_polynomials,
578 handler.process_round_univariate(round_idx, round_univariate);
580 const FF round_challenge =
586 if constexpr (IsTranslatorFlavor<Flavor>) {
587 if (round_idx == Flavor::LOG_MINI_CIRCUIT_SIZE - 1) {
590 transcript->send_to_verifier(
"Sumcheck:minicircuit_evaluations",
591 Flavor::get_minicircuit_evaluations(partially_evaluated_polynomials));
596 zk_sumcheck_data.update_zk_sumcheck_data(round_challenge, round_idx);
599 gate_separators.partially_evaluate(round_challenge);
621 if constexpr (IsTranslatorFlavor<Flavor>) {
622 transcript->send_to_verifier(
"Sumcheck:evaluations",
623 Flavor::get_full_circuit_evaluations(multivariate_evaluations));
625 transcript->send_to_verifier(
"Sumcheck:evaluations", multivariate_evaluations.get_all());
631 for (
const auto& libra_eval : zk_sumcheck_data.libra_evaluations) {
639 .claimed_evaluations = multivariate_evaluations,
641 .round_univariates = handler.get_univariates(),
642 .round_univariate_evaluations = handler.get_evaluations() };
643 vinfo(
"finished sumcheck");
653 const FF& round_challenge)
655 auto source_view = source_polynomials.get_all();
656 auto dest_view = dest_polynomials.get_all();
658 const auto& poly = source_view[j];
659 size_t limit = poly.end_index();
660 for (size_t i = 0; i < limit; i += 2) {
661 dest_view[j].at(i >> 1) = poly[i] + round_challenge * (poly[i + 1] - poly[i]);
663 dest_view[j].shrink_end_index((limit / 2) + (limit % 2));
674 const FF& round_challenge)
677 partially_evaluate(full_polynomials, partially_evaluated_polynomials, round_challenge);
678 return partially_evaluated_polynomials;
686 partially_evaluate(polynomials, polynomials, round_challenge);
703 for (
auto [eval, poly] :
704 zip_view(multivariate_evaluations.get_all(), partially_evaluated_polynomials.get_all())) {
707 return multivariate_evaluations;
786 size_t virtual_log_n,
788 : transcript(
std::move(transcript))
790 , virtual_log_n(virtual_log_n)
804 const std::vector<FF>& gate_challenges,
805 const std::vector<FF>& padding_indicator_array)
814 std::vector<FF> multivariate_challenge;
815 multivariate_challenge.reserve(virtual_log_n);
822 bool verified =
true;
824 for (
size_t round_idx = 0; round_idx < virtual_log_n; round_idx++) {
826 transcript, multivariate_challenge, gate_separators, padding_indicator_array[round_idx], round_idx);
830 if (round_idx == Flavor::LOG_MINI_CIRCUIT_SIZE - 1) {
833 Flavor::set_minicircuit_evaluations(
834 purported_evaluations,
836 "Sumcheck:minicircuit_evaluations"));
845 auto get_full_circuit_evaluations =
846 transcript->template receive_from_prover<std::array<FF, Flavor::NUM_FULL_CIRCUIT_EVALUATIONS>>(
847 "Sumcheck:evaluations");
848 Flavor::complete_full_circuit_evaluations(
849 purported_evaluations, get_full_circuit_evaluations,
std::span<const FF>(multivariate_challenge));
851 auto transcript_evaluations =
852 transcript->template receive_from_prover<std::array<FF, NUM_POLYNOMIALS>>(
"Sumcheck:evaluations");
853 for (
auto [eval, transcript_eval] :
zip_view(purported_evaluations.get_all(), transcript_evaluations)) {
854 eval = transcript_eval;
861 const auto challenge_tag = multivariate_challenge.back().get_origin_tag();
862 for (
auto& eval : purported_evaluations.get_all()) {
863 eval.set_origin_tag(challenge_tag);
870 purported_evaluations, relation_parameters, gate_separators, alphas);
875 full_honk_purported_value, multivariate_challenge, padding_indicator_array);
882 .claimed_evaluations = purported_evaluations,
883 .verified = verified,
894 for (
size_t i = 1; i < N; ++i) {
895 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 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
PartiallyEvaluatedMultivariatesBase< AllEntities< Polynomial >, ProverPolynomials, Polynomial > PartiallyEvaluatedMultivariates
A container for storing the partially evaluated multivariates produced by sumcheck.
bb::CommitmentKey< Curve > CommitmentKey
static constexpr size_t BATCHED_RELATION_PARTIAL_LENGTH
BaseTranscript< Codec, HashFunction > Transcript
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 .
SumcheckOutput< Flavor > static prove(ZKData &zk_sumcheck_data) void partially_evaluate(auto &source_polynomials, PartiallyEvaluatedMultivariates &dest_polynomials, const FF &round_challenge)
ZK-version of prove that runs Sumcheck with disabled rows and masking of Round Univariates....
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
PartiallyEvaluatedMultivariates partially_evaluate_first_round(ProverPolynomials &full_polynomials, const FF &round_challenge)
Initialize partially evaluated polynomials and perform first round of partial evaluation.
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
static void partially_evaluate_in_place(PartiallyEvaluatedMultivariates &polynomials, const FF &round_challenge)
Evaluate at the round challenge in-place.
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
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
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.