3#include <gtest/gtest.h>
66 op_queue->add_accumulate(
a);
67 op_queue->mul_accumulate(
a, x);
68 op_queue->mul_accumulate(
b, x);
69 op_queue->mul_accumulate(
b, y);
70 op_queue->add_accumulate(
a);
71 op_queue->mul_accumulate(
b, x);
72 op_queue->eq_and_reset();
73 op_queue->add_accumulate(c);
74 op_queue->mul_accumulate(
a, x);
75 op_queue->mul_accumulate(
b, x);
76 op_queue->eq_and_reset();
77 op_queue->mul_accumulate(
a, x);
78 op_queue->mul_accumulate(
b, x);
79 op_queue->mul_accumulate(c, x);
81 add_hiding_op_for_test(op_queue);
97 for (
auto i = 0; i < 8; i++) {
99 op_queue->mul_accumulate(Curve::Group::affine_point_at_infinity, x);
102 for (
auto i = 0; i < 8; i++) {
104 op_queue->mul_accumulate(g, 0);
108 add_hiding_op_for_test(op_queue);
116 std::vector<FF>& gate_challenges)
122 const FF beta_sqr = beta * beta;
123 relation_parameters.
gamma = gamma;
124 relation_parameters.
beta = beta;
125 relation_parameters.
beta_sqr = beta_sqr;
126 relation_parameters.
beta_cube = beta_sqr * beta;
128 gamma * (gamma + beta_sqr) * (gamma + beta_sqr + beta_sqr) * (gamma + beta_sqr + beta_sqr + beta_sqr);
131 const size_t unmasked_witness_size = pk->circuit_size - NUM_DISABLED_ROWS_IN_SUMCHECK;
133 compute_logderivative_inverse<FF, ECCVMFlavor::LookupRelation>(
134 pk->polynomials, relation_parameters, unmasked_witness_size);
135 compute_grand_products<ECCVMFlavor>(pk->polynomials, relation_parameters, unmasked_witness_size);
138 for (
size_t idx = 0; idx < CONST_ECCVM_LOG_N; idx++) {
152 ECCVMFlavor::PCS::compute_opening_proof(prover.
key->commitment_key, opening_claim, ipa_transcript);
160 bool ipa_verified = ECCVMFlavor::PCS::reduce_verify(
161 verifier.
key->pcs_verification_key, verifier_opening_claim, ipa_verifier_transcript);
166 ASSERT_TRUE(verified);
177 ECCVMFlavor::PCS::compute_opening_proof(prover.
key->commitment_key, opening_claim, ipa_transcript);
184 bool ipa_verified = ECCVMFlavor::PCS::reduce_verify(
185 verifier.
key->pcs_verification_key, verifier_opening_claim, ipa_verifier_transcript);
190 ASSERT_TRUE(verified);
202 op_queue->eq_and_reset();
204 add_hiding_op_for_test(op_queue);
212 ECCVMFlavor::PCS::compute_opening_proof(prover.
key->commitment_key, opening_claim, ipa_transcript);
219 bool ipa_verified = ECCVMFlavor::PCS::reduce_verify(
220 verifier.
key->pcs_verification_key, verifier_opening_claim, ipa_verifier_transcript);
225 ASSERT_TRUE(verified);
253 ECCVMFlavor::PCS::compute_opening_proof(prover.
key->commitment_key, opening_claim, ipa_transcript);
260 bool ipa_verified = ECCVMFlavor::PCS::reduce_verify(
261 verifier.
key->pcs_verification_key, verifier_opening_claim, ipa_verifier_transcript);
266 ASSERT_TRUE(verified);
273 builder.op_queue->add_erroneous_equality_op_for_testing();
282 ECCVMFlavor::PCS::compute_opening_proof(prover.
key->commitment_key, opening_claim, ipa_transcript);
289 bool ipa_verified = ECCVMFlavor::PCS::reduce_verify(
290 verifier.
key->pcs_verification_key, verifier_opening_claim, ipa_verifier_transcript);
294 ASSERT_FALSE(verified);
306 std::vector<FF> gate_challenges(CONST_ECCVM_LOG_N);
331 ZKData zk_sumcheck_data = ZKData(CONST_ECCVM_LOG_N, prover_transcript);
333 auto prover_output = sumcheck_prover.
prove(zk_sumcheck_data);
339 std::vector<FF> padding_indicator_array(CONST_ECCVM_LOG_N,
FF(1));
341 sumcheck_verifier.
verify(relation_parameters, gate_challenges, padding_indicator_array);
345 for (
size_t idx = 0; idx < CONST_ECCVM_LOG_N; idx++) {
346 FF true_eval_at_the_challenge = prover_output.round_univariates[idx].evaluate(prover_output.challenge[idx]);
348 EXPECT_TRUE(true_eval_at_the_challenge == verifier_eval_at_the_challenge);
352 FF prover_target_sum = zk_sumcheck_data.libra_challenge * zk_sumcheck_data.libra_total_sum;
357 EXPECT_TRUE(verifier_output.
verified);
386 auto labels = verifier.
key->get_labels();
388 for (
auto [vk_commitment, fixed_commitment] :
zip_view(vk_computed_by_prover.get_all(), fixed_vk.get_all())) {
389 EXPECT_EQ(vk_commitment, fixed_commitment)
390 <<
"Mismatch between vk_commitment and fixed_commitment at label: " << labels[
index];
395 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...
VerifierCommitmentKey pcs_verification_key
typename Curve::ScalarField FF
static constexpr size_t PROOF_LENGTH_WITHOUT_PUB_INPUTS
NativeTranscript Transcript
std::pair< Proof, OpeningClaim > construct_proof()
std::shared_ptr< ProvingKey > key
Unified ECCVM verifier class for both native and recursive verification.
bool translation_masking_consistency_checked
std::shared_ptr< VerificationKey > key
OpeningClaim< Curve > verify_proof()
Verifies an ECCVM Honk proof for given program settings.
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.
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