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) });
138 EXPECT_FALSE(verifier.
verify_proof(inner_proof).result);
144 StdlibProof stdlib_inner_proof(circuit, inner_proof);
145 VerifierOutput output = verifier.
verify_proof(stdlib_inner_proof);
149 inputs.pairing_inputs = output.points_accumulator;
172 input.
honk_vk->to_field_elements(),
178 constraint.
proof = {};
202 hn_recursion_constraints.reserve(verification_queue.size());
203 for (
const auto& queue_entry : verification_queue) {
212 hn_recursion_constraints.size() == 1
224 auto kernel = acir_format::create_circuit<Builder>(mock_kernel_program, metadata);
226 ivc->accumulate(kernel, kernel_vk);
245 auto kernel = acir_format::create_circuit<Builder>(program);
250 return verification_key;
257 return verification_key;
270 EXPECT_EQ(merge_proof.size(), MERGE_PROOF_SIZE);
282 construct_and_accumulate_mock_app(ivc);
285 construct_and_accumulate_mock_kernel(ivc);
288 construct_and_accumulate_trailing_kernels(ivc);
290 auto proof = ivc->prove();
292 auto vk_and_hash = ivc->get_hiding_kernel_vk_and_hash();
294 EXPECT_TRUE(verifier.
verify(proof));
308 construct_and_accumulate_mock_app(ivc);
313 construct_and_accumulate_mock_kernel(ivc);
316 construct_and_accumulate_mock_app(ivc);
319 construct_and_accumulate_mock_kernel(ivc);
322 construct_and_accumulate_trailing_kernels(ivc);
324 auto proof = ivc->prove();
327 EXPECT_TRUE(verifier.
verify(proof));
341 construct_and_accumulate_mock_app(ivc);
344 construct_and_accumulate_mock_kernel(ivc);
345 expected_kernel_vk = ivc->verification_queue.back().honk_vk;
355 AcirProgram program = construct_mock_kernel_program(ivc->verification_queue);
358 kernel_vk = construct_kernel_vk_from_acir_program(program);
362 EXPECT_EQ(*kernel_vk.get(), *expected_kernel_vk.get());
377 construct_and_accumulate_mock_app(ivc);
380 construct_and_accumulate_mock_kernel(ivc);
381 EXPECT_TRUE(ivc->verification_queue.size() == 1);
385 construct_and_accumulate_mock_kernel(ivc);
386 expected_kernel_vk = ivc->verification_queue.back().honk_vk;
396 AcirProgram program = construct_mock_kernel_program(ivc->verification_queue);
398 kernel_vk = construct_kernel_vk_from_acir_program(program);
402 EXPECT_EQ(*kernel_vk.get(), *expected_kernel_vk.get());
417 construct_and_accumulate_mock_app(ivc);
420 construct_and_accumulate_mock_kernel(ivc);
423 construct_and_accumulate_mock_kernel(ivc);
426 EXPECT_TRUE(ivc->verification_queue.size() == 1);
428 construct_and_accumulate_mock_kernel(ivc);
430 expected_kernel_vk = ivc->verification_queue.back().honk_vk;
440 AcirProgram program = construct_mock_kernel_program(ivc->verification_queue);
443 kernel_vk = construct_kernel_vk_from_acir_program(program);
447 EXPECT_EQ(*kernel_vk.get(), *expected_kernel_vk.get());
464 construct_and_accumulate_mock_app(ivc);
468 construct_and_accumulate_mock_kernel(ivc);
471 construct_and_accumulate_mock_app(ivc);
475 EXPECT_TRUE(ivc->verification_queue.size() == 2);
477 construct_and_accumulate_mock_kernel(ivc);
480 expected_kernel_vk = ivc->verification_queue.back().honk_vk;
491 AcirProgram program = construct_mock_kernel_program(ivc->verification_queue);
494 kernel_vk = construct_kernel_vk_from_acir_program(program);
498 EXPECT_EQ(*kernel_vk.get(), *expected_kernel_vk.get());
513 construct_and_accumulate_mock_app(ivc);
518 construct_and_accumulate_mock_kernel(ivc);
521 construct_and_accumulate_trailing_kernels(ivc);
524 expected_hiding_kernel_vk = ivc->verification_queue[0].honk_vk;
535 Chonk::QUEUE_TYPE::HN_FINAL,
537 AcirProgram program = construct_mock_kernel_program(ivc->verification_queue);
539 kernel_vk = construct_kernel_vk_from_acir_program(program);
543 EXPECT_EQ(*kernel_vk.get(), *expected_hiding_kernel_vk.get());
554 Builder app_circuit = construct_mock_UH_recursion_app_circuit(ivc,
false);
557 ivc->accumulate(app_circuit, get_verification_key(app_circuit));
560 construct_and_accumulate_mock_kernel(ivc);
562 construct_and_accumulate_trailing_kernels(ivc);
564 auto proof = ivc->prove();
567 EXPECT_TRUE(verifier.
verify(proof));
582 Builder app_circuit = construct_mock_UH_recursion_app_circuit(ivc,
true);
583 ivc->accumulate(app_circuit, get_verification_key(app_circuit));
586 construct_and_accumulate_mock_kernel(ivc);
589 construct_and_accumulate_trailing_kernels(ivc);
592 auto proof = ivc->prove();
595 EXPECT_FALSE(verifier.
verify(proof));
611 AcirProgram program = construct_mock_kernel_program(ivc->verification_queue);
614 auto kernel = acir_format::create_circuit<Builder>(program, metadata);
623 size_t actual_ecc_rows = kernel.op_queue->get_num_rows();
627 size_t actual_ultra_ops = kernel.op_queue->get_current_subtable_size();
644 AcirProgram program = construct_mock_kernel_program(ivc->verification_queue);
647 auto kernel = acir_format::create_circuit<Builder>(program, metadata);
656 size_t actual_ecc_rows = kernel.op_queue->get_num_rows();
660 size_t actual_ultra_ops = kernel.op_queue->get_current_subtable_size();
676 AcirProgram program = construct_mock_kernel_program(ivc->verification_queue);
679 auto kernel = acir_format::create_circuit<Builder>(program, metadata);
688 size_t actual_ecc_rows = kernel.op_queue->get_num_rows();
692 size_t actual_ultra_ops = kernel.op_queue->get_current_subtable_size();
708 AcirProgram program = construct_mock_kernel_program(ivc->verification_queue);
711 auto kernel = acir_format::create_circuit<Builder>(program, metadata);
720 size_t actual_ecc_rows = kernel.op_queue->get_num_rows();
724 size_t actual_ultra_ops = kernel.op_queue->get_current_subtable_size();
740 AcirProgram program = construct_mock_kernel_program(ivc->verification_queue);
748 "hn_recursion_data constraints/indices size mismatch");
759 AcirProgram program = construct_mock_kernel_program(ivc->verification_queue);
768 "mismatch in number of recursive verifications");
779 AcirProgram program = construct_mock_kernel_program(ivc->verification_queue);
787 "unexpected non-empty public_inputs in HN constraint");
798 AcirProgram program = construct_mock_kernel_program(ivc->verification_queue);
807 "ACIR constraint proof_type does not match IVC queue type");
#define EXPECT_THROW_WITH_MESSAGE(code, expectedMessageRegex)
#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.
QUEUE_TYPE
Proof type determining recursive verification logic in kernel circuits.
std::deque< VerifierInputs > VerificationQueue
stdlib::recursion::PairingPoints< stdlib::bn254< ClientCircuit > > PairingPoints
Verifier for Chonk IVC proofs (both native and recursive).
Output verify(const Proof &proof)
Verify a Chonk proof.
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
NativeVerificationKey_< PrecomputedEntities< Commitment >, Codec, HashFunction, CommitmentKey > VerificationKey
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.
Base Native verification key class.
The recursive counterpart to the "native" Ultra flavor.
Output verify_proof(const Proof &proof)
Perform ultra verification.
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
static constexpr field zero()
An object storing two EC points that represent the inputs to a pairing check.
Output type for recursive ultra verification.