76 eval_domain.push_back(
FF(idx));
88 transcript->send_to_verifier(
"Sumcheck:univariate_comm_" + idx,
ck.commit(round_poly_monomial));
91 round_univariates.push_back(
std::move(round_poly_monomial));
94 transcript->send_to_verifier(
"Sumcheck:univariate_" + idx +
"_eval_0", round_univariate.
value_at(0));
95 transcript->send_to_verifier(
"Sumcheck:univariate_" + idx +
"_eval_1", round_univariate.
value_at(1));
98 round_evaluations.push_back({ round_univariate.
value_at(0), round_univariate.
value_at(1),
FF(0) });
100 round_evaluations[round_idx - 1][2] = round_univariate.
value_at(0) + round_univariate.
value_at(1);
106 const FF& last_challenge)
108 round_evaluations[multivariate_d - 1][2] = round_univariate.
evaluate(last_challenge);
157 , libra_total_sum(this->
transcript->template receive_from_prover<
FF>(
"Libra:Sum"))
169 multivariate_challenge, multivariate_challenge.size());
178 const auto challenge_tag = multivariate_challenge.back().get_origin_tag();
353 const FF& relation_separator,
394 vinfo(
"starting sumcheck rounds...");
406 auto round_univariate =
410 transcript->send_to_verifier(
"Sumcheck:univariate_0", round_univariate);
411 FF round_challenge =
transcript->template get_challenge<FF>(
"Sumcheck:u_0");
420 for (
size_t round_idx = 1; round_idx <
multivariate_d; round_idx++) {
424 auto round_univariate =
444 for (
size_t i = 0; i < k; i++) {
447 index_1_challenge[k] =
FF(1);
448 if (partially_evaluated_polynomials.eq_accumulator.size() == 1) {
451 auto new_polynomial =
452 Polynomial<FF>(2, partially_evaluated_polynomials.eq_accumulator.virtual_size());
453 new_polynomial.at(0) = partially_evaluated_polynomials.eq_accumulator.at(0);
454 partially_evaluated_polynomials.eq_accumulator = new_polynomial;
456 if (partially_evaluated_polynomials.eq_instance.size() == 1) {
458 auto new_polynomial =
Polynomial<FF>(2, partially_evaluated_polynomials.eq_instance.virtual_size());
459 new_polynomial.at(0) = partially_evaluated_polynomials.eq_instance.at(0);
460 partially_evaluated_polynomials.eq_instance = new_polynomial;
462 partially_evaluated_polynomials.eq_accumulator.at(1) =
464 partially_evaluated_polynomials.eq_instance.at(1) =
466 index_1_challenge[k] =
FF(0);
470 const auto virtual_round_univariate =
round.compute_virtual_contribution(
479 for (
auto& poly : partially_evaluated_polynomials.get_all()) {
481 if (poly.size() > 0) {
482 if (poly.size() == 1) {
483 poly.at(0) *= (
FF(1) - round_challenge);
484 }
else if (poly.size() == 2) {
486 poly.at(0) = poly.at(0) * (
FF(1) - round_challenge) + poly.at(1) * round_challenge;
489 BB_ASSERT_EQ(
true,
false,
"Polynomial size is not 1 or 2");
497 transcript->send_to_verifier(
"Sumcheck:evaluations", multivariate_evaluations.get_all());
500 vinfo(
"finished sumcheck");
502 .claimed_evaluations = multivariate_evaluations };
516 vinfo(
"starting sumcheck rounds...");
523 size_t round_idx = 0;
529 auto round_univariate =
533 auto hiding_univariate =
round.compute_libra_univariate(zk_sumcheck_data, round_idx);
534 round_univariate += hiding_univariate;
538 round_univariate +=
round.compute_disabled_contribution(
542 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 if constexpr (UseRowDisablingPolynomial<Flavor>) {
557 round.excluded_head_size = 2;
559 for (
size_t round_idx = 1; round_idx <
multivariate_d; round_idx++) {
568 hiding_univariate =
round.compute_libra_univariate(zk_sumcheck_data, round_idx);
570 round_univariate += hiding_univariate;
572 if constexpr (UseRowDisablingPolynomial<Flavor>) {
573 round_univariate +=
round.compute_disabled_contribution(partially_evaluated_polynomials,
580 handler.process_round_univariate(round_idx, round_univariate);
582 const FF round_challenge =
589 if constexpr (IsTranslatorFlavor<Flavor>) {
590 if (round_idx == Flavor::LOG_MINI_CIRCUIT_SIZE - 1) {
593 transcript->send_to_verifier(
"Sumcheck:minicircuit_evaluations",
594 Flavor::get_minicircuit_evaluations(partially_evaluated_polynomials));
599 zk_sumcheck_data.update_zk_sumcheck_data(round_challenge, round_idx);
602 gate_separators.partially_evaluate(round_challenge);
618 partially_evaluated_polynomials,
620 virtual_gate_separator,
624 hiding_univariate =
round.compute_libra_univariate(zk_sumcheck_data, idx);
625 round_univariate += hiding_univariate;
627 handler.process_round_univariate(idx, round_univariate);
632 zk_sumcheck_data.update_zk_sumcheck_data(round_challenge, idx);
634 virtual_gate_separator.partially_evaluate(round_challenge);
641 if constexpr (IsTranslatorFlavor<Flavor>) {
642 transcript->send_to_verifier(
"Sumcheck:evaluations",
643 Flavor::get_full_circuit_evaluations(multivariate_evaluations));
645 transcript->send_to_verifier(
"Sumcheck:evaluations", multivariate_evaluations.get_all());
650 for (
const auto& libra_eval : zk_sumcheck_data.libra_evaluations) {
657 vinfo(
"finished sumcheck");
659 .claimed_evaluations = multivariate_evaluations,
661 .round_univariates = handler.get_univariates(),
662 .round_univariate_evaluations = handler.get_evaluations() };
672 const FF& round_challenge)
674 auto source_view = source_polynomials.get_all();
675 auto dest_view = dest_polynomials.get_all();
677 BB_BENCH_TRACY_NAME(
"Sumcheck::partially_evaluate");
678 const auto& poly = source_view[j];
679 size_t limit = poly.end_index();
680 for (size_t i = 0; i < limit; i += 2) {
681 dest_view[j].at(i >> 1) = poly[i] + round_challenge * (poly[i + 1] - poly[i]);
683 dest_view[j].shrink_end_index((limit / 2) + (limit % 2));
694 const FF& round_challenge)
697 partially_evaluate(full_polynomials, partially_evaluated_polynomials, round_challenge);
698 return partially_evaluated_polynomials;
706 partially_evaluate(polynomials, polynomials, round_challenge);
723 for (
auto [eval, poly] :
724 zip_view(multivariate_evaluations.get_all(), partially_evaluated_polynomials.get_all())) {
727 return multivariate_evaluations;
736 template <
typename PartialEvals,
typename Alphas>
739 PartialEvals& partially_evaluated_polynomials,
742 const Alphas& alphas,
746 partially_evaluated_polynomials, relation_parameters, gate_separator, alphas);
750 univariate *= one_minus_L.template extend_to<Flavor::BATCHED_RELATION_PARTIAL_LENGTH>();
760 for (
auto& poly : pe.get_all()) {
761 if (poly.end_index() > 0) {
762 poly.at(0) *= (
FF(1) - round_challenge);
843 size_t virtual_log_n,
845 : transcript(
std::move(transcript))
847 , virtual_log_n(virtual_log_n)
860 const std::vector<FF>& gate_challenges)
869 std::vector<FF> multivariate_challenge;
870 multivariate_challenge.reserve(virtual_log_n);
877 bool verified =
true;
883 for (
size_t round_idx = 0; round_idx < virtual_log_n; round_idx++) {
884 round.
process_round(transcript, multivariate_challenge, gate_separators, round_idx);
888 if (round_idx == Flavor::LOG_MINI_CIRCUIT_SIZE - 1) {
891 Flavor::set_minicircuit_evaluations(
892 purported_evaluations,
894 "Sumcheck:minicircuit_evaluations"));
904 transcript->template receive_from_prover<std::array<FF, Flavor::NUM_FULL_CIRCUIT_EVALUATIONS>>(
905 "Sumcheck:evaluations"));
906 Flavor::complete_full_circuit_evaluations(
907 purported_evaluations, *get_full_circuit_evaluations,
std::span<const FF>(multivariate_challenge));
911 transcript->template receive_from_prover<std::array<FF, NUM_POLYNOMIALS>>(
"Sumcheck:evaluations"));
912 for (
auto [eval, transcript_eval] :
zip_view(purported_evaluations.get_all(), *transcript_evaluations)) {
913 eval = transcript_eval;
920 const auto challenge_tag = multivariate_challenge.back().get_origin_tag();
921 for (
auto& eval : purported_evaluations.get_all()) {
922 eval.set_origin_tag(challenge_tag);
929 purported_evaluations, relation_parameters, gate_separators, alphas);
937 verified = final_check && verified;
941 .claimed_evaluations =
std::move(purported_evaluations),
942 .verified = verified,
953 for (
size_t i = 1; i < N; ++i) {
954 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
static void fold_for_zero_extension(PartiallyEvaluatedMultivariates &pe, const FF &round_challenge)
Fold partially-evaluated polynomials for zero-extension: PE[0] *= (1 - u_k).
std::vector< FF > multivariate_challenge
static bb::Univariate< FF, Flavor::BATCHED_RELATION_PARTIAL_LENGTH > compute_virtual_round_univariate(SumcheckProverRound< Flavor > &round, PartialEvals &partially_evaluated_polynomials, const RelationParameters< FF > &relation_parameters, GateSeparatorPolynomial< FF > &gate_separator, const Alphas &alphas, RowDisablingPolynomial< FF > &row_disabling_polynomial)
Compute the virtual round univariate with the row-disabling polynomial factor applied.
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.
SumcheckRoundUnivariate compute_virtual_contribution(ProverPolynomialsOrPartiallyEvaluatedMultivariates &polynomials, const bb::RelationParameters< FF > &relation_parameters, const GateSeparatorPolynomial< FF > &gate_separator, const SubrelationSeparators &alphas)
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
SumcheckOutput< Flavor > verify(const bb::RelationParameters< FF > &relation_parameters, const std::vector< FF > &gate_challenges)
The Sumcheck verification method. First it extracts round univariate, checks sum (the sumcheck univar...
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
Implementation of the Sumcheck Verifier Round.
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.
void process_round(const std::shared_ptr< Transcript > &transcript, std::vector< FF > &multivariate_challenge, bb::GateSeparatorPolynomial< FF > &gate_separators, size_t round_idx)
Process a single sumcheck round: receive univariate from transcript, verify sum, generate challenge.
std::vector< Commitment > get_round_univariate_commitments()
Get round univariate commitments (only used for Grumpkin flavors).
bool perform_final_verification(const FF &full_honk_purported_value)
Perform final verification: check that the computed target sum matches the full relation evaluation....
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...
static constexpr size_t BATCHED_RELATION_PARTIAL_LENGTH
typename Flavor::Transcript Transcript
void finalize_last_round(size_t, const bb::Univariate< FF, BATCHED_RELATION_PARTIAL_LENGTH > &, const FF &)
void process_round_univariate(size_t round_idx, bb::Univariate< FF, BATCHED_RELATION_PARTIAL_LENGTH > &round_univariate)
std::shared_ptr< Transcript > transcript
typename Flavor::CommitmentKey CommitmentKey
std::vector< Polynomial< FF > > get_univariates()
RoundUnivariateHandler(std::shared_ptr< Transcript > transcript)
std::vector< std::array< FF, 3 > > get_evaluations()
Polynomial for Sumcheck with disabled Rows.
static FF evaluate_at_challenge(std::span< const 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)
void apply_zk_corrections(FF &full_honk_purported_value, std::vector< FF > &multivariate_challenge)
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
Handler for ZK-related verification adjustments in sumcheck. Default implementation: no ZK adjustment...
void apply_zk_corrections(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.
static constexpr field one()