49template <
typename Curve>
50template <
typename Transcript>
56 const std::shared_ptr<Transcript>& transcript,
61 const size_t virtual_log_n = multilinear_challenge.size();
65 const Fr rho = transcript->template get_challenge<Fr>(
"rho");
73 for (
size_t l = 0; l < virtual_log_n - 1; l++) {
76 transcript->send_to_verifier(label, commitment_key.
commit(fold_polynomials[l]));
78 const Fr r_challenge = transcript->template get_challenge<Fr>(
"Gemini:r");
80 const bool gemini_challenge_in_small_subgroup = (has_zk) && (r_challenge.pow(
Curve::SUBGROUP_SIZE) ==
Fr(1));
85 if (gemini_challenge_in_small_subgroup) {
86 throw_or_abort(
"Gemini evaluation challenge is in the SmallSubgroup.");
95 for (
size_t l = 1; l <= virtual_log_n; l++) {
97 transcript->send_to_verifier(label, claims[l].opening_pair.evaluation);
110template <
typename Curve>
115 BB_ASSERT_GTE(log_n,
size_t(2),
"Gemini folding requires at least 4-element polynomials");
116 const size_t virtual_log_n = multilinear_challenge.size();
119 constexpr size_t fold_iteration_cost =
125 size_t actual_size =
std::max(A_0.
end_index(),
static_cast<size_t>(NUM_DISABLED_ROWS_IN_SUMCHECK));
129 fold_polynomials.reserve(virtual_log_n - 1);
130 for (
size_t l = 0; l < log_n - 1; ++l) {
131 const size_t fold_size = (actual_size + 1) / 2;
134 fold_polynomials.emplace_back(
Polynomial(fold_size));
135 actual_size = fold_size;
142 auto A_l = A_0.
data();
143 for (
size_t l = 0; l < log_n - 1; ++l) {
144 const size_t fold_size = (actual_size + 1) / 2;
145 const size_t num_pairs = actual_size / 2;
148 const Fr u_l = l < virtual_log_n ? multilinear_challenge[l] :
Fr(0);
151 auto A_l_fold = fold_polynomials[l].data();
159 A_l_fold[j] = A_l[j << 1] + u_l * (A_l[(j << 1) + 1] - A_l[j << 1]);
161 fold_iteration_cost);
163 if (actual_size & 1) {
164 A_l_fold[num_pairs] = A_l[actual_size - 1] * (
Fr(1) - u_l);
168 actual_size = fold_size;
175 const auto& last = fold_polynomials.back();
176 const Fr u_last = (log_n - 1) < virtual_log_n ? multilinear_challenge[log_n - 1] :
Fr(0);
177 const Fr final_eval = last.at(0) + u_last * (last.at(1) - last.at(0));
179 const_fold.at(0) = final_eval;
180 fold_polynomials.emplace_back(const_fold);
184 for (
size_t k = log_n; k < virtual_log_n - 1; ++k) {
185 tail *= (
Fr(1) - multilinear_challenge[k]);
187 next_const.
at(0) = final_eval * tail;
188 fold_polynomials.emplace_back(next_const);
191 return fold_polynomials;
215template <
typename Curve>
221 const Fr& r_challenge)
226 Fr a_0_pos = A_0_pos.evaluate(r_challenge);
227 claims.emplace_back(
Claim{
std::move(A_0_pos), { r_challenge, a_0_pos } });
229 Fr a_0_neg = A_0_neg.evaluate(-r_challenge);
230 claims.emplace_back(
Claim{
std::move(A_0_neg), { -r_challenge, a_0_neg } });
237 const bool gemini_fold =
true;
240 for (
size_t l = 0; l < log_n - 1; ++l) {
241 Fr evaluation = fold_polynomials[l].evaluate(-r_squares[l + 1]);
242 claims.emplace_back(
Claim{
std::move(fold_polynomials[l]), { -r_squares[l + 1], evaluation }, gemini_fold });
#define BB_ASSERT_GTE(left, right,...)
#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)
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)