10#include <gtest/gtest.h>
27 static void add_random_ops(std::shared_ptr<bb::ECCOpQueue>& op_queue,
size_t count = 1)
29 for (
size_t i = 0; i < count; i++) {
30 op_queue->random_op_ultra_only();
34 static void add_mixed_ops(std::shared_ptr<bb::ECCOpQueue>& op_queue,
size_t count = 100)
39 for (
size_t i = 0; i < count; i++) {
40 op_queue->add_accumulate(P1);
41 op_queue->mul_accumulate(P2, z);
43 op_queue->eq_and_reset();
48 const Fq& evaluation_challenge_x,
49 const size_t circuit_size_parameter = 500)
54 op_queue->no_op_ultra_only();
62 return CircuitBuilder{ batching_challenge_v, evaluation_challenge_x, op_queue };
66 const Fq& evaluation_challenge_x,
67 const Fq& batching_challenge_v)
72 auto initial_transcript = prover_transcript->export_proof();
76 verifier_transcript->template receive_from_prover<Fq>(
"init");
90 uint256_t accumulated_result = prover.get_accumulated_result();
94 op_queue_commitments[0] =
95 proving_key->proving_key->commitment_key.commit(proving_key->proving_key->polynomials.op);
96 op_queue_commitments[1] =
97 proving_key->proving_key->commitment_key.commit(proving_key->proving_key->polynomials.x_lo_y_hi);
98 op_queue_commitments[2] =
99 proving_key->proving_key->commitment_key.commit(proving_key->proving_key->polynomials.x_hi_z_1);
100 op_queue_commitments[3] =
101 proving_key->proving_key->commitment_key.commit(proving_key->proving_key->polynomials.y_lo_z_2);
105 proof, evaluation_challenge_x, batching_challenge_v, accumulated_result, op_queue_commitments);
124 CircuitBuilder circuit_builder = generate_test_circuit(batching_challenge_v, evaluation_challenge_x);
129 prover_transcript->export_proof();
151 CircuitBuilder circuit_builder = generate_test_circuit(batching_challenge_v, evaluation_challenge_x);
154 bool verified = prove_and_verify(circuit_builder, evaluation_challenge_x, batching_challenge_v);
155 EXPECT_TRUE(verified);
172 op_queue->no_op_ultra_only();
174 add_mixed_ops(op_queue, 100);
176 auto circuit_builder =
CircuitBuilder{ batching_challenge_v, evaluation_challenge_x, op_queue,
true };
179 bool verified = prove_and_verify(circuit_builder, evaluation_challenge_x, batching_challenge_v);
180 EXPECT_TRUE(verified);
197 prover_transcript->export_proof();
205 auto compare_computed_vk_against_fixed = [&](
size_t circuit_size_parameter) {
207 generate_test_circuit(batching_challenge_v, evaluation_challenge_x, circuit_size_parameter);
211 auto labels = TranslatorFlavor::VerificationKey::get_labels();
213 for (
auto [vk_commitment, fixed_commitment] :
zip_view(computed_vk.get_all(), fixed_vk.get_all())) {
214 EXPECT_EQ(vk_commitment, fixed_commitment)
215 <<
"Mismatch between computed vk_commitment and fixed_commitment at label: " << labels[
index];
219 EXPECT_EQ(computed_vk, fixed_vk);
223 const size_t circuit_size_parameter_1 = 1 << 2;
224 const size_t circuit_size_parameter_2 = 1 << 3;
226 compare_computed_vk_against_fixed(circuit_size_parameter_1);
227 compare_computed_vk_against_fixed(circuit_size_parameter_2);
static bool prove_and_verify(const CircuitBuilder &circuit_builder, const Fq &evaluation_challenge_x, const Fq &batching_challenge_v)
static void add_random_ops(std::shared_ptr< bb::ECCOpQueue > &op_queue, size_t count=1)
static CircuitBuilder generate_test_circuit(const Fq &batching_challenge_v, const Fq &evaluation_challenge_x, const size_t circuit_size_parameter=500)
static void SetUpTestSuite()
static void add_mixed_ops(std::shared_ptr< bb::ECCOpQueue > &op_queue, size_t count=100)
Common transcript class for both parties. Stores the data for the current round, as well as the manif...
Used to construct execution trace representations of elliptic curve operations.
static const size_t OP_QUEUE_SIZE
TranslatorCircuitBuilder creates a circuit that evaluates the correctness of the evaluation of EccOpQ...
static constexpr size_t NUM_RANDOM_OPS_END
static constexpr size_t NUM_RANDOM_OPS_START
static bool check(const Builder &circuit)
Check the witness satisifies the circuit.
The verification key is responsible for storing the commitments to the precomputed (non-witnessk) pol...
TranslatorCircuitBuilder CircuitBuilder
static constexpr size_t PROOF_LENGTH_WITHOUT_PUB_INPUTS
NativeTranscript Transcript
HonkProof construct_proof()
bool verify_proof(const HonkProof &proof, const uint256_t &evaluation_input_x, const BF &batching_challenge_v, const uint256_t &accumulated_result, const std::array< Commitment, TranslatorFlavor::NUM_OP_QUEUE_WIRES > &op_queue_wire_commitments)
This function verifies a TranslatorFlavor Honk proof for given program settings.
static affine_element random_element(numeric::RNG *engine=nullptr) noexcept
Samples a random point on the curve.
group_elements::affine_element< Fq, Fr, Params > affine_element
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.
field< Bn254FqParams > fq
TEST_F(IPATest, ChallengesAreZero)
field< Bn254FrParams > fr
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
static field random_element(numeric::RNG *engine=nullptr) noexcept