14#include "../gemini/gemini.hpp"
15#include "../kzg/kzg.hpp"
16#include "../pcs_test_utils.hpp"
22#include <gtest/gtest.h>
39 static constexpr size_t n = 1UL <<
log_n;
40 static constexpr size_t k = 4;
50 for (
size_t idx = 1; idx <
MINI; ++idx) {
64 for (
size_t idx = 1; idx <
MINI; ++idx) {
65 concatenated.
at(j *
MINI + idx) = polys[j][idx];
79 for (
size_t i = 0; i <
k; ++i) {
86 for (
size_t bit = 0; bit <
k; ++bit) {
87 bool bit_set = (j >> bit) & 1;
88 lagrange_j *= bit_set ? challenge[
log_n -
k + bit] : (
Fr::one() - challenge[
log_n -
k + bit]);
90 result += lagrange_j * individual_evals[j];
92 return result * padding.
invert();
101 const std::vector<Fr>& challenge)
107 wire_evals[j] = wires[j].evaluate_mle(challenge);
108 wire_shift_evals[j] = wires[j].shifted().evaluate_mle(challenge);
114 EXPECT_EQ(batched_unshifted, concat_poly.
evaluate_mle(challenge));
117 return { batched_unshifted, batched_shifted };
128 std::vector<Fr>& challenge)
136 PolynomialBatcher polynomial_batcher(
n);
142 auto prover_opening_claim =
150 using ClaimBatch = ClaimBatcher::Batch;
152 ClaimBatcher claim_batcher{
157 std::vector<Fr> padding_indicator(challenge.size(),
Fr{ 1 });
160 padding_indicator, claim_batcher, challenge, Commitment::one(), verifier_transcript);
163 std::move(shplemini_output.batch_opening_claim), verifier_transcript);
165 return pairing_points.check();
171 auto wires = create_minicircuit_polynomials();
177 std::vector<Fr> challenge(log_n);
178 for (
auto& u : challenge) {
182 auto [unshifted, shifted] = evaluate_concatenation_group(wires, concat_polys[0], challenge);
186 EXPECT_TRUE(prove_and_verify(concat_polys, commitments, unshifted_evals, shifted_evals, challenge));
191 constexpr size_t NUM_GROUPS = 5;
199 for (
size_t g = 0; g < NUM_GROUPS; ++g) {
200 all_groups[g] = create_minicircuit_polynomials();
201 concat_polys[g] = concatenate_polynomials(all_groups[g]);
202 commitments[g] =
ck.commit(concat_polys[g]);
205 std::vector<Fr> challenge(log_n);
206 for (
auto& u : challenge) {
213 for (
size_t g = 0; g < NUM_GROUPS; ++g) {
214 auto [u, s] = evaluate_concatenation_group(all_groups[g], concat_polys[g], challenge);
215 unshifted_evals[g] = u;
216 shifted_evals[g] = s;
219 EXPECT_TRUE(prove_and_verify(concat_polys, commitments, unshifted_evals, shifted_evals, challenge));
static std::shared_ptr< BaseTranscript > test_prover_init_empty()
For testing: initializes transcript with some arbitrary data so that a challenge can be generated aft...
static std::shared_ptr< BaseTranscript > test_verifier_init_empty(const std::shared_ptr< BaseTranscript > &transcript)
For testing: initializes transcript based on proof data then receives junk data produced by BaseTrans...
CommitmentKey object over a pairing group 𝔾₁.
Class responsible for computation of the batched multilinear polynomials required by the Gemini proto...
static PairingPointsType reduce_verify_batch_opening_claim(BatchOpeningClaim< Curve > &&batch_opening_claim, const std::shared_ptr< Transcript > &transcript, const size_t expected_final_msm_size=0)
Computes the input points for the pairing check needed to verify a KZG opening claim obtained from a ...
static void compute_opening_proof(const CK &ck, const ProverOpeningClaim< Curve > &opening_claim, const std::shared_ptr< Transcript > &prover_trancript)
Computes the KZG commitment to an opening proof polynomial at a single evaluation point.
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.
Fr evaluate_mle(std::span< const Fr > evaluation_points, bool shift=false) const
evaluate multi-linear extension p(X_0,…,X_{n-1}) = \sum_i a_i*L_i(X_0,…,X_{n-1}) at u = (u_0,...
Fr & at(size_t index)
Our mutable accessor, unlike operator[]. We abuse precedent a bit to differentiate at() and operator[...
A template class for a reference array. Behaves as if std::array<T&, N> was possible.
A template class for a reference vector. Behaves as if std::vector<T&> was possible.
static constexpr size_t mini_log_n
bool prove_and_verify(std::array< Polynomial, N > &concat_polys, std::array< Commitment, N > &commitments, std::array< Fr, N > &unshifted_evals, std::array< Fr, N > &shifted_evals, std::vector< Fr > &challenge)
Run Shplemini prove-and-verify for N concatenated polynomials (unshifted + shifted).
Curve::AffineElement Commitment
static constexpr size_t n
static constexpr size_t log_n
std::array< Polynomial, CONCATENATION_GROUP_SIZE > create_minicircuit_polynomials()
Create 16 minicircuit-sized random polynomials with values in [1, MINI)
bb::Polynomial< Fr > Polynomial
static constexpr size_t MINI
Fr compute_batched_evaluation(const std::vector< Fr > &challenge, const std::array< Fr, CONCATENATION_GROUP_SIZE > &individual_evals)
Compute batched evaluation = [1/L₀(u_top)] * Σⱼ Lⱼ(u_top) * eval_j.
static constexpr size_t CONCATENATION_GROUP_SIZE
std::pair< Fr, Fr > evaluate_concatenation_group(const std::array< Polynomial, CONCATENATION_GROUP_SIZE > &wires, const Polynomial &concat_poly, const std::vector< Fr > &challenge)
Compute batched evaluations (unshifted + shifted) for a group of wires at a challenge point,...
static constexpr size_t k
Polynomial concatenate_polynomials(const std::array< Polynomial, CONCATENATION_GROUP_SIZE > &polys)
Concatenate 16 minicircuit polynomials: concat[j*MINI + idx] = wire[j][idx].
static OpeningClaim prove(size_t circuit_size, PolynomialBatcher &polynomial_batcher, std::span< FF > multilinear_challenge, const CommitmentKey< Curve > &commitment_key, const std::shared_ptr< Transcript > &transcript, const std::array< Polynomial, NUM_SMALL_IPA_EVALUATIONS > &libra_polynomials={}, const std::vector< Polynomial > &sumcheck_round_univariates={}, const std::vector< std::array< FF, 3 > > &sumcheck_round_evaluations={})
static ShpleminiVerifierOutput compute_batch_opening_claim(std::span< const Fr > padding_indicator_array, ClaimBatcher &claim_batcher, const std::vector< Fr > &multivariate_challenge, const Commitment &g1_identity, const std::shared_ptr< Transcript > &transcript, const RepeatedCommitmentsData &repeated_commitments={}, const std::array< Commitment, NUM_LIBRA_COMMITMENTS > &libra_commitments={}, const Fr &libra_univariate_evaluation=Fr{ 0 }, const std::vector< Commitment > &sumcheck_round_commitments={}, const std::vector< std::array< Fr, 3 > > &sumcheck_round_evaluations={})
This method receives commitments to all prover polynomials, their claimed evaluations,...
Representation of the Grumpkin Verifier Commitment Key inside a bn254 circuit.
typename Group::affine_element AffineElement
Entry point for Barretenberg command-line interface.
TEST_F(IPATest, ChallengesAreZero)
CommitmentKey< Curve > ck
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Logic to support batching opening claims for unshifted and shifted polynomials in Shplemini.
std::optional< Batch > unshifted
static constexpr field one()
constexpr field invert() const noexcept
static field random_element(numeric::RNG *engine=nullptr) noexcept
static constexpr field zero()