15#include <gtest/gtest.h>
67 EXPECT_EQ(ivc->verification_queue.size(), 1);
68 EXPECT_EQ(ivc->verification_queue[0].type, QUEUE_TYPE::HN);
72 EXPECT_EQ(ivc->verification_queue.size(), 1);
73 EXPECT_EQ(ivc->verification_queue[0].type, QUEUE_TYPE::HN_TAIL);
77 EXPECT_EQ(ivc->verification_queue.size(), 1);
78 EXPECT_EQ(ivc->verification_queue[0].type, QUEUE_TYPE::HN_FINAL);
87 const size_t num_gates = (1 << log_num_gates);
88 for (
size_t i = 0; i < num_gates; ++i) {
90 uint32_t a_idx =
builder.add_variable(
a);
95 uint32_t b_idx =
builder.add_variable(
b);
96 uint32_t c_idx =
builder.add_variable(c);
97 uint32_t d_idx =
builder.add_variable(d);
99 builder.create_big_add_gate({ a_idx, b_idx, c_idx, d_idx,
fr(1),
fr(1),
fr(1),
fr(-1),
fr(0) });
137 EXPECT_FALSE(verifier.template verify_proof<DefaultIO>(inner_proof).result);
143 StdlibProof stdlib_inner_proof(circuit, inner_proof);
144 VerifierOutput output = verifier.template verify_proof<StdlibIO>(stdlib_inner_proof);
148 inputs.pairing_inputs = output.points_accumulator;
166 std::vector<FF> key_witnesses = input.
honk_vk->to_field_elements();
167 FF key_hash_witness = input.
honk_vk->hash();
168 std::vector<FF> proof_witnesses = input.
proof;
171 auto [key_indices, key_hash_index, proof_indices, public_inputs_indices] =
173 witness, proof_witnesses, key_witnesses, key_hash_witness, 0);
177 switch (input.
type) {
178 case QUEUE_TYPE::OINK:
184 case QUEUE_TYPE::HN_FINAL:
187 case QUEUE_TYPE::HN_TAIL:
191 throw std::runtime_error(
"Invalid proof type");
197 .public_inputs = public_inputs_indices,
198 .key_hash = key_hash_index,
199 .proof_type = proof_type,
222 hn_recursion_constraints.reserve(verification_queue.size());
223 for (
const auto& queue_entry : verification_queue) {
242 auto kernel = acir_format::create_circuit<Builder>(mock_kernel_program, metadata);
244 ivc->accumulate(kernel, kernel_vk);
263 auto kernel = acir_format::create_circuit<Builder>(program);
268 return verification_key;
275 return verification_key;
288 EXPECT_EQ(merge_proof.size(), MERGE_PROOF_SIZE);
300 construct_and_accumulate_mock_app(ivc);
303 construct_and_accumulate_mock_kernel(ivc);
306 construct_and_accumulate_trailing_kernels(ivc);
308 auto proof = ivc->prove();
322 construct_and_accumulate_mock_app(ivc);
327 construct_and_accumulate_mock_kernel(ivc);
330 construct_and_accumulate_mock_app(ivc);
333 construct_and_accumulate_mock_kernel(ivc);
336 construct_and_accumulate_trailing_kernels(ivc);
338 auto proof = ivc->prove();
352 construct_and_accumulate_mock_app(ivc);
355 construct_and_accumulate_mock_kernel(ivc);
356 expected_kernel_vk = ivc->verification_queue.back().honk_vk;
366 AcirProgram program = construct_mock_kernel_program(ivc->verification_queue);
369 kernel_vk = construct_kernel_vk_from_acir_program(program);
373 EXPECT_EQ(*kernel_vk.get(), *expected_kernel_vk.get());
388 construct_and_accumulate_mock_app(ivc);
391 construct_and_accumulate_mock_kernel(ivc);
392 EXPECT_TRUE(ivc->verification_queue.size() == 1);
396 construct_and_accumulate_mock_kernel(ivc);
397 expected_kernel_vk = ivc->verification_queue.back().honk_vk;
407 AcirProgram program = construct_mock_kernel_program(ivc->verification_queue);
409 kernel_vk = construct_kernel_vk_from_acir_program(program);
413 EXPECT_EQ(*kernel_vk.get(), *expected_kernel_vk.get());
428 construct_and_accumulate_mock_app(ivc);
431 construct_and_accumulate_mock_kernel(ivc);
434 construct_and_accumulate_mock_kernel(ivc);
437 EXPECT_TRUE(ivc->verification_queue.size() == 1);
439 construct_and_accumulate_mock_kernel(ivc);
441 expected_kernel_vk = ivc->verification_queue.back().honk_vk;
451 AcirProgram program = construct_mock_kernel_program(ivc->verification_queue);
454 kernel_vk = construct_kernel_vk_from_acir_program(program);
458 EXPECT_EQ(*kernel_vk.get(), *expected_kernel_vk.get());
475 construct_and_accumulate_mock_app(ivc);
479 construct_and_accumulate_mock_kernel(ivc);
482 construct_and_accumulate_mock_app(ivc);
486 EXPECT_TRUE(ivc->verification_queue.size() == 2);
488 construct_and_accumulate_mock_kernel(ivc);
491 expected_kernel_vk = ivc->verification_queue.back().honk_vk;
502 AcirProgram program = construct_mock_kernel_program(ivc->verification_queue);
505 kernel_vk = construct_kernel_vk_from_acir_program(program);
509 EXPECT_EQ(*kernel_vk.get(), *expected_kernel_vk.get());
524 construct_and_accumulate_mock_app(ivc);
529 construct_and_accumulate_mock_kernel(ivc);
532 construct_and_accumulate_trailing_kernels(ivc);
535 expected_hiding_kernel_vk = ivc->verification_queue[0].honk_vk;
546 Chonk::QUEUE_TYPE::HN_FINAL,
548 AcirProgram program = construct_mock_kernel_program(ivc->verification_queue);
550 kernel_vk = construct_kernel_vk_from_acir_program(program);
554 EXPECT_EQ(*kernel_vk.get(), *expected_hiding_kernel_vk.get());
565 Builder app_circuit = construct_mock_UH_recursion_app_circuit(ivc,
false);
568 ivc->accumulate(app_circuit, get_verification_key(app_circuit));
571 construct_and_accumulate_mock_kernel(ivc);
573 construct_and_accumulate_trailing_kernels(ivc);
575 auto proof = ivc->prove();
590 Builder app_circuit = construct_mock_UH_recursion_app_circuit(ivc,
true);
591 ivc->accumulate(app_circuit, get_verification_key(app_circuit));
594 construct_and_accumulate_mock_kernel(ivc);
597 construct_and_accumulate_trailing_kernels(ivc);
600 auto proof = ivc->prove();
616 AcirProgram program = construct_mock_kernel_program(ivc->verification_queue);
619 auto kernel = acir_format::create_circuit<Builder>(program, metadata);
628 size_t actual_ecc_rows = kernel.op_queue->get_num_rows();
632 size_t actual_ultra_ops = kernel.op_queue->get_current_subtable_size();
649 AcirProgram program = construct_mock_kernel_program(ivc->verification_queue);
652 auto kernel = acir_format::create_circuit<Builder>(program, metadata);
661 size_t actual_ecc_rows = kernel.op_queue->get_num_rows();
665 size_t actual_ultra_ops = kernel.op_queue->get_current_subtable_size();
681 AcirProgram program = construct_mock_kernel_program(ivc->verification_queue);
684 auto kernel = acir_format::create_circuit<Builder>(program, metadata);
693 size_t actual_ecc_rows = kernel.op_queue->get_num_rows();
697 size_t actual_ultra_ops = kernel.op_queue->get_current_subtable_size();
713 AcirProgram program = construct_mock_kernel_program(ivc->verification_queue);
716 auto kernel = acir_format::create_circuit<Builder>(program, metadata);
725 size_t actual_ecc_rows = kernel.op_queue->get_num_rows();
729 size_t actual_ultra_ops = kernel.op_queue->get_current_subtable_size();
#define BB_DISABLE_ASSERTS()
Shared type definitions for the Barretenberg RPC API.
static void construct_and_accumulate_mock_app(std::shared_ptr< Chonk > ivc)
static void construct_and_accumulate_mock_kernel(std::shared_ptr< Chonk > ivc)
static UltraCircuitBuilder create_inner_circuit(size_t log_num_gates=10)
static constexpr size_t NUM_TRAILING_KERNELS
static AcirProgram construct_mock_kernel_program(const VerificationQueue &verification_queue)
Generate an acir program {constraints, witness} for a mock kernel.
Chonk::VerificationQueue VerificationQueue
static void construct_and_accumulate_trailing_kernels(const std::shared_ptr< Chonk > &ivc)
static std::shared_ptr< Chonk::MegaVerificationKey > construct_kernel_vk_from_acir_program(AcirProgram &program)
Construct a kernel circuit VK from an acir program with IVC recursion constraints.
static std::shared_ptr< Chonk::MegaVerificationKey > get_kernel_vk_from_circuit(Builder &kernel)
static Builder construct_mock_app_circuit(const std::shared_ptr< Chonk > &ivc)
Constuct a simple arbitrary circuit to represent a mock app circuit.
static std::shared_ptr< VerificationKey > get_verification_key(Builder &builder_in)
static Builder construct_mock_UH_recursion_app_circuit(const std::shared_ptr< Chonk > &ivc, const bool tamper_vk)
Constuct a mock app circuit with a UH recursive verifier.
static RecursionConstraint create_recursion_constraint(const VerifierInputs &input, std::vector< FF > &witness)
Create an ACIR RecursionConstraint given the corresponding verifier inputs.
std::deque< VerifierInputs > VerificationQueue
static bool verify(const Proof &proof, const VerificationKey &vk)
stdlib::recursion::PairingPoints< stdlib::bn254< 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.
static void add_default(Builder &builder)
Add default public inputs when they are not present.
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
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.