13#include <gtest/gtest.h>
69 EXPECT_EQ(ivc->verification_queue.size(), 1);
70 EXPECT_EQ(ivc->verification_queue[0].type, QUEUE_TYPE::PG);
74 EXPECT_EQ(ivc->verification_queue.size(), 1);
75 EXPECT_EQ(ivc->verification_queue[0].type, QUEUE_TYPE::PG_TAIL);
79 EXPECT_EQ(ivc->verification_queue.size(), 1);
80 EXPECT_EQ(ivc->verification_queue[0].type, QUEUE_TYPE::PG_FINAL);
91 const size_t num_gates = (1 << log_num_gates);
92 for (
size_t i = 0; i < num_gates; ++i) {
94 uint32_t a_idx =
builder.add_variable(
a);
99 uint32_t b_idx =
builder.add_variable(
b);
100 uint32_t c_idx =
builder.add_variable(c);
101 uint32_t d_idx =
builder.add_variable(d);
103 builder.create_big_add_gate({ a_idx, b_idx, c_idx, d_idx,
fr(1),
fr(1),
fr(1),
fr(-1),
fr(0) });
106 InnerPairingPoints::add_default_to_public_inputs(
builder);
141 EXPECT_FALSE(verifier.template verify_proof<DefaultIO>(inner_proof).result);
147 StdlibProof stdlib_inner_proof(circuit, inner_proof);
148 VerifierOutput output = verifier.template verify_proof<StdlibIO>(stdlib_inner_proof);
152 inputs.pairing_inputs = output.points_accumulator;
170 std::vector<FF> key_witnesses = input.
honk_vk->to_field_elements();
171 FF key_hash_witness = input.
honk_vk->hash();
172 std::vector<FF> proof_witnesses = input.
proof;
175 auto [key_indices, key_hash_index, proof_indices, public_inputs_indices] =
177 witness, proof_witnesses, key_witnesses, key_hash_witness, 0);
181 switch (input.
type) {
182 case QUEUE_TYPE::OINK:
188 case QUEUE_TYPE::PG_FINAL:
191 case QUEUE_TYPE::PG_TAIL:
195 throw std::runtime_error(
"Invalid proof type");
201 .public_inputs = public_inputs_indices,
202 .key_hash = key_hash_index,
203 .proof_type = proof_type,
226 pg_recursion_constraints.reserve(verification_queue.size());
227 for (
const auto& queue_entry : verification_queue) {
246 auto kernel = acir_format::create_circuit<Builder>(mock_kernel_program, metadata);
248 ivc->accumulate(kernel, kernel_vk);
269 Builder kernel = acir_format::create_circuit<Builder>(program);
274 return verification_key;
282 return verification_key;
295 EXPECT_EQ(merge_proof.size(), MERGE_PROOF_SIZE);
308 construct_and_accumulate_mock_app(ivc, trace_settings);
311 construct_and_accumulate_mock_kernel(ivc, trace_settings);
314 construct_and_accumulate_trailing_kernels(ivc, trace_settings);
316 EXPECT_TRUE(ivc->prove_and_verify());
330 construct_and_accumulate_mock_app(ivc, trace_settings);
335 construct_and_accumulate_mock_kernel(ivc, trace_settings);
338 construct_and_accumulate_mock_app(ivc, trace_settings);
341 construct_and_accumulate_mock_kernel(ivc, trace_settings);
344 construct_and_accumulate_trailing_kernels(ivc, trace_settings);
346 EXPECT_TRUE(ivc->prove_and_verify());
360 construct_and_accumulate_mock_app(ivc, trace_settings);
363 construct_and_accumulate_mock_kernel(ivc, trace_settings);
364 expected_kernel_vk = ivc->verification_queue.back().honk_vk;
374 AcirProgram program = construct_mock_kernel_program(ivc->verification_queue);
377 kernel_vk = construct_kernel_vk_from_acir_program(program, trace_settings);
381 EXPECT_EQ(*kernel_vk.get(), *expected_kernel_vk.get());
397 construct_and_accumulate_mock_app(ivc, trace_settings);
400 construct_and_accumulate_mock_kernel(ivc, trace_settings);
401 EXPECT_TRUE(ivc->verification_queue.size() == 1);
405 construct_and_accumulate_mock_kernel(ivc, trace_settings);
406 expected_kernel_vk = ivc->verification_queue.back().honk_vk;
416 AcirProgram program = construct_mock_kernel_program(ivc->verification_queue);
418 kernel_vk = construct_kernel_vk_from_acir_program(program, trace_settings);
422 EXPECT_EQ(*kernel_vk.get(), *expected_kernel_vk.get());
438 construct_and_accumulate_mock_app(ivc, trace_settings);
441 construct_and_accumulate_mock_kernel(ivc, trace_settings);
444 construct_and_accumulate_mock_kernel(ivc, trace_settings);
447 EXPECT_TRUE(ivc->verification_queue.size() == 1);
449 construct_and_accumulate_mock_kernel(ivc, trace_settings);
451 expected_kernel_vk = ivc->verification_queue.back().honk_vk;
461 AcirProgram program = construct_mock_kernel_program(ivc->verification_queue);
464 kernel_vk = construct_kernel_vk_from_acir_program(program, trace_settings);
468 EXPECT_EQ(*kernel_vk.get(), *expected_kernel_vk.get());
486 construct_and_accumulate_mock_app(ivc, trace_settings);
490 construct_and_accumulate_mock_kernel(ivc, trace_settings);
493 construct_and_accumulate_mock_app(ivc, trace_settings);
497 EXPECT_TRUE(ivc->verification_queue.size() == 2);
499 construct_and_accumulate_mock_kernel(ivc, trace_settings);
502 expected_kernel_vk = ivc->verification_queue.back().honk_vk;
513 AcirProgram program = construct_mock_kernel_program(ivc->verification_queue);
516 kernel_vk = construct_kernel_vk_from_acir_program(program, trace_settings);
520 EXPECT_EQ(*kernel_vk.get(), *expected_kernel_vk.get());
536 construct_and_accumulate_mock_app(ivc, trace_settings);
541 construct_and_accumulate_mock_kernel(ivc, trace_settings);
544 construct_and_accumulate_trailing_kernels(ivc, trace_settings);
547 expected_hiding_kernel_vk = ivc->verification_queue[0].honk_vk;
558 AcirProgram program = construct_mock_kernel_program(ivc->verification_queue);
560 kernel_vk = construct_kernel_vk_from_acir_program(program,
TraceSettings());
564 EXPECT_EQ(*kernel_vk.get(), *expected_hiding_kernel_vk.get());
577 Builder app_circuit = construct_mock_UH_recursion_app_circuit(ivc,
false);
580 ivc->accumulate(app_circuit, get_verification_key(app_circuit, trace_settings));
583 construct_and_accumulate_mock_kernel(ivc, trace_settings);
585 construct_and_accumulate_trailing_kernels(ivc, trace_settings);
587 EXPECT_TRUE(ivc->prove_and_verify());
600 Builder app_circuit = construct_mock_UH_recursion_app_circuit(ivc,
true);
601 ivc->accumulate(app_circuit, get_verification_key(app_circuit, trace_settings));
604 construct_and_accumulate_mock_kernel(ivc, trace_settings);
607 construct_and_accumulate_trailing_kernels(ivc, trace_settings);
610 EXPECT_FALSE(ivc->prove_and_verify());
static std::shared_ptr< ClientIVC::MegaVerificationKey > get_kernel_vk_from_circuit(Builder &kernel, TraceSettings trace_settings)
static RecursionConstraint create_recursion_constraint(const VerifierInputs &input, SlabVector< FF > &witness)
Create an ACIR RecursionConstraint given the corresponding verifier inputs.
static constexpr size_t NUM_TRAILING_KERNELS
static Builder construct_mock_app_circuit(const std::shared_ptr< ClientIVC > &ivc)
Constuct a simple arbitrary circuit to represent a mock app circuit.
static std::shared_ptr< ClientIVC::MegaVerificationKey > construct_kernel_vk_from_acir_program(AcirProgram &program, const TraceSettings &trace_settings)
Construct a kernel circuit VK from an acir program with IVC recursion constraints.
static void construct_and_accumulate_trailing_kernels(const std::shared_ptr< ClientIVC > &ivc, TraceSettings trace_settings)
static UltraCircuitBuilder create_inner_circuit(size_t log_num_gates=10)
ClientIVC::VerificationQueue VerificationQueue
static AcirProgram construct_mock_kernel_program(const VerificationQueue &verification_queue)
Generate an acir program {constraints, witness} for a mock kernel.
static std::shared_ptr< VerificationKey > get_verification_key(Builder &builder_in, const TraceSettings &trace_settings)
static void construct_and_accumulate_mock_app(std::shared_ptr< ClientIVC > ivc, TraceSettings trace_settings)
static Builder construct_mock_UH_recursion_app_circuit(const std::shared_ptr< ClientIVC > &ivc, const bool tamper_vk)
Constuct a mock app circuit with a UH recursive verifier.
static void construct_and_accumulate_mock_kernel(std::shared_ptr< ClientIVC > ivc, TraceSettings trace_settings)
std::deque< VerifierInputs > VerificationQueue
stdlib::recursion::PairingPoints< ClientCircuit > PairingPoints
MergeProver::MergeProof MergeProof
static void add_some_ecc_op_gates(MegaBuilder &builder)
Generate a simple test circuit with some ECC op gates and conventional arithmetic gates.
std::shared_ptr< ECCOpQueue > op_queue
The verification key is responsible for storing the commitments to the precomputed (non-witness) poly...
static void add_arithmetic_gates(Builder &builder, const size_t num_gates=4)
Add a specified number of arithmetic gates to the provided circuit.
The recursive counterpart to the "native" Ultra flavor.
static constexpr element one
A simple wrapper around a vector of stdlib field elements representing a proof.
Manages the data that is propagated on the public inputs of an application/function circuit.
std::filesystem::path bb_crs_path()
void init_file_crs_factory(const std::filesystem::path &path)
TEST_F(BoomerangGoblinRecursiveVerifierTests, graph_description_basic)
Construct and check a goblin recursive verification circuit.
Entry point for Barretenberg command-line interface.
field< Bn254FrParams > fr
std::vector< T, bb::ContainerSlabAllocator< T > > SlabVector
A vector that uses the slab allocator.
MegaCircuitBuilder_< field< Bn254FrParams > > MegaCircuitBuilder
VerifierCommitmentKey< Curve > vk
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
static field random_element(numeric::RNG *engine=nullptr) noexcept
An object storing two EC points that represent the inputs to a pairing check.
static void add_default_to_public_inputs(Builder &builder)
Adds default public inputs to the builder.