Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions barretenberg/cpp/src/barretenberg/sumcheck/sumcheck.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ template <typename Flavor, const size_t virtual_log_n = CONST_PROOF_SIZE_LOG_N>
// separate linearly independent subrelation.
SubrelationSeparators alphas;
// pow_β(X₀, ..., X_{d−1}) = ∏ₖ₌₀^{d−1} (1 − Xₖ + Xₖ ⋅ βₖ)
bb::GateSeparatorPolynomial<FF> gate_separators;
std::vector<FF> gate_challenges;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the size of gate_challenges is ~ log of the circuit size

// Contains various challenges, such as `beta` and `gamma` used in the Grand Product argument.
bb::RelationParameters<FF> relation_parameters;

Expand Down Expand Up @@ -196,7 +196,7 @@ template <typename Flavor, const size_t virtual_log_n = CONST_PROOF_SIZE_LOG_N>
, transcript(std::move(transcript))
, round(multivariate_n)
, alphas(relation_separator)
, gate_separators(gate_challenges, multivariate_d)
, gate_challenges(gate_challenges)
, relation_parameters(relation_parameters){};

// SumcheckProver constructor for the Flavors that generate a single challeng `alpha` and use its powers as
Expand All @@ -213,7 +213,7 @@ template <typename Flavor, const size_t virtual_log_n = CONST_PROOF_SIZE_LOG_N>
, transcript(std::move(transcript))
, round(multivariate_n)
, alphas(initialize_relation_separator<FF, Flavor::NUM_SUBRELATIONS - 1>(alpha))
, gate_separators(gate_challenges, multivariate_d)
, gate_challenges(gate_challenges)
, relation_parameters(relation_parameters){};
/**
* @brief Non-ZK version: Compute round univariate, place it in transcript, compute challenge, partially evaluate.
Expand All @@ -223,6 +223,11 @@ template <typename Flavor, const size_t virtual_log_n = CONST_PROOF_SIZE_LOG_N>
*/
SumcheckOutput<Flavor> prove()
{
// Given gate challenges β = (β₀, ..., β_{d−1}) and d = `multivariate_d`, compute the evaluations of
// GateSeparator_β (X₀, ..., X_{d−1}) = ∏ₖ₌₀^{d−1} (1 − Xₖ + Xₖ · βₖ)
// on the boolean hypercube.
GateSeparatorPolynomial<FF> gate_separators(gate_challenges, multivariate_d);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GateSeparator is a poly of circuit size, so should be created locally


multivariate_challenge.reserve(virtual_log_n);
// In the first round, we compute the first univariate polynomial and populate the book-keeping table of
// #partially_evaluated_polynomials, which has \f$ n/2 \f$ rows and \f$ N \f$ columns. When the Flavor has ZK,
Expand Down Expand Up @@ -306,6 +311,10 @@ template <typename Flavor, const size_t virtual_log_n = CONST_PROOF_SIZE_LOG_N>
}

vinfo("starting sumcheck rounds...");
// Given gate challenges β = (β₀, ..., β_{d−1}) and d = `multivariate_d`, compute the evaluations of
// GateSeparator_β (X₀, ..., X_{d−1}) = ∏ₖ₌₀^{d−1} (1 − Xₖ + Xₖ · βₖ)
// on the boolean hypercube.
GateSeparatorPolynomial<FF> gate_separators(gate_challenges, multivariate_d);

multivariate_challenge.reserve(multivariate_d);
size_t round_idx = 0;
Expand Down Expand Up @@ -403,14 +412,8 @@ template <typename Flavor, const size_t virtual_log_n = CONST_PROOF_SIZE_LOG_N>
// Zero univariates are used to pad the proof to the fixed size virtual_log_n.
auto zero_univariate = bb::Univariate<FF, Flavor::BATCHED_RELATION_PARTIAL_LENGTH>::zero();
for (size_t idx = multivariate_d; idx < virtual_log_n; idx++) {
if constexpr (!IsGrumpkinFlavor<Flavor>) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This loop is never triggered when IsGrumkinFlavor<Flavor> == true

@johnathan79717 johnathan79717 Jul 15, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it's worth adding something like an ASSERT(!IsGrumpkinFlavor<Flavor>); to make sure.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note you can do static_assert() also

transcript->send_to_verifier("Sumcheck:univariate_" + std::to_string(idx), zero_univariate);
} else {
transcript->send_to_verifier("Sumcheck:univariate_comm_" + std::to_string(idx),
ck.commit(Polynomial<FF>(std::span(zero_univariate))));
transcript->send_to_verifier("Sumcheck:univariate_" + std::to_string(idx) + "_eval_0", FF(0));
transcript->send_to_verifier("Sumcheck:univariate_" + std::to_string(idx) + "_eval_1", FF(0));
}
transcript->send_to_verifier("Sumcheck:univariate_" + std::to_string(idx), zero_univariate);

FF round_challenge = transcript->template get_challenge<FF>("Sumcheck:u_" + std::to_string(idx));
multivariate_challenge.emplace_back(round_challenge);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,8 @@ template <typename Flavor> class SumcheckProverRound {
ExtendedEdges extended_edges;
SumcheckRoundUnivariate result;

// In Round 0, we have to compute the contribution from 2 edges: n - 1 = (1,1,...,1) and n-4 = (0,1,...,1).
// In Round 0, we have to compute the contribution from 2 edges: (1, 1,..., 1) and (0, 1, ..., 1) (as points on
// (d-1) - dimensional Boolean hypercube).
size_t start_edge_idx = (round_idx == 0) ? round_size - 4 : round_size - 2;

for (size_t edge_idx = start_edge_idx; edge_idx < round_size; edge_idx += 2) {
Expand Down
Loading