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->load_proof(initial_transcript);
77 verifier_transcript->template receive_from_prover<Fq>(
"init");
91 return verifier.
verify_proof(proof, evaluation_challenge_x, batching_challenge_v);
110 CircuitBuilder circuit_builder = generate_test_circuit(batching_challenge_v, evaluation_challenge_x);
115 prover_transcript->export_proof();
137 CircuitBuilder circuit_builder = generate_test_circuit(batching_challenge_v, evaluation_challenge_x);
140 bool verified = prove_and_verify(circuit_builder, evaluation_challenge_x, batching_challenge_v);
141 EXPECT_TRUE(verified);
158 op_queue->no_op_ultra_only();
160 add_mixed_ops(op_queue, 100);
162 auto circuit_builder =
CircuitBuilder{ batching_challenge_v, evaluation_challenge_x, op_queue,
true };
165 bool verified = prove_and_verify(circuit_builder, evaluation_challenge_x, batching_challenge_v);
166 EXPECT_TRUE(verified);
183 prover_transcript->export_proof();
191 auto compare_computed_vk_against_fixed = [&](
size_t circuit_size_parameter) {
193 generate_test_circuit(batching_challenge_v, evaluation_challenge_x, circuit_size_parameter);
197 auto labels = TranslatorFlavor::VerificationKey::get_labels();
199 for (
auto [vk_commitment, fixed_commitment] :
zip_view(computed_vk.get_all(), fixed_vk.get_all())) {
200 EXPECT_EQ(vk_commitment, fixed_commitment)
201 <<
"Mismatch between computed vk_commitment and fixed_commitment at label: " << labels[index];
205 EXPECT_EQ(computed_vk, fixed_vk);
209 const size_t circuit_size_parameter_1 = 1 << 2;
210 const size_t circuit_size_parameter_2 = 1 << 3;
212 compare_computed_vk_against_fixed(circuit_size_parameter_1);
213 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)
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