12#include <gtest/gtest.h>
61 for (
size_t idx = 0; idx < num_iterations; idx++) {
62 op_queue->add_accumulate(
a);
63 op_queue->mul_accumulate(
a, x);
64 op_queue->mul_accumulate(
b, x);
65 op_queue->mul_accumulate(
b, y);
66 op_queue->add_accumulate(
a);
67 op_queue->mul_accumulate(
b, x);
68 op_queue->eq_and_reset();
69 op_queue->add_accumulate(c);
70 op_queue->mul_accumulate(
a, x);
71 op_queue->mul_accumulate(
b, x);
72 op_queue->eq_and_reset();
73 op_queue->mul_accumulate(
a, x);
74 op_queue->mul_accumulate(
b, x);
75 op_queue->mul_accumulate(c, x);
90 info(
"ECCVM Recursive Verifier");
93 RecursiveVerifier verifier{ &outer_circuit, verification_key, stdlib_verifier_transcript };
94 verifier.transcript->enable_manifest();
95 auto [opening_claim, ipa_transcript] = verifier.verify_proof(proof);
101 EXPECT_EQ(outer_circuit.
failed(),
false) << outer_circuit.
err();
108 native_verifier.
transcript->enable_manifest();
109 bool native_result = native_verifier.
verify_proof(proof);
110 EXPECT_TRUE(native_result);
111 auto recursive_manifest = verifier.transcript->get_manifest();
112 auto native_manifest = native_verifier.
transcript->get_manifest();
114 ASSERT_GT(recursive_manifest.size(), 0);
115 for (
size_t i = 0; i < recursive_manifest.size(); ++i) {
116 EXPECT_EQ(recursive_manifest[i], native_manifest[i])
117 <<
"Recursive Verifier/Verifier manifest discrepency in round " << i;
121 EXPECT_EQ(
static_cast<uint64_t
>(verifier.key->log_circuit_size.get_value()),
122 verification_key->log_circuit_size);
123 EXPECT_EQ(
static_cast<uint64_t
>(verifier.key->num_public_inputs.get_value()),
124 verification_key->num_public_inputs);
125 for (
auto [vk_poly, native_vk_poly] :
zip_view(verifier.key->get_all(), verification_key->get_all())) {
126 EXPECT_EQ(vk_poly.get_value(), native_vk_poly);
133 OuterProver prover(prover_instance, verification_key);
136 bool verified = verifier.template verify_proof<DefaultIO>(proof).result;
138 ASSERT_TRUE(verified);
142 uint32_t NUM_GATES_EXPECTED = 216315;
144 <<
"Ultra-arithmetized ECCVM Recursive verifier gate count changed! Update this value if you are sure this "
151 builder.op_queue->add_erroneous_equality_op_for_testing();
161 RecursiveVerifier verifier{ &outer_circuit, verification_key, stdlib_verifier_transcript };
162 [[maybe_unused]]
auto output = verifier.verify_proof(proof);
172 for (
size_t idx = 0; idx < 2; idx++) {
179 tamper_with_proof<InnerProver, InnerFlavor>(proof.
pre_ipa_proof,
static_cast<bool>(idx));
185 RecursiveVerifier verifier{ &outer_circuit, verification_key, stdlib_verifier_transcript };
186 auto [opening_claim, ipa_proof] = verifier.verify_proof(proof);
200 &outer_circuit, 1UL << CONST_ECCVM_LOG_N, native_pcs_vk);
204 ipa_transcript->load_proof(ipa_proof);
215 auto get_blocks = [](
size_t inner_size)
219 InnerProver inner_prover(inner_circuit, prover_transcript);
228 RecursiveVerifier verifier{ &outer_circuit, verification_key, stdlib_verifier_transcript };
230 auto [opening_claim, ipa_transcript] = verifier.verify_proof(inner_proof);
234 auto outer_verification_key =
237 return { outer_circuit.
blocks, outer_verification_key };
240 auto [blocks_20, verification_key_20] = get_blocks(20);
241 auto [blocks_40, verification_key_40] = get_blocks(40);
243 compare_ultra_blocks_and_verification_keys<OuterFlavor>({ blocks_20, blocks_40 },
244 { verification_key_20, verification_key_40 });
#define BB_DISABLE_ASSERTS()
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.
The verification key is responsible for storing the commitments to the precomputed (non-witnessk) pol...
typename Curve::ScalarField FF
ECCVMCircuitBuilder CircuitBuilder
typename G1::affine_element Commitment
typename Curve::BaseField BF
NativeTranscript Transcript
ECCVMProof construct_proof()
std::shared_ptr< ProvingKey > key
StdlibTranscript< CircuitBuilder > Transcript
UltraCircuitBuilder CircuitBuilder
static void test_recursive_verification()
static void test_recursive_verification_failure()
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 test_recursive_verification_failure_tampered_proof()
static void SetUpTestSuite()
std::conditional_t< IsMegaBuilder< OuterBuilder >, MegaFlavor, UltraFlavor > OuterFlavor
static void test_independent_vk_hash()
bool verify_proof(const ECCVMProof &proof)
This function verifies an ECCVM Honk proof for given program settings.
std::shared_ptr< Transcript > transcript
IPA (inner product argument) commitment scheme class.
A ProverInstance is normally constructed from a finalized circuit and it contains all the information...
static bool check(const Builder &circuit)
Check the witness satisifies the circuit.
size_t get_num_finalized_gates() const override
Get the number of gates in a finalized circuit.
size_t get_estimated_num_finalized_gates() const override
Get the final number of gates in a circuit, which consists of the sum of: 1) Current number number of...
ExecutionTrace_ ExecutionTrace
Representation of the Grumpkin Verifier Commitment Key inside a bn254 circuit.
typename Group::element 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.
TEST_F(IPATest, ChallengesAreZero)
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
static field random_element(numeric::RNG *engine=nullptr) noexcept
static void add_default_to_public_inputs(Builder &builder)
Adds default public inputs to the builder.