76template <
class Fr>
inline std::vector<Fr>
powers_of_rho(
const Fr& rho,
const size_t num_powers)
79 rhos.reserve(num_powers);
80 if (num_powers >= 1) {
81 rhos.emplace_back(
Fr(1));
83 for (
size_t j = 1; j < num_powers; j++) {
84 rhos.emplace_back(rhos[j - 1] * rho);
98 std::vector<Fr> squares = { r };
99 squares.reserve(num_squares);
100 for (
size_t j = 1; j < num_squares; j++) {
101 squares.emplace_back(squares[j - 1].sqr());
184 Fr running_scalar(1);
189 const size_t n = polynomials_to_batch.size();
191 std::vector<Fr> scalars;
194 for (
size_t i = 0; i < n; ++i) {
195 sources.emplace_back(polynomials_to_batch[i]);
196 scalars.push_back(running_scalar);
197 running_scalar *= challenge;
206 auto batch_tails = [&](
Polynomial& batched_tail,
208 const Fr& base_scalar) {
209 for (
const auto& [idx, tail] : tail_list) {
211 batched_tail =
Polynomial(tail.size(), tail.virtual_size(), tail.start_index());
213 batched_tail.
add_scaled(tail, base_scalar * challenge.pow(idx));
219 Fr unshifted_base(1);
229 Fr shifted_base = running_scalar;
263 Fr r_inv = r_challenge.invert();
273 return { A_0_pos, A_0_neg };
285 const Fr& r_challenge);
287 template <
typename Transcript>
292 const std::shared_ptr<Transcript>& transcript,
293 bool has_zk =
false);
315 std::vector<Commitment> fold_commitments;
316 fold_commitments.reserve(virtual_log_n - 1);
317 for (
size_t i = 1; i < virtual_log_n; ++i) {
319 transcript->template receive_from_prover<Commitment>(
"Gemini:FOLD_" +
std::to_string(i));
320 fold_commitments.emplace_back(commitment);
322 return fold_commitments;
336 std::vector<Fr> gemini_evaluations;
337 gemini_evaluations.reserve(virtual_log_n);
339 for (
size_t i = 1; i <= virtual_log_n; ++i) {
340 const Fr evaluation = transcript->template receive_from_prover<Fr>(
"Gemini:a_" +
std::to_string(i));
341 gemini_evaluations.emplace_back(evaluation);
343 return gemini_evaluations;
374 const size_t virtual_log_n = evaluation_point.size();
376 std::vector<Fr> evals(fold_neg_evals.begin(), fold_neg_evals.end());
378 Fr eval_pos_prev = batched_evaluation;
380 std::vector<Fr> fold_pos_evaluations;
381 fold_pos_evaluations.reserve(virtual_log_n);
384 for (
size_t l = virtual_log_n; l != 0; --l) {
386 const Fr& challenge_power = challenge_powers[l - 1];
388 const Fr& u = evaluation_point[l - 1];
390 const Fr& eval_neg = evals[l - 1];
392 Fr eval_pos = ((challenge_power * eval_pos_prev * 2) - eval_neg * (challenge_power * (
Fr(1) - u) - u));
394 eval_pos *= (challenge_power * (
Fr(1) - u) + u).invert();
396 eval_pos_prev = eval_pos;
397 fold_pos_evaluations.emplace_back(eval_pos_prev);
400 std::reverse(fold_pos_evaluations.begin(), fold_pos_evaluations.end());
402 return fold_pos_evaluations;
#define BB_BENCH_NAME(name)
CommitmentKey object over a pairing group 𝔾₁.
Class responsible for computation of the batched multilinear polynomials required by the Gemini proto...
void set_to_be_shifted_by_one(RefVector< Polynomial > polynomials)
bool has_to_be_shifted_by_one() const
void add_unshifted_tail(size_t batcher_index, Polynomial &&tail)
Polynomial batched_shifted_tail_
PolynomialBatcher(const size_t full_batched_size, const size_t actual_data_size=0)
Polynomial batched_unshifted_tail_
void set_unshifted(RefVector< Polynomial > polynomials)
Polynomial batched_unshifted
Polynomial compute_batched(const Fr &challenge)
Compute batched polynomial A₀ = F + G/X as the linear combination of all polynomials to be opened,...
RefVector< Polynomial > to_be_shifted_by_one
void add_shifted_tail(size_t batcher_index, Polynomial &&tail)
std::pair< Polynomial, Polynomial > compute_partially_evaluated_batch_polynomials(const Fr &r_challenge)
Compute partially evaluated batched polynomials A₀(X, r) = A₀₊ = F + G/r, A₀(X, -r) = A₀₋ = F - G/r.
std::vector< std::pair< size_t, Polynomial > > shifted_tails_
RefVector< Polynomial > unshifted
bool has_unshifted() const
Polynomial batched_to_be_shifted_by_one
std::vector< std::pair< size_t, Polynomial > > unshifted_tails_
static std::vector< Claim > prove(size_t circuit_size, PolynomialBatcher &polynomial_batcher, std::span< Fr > multilinear_challenge, const CommitmentKey< Curve > &commitment_key, const std::shared_ptr< Transcript > &transcript, bool has_zk=false)
bb::Polynomial< Fr > Polynomial
static std::vector< Claim > construct_univariate_opening_claims(const size_t log_n, Polynomial &&A_0_pos, Polynomial &&A_0_neg, std::vector< Polynomial > &&fold_polynomials, const Fr &r_challenge)
Computes/aggragates d+1 univariate polynomial opening claims of the form {polynomial,...
typename Curve::ScalarField Fr
typename Curve::AffineElement Commitment
static std::vector< Polynomial > compute_fold_polynomials(const size_t log_n, std::span< const Fr > multilinear_challenge, const Polynomial &A_0)
Computes d-1 fold polynomials Fold_i, i = 1, ..., d-1.
Gemini Verifier utility methods used by ShpleminiVerifier.
typename Curve::ScalarField Fr
static std::vector< Fr > compute_fold_pos_evaluations(const Fr &batched_evaluation, std::span< const Fr > evaluation_point, std::span< const Fr > challenge_powers, std::span< const Fr > fold_neg_evals)
Compute .
static std::vector< Commitment > get_fold_commitments(const size_t virtual_log_n, auto &transcript)
Receive the fold commitments from the prover. This method is used by Shplemini where padding may be e...
static std::vector< Fr > get_gemini_evaluations(const size_t virtual_log_n, auto &transcript)
Receive the fold evaluations from the prover. This method is used by Shplemini where padding may be e...
typename Curve::AffineElement Commitment
Structured polynomial class that represents the coefficients 'a' of a_0 + a_1 x .....
Polynomial shifted() const
Returns a Polynomial the left-shift of self.
size_t start_index() const
void add_scaled(PolynomialSpan< const Fr > other, const Fr &scaling_factor)
adds the polynomial q(X) 'other', multiplied by a scaling factor.
Polynomial p and an opening pair (r,v) such that p(r) = v.
A template class for a reference vector. Behaves as if std::vector<T&> was possible.
typename Group::affine_element AffineElement
std::vector< Fr > powers_of_evaluation_challenge(const Fr &r, const size_t num_squares)
Compute squares of folding challenge r.
std::vector< Fr > powers_of_rho(const Fr &rho, const size_t num_powers)
Compute powers of challenge ρ
Entry point for Barretenberg command-line interface.
void add_scaled_batch(Polynomial< Fr > &dst, std::span< const PolynomialSpan< const Fr > > sources, std::span< const Fr > scalars)
Fused parallel batched add: dst += sum_i scalars[i] * sources[i].
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
std::string to_string(bb::avm2::ValueTag tag)