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
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,12 @@ namespace gemini {
*/
template <class Fr> inline std::vector<Fr> powers_of_rho(const Fr& rho, const size_t num_powers)
{
std::vector<Fr> rhos = { Fr(1), rho };
std::vector<Fr> rhos;
rhos.reserve(num_powers);
for (size_t j = 2; j < num_powers; j++) {
if (num_powers >= 1) {
rhos.emplace_back(Fr(1));
}
for (size_t j = 1; j < num_powers; j++) {
rhos.emplace_back(rhos[j - 1] * rho);
}
return rhos;
Expand Down Expand Up @@ -250,14 +253,12 @@ template <typename Curve> class GeminiProver_ {

Fr r_inv = r_challenge.invert();
if (has_to_be_shifted_by_one()) {
batched_to_be_shifted_by_one *= r_inv;
A_0_pos += batched_to_be_shifted_by_one;
A_0_neg -= batched_to_be_shifted_by_one;
A_0_pos.add_scaled(batched_to_be_shifted_by_one, r_inv);
A_0_neg.add_scaled(batched_to_be_shifted_by_one, -r_inv);
}
if (!batched_shifted_tail_.is_empty()) {
batched_shifted_tail_ *= r_inv;
A_0_pos += batched_shifted_tail_;
A_0_neg -= batched_shifted_tail_;
A_0_pos.add_scaled(batched_shifted_tail_, r_inv);
A_0_neg.add_scaled(batched_shifted_tail_, -r_inv);
}

return { A_0_pos, A_0_neg };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ std::vector<typename GeminiProver_<Curve>::Polynomial> GeminiProver_<Curve>::com
const size_t log_n, std::span<const Fr> multilinear_challenge, const Polynomial& A_0, const bool& has_zk)
{
BB_BENCH_NAME("Gemini::compute_fold_polynomials");
BB_ASSERT_GTE(log_n, size_t(2), "Gemini folding requires at least 4-element polynomials");
const size_t virtual_log_n = multilinear_challenge.size();

// Cost per iteration: 1 subtraction + 1 multiplication + 1 addition
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -575,14 +575,14 @@ template <typename Curve_, size_t log_poly_length = CONST_ECCVM_LOG_N> class IPA

// Step 6.
// Receive a_zero from the prover
const auto a_zero = transcript->template receive_from_prover<Fr>("IPA:a_0");
auto a_zero = transcript->template receive_from_prover<Fr>("IPA:a_0");

// OriginTag false positive: G_zero and a_zero are fully determined once all round challenges are fixed - the
// prover must send the correct values or the final relation check fails.
if constexpr (Curve::is_stdlib_type) {
const auto last_round_tag = round_challenges.back().get_origin_tag();
G_zero.set_origin_tag(last_round_tag);
const_cast<Fr&>(a_zero).set_origin_tag(last_round_tag);
a_zero.set_origin_tag(last_round_tag);
}

// Step 7.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,7 @@ template <typename Curve, bool HasZK = false> class ShpleminiVerifier_ {
const Fr gemini_evaluation_challenge = transcript->template get_challenge<Fr>("Gemini:r");

// - Get negative fold evaluations (A₀(−r), A₁(−r²), ... , Aₙ₋₁(−r²⁽ⁿ⁻¹⁾))
const std::vector<Fr> gemini_fold_neg_evaluations =
GeminiVerifier::get_gemini_evaluations(virtual_log_n, transcript);
std::vector<Fr> gemini_fold_neg_evaluations = GeminiVerifier::get_gemini_evaluations(virtual_log_n, transcript);

// - Compute vector (r, r², ... , r^{2^{d-1}}), where d = log_n
const std::vector<Fr> gemini_eval_challenge_powers =
Expand Down Expand Up @@ -290,7 +289,7 @@ template <typename Curve, bool HasZK = false> class ShpleminiVerifier_ {
if constexpr (Curve::is_stdlib_type) {
const auto challenge_tag = shplonk_evaluation_challenge.get_origin_tag();
// Tag the Gemini fold evaluations
for (auto& eval : const_cast<std::vector<Fr>&>(gemini_fold_neg_evaluations)) {
for (auto& eval : gemini_fold_neg_evaluations) {
eval.set_origin_tag(challenge_tag);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ template <typename FF> struct GateSeparatorPolynomial {
}

BB_BENCH_NAME("GateSeparatorPolynomial::compute_beta_products");
size_t pow_size = 1 << log_num_monomials;
size_t pow_size = static_cast<size_t>(1) << log_num_monomials;
Polynomial<FF> beta_products(pow_size, Polynomial<FF>::DontZeroMemory::FLAG);

// Explanations of the algorithm:
Expand Down
4 changes: 2 additions & 2 deletions barretenberg/cpp/src/barretenberg/sumcheck/sumcheck.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -499,9 +499,9 @@ template <typename Flavor> class SumcheckProver {
transcript->send_to_verifier("Sumcheck:evaluations", multivariate_evaluations.get_all());
// For ZK Flavors: the evaluations of Libra univariates are included in the Sumcheck Output

vinfo("finished sumcheck");
return SumcheckOutput<Flavor>{ .challenge = multivariate_challenge,
.claimed_evaluations = multivariate_evaluations };
vinfo("finished sumcheck");
};

/**
Expand Down Expand Up @@ -671,12 +671,12 @@ template <typename Flavor> class SumcheckProver {

// The sum of the Libra constant term and the evaluations of Libra univariates at corresponding sumcheck
// challenges is included in the Sumcheck Output
vinfo("finished sumcheck");
return SumcheckOutput<Flavor>{ .challenge = multivariate_challenge,
.claimed_evaluations = multivariate_evaluations,
.claimed_libra_evaluation = libra_evaluation,
.round_univariates = handler.get_univariates(),
.round_univariate_evaluations = handler.get_evaluations() };
vinfo("finished sumcheck");
};

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,9 +295,6 @@ template <typename Flavor> struct ZKSumcheckData {
this->libra_univariates[round_idx].evaluate(round_challenge) / this->libra_scaling_factor;
// place the evalution into the vector of Libra evaluations
this->libra_evaluations.emplace_back(libra_evaluation);
for (auto univariate : this->libra_univariates) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

dead code

univariate *= FF(1) / this->libra_challenge;
}
};
}
};
Expand Down
Loading