202 ,
alphas(relation_separator)
241 auto round_univariate =
247 vinfo(
"starting sumcheck rounds...");
252 transcript->send_to_verifier(
"Sumcheck:univariate_0", round_univariate);
253 FF round_challenge =
transcript->template get_challenge<FF>(
"Sumcheck:u_0");
262 for (
size_t round_idx = 1; round_idx <
multivariate_d; round_idx++) {
285 const auto virtual_round_univariate =
round.compute_virtual_contribution(
296 if (poly.size() > 0) {
297 poly.at(0) *= (
FF(1) - round_challenge);
304 transcript->send_to_verifier(
"Sumcheck:evaluations", multivariate_evaluations.get_all());
308 .claimed_evaluations = multivariate_evaluations };
309 vinfo(
"finished sumcheck");
333 vinfo(
"starting sumcheck rounds...");
340 size_t round_idx = 0;
343 auto hiding_univariate =
round.compute_hiding_univariate(round_idx,
350 auto round_univariate =
352 round_univariate += hiding_univariate;
361 if constexpr (!IsGrumpkinFlavor<Flavor>) {
363 transcript->send_to_verifier(
"Sumcheck:univariate_0", round_univariate);
371 const FF round_challenge =
transcript->template get_challenge<FF>(
"Sumcheck:u_0");
377 zk_sumcheck_data.update_zk_sumcheck_data(round_challenge, round_idx);
379 gate_separators.partially_evaluate(round_challenge);
384 for (
size_t round_idx = 1; round_idx <
multivariate_d; round_idx++) {
391 hiding_univariate =
round.compute_hiding_univariate(round_idx,
400 round_univariate += hiding_univariate;
402 if constexpr (!IsGrumpkinFlavor<Flavor>) {
411 const FF round_challenge =
417 zk_sumcheck_data.update_zk_sumcheck_data(round_challenge, round_idx);
420 gate_separators.partially_evaluate(round_challenge);
424 if constexpr (IsGrumpkinFlavor<Flavor>) {
442 transcript->send_to_verifier(
"Sumcheck:evaluations", multivariate_evaluations.get_all());
447 for (
const auto& libra_eval : zk_sumcheck_data.libra_evaluations) {
454 if constexpr (!IsGrumpkinFlavor<Flavor>) {
456 .claimed_evaluations = multivariate_evaluations,
460 .claimed_evaluations = multivariate_evaluations,
465 vinfo(
"finished sumcheck");
506 auto poly_view = polynomials.get_all();
509 const auto& poly = poly_view[j];
511 size_t limit = poly.end_index();
512 for (size_t i = 0; i < limit; i += 2) {
513 pep_view[j].at(i >> 1) = poly[i] + round_challenge * (poly[i + 1] - poly[i]);
521 pep_view[j].shrink_end_index(limit / 2 + limit % 2);
528 template <
typename PolynomialT, std::
size_t N>
531 auto pep_view = partially_evaluated_polynomials.get_all();
534 const auto& poly = polynomials[j];
536 size_t limit = poly.end_index();
537 for (size_t i = 0; i < limit; i += 2) {
538 pep_view[j].at(i >> 1) = poly[i] + round_challenge * (poly[i + 1] - poly[i]);
546 pep_view[j].shrink_end_index(limit / 2 + limit % 2);
564 for (
auto [eval, poly] :
565 zip_view(multivariate_evaluations.get_all(), partially_evaluated_polynomials.get_all())) {
568 return multivariate_evaluations;
593 transcript->send_to_verifier(
"Sumcheck:univariate_comm_" + idx,
ck.commit(round_poly_monomial));
596 round_univariates.push_back(
std::move(round_poly_monomial));
599 transcript->send_to_verifier(
"Sumcheck:univariate_" + idx +
"_eval_0", round_univariate.
value_at(0));
600 transcript->send_to_verifier(
"Sumcheck:univariate_" + idx +
"_eval_1", round_univariate.
value_at(1));
603 round_evaluations.push_back({ round_univariate.
value_at(0), round_univariate.
value_at(1),
FF(0) });
605 round_evaluations[round_idx - 1][2] = round_univariate.
value_at(0) + round_univariate.
value_at(1);
683 FF libra_evaluation{ 0 };
689 std::vector<Commitment> round_univariate_commitments = {};
694 size_t virtual_log_n,
696 : transcript(
std::move(transcript))
698 , virtual_log_n(virtual_log_n)
699 , alphas(relation_separator) {};
703 size_t virtual_log_n,
705 : transcript(
std::move(transcript))
707 , virtual_log_n(virtual_log_n)
719 std::vector<FF>& gate_challenges,
720 const std::vector<FF>& padding_indicator_array)
734 libra_total_sum = transcript->template receive_from_prover<FF>(
"Libra:Sum");
735 libra_challenge = transcript->template get_challenge<FF>(
"Libra:Challenge");
739 std::vector<FF> multivariate_challenge;
740 multivariate_challenge.reserve(virtual_log_n);
741 for (
size_t round_idx = 0; round_idx < virtual_log_n; round_idx++) {
743 std::string round_univariate_label =
"Sumcheck:univariate_" +
std::to_string(round_idx);
745 transcript->template receive_from_prover<bb::Univariate<FF, BATCHED_RELATION_PARTIAL_LENGTH>>(
746 round_univariate_label);
747 FF round_challenge = transcript->template get_challenge<FF>(
"Sumcheck:u_" +
std::to_string(round_idx));
748 multivariate_challenge.emplace_back(round_challenge);
750 const bool checked = round.
check_sum(round_univariate, padding_indicator_array[round_idx]);
752 gate_separators.
partially_evaluate(round_challenge, padding_indicator_array[round_idx]);
754 verified = verified && checked;
759 auto transcript_evaluations =
760 transcript->template receive_from_prover<std::array<FF, NUM_POLYNOMIALS>>(
"Sumcheck:evaluations");
761 for (
auto [eval, transcript_eval] :
zip_view(purported_evaluations.get_all(), transcript_evaluations)) {
762 eval = transcript_eval;
768 purported_evaluations, relation_parameters, gate_separators, alphas);
776 full_honk_purported_value *=
780 libra_evaluation = transcript->template receive_from_prover<FF>(
"Libra:claimed_evaluation");
781 full_honk_purported_value += libra_evaluation * libra_challenge;
785 bool final_check(
false);
788 final_check = (full_honk_purported_value.get_value() == round.
target_total_sum.get_value());
789 verified = verified && final_check;
794 verified = verified && final_check;
798 .claimed_evaluations = purported_evaluations,
799 .verified = verified,
800 .claimed_libra_evaluation = libra_evaluation };
819 const std::vector<FF>& gate_challenges)
822 bool verified(
false);
827 libra_total_sum = transcript->template receive_from_prover<FF>(
"Libra:Sum");
829 const FF libra_challenge = transcript->template get_challenge<FF>(
"Libra:Challenge");
831 std::vector<FF> multivariate_challenge;
832 multivariate_challenge.reserve(virtual_log_n);
837 for (
size_t round_idx = 0; round_idx < virtual_log_n; round_idx++) {
839 const std::string round_univariate_comm_label =
"Sumcheck:univariate_comm_" +
std::to_string(round_idx);
840 const std::string univariate_eval_label_0 =
"Sumcheck:univariate_" +
std::to_string(round_idx) +
"_eval_0";
841 const std::string univariate_eval_label_1 =
"Sumcheck:univariate_" +
std::to_string(round_idx) +
"_eval_1";
844 round_univariate_commitments.push_back(
845 transcript->template receive_from_prover<Commitment>(round_univariate_comm_label));
847 round_univariate_evaluations.push_back(
848 { transcript->template receive_from_prover<FF>(univariate_eval_label_0),
849 transcript->template receive_from_prover<FF>(univariate_eval_label_1) });
851 const FF round_challenge =
852 transcript->template get_challenge<FF>(
"Sumcheck:u_" +
std::to_string(round_idx));
853 multivariate_challenge.emplace_back(round_challenge);
858 FF first_sumcheck_round_evaluations_sum =
859 round_univariate_evaluations[0][0] + round_univariate_evaluations[0][1];
863 auto transcript_evaluations =
864 transcript->template receive_from_prover<std::array<FF, NUM_POLYNOMIALS>>(
"Sumcheck:evaluations");
865 for (
auto [eval, transcript_eval] :
zip_view(purported_evaluations.get_all(), transcript_evaluations)) {
866 eval = transcript_eval;
872 purported_evaluations, relation_parameters, gate_separators, alphas);
876 full_honk_purported_value *=
880 const FF libra_evaluation = transcript->template receive_from_prover<FF>(
"Libra:claimed_evaluation");
883 full_honk_purported_value += libra_evaluation * libra_challenge;
887 for (
size_t round_idx = 1; round_idx < virtual_log_n; round_idx++) {
888 round_univariate_evaluations[round_idx - 1][2] =
889 round_univariate_evaluations[round_idx][0] + round_univariate_evaluations[round_idx][1];
894 first_sumcheck_round_evaluations_sum.self_reduce();
898 verified = (first_sumcheck_round_evaluations_sum.get_value() == round.
target_total_sum.get_value());
904 full_honk_purported_value.self_reduce();
909 verified = (first_sumcheck_round_evaluations_sum == round.
target_total_sum);
912 round_univariate_evaluations[virtual_log_n - 1][2] = full_honk_purported_value;
917 .claimed_evaluations = purported_evaluations,
918 .verified = verified,
919 .claimed_libra_evaluation = libra_evaluation,
920 .round_univariate_commitments = round_univariate_commitments,
921 .round_univariate_evaluations = round_univariate_evaluations };
929 for (
size_t i = 1; i < N; ++i) {
930 alphas[i] = alphas[i - 1] * alpha;
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< 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,...
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
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 SubrelationSeparators &relation_separator, const std::vector< FF > &gate_challenges, const RelationParameters< FF > &relation_parameters, const size_t virtual_log_n)
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)
#define PROFILE_THIS_NAME(name)
Implementation of the methods for the -polynomials used in Protogalaxy and -polynomials used in Sumch...
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
This structure is created to contain various polynomials and constants required by ZK Sumcheck.