49template <
typename Curve>
50template <
typename Transcript>
56 const std::shared_ptr<Transcript>& transcript,
60 const size_t virtual_log_n = multilinear_challenge.size();
64 const Fr rho = transcript->template get_challenge<Fr>(
"rho");
72 for (
size_t l = 0; l < virtual_log_n - 1; l++) {
75 transcript->send_to_verifier(label, commitment_key.
commit(fold_polynomials[l]));
77 const Fr r_challenge = transcript->template get_challenge<Fr>(
"Gemini:r");
79 const bool gemini_challenge_in_small_subgroup = (has_zk) && (r_challenge.pow(
Curve::SUBGROUP_SIZE) ==
Fr(1));
84 if (gemini_challenge_in_small_subgroup) {
85 throw_or_abort(
"Gemini evaluation challenge is in the SmallSubgroup.");
94 for (
size_t l = 1; l <= virtual_log_n; l++) {
96 transcript->send_to_verifier(label, claims[l].opening_pair.evaluation);
109template <
typename Curve>
114 const size_t virtual_log_n = multilinear_challenge.size();
117 constexpr size_t fold_iteration_cost =
122 fold_polynomials.reserve(virtual_log_n - 1);
123 for (
size_t l = 0; l < log_n - 1; ++l) {
125 const size_t n_l = 1 << (log_n - l - 1);
128 fold_polynomials.emplace_back(
Polynomial(n_l));
134 auto A_l = A_0.
data();
135 for (
size_t l = 0; l < log_n - 1; ++l) {
137 const size_t n_l = 1 << (log_n - l - 1);
140 const Fr u_l = multilinear_challenge[l];
143 auto A_l_fold = fold_polynomials[l].
data();
151 A_l_fold[j] = A_l[j << 1] + u_l * (A_l[(j << 1) + 1] - A_l[j << 1]);
153 fold_iteration_cost);
162 const auto& last = fold_polynomials.back();
163 const Fr u_last = multilinear_challenge[log_n - 1];
164 const Fr final_eval = last.at(0) + u_last * (last.at(1) - last.at(0));
168 const_fold.at(0) = final_eval *
Fr(
static_cast<int>(!has_zk));
169 fold_polynomials.emplace_back(const_fold);
173 for (
size_t k = log_n; k < virtual_log_n - 1; ++k) {
174 tail *= (
Fr(1) - multilinear_challenge[k]);
176 next_const.
at(0) = final_eval * tail *
Fr(
static_cast<int>(!has_zk));
177 fold_polynomials.emplace_back(next_const);
180 return fold_polynomials;
204template <
typename Curve>
210 const Fr& r_challenge)
215 Fr a_0_pos = A_0_pos.evaluate(r_challenge);
216 claims.emplace_back(
Claim{
std::move(A_0_pos), { r_challenge, a_0_pos } });
218 Fr a_0_neg = A_0_neg.evaluate(-r_challenge);
219 claims.emplace_back(
Claim{
std::move(A_0_neg), { -r_challenge, a_0_neg } });
226 const bool gemini_fold =
true;
229 for (
size_t l = 0; l < log_n - 1; ++l) {
230 Fr evaluation = fold_polynomials[l].evaluate(-r_squares[l + 1]);
231 claims.emplace_back(
Claim{
std::move(fold_polynomials[l]), { -r_squares[l + 1], evaluation }, gemini_fold });
#define BB_BENCH_NAME(name)
CommitmentKey object over a pairing group 𝔾₁.
Commitment commit(PolynomialSpan< const Fr > polynomial) const
Uses the ProverSRS to create a commitment to p(X)
Class responsible for computation of the batched multilinear polynomials required by the Gemini proto...
Polynomial compute_batched(const Fr &challenge)
Compute batched polynomial A₀ = F + G/X as the linear combination of all polynomials to be opened,...
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.
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
static std::vector< Polynomial > compute_fold_polynomials(const size_t log_n, std::span< const Fr > multilinear_challenge, const Polynomial &A_0, const bool &has_zk=false)
Computes d-1 fold polynomials Fold_i, i = 1, ..., d-1.
Structured polynomial class that represents the coefficients 'a' of a_0 + a_1 x .....
Fr & at(size_t index)
Our mutable accessor, unlike operator[]. We abuse precedent a bit to differentiate at() and operator[...
Polynomial p and an opening pair (r,v) such that p(r) = v.
static constexpr size_t SUBGROUP_SIZE
std::vector< Fr > powers_of_evaluation_challenge(const Fr &r, const size_t num_squares)
Compute squares of folding challenge r.
constexpr T get_msb(const T in)
constexpr size_t FF_ADDITION_COST
constexpr size_t FF_MULTIPLICATION_COST
Entry point for Barretenberg command-line interface.
void parallel_for_heuristic(size_t num_points, const std::function< void(size_t, size_t, size_t)> &func, size_t heuristic_cost)
Split a loop into several loops running in parallel based on operations in 1 iteration.
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
std::string to_string(bb::avm2::ValueTag tag)
void throw_or_abort(std::string const &err)