15#include <gtest/gtest.h>
67 for (
size_t idx = 0; idx < num_iterations; idx++) {
68 op_queue->add_accumulate(
a);
69 op_queue->mul_accumulate(
a, x);
70 op_queue->mul_accumulate(
b, x);
71 op_queue->mul_accumulate(
b, y);
72 op_queue->add_accumulate(
a);
73 op_queue->mul_accumulate(
b, x);
74 op_queue->eq_and_reset();
75 op_queue->add_accumulate(c);
76 op_queue->mul_accumulate(
a, x);
77 op_queue->mul_accumulate(
b, x);
78 op_queue->eq_and_reset();
79 op_queue->mul_accumulate(
a, x);
80 op_queue->mul_accumulate(
b, x);
81 op_queue->mul_accumulate(c, x);
99 PCS::compute_opening_proof(prover.
key->commitment_key, opening_claim, ipa_transcript);
100 HonkProof ipa_proof = ipa_transcript->export_proof();
104 info(
"ECCVM Recursive Verifier");
110 [[maybe_unused]]
auto recursive_result = verifier.reduce_to_ipa_opening();
116 EXPECT_EQ(outer_circuit.
failed(),
false) << outer_circuit.
err();
123 verifier_transcript->enable_manifest();
128 ipa_verify_transcript->load_proof(ipa_proof);
131 EXPECT_TRUE(ipa_verified && native_result.reduction_succeeded);
132 auto recursive_manifest = verifier.get_transcript()->get_manifest();
133 auto native_manifest = native_verifier.
get_transcript()->get_manifest();
135 ASSERT_GT(recursive_manifest.size(), 0);
136 for (
size_t i = 0; i < recursive_manifest.size(); ++i) {
137 EXPECT_EQ(recursive_manifest[i], native_manifest[i])
138 <<
"Recursive Verifier/Verifier manifest discrepency in round " << i;
142 EXPECT_EQ(
static_cast<uint64_t
>(verifier.get_verification_key()->log_circuit_size.get_value()),
143 verification_key->log_circuit_size);
144 EXPECT_EQ(
static_cast<uint64_t
>(verifier.get_verification_key()->num_public_inputs.get_value()),
145 verification_key->num_public_inputs);
146 for (
auto [vk_poly, native_vk_poly] :
147 zip_view(verifier.get_verification_key()->get_all(), verification_key->get_all())) {
148 EXPECT_EQ(vk_poly.get_value(), native_vk_poly);
156 OuterProver prover(prover_instance, verification_key);
161 ASSERT_TRUE(verified);
166 <<
"Ultra-arithmetized ECCVM Recursive verifier gate count changed! Update this value if you are sure this "
173 builder.op_queue->add_erroneous_equality_op_for_testing();
181 PCS::compute_opening_proof(prover.
key->commitment_key, opening_claim, ipa_transcript);
182 HonkProof ipa_proof = ipa_transcript->export_proof();
193 info(
"Recursive Verifier: estimated num finalized gates = ",
202 for (
size_t idx = 0; idx < 2; idx++) {
210 PCS::compute_opening_proof(prover.
key->commitment_key, opening_claim, ipa_transcript_prover);
211 HonkProof ipa_proof_native = ipa_transcript_prover->export_proof();
214 tamper_with_proof<InnerProver, InnerFlavor>(proof,
static_cast<bool>(idx));
234 &outer_circuit, 1UL << CONST_ECCVM_LOG_N, native_pcs_vk);
240 stdlib_pcs_vkey, recursive_result.ipa_claim, ipa_transcript));
249 auto get_blocks = [](
size_t inner_size)
253 InnerProver inner_prover(inner_circuit, prover_transcript);
259 PCS::compute_opening_proof(inner_prover.
key->commitment_key, opening_claim, ipa_transcript);
260 HonkProof ipa_proof = ipa_transcript->export_proof();
273 auto outer_verification_key =
276 return { outer_circuit.
blocks, outer_verification_key };
279 auto [blocks_20, verification_key_20] = get_blocks(20);
280 auto [blocks_40, verification_key_40] = get_blocks(40);
282 compare_ultra_blocks_and_verification_keys<OuterFlavor>({ blocks_20, blocks_40 },
283 { 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...
static constexpr size_t ECCVM_FIXED_SIZE
typename Curve::ScalarField FF
ECCVMCircuitBuilder CircuitBuilder
typename G1::affine_element Commitment
typename Curve::BaseField BF
BaseTranscript< Codec, HashFunction > Transcript
std::pair< Proof, OpeningClaim > 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()
Unified ECCVM verifier class for both native and recursive verification.
std::shared_ptr< Transcript > get_transcript() const
ReductionResult reduce_to_ipa_opening()
Reduce the ECCVM proof to an IPA opening claim.
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.
ExecutionTrace_ ExecutionTrace
size_t get_num_finalized_gates_inefficient(bool ensure_nonzero=true) const
Get the number of gates in the finalized version of the circuit.
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
static field random_element(numeric::RNG *engine=nullptr) noexcept