73 const size_t num_gates = 1 << log_num_gates;
74 for (
size_t i = 0; i < num_gates; ++i) {
76 uint32_t a_idx =
builder.add_variable(
a);
81 uint32_t b_idx =
builder.add_variable(
b);
82 uint32_t c_idx =
builder.add_variable(c);
83 uint32_t d_idx =
builder.add_variable(d);
85 builder.create_big_add_gate({ a_idx, b_idx, c_idx, d_idx,
fr(1),
fr(1),
fr(1),
fr(-1),
fr(0) });
93 for (
size_t i = 0; i < 32; ++i) {
102 fr bigfield_data_a{ bigfield_data.
data[0], bigfield_data.
data[1], 0, 0 };
103 fr bigfield_data_b{ bigfield_data.
data[2], bigfield_data.
data[3], 0, 0 };
129 { decider_vk_1, decider_vk_2 },
134 auto [prover_accumulator, folding_proof] = folding_prover.prove();
136 return { prover_accumulator, verifier_accumulator };
149 EXPECT_EQ(result,
true);
163 std::vector<fr> coeffs;
165 for (
size_t idx = 0; idx < 8; idx++) {
167 coeffs.emplace_back(el);
175 auto res2 = evaluate_perturbator(coeffs_ct, point_ct);
176 EXPECT_EQ(res1, res2.get_value());
200 { decider_vk_1, decider_vk_2 },
202 auto folding_proof = folding_prover.
prove();
212 recursive_decider_vk_1,
213 { recursive_vk_and_hash_2 },
216 for (
size_t idx = 0; idx < num_verifiers; idx++) {
218 accumulator = verifier.verify_folding_proof(stdlib_proof);
219 if (idx < num_verifiers - 1) {
224 { recursive_vk_and_hash },
228 info(
"Folding Recursive Verifier: num gates unfinalized = ", folding_circuit.num_gates);
229 EXPECT_EQ(folding_circuit.failed(),
false) << folding_circuit.err();
235 native_folding_verifier.
transcript->enable_manifest();
237 for (
size_t idx = 0; idx < num_verifiers; idx++) {
238 native_accumulator = native_folding_verifier.verify_folding_proof(folding_proof.proof);
239 if (idx < num_verifiers - 1) {
240 native_folding_verifier =
243 native_folding_verifier.
transcript->enable_manifest();
249 auto recursive_folding_manifest = verifier.transcript->get_manifest();
250 auto native_folding_manifest = native_folding_verifier.transcript->get_manifest();
252 ASSERT_GT(recursive_folding_manifest.size(), 0);
253 for (
size_t i = 0; i < recursive_folding_manifest.size(); ++i) {
254 EXPECT_EQ(recursive_folding_manifest[i], native_folding_manifest[i])
255 <<
"Recursive Verifier/Verifier manifest discrepency in round " << i;
262 folding_circuit.finalize_circuit(
true);
263 info(
"Folding Recursive Verifier: num gates finalized = ", folding_circuit.num_gates);
265 info(
"Dyadic size of verifier circuit: ", decider_pk->dyadic_size());
270 bool verified = verifier.template verify_proof<bb::DefaultIO>(proof).result;
272 ASSERT_TRUE(verified);
300 { decider_vk_1, decider_vk_2 },
302 auto folding_proof = folding_prover.
prove();
311 recursive_decider_vk_1,
312 { recursive_vk_and_hash_2 },
315 auto recursive_verifier_native_accum = verifier.verify_folding_proof(stdlib_proof);
316 auto native_verifier_acc =
318 info(
"Folding Recursive Verifier: num gates = ", folding_circuit.get_estimated_num_finalized_gates());
321 EXPECT_EQ(folding_circuit.failed(),
false) << folding_circuit.err();
327 native_folding_verifier.
transcript->enable_manifest();
328 auto verifier_accumulator = native_folding_verifier.verify_folding_proof(folding_proof.proof);
332 auto recursive_folding_manifest = verifier.transcript->get_manifest();
333 auto native_folding_manifest = native_folding_verifier.transcript->get_manifest();
335 ASSERT_GT(recursive_folding_manifest.size(), 0);
336 for (
size_t i = 0; i < recursive_folding_manifest.size(); ++i) {
337 EXPECT_EQ(recursive_folding_manifest[i], native_folding_manifest[i])
338 <<
"Recursive Verifier/Verifier manifest discrepency in round " << i;
347 auto pairing_points = decider_verifier.
verify_proof(decider_proof);
354 info(
"Decider Recursive Verifier: num gates = ", decider_circuit.num_gates);
356 EXPECT_EQ(decider_circuit.failed(),
false) << decider_circuit.err();
361 auto native_decider_output = native_decider_verifier.
verify_proof(decider_proof);
362 auto native_result = native_decider_output.
check();
363 NativeVerifierCommitmentKey pcs_vkey{};
364 auto recursive_result = pcs_vkey.pairing_check(pairing_points.P0.get_value(), pairing_points.P1.get_value());
365 EXPECT_EQ(native_result, recursive_result);
373 bool verified = verifier.template verify_proof<bb::DefaultIO>(proof).result;
375 ASSERT_TRUE(verified);
395 [[maybe_unused]]
auto output = decider_verifier.
verify_proof(decider_proof);
396 info(
"Decider Recursive Verifier: num gates = ", decider_circuit.num_gates);
420 { verifier_accumulator, verifier_inst },
422 auto folding_proof = folding_prover.
prove();
427 auto recursive_decider_vk_1 =
433 recursive_decider_vk_1,
434 { recursive_vk_and_hash_2 },
439 EXPECT_FALSE(folding_proof.accumulator->target_sum == recursive_verifier_acc->target_sum.get_value());
445 struct ProofAndVerifier {
451 auto produce_proof_and_verifier_circuit = [](
size_t log_num_gates) -> ProofAndVerifier {
465 { decider_vk_1, decider_vk_2 },
467 auto fold_result = folding_prover.
prove();
471 auto recursive_decider_vk_1 =
478 recursive_decider_vk_1,
479 { recursive_vk_and_hash_2 },
483 return { fold_result.proof, verifier_circuit };
487 auto [proof_1, verifier_circuit_1] = produce_proof_and_verifier_circuit(10);
488 auto [proof_2, verifier_circuit_2] = produce_proof_and_verifier_circuit(11);
494 EXPECT_EQ(proof_1.size(), proof_2.size());
495 EXPECT_EQ(verifier_circuit_1.get_estimated_num_finalized_gates(),
496 verifier_circuit_2.get_estimated_num_finalized_gates());
499 EXPECT_EQ(verifier_circuit_1.blocks, verifier_circuit_2.blocks);
virtual uint32_t add_public_variable(const FF &in)
A DeciderProvingKey is normally constructed from a finalized circuit and it contains all the informat...
The DeciderVerificationKey encapsulates all the necessary information for a Mega Honk Verifier to ver...
Output verify_proof(const DeciderProof &)
Verify a decider proof relative to a decider verification key (ϕ, \vec{β*}, e*).
The verification key is responsible for storing the commitments to the precomputed (non-witness) poly...
bb::VerifierCommitmentKey< Curve > VerifierCommitmentKey
MegaCircuitBuilder CircuitBuilder
Curve::AffineElement Commitment
The recursive counterpart to the "native" Mega flavor.
BuilderType CircuitBuilder
Structured polynomial class that represents the coefficients 'a' of a_0 + a_1 x .....
Fr evaluate(const Fr &z, size_t target_size) const
BB_PROFILE FoldingResult< Flavor > prove()
Execute the folding prover.
std::shared_ptr< Transcript > transcript
std::shared_ptr< DeciderVK > verify_folding_proof(const std::vector< FF > &)
Run the folding protocol on the verifier side to establish whether the public data ϕ of the new accum...
static bool check(const Builder &circuit)
Check the witness satisifies the circuit.
static byte_array_ct hash(const byte_array_ct &input)
A simple wrapper around a vector of stdlib field elements representing a proof.
Represents a dynamic array of bytes in-circuit.
static field_ct hash(const std::vector< field_ct > &in, GeneratorContext context={})
PairingPoints verify_proof(const HonkProof &proof)
Creates a circuit that executes the decider verifier algorithm up to the final pairing check.
Manages the data that is propagated on the public inputs of an application/function circuit.
void set_public()
Set each IO component to be a public input of the underlying circuit.
PairingInputs pairing_inputs
static void add_default(Builder &builder)
Add default public inputs when they are not present.
static void test_constant_pg_verifier_circuit()
RecursiveDeciderVerificationKeys::VKAndHash RecursiveVKAndHash
static std::tuple< std::shared_ptr< InnerDeciderProvingKey >, std::shared_ptr< InnerDeciderVerificationKey > > fold_and_verify_native()
InnerFlavor::Commitment Commitment
static void SetUpTestSuite()
static void test_full_protogalaxy_recursive()
Perform two rounds of folding valid circuits and then recursive verify the final decider proof,...
RecursiveDeciderVerificationKeys::VerificationKey RecursiveVerificationKey
static void test_tampered_accumulator()
RecursiveFlavor::CircuitBuilder OuterBuilder
static void test_tampered_decider_proof()
static void create_function_circuit(InnerBuilder &builder, size_t log_num_gates=10)
Create a non-trivial arbitrary inner circuit, the proof of which will be recursively verified.
static void test_new_evaluate()
Ensure that evaluating the perturbator in the recursive folding verifier returns the same result as e...
static void test_recursive_folding(const size_t num_verifiers=1)
Tests that a valid recursive fold works as expected.
static void test_circuit()
Create inner circuit and call check_circuit on it.
std::shared_ptr< Transcript > transcript
std::shared_ptr< DeciderVK > verify_folding_proof(const stdlib::Proof< Builder > &)
Run the folding protocol on the verifier side to establish whether the public data ϕ of the new accum...
The stdlib counterpart of DeciderVerificationKey, used in recursive folding verification.
bn254::public_witness_ct public_witness_ct
bn254::witness_ct witness_ct
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)
TEST_F(BoomerangGoblinRecursiveVerifierTests, graph_description_basic)
Construct and check a goblin recursive verification circuit.
std::vector< fr > HonkProof
field< Bn254FrParams > fr
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
static field random_element(numeric::RNG *engine=nullptr) noexcept
field_t< CircuitBuilder > ScalarField
byte_array< CircuitBuilder > byte_array_ct
curve::BN254::ScalarField ScalarFieldNative
public_witness_t< CircuitBuilder > public_witness_ct
witness_t< CircuitBuilder > witness_ct
typename Flavor::VerificationKey VerificationKey
typename Flavor::VKAndHash VKAndHash
RecursiveDeciderVerificationKey_< Flavor > DeciderVK