Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
graph_description_merge_recursive_verifier.test.cpp
Go to the documentation of this file.
7
8using namespace cdg;
9
11
19template <class RecursiveBuilder> class BoomerangRecursiveMergeVerifierTest : public testing::Test {
20
21 // Types for recursive verifier circuit
25
26 // Define types relevant for inner circuit
30
31 // Define additional types for testing purposes
38
39 public:
41
42 static void analyze_circuit(RecursiveBuilder& outer_circuit)
43 {
44 auto tool = StaticAnalyzer_<bb::fr, RecursiveBuilder>(outer_circuit);
45 auto result = tool.analyze_circuit();
46 EXPECT_EQ(result.first.size(), 1);
47 EXPECT_EQ(result.second.size(), 0);
48 }
49
52 const bool run_analyzer = false)
53
54 {
55 RecursiveBuilder outer_circuit;
56
57 auto prover_transcript = std::make_shared<NativeTranscript>();
58 MergeProver merge_prover{ op_queue, prover_transcript, settings };
59 auto merge_proof = merge_prover.construct_proof();
60
61 // Subtable values and commitments - needed for (Recursive)MergeVerifier
62 MergeCommitments merge_commitments;
63 RecursiveMergeCommitments recursive_merge_commitments;
64 auto t_current = op_queue->construct_current_ultra_ops_subtable_columns();
65 auto T_prev = op_queue->construct_previous_ultra_ops_table_columns();
66 for (size_t idx = 0; idx < InnerFlavor::NUM_WIRES; idx++) {
67 merge_commitments.t_commitments[idx] = merge_prover.pcs_commitment_key.commit(t_current[idx]);
68 merge_commitments.T_prev_commitments[idx] = merge_prover.pcs_commitment_key.commit(T_prev[idx]);
69 recursive_merge_commitments.t_commitments[idx] =
70 RecursiveMergeVerifier::Commitment::from_witness(&outer_circuit, merge_commitments.t_commitments[idx]);
71 recursive_merge_commitments.T_prev_commitments[idx] = RecursiveMergeVerifier::Commitment::from_witness(
72 &outer_circuit, merge_commitments.T_prev_commitments[idx]);
73 // Removing the free witness tag, since the merge commitments in the full scheme are supposed to
74 // be fiat-shamirred earlier
75 recursive_merge_commitments.t_commitments[idx].unset_free_witness_tag();
76 recursive_merge_commitments.T_prev_commitments[idx].unset_free_witness_tag();
77 }
78
79 // Create a recursive merge verification circuit for the merge proof
81 RecursiveMergeVerifier verifier{ settings, merge_transcript };
82 const stdlib::Proof<RecursiveBuilder> stdlib_merge_proof(outer_circuit, merge_proof);
83 auto [pairing_points, merged_commitments, reduction_succeeded] =
84 verifier.reduce_to_pairing_check(stdlib_merge_proof, recursive_merge_commitments);
85
86 // The pairing points are public outputs from the recursive verifier that will be verified externally via a
87 // pairing check. Their output coordinate limbs (from goblin batch_mul's queue_ecc_eq) may only appear in a
88 // single ECC op gate. Calling fix_witness() adds explicit constraints on these values so the StaticAnalyzer
89 // does not flag them as under-constrained.
90 pairing_points.fix_witness();
91
92 // Check for a failure flag in the recursive verifier circuit
93 EXPECT_FALSE(outer_circuit.failed());
94 if (run_analyzer) {
95 analyze_circuit(outer_circuit);
96 }
97 }
98
100 {
101 auto op_queue = std::make_shared<ECCOpQueue>();
102
103 InnerBuilder circuit{ op_queue };
105 prove_and_verify_merge(op_queue);
106
107 InnerBuilder circuit2{ op_queue };
109 prove_and_verify_merge(op_queue);
110
111 InnerBuilder circuit3{ op_queue };
114 }
115
117 {
118 auto op_queue = std::make_shared<ECCOpQueue>();
119
120 InnerBuilder circuit{ op_queue };
122 prove_and_verify_merge(op_queue);
123
124 InnerBuilder circuit2{ op_queue };
126 prove_and_verify_merge(op_queue);
127
128 InnerBuilder circuit3{ op_queue };
131 }
132};
133
134using Builder = testing::Types<MegaCircuitBuilder>;
135
137
139{
140 TestFixture::test_recursive_merge_verification_prepend();
141};
142
144{
145 TestFixture::test_recursive_merge_verification_append();
146};
147
148} // namespace bb::stdlib::recursion::goblin
static void construct_simple_circuit(MegaBuilder &builder)
Generate a simple test circuit with some ECC op gates and conventional arithmetic gates.
Curve::ScalarField FF
static constexpr size_t NUM_WIRES
MegaCircuitBuilder CircuitBuilder
Curve::AffineElement Commitment
Prover class for the Goblin ECC op queue transcript merge protocol.
std::vector< FF > MergeProof
BB_PROFILE MergeProof construct_proof()
Prove proper construction of the aggregate Goblin ECC op queue polynomials T_j.
Unified verifier class for the Goblin ECC op queue transcript merge protocol.
std::array< Commitment, NUM_WIRES > TableCommitments
Contains all the information required by a Honk prover to create a proof, constructed from a finalize...
Representation of the Grumpkin Verifier Commitment Key inside a bn254 circuit.
A simple wrapper around a vector of stdlib field elements representing a proof.
Definition proof.hpp:19
static void prove_and_verify_merge(const std::shared_ptr< ECCOpQueue > &op_queue, const MergeSettings settings=MergeSettings::PREPEND, const bool run_analyzer=false)
std::filesystem::path bb_crs_path()
void init_file_crs_factory(const std::filesystem::path &path)
TYPED_TEST_SUITE(BoomerangRecursiveMergeVerifierTest, Builder)
TYPED_TEST(BoomerangRecursiveMergeVerifierTest, RecursiveVerificationPrepend)
MergeSettings
The MergeSettings define whether an current subtable will be added at the beginning (PREPEND) or at t...
Definition graph.cpp:21
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13