11#include <gtest/gtest.h>
63 for (
size_t idx = 0; idx < num_iterations; idx++) {
64 op_queue->add_accumulate(
a);
65 op_queue->mul_accumulate(
a, x);
66 op_queue->mul_accumulate(
b, x);
67 op_queue->mul_accumulate(
b, y);
68 op_queue->add_accumulate(
a);
69 op_queue->mul_accumulate(
b, x);
70 op_queue->eq_and_reset();
71 op_queue->add_accumulate(c);
72 op_queue->mul_accumulate(
a, x);
73 op_queue->mul_accumulate(
b, x);
74 op_queue->eq_and_reset();
75 op_queue->mul_accumulate(
a, x);
76 op_queue->mul_accumulate(
b, x);
77 op_queue->mul_accumulate(c, x);
95 info(
"ECCVM Recursive Verifier");
101 [[maybe_unused]]
auto recursive_result = verifier.reduce_to_triple_ipa_claim();
107 EXPECT_EQ(outer_circuit.
failed(),
false) << outer_circuit.
err();
114 verifier_transcript->enable_manifest();
123 EXPECT_TRUE(ipa_verified && native_result.reduction_succeeded);
124 auto recursive_manifest = verifier.get_transcript()->get_manifest();
125 auto native_manifest = native_verifier.
get_transcript()->get_manifest();
127 ASSERT_GT(recursive_manifest.size(), 0);
128 for (
size_t i = 0; i < recursive_manifest.size(); ++i) {
129 EXPECT_EQ(recursive_manifest[i], native_manifest[i])
130 <<
"Recursive Verifier/Verifier manifest discrepency in round " << i;
134 for (
auto [vk_poly, native_vk_poly] :
135 zip_view(verifier.get_verification_key()->get_all(), verification_key->get_all())) {
136 EXPECT_EQ(vk_poly.get_value(), native_vk_poly);
144 OuterProver prover(prover_instance, verification_key);
149 ASSERT_TRUE(verified);
154 <<
"Ultra-arithmetized ECCVM Recursive verifier gate count changed! Update this value if you are sure this "
161 builder.op_queue->add_erroneous_equality_op_for_testing();
176 info(
"Recursive Verifier: estimated num finalized gates = ",
198 auto proof_data = prover.
transcript->test_get_proof_data();
199 structured_proof.deserialize(proof_data, 0, CONST_ECCVM_LOG_N);
200 structured_proof.serialize(proof_data, CONST_ECCVM_LOG_N);
202 auto original_data = prover.
transcript->test_get_proof_data();
203 ASSERT_EQ(proof_data.size(), original_data.size());
204 EXPECT_EQ(proof_data, original_data);
224 structured_proof.deserialize(
225 prover.
transcript->test_get_proof_data(), 0, CONST_ECCVM_LOG_N);
227 switch (tamper_type) {
239 structured_proof.final_shplonk_q_comm = structured_proof.final_shplonk_q_comm *
FF(2);
251 structured_proof.serialize(prover.
transcript->test_get_proof_data(), CONST_ECCVM_LOG_N);
258 for (
size_t idx = 0; idx < static_cast<size_t>(
TamperType::END); idx++) {
295 EXPECT_FALSE(
CircuitChecker::check(outer_circuit)) <<
"Expected circuit failure for TamperType " << idx;
304 auto get_blocks = [](
size_t inner_size)
308 InnerProver inner_prover(inner_circuit, prover_transcript);
323 auto outer_verification_key =
326 return { outer_circuit.
blocks, outer_verification_key };
329 auto [blocks_20, verification_key_20] = get_blocks(20);
330 auto [blocks_40, verification_key_40] = get_blocks(40);
332 compare_ultra_blocks_and_verification_keys<OuterFlavor>({ blocks_20, blocks_40 },
333 { verification_key_20, verification_key_40 });
bb::field< bb::Bn254FrParams > FF
Common transcript class for both parties. Stores the data for the current round, as well as the manif...
const std::string & err() const
The proving key is responsible for storing the polynomials used by the prover.
static constexpr size_t ECCVM_FIXED_SIZE
typename Curve::ScalarField FF
ECCVMCircuitBuilder CircuitBuilder
typename G1::affine_element Commitment
typename Curve::BaseField BF
static constexpr size_t PROOF_LENGTH
static constexpr size_t NUM_PRECOMPUTED_ENTITIES
FixedVKAndHash_< PrecomputedEntities< Commitment >, BF, ECCVMHardcodedVKAndHash > VerificationKey
The verification key stores commitments to the precomputed polynomials used by the verifier.
BaseTranscript< Codec, HashFunction > Transcript
std::shared_ptr< Transcript > transcript
StdlibTranscript< CircuitBuilder > Transcript
UltraCircuitBuilder CircuitBuilder
static void test_recursive_verification()
static void tamper_eccvm_proof(InnerProver &prover, typename InnerFlavor::Transcript::Proof &proof, TamperType tamper_type)
static void test_recursive_verification_failure()
@ MODIFY_SUMCHECK_UNIVARIATE
@ MODIFY_TRIPLE_IPA_CLAIM
@ MODIFY_TRANSLATION_EVAL
static InnerBuilder generate_circuit(numeric::RNG *engine=nullptr, const size_t num_iterations=1)
Adds operations in BN254 to the op_queue and then constructs and ECCVM circuit from the op_queue.
InnerFlavor::Commitment InnerG1
static void SetUpTestSuite()
static void test_structured_proof_round_trip()
Verify that StructuredProof<ECCVMFlavor> can round-trip serialize/deserialize a proof.
std::conditional_t< IsMegaBuilder< OuterBuilder >, MegaFlavor, UltraFlavor > OuterFlavor
static void test_recursive_verification_fails()
static void test_independent_vk_hash()
Unified ECCVM verifier class for both native and recursive verification.
ReductionResult reduce_to_triple_ipa_claim()
Reduce the ECCVM proof to a compact TripleIPA verifier claim.
bb::TripleIPA< Curve, CONST_ECCVM_LOG_N > TripleIPA
std::shared_ptr< Transcript > get_transcript() const
Simple verification key class for fixed-size circuits (ECCVM, Translator, AVM).
Contains all the information required by a Honk prover to create a proof, constructed from a finalize...
static bool check(const Builder &circuit)
Check the witness satisifies the circuit.
static NativeAccumulator reduce_to_accumulator(const TripleIpaClaim &claim, const auto &transcript)
static bool verify_accumulator(const VK &vk, const NativeAccumulator &accumulator)
size_t get_num_finalized_gates() const override
Get the number of gates in a finalized circuit.
size_t get_num_finalized_gates_inefficient() const
Get the number of gates in the finalized version of the circuit.
ExecutionTrace_ ExecutionTrace
Output verify_proof(const Proof &proof)
Perform ultra verification.
Representation of the Grumpkin Verifier Commitment Key inside a bn254 circuit.
typename Group::element Element
A simple wrapper around a vector of stdlib field elements representing a proof.
static void add_default(Builder &builder)
Add default public inputs when they are not present.
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.
std::vector< fr > HonkProof
ECCVMVerifier_< ECCVMRecursiveFlavor > ECCVMRecursiveVerifier
TEST_F(IPATest, ChallengesAreZero)
ECCVMVerifier_< ECCVMFlavor > ECCVMVerifier
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Test utility for deserializing/serializing proof data into typed structures.
static field random_element(numeric::RNG *engine=nullptr) noexcept