36template <
typename Fr>
inline std::vector<Fr>
batching_scalars(
const Fr& challenge,
const size_t count)
38 std::vector<Fr> scalars;
39 scalars.reserve(count);
41 for (
size_t idx = 0; idx < count; ++idx) {
42 scalars.emplace_back(scalar);
48template <
typename Curve>
54 if (evaluations.empty()) {
58 constexpr size_t max_products = 16;
60 for (
size_t start = 0; start < evaluations.size(); start += max_products) {
61 const size_t len = std::min(max_products, evaluations.size() - start);
62 std::vector<Fr> scalar_chunk(scalars.begin() +
static_cast<std::ptrdiff_t>(start),
64 std::vector<Fr> evaluation_chunk(evaluations.begin() +
static_cast<std::ptrdiff_t>(start),
66 result = (start == 0) ? Fr::mult_madd(scalar_chunk, evaluation_chunk, {})
67 : Fr::mult_madd(scalar_chunk, evaluation_chunk, {
result });
72 for (
size_t idx = 0; idx < evaluations.size(); ++idx) {
73 result += scalars[idx] * evaluations[idx];
79template <
typename Curve>
89 std::vector<Fr> scalars_copy(scalars.begin(), scalars.end());
91 return GroupElement::batch_mul(std::vector<Commitment>(commitments.begin(), commitments.end()), scalars_copy);
93 return Commitment::batch_mul(commitments,
std::span<Fr>(scalars_copy));
152 const Fr& nu_challenge,
153 const Fr& r_challenge)
155 const Fr& inverse_vanishing_eval_pos = inverted_vanishing_evals[0];
156 const Fr& inverse_vanishing_eval_neg = inverted_vanishing_evals[1];
160 unshifted->scalar = inverse_vanishing_eval_pos + nu_challenge * inverse_vanishing_eval_neg;
174 r_challenge.invert() * (inverse_vanishing_eval_pos - nu_challenge * inverse_vanishing_eval_neg);
188 std::vector<Fr>& scalars,
189 Fr& batched_evaluation,
192 size_t num_powers = 0;
194 num_powers +=
shifted.has_value() ?
shifted->commitments.size() : 0;
196 Fr rho_power =
Fr(1);
197 size_t power_idx = 0;
201 auto aggregate_claim_data_and_update_batched_evaluation = [&](
const Batch& batch) {
202 for (
auto [commitment, evaluation] :
zip_view(batch.commitments, batch.evaluations)) {
203 commitments.emplace_back(
std::move(commitment));
204 scalars.emplace_back(-batch.scalar * rho_power);
205 batched_evaluation += evaluation * rho_power;
207 if (power_idx < num_powers) {
217 aggregate_claim_data_and_update_batched_evaluation(*
unshifted);
221 aggregate_claim_data_and_update_batched_evaluation(*
shifted);
#define BB_ASSERT_GT(left, right,...)
#define BB_ASSERT_EQ(actual, expected,...)
Unverified claim (C,r,v) for some witness polynomial p(X) such that.
Polynomial p and an opening pair (r,v) such that p(r) = v.
OpeningPair< Curve > opening_pair
A template class for a reference vector. Behaves as if std::vector<T&> was possible.
typename Group::element Element
static constexpr bool is_stdlib_type
typename Group::affine_element AffineElement
Entry point for Barretenberg command-line interface.
Curve::AffineElement batch_commitments(std::span< const typename Curve::AffineElement > commitments, std::span< const typename Curve::ScalarField > scalars)
Curve::ScalarField batch_evaluations(std::span< const typename Curve::ScalarField > evaluations, std::span< const typename Curve::ScalarField > scalars)
std::vector< Fr > batching_scalars(const Fr &challenge, const size_t count)
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
RefVector< Commitment > commitments
RefVector< Fr > evaluations
Logic to support batching opening claims for unshifted and shifted polynomials in Shplemini.
std::optional< Batch > unshifted
void update_batch_mul_inputs_and_batched_evaluation(std::vector< Commitment > &commitments, std::vector< Fr > &scalars, Fr &batched_evaluation, const Fr &rho)
Append the commitments and scalars from each batch of claims to the Shplemini vectors which subsequen...
std::optional< Batch > shifted
void compute_scalars_for_each_batch(std::span< const Fr > inverted_vanishing_evals, const Fr &nu_challenge, const Fr &r_challenge)
Compute scalars used to batch each set of claims, excluding contribution from batching challenge \rho...
typename Curve::ScalarField Fr
Fr get_unshifted_batch_scalar() const
typename Curve::AffineElement Commitment
std::vector< VerifierClaim > verifier_claims
void add(ProverClaim prover_claim, Commitment commitment)
typename Curve::AffineElement Commitment
std::vector< ProverClaim > prover_claims
static constexpr field one()
static constexpr field zero()