15#include <gtest/gtest.h>
58 if (is_hiding_kernel) {
71 EXPECT_EQ(ivc->verification_queue.size(), 1);
72 EXPECT_EQ(ivc->verification_queue[0].type, QUEUE_TYPE::HN);
76 EXPECT_EQ(ivc->verification_queue.size(), 1);
77 EXPECT_EQ(ivc->verification_queue[0].type, QUEUE_TYPE::HN_TAIL);
81 EXPECT_EQ(ivc->verification_queue.size(), 1);
82 EXPECT_EQ(ivc->verification_queue[0].type, QUEUE_TYPE::HN_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) });
142 EXPECT_FALSE(verifier.
verify_proof(inner_proof).result);
148 StdlibProof stdlib_inner_proof(circuit, inner_proof);
149 VerifierOutput output = verifier.
verify_proof(stdlib_inner_proof);
153 inputs.pairing_inputs = output.points_accumulator;
176 input.
honk_vk->to_field_elements(),
182 constraint.
proof = {};
206 hn_recursion_constraints.reserve(verification_queue.size());
207 for (
const auto& queue_entry : verification_queue) {
215 for (
size_t idx = 0; idx < hn_recursion_constraints.size(); ++idx) {
227 auto kernel = acir_format::create_circuit<Builder>(mock_kernel_program, metadata);
228 const bool is_hiding_kernel = ivc->num_circuits_accumulated == ivc->get_num_circuits() - 1;
230 ivc->accumulate(kernel, kernel_vk);
247 AcirProgram& program,
bool is_hiding_kernel =
false)
250 auto kernel = acir_format::create_circuit<Builder>(program);
251 if (is_hiding_kernel) {
260 bool is_hiding_kernel =
false)
262 if (is_hiding_kernel) {
280 EXPECT_EQ(merge_proof.size(), MERGE_PROOF_SIZE);
292 construct_and_accumulate_mock_app(ivc);
295 construct_and_accumulate_mock_kernel(ivc);
298 construct_and_accumulate_trailing_kernels(ivc);
300 auto proof = ivc->prove();
302 auto vk_and_hash = ivc->get_hiding_kernel_vk_and_hash();
304 EXPECT_TRUE(verifier.
verify(proof));
318 construct_and_accumulate_mock_app(ivc);
323 construct_and_accumulate_mock_kernel(ivc);
326 construct_and_accumulate_mock_app(ivc);
329 construct_and_accumulate_mock_kernel(ivc);
332 construct_and_accumulate_trailing_kernels(ivc);
334 auto proof = ivc->prove();
337 EXPECT_TRUE(verifier.
verify(proof));
351 construct_and_accumulate_mock_app(ivc);
354 construct_and_accumulate_mock_kernel(ivc);
355 expected_kernel_vk = ivc->verification_queue.back().honk_vk;
365 AcirProgram program = construct_mock_kernel_program(ivc->verification_queue);
368 kernel_vk = construct_kernel_vk_from_acir_program(program);
372 EXPECT_EQ(*kernel_vk.get(), *expected_kernel_vk.get());
387 construct_and_accumulate_mock_app(ivc);
390 construct_and_accumulate_mock_kernel(ivc);
391 EXPECT_TRUE(ivc->verification_queue.size() == 1);
395 construct_and_accumulate_mock_kernel(ivc);
396 expected_kernel_vk = ivc->verification_queue.back().honk_vk;
406 AcirProgram program = construct_mock_kernel_program(ivc->verification_queue);
408 kernel_vk = construct_kernel_vk_from_acir_program(program);
412 EXPECT_EQ(*kernel_vk.get(), *expected_kernel_vk.get());
427 construct_and_accumulate_mock_app(ivc);
430 construct_and_accumulate_mock_kernel(ivc);
433 construct_and_accumulate_mock_kernel(ivc);
436 EXPECT_TRUE(ivc->verification_queue.size() == 1);
438 construct_and_accumulate_mock_kernel(ivc);
440 expected_kernel_vk = ivc->verification_queue.back().honk_vk;
450 AcirProgram program = construct_mock_kernel_program(ivc->verification_queue);
453 kernel_vk = construct_kernel_vk_from_acir_program(program);
457 EXPECT_EQ(*kernel_vk.get(), *expected_kernel_vk.get());
474 construct_and_accumulate_mock_app(ivc);
478 construct_and_accumulate_mock_kernel(ivc);
481 construct_and_accumulate_mock_app(ivc);
485 EXPECT_TRUE(ivc->verification_queue.size() == 2);
487 construct_and_accumulate_mock_kernel(ivc);
490 expected_kernel_vk = ivc->verification_queue.back().honk_vk;
501 AcirProgram program = construct_mock_kernel_program(ivc->verification_queue);
504 kernel_vk = construct_kernel_vk_from_acir_program(program);
508 EXPECT_EQ(*kernel_vk.get(), *expected_kernel_vk.get());
523 construct_and_accumulate_mock_app(ivc);
528 construct_and_accumulate_mock_kernel(ivc);
531 construct_and_accumulate_trailing_kernels(ivc);
534 expected_hiding_kernel_vk = ivc->verification_queue[0].honk_vk;
545 Chonk::QUEUE_TYPE::HN_FINAL,
547 AcirProgram program = construct_mock_kernel_program(ivc->verification_queue);
549 kernel_vk = construct_kernel_vk_from_acir_program(program,
true);
553 EXPECT_EQ(*kernel_vk.get(), *expected_hiding_kernel_vk.get());
564 Builder app_circuit = construct_mock_UH_recursion_app_circuit(ivc,
false);
567 ivc->accumulate(app_circuit, get_verification_key(app_circuit));
570 construct_and_accumulate_mock_kernel(ivc);
572 construct_and_accumulate_trailing_kernels(ivc);
574 auto proof = ivc->prove();
577 EXPECT_TRUE(verifier.
verify(proof));
592 Builder app_circuit = construct_mock_UH_recursion_app_circuit(ivc,
true);
593 ivc->accumulate(app_circuit, get_verification_key(app_circuit));
596 construct_and_accumulate_mock_kernel(ivc);
599 construct_and_accumulate_trailing_kernels(ivc);
602 auto proof = ivc->prove();
605 EXPECT_FALSE(verifier.
verify(proof));
621 AcirProgram program = construct_mock_kernel_program(ivc->verification_queue);
624 auto kernel = acir_format::create_circuit<Builder>(program, metadata);
633 size_t actual_ecc_rows = kernel.op_queue->get_num_rows();
637 size_t actual_ultra_ops = kernel.op_queue->get_current_subtable_size();
654 AcirProgram program = construct_mock_kernel_program(ivc->verification_queue);
657 auto kernel = acir_format::create_circuit<Builder>(program, metadata);
666 size_t actual_ecc_rows = kernel.op_queue->get_num_rows();
670 size_t actual_ultra_ops = kernel.op_queue->get_current_subtable_size();
686 AcirProgram program = construct_mock_kernel_program(ivc->verification_queue);
689 auto kernel = acir_format::create_circuit<Builder>(program, metadata);
698 size_t actual_ecc_rows = kernel.op_queue->get_num_rows();
702 size_t actual_ultra_ops = kernel.op_queue->get_current_subtable_size();
718 AcirProgram program = construct_mock_kernel_program(ivc->verification_queue);
721 auto kernel = acir_format::create_circuit<Builder>(program, metadata);
730 size_t actual_ecc_rows = kernel.op_queue->get_num_rows();
734 size_t actual_ultra_ops = kernel.op_queue->get_current_subtable_size();
750 AcirProgram program = construct_mock_kernel_program(ivc->verification_queue);
758 "hn_recursion_data constraints/indices size mismatch");
769 AcirProgram program = construct_mock_kernel_program(ivc->verification_queue);
778 "mismatch in number of recursive verifications");
789 AcirProgram program = construct_mock_kernel_program(ivc->verification_queue);
797 "unexpected non-empty public_inputs in HN constraint");
808 AcirProgram program = construct_mock_kernel_program(ivc->verification_queue);
817 "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 std::shared_ptr< Chonk::MegaVerificationKey > get_kernel_vk_from_circuit(Builder &kernel, bool is_hiding_kernel=false)
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, bool is_hiding_kernel=false)
Construct a kernel circuit VK from an acir program with IVC recursion constraints.
static Builder construct_mock_app_circuit(const std::shared_ptr< Chonk > &ivc)
Constuct a simple arbitrary circuit to represent a mock app circuit.
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 std::shared_ptr< VerificationKey > get_verification_key(Builder &builder_in, bool is_hiding_kernel=false)
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 stores commitments to the precomputed (non-witness) polynomials used by the veri...
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()
Output type for recursive ultra verification.