3#include <gtest/gtest.h>
55 op_queue->add_accumulate(
a);
56 op_queue->mul_accumulate(
a, x);
57 op_queue->mul_accumulate(
b, x);
58 op_queue->mul_accumulate(
b, y);
59 op_queue->add_accumulate(
a);
60 op_queue->mul_accumulate(
b, x);
61 op_queue->eq_and_reset();
62 op_queue->add_accumulate(c);
63 op_queue->mul_accumulate(
a, x);
64 op_queue->mul_accumulate(
b, x);
65 op_queue->eq_and_reset();
66 op_queue->mul_accumulate(
a, x);
67 op_queue->mul_accumulate(
b, x);
68 op_queue->mul_accumulate(c, x);
70 add_hiding_op_for_test(op_queue);
86 for (
auto i = 0; i < 8; i++) {
88 op_queue->mul_accumulate(Curve::Group::affine_point_at_infinity, x);
91 for (
auto i = 0; i < 8; i++) {
93 op_queue->mul_accumulate(g, 0);
97 add_hiding_op_for_test(op_queue);
105 std::vector<FF>& gate_challenges)
111 const FF beta_sqr = beta * beta;
112 relation_parameters.
gamma = gamma;
113 relation_parameters.
beta = beta;
114 relation_parameters.
beta_sqr = beta_sqr;
115 relation_parameters.
beta_cube = beta_sqr * beta;
117 gamma * (gamma + beta_sqr) * (gamma + beta_sqr + beta_sqr) * (gamma + beta_sqr + beta_sqr + beta_sqr);
120 const size_t unmasked_witness_size = pk->circuit_size - NUM_DISABLED_ROWS_IN_SUMCHECK;
122 compute_logderivative_inverse<FF, ECCVMFlavor::LookupRelation>(
123 pk->polynomials, relation_parameters, unmasked_witness_size);
124 compute_grand_products<ECCVMFlavor>(pk->polynomials, relation_parameters, unmasked_witness_size);
127 for (
size_t idx = 0; idx < CONST_ECCVM_LOG_N; idx++) {
141 PCS::compute_opening_proof(prover.
key->commitment_key, opening_claim, ipa_transcript);
152 ASSERT_TRUE(ipa_verified && eccvm_result.reduction_succeeded);
160 EXPECT_THROW(op_queue->get_eccvm_ops(), std::runtime_error);
167 add_hiding_op_for_test(op_queue);
175 PCS::compute_opening_proof(prover.
key->commitment_key, opening_claim, ipa_transcript);
186 ASSERT_TRUE(ipa_verified && eccvm_result.reduction_succeeded);
198 PCS::compute_opening_proof(prover.
key->commitment_key, opening_claim, ipa_transcript);
208 ASSERT_TRUE(ipa_verified && eccvm_result.reduction_succeeded);
220 op_queue->eq_and_reset();
222 add_hiding_op_for_test(op_queue);
230 PCS::compute_opening_proof(prover.
key->commitment_key, opening_claim, ipa_transcript);
240 ASSERT_TRUE(ipa_verified && eccvm_result.reduction_succeeded);
268 PCS::compute_opening_proof(prover.
key->commitment_key, opening_claim, ipa_transcript);
278 ASSERT_TRUE(ipa_verified && eccvm_result.reduction_succeeded);
285 builder.op_queue->add_erroneous_equality_op_for_testing();
294 PCS::compute_opening_proof(prover.
key->commitment_key, opening_claim, ipa_transcript);
304 ASSERT_FALSE(ipa_verified && eccvm_result.reduction_succeeded);
316 std::vector<FF> gate_challenges(CONST_ECCVM_LOG_N);
341 ZKData zk_sumcheck_data = ZKData(CONST_ECCVM_LOG_N, prover_transcript);
343 auto prover_output = sumcheck_prover.
prove(zk_sumcheck_data);
349 std::vector<FF> padding_indicator_array(CONST_ECCVM_LOG_N,
FF(1));
351 sumcheck_verifier.
verify(relation_parameters, gate_challenges, padding_indicator_array);
355 for (
size_t idx = 0; idx < CONST_ECCVM_LOG_N; idx++) {
356 FF true_eval_at_the_challenge = prover_output.round_univariates[idx].evaluate(prover_output.challenge[idx]);
358 EXPECT_TRUE(true_eval_at_the_challenge == verifier_eval_at_the_challenge);
362 FF prover_target_sum = zk_sumcheck_data.libra_challenge * zk_sumcheck_data.libra_total_sum;
367 EXPECT_TRUE(verifier_output.
verified);
392 const auto& labels = bb::ECCVMFlavor::VerificationKey::get_labels();
394 for (
auto [vk_commitment, fixed_commitment] :
zip_view(vk_computed_by_prover.get_all(), fixed_vk.get_all())) {
395 EXPECT_EQ(vk_commitment, fixed_commitment)
396 <<
"Mismatch between vk_commitment and fixed_commitment at label: " << labels[
index];
401 EXPECT_EQ(fixed_vk, vk_computed_by_prover);
Common transcript class for both parties. Stores the data for the current round, as well as the manif...
The proving key is responsible for storing the polynomials used by the prover.
The verification key is responsible for storing the commitments to the precomputed (non-witnessk) pol...
static constexpr size_t ECCVM_FIXED_SIZE
typename Curve::ScalarField FF
static constexpr size_t PROOF_LENGTH_WITHOUT_PUB_INPUTS
BaseTranscript< Codec, HashFunction > Transcript
std::pair< Proof, OpeningClaim > construct_proof()
std::shared_ptr< ProvingKey > key
Unified ECCVM verifier class for both native and recursive verification.
ReductionResult reduce_to_ipa_opening()
Reduce the ECCVM proof to an IPA opening claim.
IPA (inner product argument) commitment scheme class.
The implementation of the sumcheck Prover for statements of the form for multilinear polynomials .
SumcheckOutput< Flavor > prove()
Non-ZK version: Compute round univariate, place it in transcript, compute challenge,...
Implementation of the sumcheck Verifier for statements of the form for multilinear polynomials .
SumcheckOutput< Flavor > verify(const bb::RelationParameters< FF > &relation_parameters, const std::vector< FF > &gate_challenges, const std::vector< FF > &padding_indicator_array)
The Sumcheck verification method. First it extracts round univariate, checks sum (the sumcheck univar...
Representation of the Grumpkin Verifier Commitment Key inside a bn254 circuit.
typename Group::element Element
void complete_proving_key_for_test(bb::RelationParameters< FF > &relation_parameters, std::shared_ptr< PK > &pk, std::vector< FF > &gate_challenges)
ECCVMCircuitBuilder generate_zero_circuit(numeric::RNG *engine=nullptr, bool zero_scalars=1)
ECCVMCircuitBuilder generate_circuit(numeric::RNG *engine=nullptr)
Adds operations in BN254 to the op_queue and then constructs and ECCVM circuit from the op_queue.
void add_hiding_op_for_test(const std::shared_ptr< ECCOpQueue > &op_queue)
Set a hiding op on the op_queue for testing.
RNG & get_debug_randomness(bool reset, std::uint_fast64_t seed)
std::filesystem::path bb_crs_path()
void init_file_crs_factory(const std::filesystem::path &path)
Entry point for Barretenberg command-line interface.
TEST_F(IPATest, ChallengesAreZero)
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Container for parameters used by the grand product (permutation, lookup) Honk relations.
T eccvm_set_permutation_delta
Contains the evaluations of multilinear polynomials at the challenge point . These are computed by S...
std::vector< std::array< FF, 3 > > round_univariate_evaluations
This structure is created to contain various polynomials and constants required by ZK Sumcheck.
static field random_element(numeric::RNG *engine=nullptr) noexcept