211 ,
alphas(relation_separator)
248 vinfo(
"starting sumcheck rounds...");
258 auto round_univariate =
268 transcript->send_to_verifier(
"Sumcheck:univariate_0", round_univariate);
269 FF round_challenge =
transcript->template get_challenge<FF>(
"Sumcheck:u_0");
279 for (
size_t round_idx = 1; round_idx <
multivariate_d; round_idx++) {
303 for (
size_t i = 0; i < k; i++) {
306 index_1_challenge[k] =
FF(1);
310 auto new_polynomial =
317 auto new_polynomial =
326 index_1_challenge[k] =
FF(0);
330 const auto virtual_round_univariate =
round.compute_virtual_contribution(
341 if (poly.size() > 0) {
342 if (poly.size() == 1) {
343 poly.at(0) *= (
FF(1) - round_challenge);
344 }
else if (poly.size() == 2) {
346 poly.at(0) = poly.at(0) * (
FF(1) - round_challenge) + poly.at(1) * round_challenge;
349 BB_ASSERT_EQ(
true,
false,
"Polynomial size is not 1 or 2");
357 transcript->send_to_verifier(
"Sumcheck:evaluations", multivariate_evaluations.get_all());
361 .claimed_evaluations = multivariate_evaluations };
362 vinfo(
"finished sumcheck");
386 vinfo(
"starting sumcheck rounds...");
393 size_t round_idx = 0;
396 auto hiding_univariate =
round.compute_hiding_univariate(round_idx,
403 auto round_univariate =
405 round_univariate += hiding_univariate;
414 if constexpr (!IsGrumpkinFlavor<Flavor>) {
416 transcript->send_to_verifier(
"Sumcheck:univariate_0", round_univariate);
424 const FF round_challenge =
transcript->template get_challenge<FF>(
"Sumcheck:u_0");
430 zk_sumcheck_data.update_zk_sumcheck_data(round_challenge, round_idx);
432 gate_separators.partially_evaluate(round_challenge);
437 for (
size_t round_idx = 1; round_idx <
multivariate_d; round_idx++) {
444 hiding_univariate =
round.compute_hiding_univariate(round_idx,
453 round_univariate += hiding_univariate;
455 if constexpr (!IsGrumpkinFlavor<Flavor>) {
464 const FF round_challenge =
470 zk_sumcheck_data.update_zk_sumcheck_data(round_challenge, round_idx);
473 gate_separators.partially_evaluate(round_challenge);
477 if constexpr (IsGrumpkinFlavor<Flavor>) {
495 transcript->send_to_verifier(
"Sumcheck:evaluations", multivariate_evaluations.get_all());
500 for (
const auto& libra_eval : zk_sumcheck_data.libra_evaluations) {
507 if constexpr (!IsGrumpkinFlavor<Flavor>) {
509 .claimed_evaluations = multivariate_evaluations,
513 .claimed_evaluations = multivariate_evaluations,
518 vinfo(
"finished sumcheck");
559 auto poly_view = polynomials.get_all();
562 const auto& poly = poly_view[j];
564 size_t limit = poly.end_index();
565 for (size_t i = 0; i < limit; i += 2) {
566 pep_view[j].at(i >> 1) = poly[i] + round_challenge * (poly[i + 1] - poly[i]);
574 pep_view[j].shrink_end_index((limit / 2) + (limit % 2));
581 template <
typename PolynomialT, std::
size_t N>
584 auto pep_view = partially_evaluated_polynomials.get_all();
587 const auto& poly = polynomials[j];
589 size_t limit = poly.end_index();
590 for (size_t i = 0; i < limit; i += 2) {
591 pep_view[j].at(i >> 1) = poly[i] + round_challenge * (poly[i + 1] - poly[i]);
599 pep_view[j].shrink_end_index((limit / 2) + (limit % 2));
617 for (
auto [eval, poly] :
618 zip_view(multivariate_evaluations.get_all(), partially_evaluated_polynomials.get_all())) {
621 return multivariate_evaluations;
646 transcript->send_to_verifier(
"Sumcheck:univariate_comm_" + idx,
ck.commit(round_poly_monomial));
649 round_univariates.push_back(
std::move(round_poly_monomial));
652 transcript->send_to_verifier(
"Sumcheck:univariate_" + idx +
"_eval_0", round_univariate.
value_at(0));
653 transcript->send_to_verifier(
"Sumcheck:univariate_" + idx +
"_eval_1", round_univariate.
value_at(1));
656 round_evaluations.push_back({ round_univariate.
value_at(0), round_univariate.
value_at(1),
FF(0) });
658 round_evaluations[round_idx - 1][2] = round_univariate.
value_at(0) + round_univariate.
value_at(1);
736 FF libra_evaluation{ 0 };
742 std::vector<Commitment> round_univariate_commitments = {};
747 size_t virtual_log_n,
749 : transcript(
std::move(transcript))
751 , virtual_log_n(virtual_log_n)
752 , alphas(relation_separator) {};
756 size_t virtual_log_n,
758 : transcript(
std::move(transcript))
760 , virtual_log_n(virtual_log_n)
772 std::vector<FF>& gate_challenges,
773 const std::vector<FF>& padding_indicator_array)
787 libra_total_sum = transcript->template receive_from_prover<FF>(
"Libra:Sum");
788 libra_challenge = transcript->template get_challenge<FF>(
"Libra:Challenge");
792 std::vector<FF> multivariate_challenge;
793 multivariate_challenge.reserve(virtual_log_n);
794 for (
size_t round_idx = 0; round_idx < virtual_log_n; round_idx++) {
796 std::string round_univariate_label =
"Sumcheck:univariate_" +
std::to_string(round_idx);
798 transcript->template receive_from_prover<bb::Univariate<FF, BATCHED_RELATION_PARTIAL_LENGTH>>(
799 round_univariate_label);
800 FF round_challenge = transcript->template get_challenge<FF>(
"Sumcheck:u_" +
std::to_string(round_idx));
801 multivariate_challenge.emplace_back(round_challenge);
803 const bool checked = round.
check_sum(round_univariate, padding_indicator_array[round_idx]);
805 gate_separators.
partially_evaluate(round_challenge, padding_indicator_array[round_idx]);
807 verified = verified && checked;
812 auto transcript_evaluations =
813 transcript->template receive_from_prover<std::array<FF, NUM_POLYNOMIALS>>(
"Sumcheck:evaluations");
814 for (
auto [eval, transcript_eval] :
zip_view(purported_evaluations.get_all(), transcript_evaluations)) {
815 eval = transcript_eval;
821 purported_evaluations, relation_parameters, gate_separators, alphas);
829 full_honk_purported_value *=
833 libra_evaluation = transcript->template receive_from_prover<FF>(
"Libra:claimed_evaluation");
834 full_honk_purported_value += libra_evaluation * libra_challenge;
838 bool final_check(
false);
841 final_check = (full_honk_purported_value.get_value() == round.
target_total_sum.get_value());
842 verified = verified && final_check;
847 verified = verified && final_check;
851 .claimed_evaluations = purported_evaluations,
852 .verified = verified,
853 .claimed_libra_evaluation = libra_evaluation };
872 const std::vector<FF>& gate_challenges)
875 bool verified(
false);
880 libra_total_sum = transcript->template receive_from_prover<FF>(
"Libra:Sum");
882 const FF libra_challenge = transcript->template get_challenge<FF>(
"Libra:Challenge");
884 std::vector<FF> multivariate_challenge;
885 multivariate_challenge.reserve(virtual_log_n);
890 for (
size_t round_idx = 0; round_idx < virtual_log_n; round_idx++) {
892 const std::string round_univariate_comm_label =
"Sumcheck:univariate_comm_" +
std::to_string(round_idx);
893 const std::string univariate_eval_label_0 =
"Sumcheck:univariate_" +
std::to_string(round_idx) +
"_eval_0";
894 const std::string univariate_eval_label_1 =
"Sumcheck:univariate_" +
std::to_string(round_idx) +
"_eval_1";
897 round_univariate_commitments.push_back(
898 transcript->template receive_from_prover<Commitment>(round_univariate_comm_label));
900 round_univariate_evaluations.push_back(
901 { transcript->template receive_from_prover<FF>(univariate_eval_label_0),
902 transcript->template receive_from_prover<FF>(univariate_eval_label_1) });
904 const FF round_challenge =
905 transcript->template get_challenge<FF>(
"Sumcheck:u_" +
std::to_string(round_idx));
906 multivariate_challenge.emplace_back(round_challenge);
911 FF first_sumcheck_round_evaluations_sum =
912 round_univariate_evaluations[0][0] + round_univariate_evaluations[0][1];
916 auto transcript_evaluations =
917 transcript->template receive_from_prover<std::array<FF, NUM_POLYNOMIALS>>(
"Sumcheck:evaluations");
918 for (
auto [eval, transcript_eval] :
zip_view(purported_evaluations.get_all(), transcript_evaluations)) {
919 eval = transcript_eval;
925 purported_evaluations, relation_parameters, gate_separators, alphas);
929 full_honk_purported_value *=
933 const FF libra_evaluation = transcript->template receive_from_prover<FF>(
"Libra:claimed_evaluation");
936 full_honk_purported_value += libra_evaluation * libra_challenge;
940 for (
size_t round_idx = 1; round_idx < virtual_log_n; round_idx++) {
941 round_univariate_evaluations[round_idx - 1][2] =
942 round_univariate_evaluations[round_idx][0] + round_univariate_evaluations[round_idx][1];
947 first_sumcheck_round_evaluations_sum.self_reduce();
951 verified = (first_sumcheck_round_evaluations_sum.get_value() == round.
target_total_sum.get_value());
957 full_honk_purported_value.self_reduce();
962 verified = (first_sumcheck_round_evaluations_sum == round.
target_total_sum);
965 round_univariate_evaluations[virtual_log_n - 1][2] = full_honk_purported_value;
970 .claimed_evaluations = purported_evaluations,
971 .verified = verified,
972 .claimed_libra_evaluation = libra_evaluation,
973 .round_univariate_commitments = round_univariate_commitments,
974 .round_univariate_evaluations = round_univariate_evaluations };
982 for (
size_t i = 1; i < N; ++i) {
983 alphas[i] = alphas[i - 1] * alpha;
#define BB_ASSERT_EQ(actual, expected,...)
#define BB_BENCH_NAME(name)
CommitmentKey object over a pairing group 𝔾₁.
static constexpr bool HasZK
typename Curve::ScalarField FF
static constexpr size_t NUM_ALL_ENTITIES
typename G1::affine_element Commitment
NativeTranscript Transcript
static constexpr size_t BATCHED_RELATION_PARTIAL_LENGTH
std::array< FF, NUM_SUBRELATIONS - 1 > SubrelationSeparators
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 handles.
bb::CommitmentKey< Curve > CommitmentKey
std::array< FF, NUM_SUBRELATIONS - 1 > SubrelationSeparators
NativeTranscript Transcript
static constexpr bool HasZK
static constexpr size_t MAX_PARTIAL_RELATION_LENGTH
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
std::vector< Polynomial< FF > > round_univariates
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
std::vector< std::array< FF, 3 > > round_evaluations
std::vector< typename Flavor::Commitment > round_univariate_commitments
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 .
void commit_to_round_univariate(const size_t round_idx, bb::Univariate< FF, BATCHED_RELATION_PARTIAL_LENGTH > &round_univariate, const CommitmentKey &ck)
Compute monomial coefficients of the round univariate, commit to it, populate an auxiliary structure ...
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 > eval_domain
SumcheckProver(size_t multivariate_n, ProverPolynomials &prover_polynomials, std::shared_ptr< Transcript > transcript, const SubrelationSeparators &relation_separator, const std::vector< FF > &gate_challenges, const RelationParameters< FF > &relation_parameters, const size_t virtual_log_n, const std::vector< FF > &accumulator_challenge={}, const std::vector< FF > &instance_challenge={})
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, const std::vector< FF > &accumulator_challenge={}, const std::vector< FF > &instance_challenge={})
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
RowDisablingPolynomial< FF > row_disabling_polynomial
typename Flavor::CommitmentKey CommitmentKey
std::vector< FF > gate_challenges
SumcheckProverRound< Flavor > round
typename Flavor::SubrelationSeparators SubrelationSeparators
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 .
SumcheckOutput< Flavor > verify(const bb::RelationParameters< FF > &relation_parameters, std::vector< FF > &gate_challenges, const std::vector< FF > &padding_indicator_array)
Extract round univariate, check sum, generate challenge, compute next target sum.....
typename std::vector< FF > ClaimedLibraEvaluations
SumcheckVerifier(std::shared_ptr< Transcript > transcript, SubrelationSeparators &relation_separator, size_t virtual_log_n, FF target_sum=0)
SumcheckOutput< Flavor > verify(const bb::RelationParameters< FF > &relation_parameters, const std::vector< FF > &gate_challenges)
Sumcheck Verifier for ECCVM and ECCVMRecursive.
typename Flavor::Commitment Commitment
SumcheckVerifierRound< Flavor > round
typename Flavor::SubrelationSeparators SubrelationSeparators
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.
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)
Given the evaluations of the ProverPolynomials at the challenge point stored in purported_evaluatio...
void compute_next_target_sum(bb::Univariate< FF, BATCHED_RELATION_PARTIAL_LENGTH > &univariate, FF &round_challenge, const FF &indicator)
After checking that the univariate is good for this round, compute the next target sum given by the e...
bool check_sum(bb::Univariate< FF, BATCHED_RELATION_PARTIAL_LENGTH > &univariate, const FF &indicator)
Check that the round target sum is correct.
A univariate polynomial represented by its values on {domain_start, domain_start + 1,...
std::array< Fr, LENGTH > evaluations
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.
Polynomial for Sumcheck with disabled Rows.
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)
This structure is created to contain various polynomials and constants required by ZK Sumcheck.