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;
99 squares.reserve(num_squares);
100 squares.emplace_back(r);
101 for (
size_t j = 1; j < num_squares; j++) {
102 squares.emplace_back(squares[j - 1].sqr());
166 Fr running_scalar(1);
171 const size_t n = polynomials_to_batch.size();
173 std::vector<Fr> scalars;
176 for (
size_t i = 0; i < n; ++i) {
177 sources.emplace_back(polynomials_to_batch[i]);
178 scalars.push_back(running_scalar);
179 running_scalar *= challenge;
216 Fr r_inv = r_challenge.invert();
222 return { A_0_pos, A_0_neg };
234 const Fr& r_challenge);
236 template <
typename Transcript>
241 const std::shared_ptr<Transcript>& transcript,
242 bool has_zk =
false);
264 std::vector<Commitment> fold_commitments;
265 fold_commitments.reserve(virtual_log_n - 1);
266 for (
size_t i = 1; i < virtual_log_n; ++i) {
268 transcript->template receive_from_prover<Commitment>(
"Gemini:FOLD_" +
std::to_string(i));
269 fold_commitments.emplace_back(commitment);
271 return fold_commitments;
285 std::vector<Fr> gemini_evaluations;
286 gemini_evaluations.reserve(virtual_log_n);
288 for (
size_t i = 1; i <= virtual_log_n; ++i) {
289 const Fr evaluation = transcript->template receive_from_prover<Fr>(
"Gemini:a_" +
std::to_string(i));
290 gemini_evaluations.emplace_back(evaluation);
292 return gemini_evaluations;
323 const size_t virtual_log_n = evaluation_point.size();
325 std::vector<Fr> evals(fold_neg_evals.begin(), fold_neg_evals.end());
327 Fr eval_pos_prev = batched_evaluation;
329 std::vector<Fr> fold_pos_evaluations;
330 fold_pos_evaluations.reserve(virtual_log_n);
333 for (
size_t l = virtual_log_n; l != 0; --l) {
335 const Fr& challenge_power = challenge_powers[l - 1];
337 const Fr& u = evaluation_point[l - 1];
339 const Fr& eval_neg = evals[l - 1];
341 Fr eval_pos = ((challenge_power * eval_pos_prev * 2) - eval_neg * (challenge_power * (
Fr(1) - u) - u));
343 eval_pos *= (challenge_power * (
Fr(1) - u) + u).invert();
345 eval_pos_prev = eval_pos;
346 fold_pos_evaluations.emplace_back(eval_pos_prev);
349 std::reverse(fold_pos_evaluations.begin(), fold_pos_evaluations.end());
351 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
PolynomialBatcher(const size_t full_batched_size, const size_t actual_data_size=0)
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
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.
RefVector< Polynomial > unshifted
bool has_unshifted() const
Polynomial batched_to_be_shifted_by_one
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)
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
Polynomial shifted() const
Returns a Polynomial the left-shift of self.
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)