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.
11
12using namespace cdg;
13
15
23template <class RecursiveBuilder> class BoomerangRecursiveMergeVerifierTest : public testing::Test {
24
25 // Types for recursive verifier circuit
29
30 // Define types relevant for inner circuit
34
35 // Define additional types for testing purposes
42
43 public:
45
46 static void analyze_circuit(RecursiveBuilder& outer_circuit)
47 {
48 if constexpr (IsMegaBuilder<RecursiveBuilder>) {
49 MegaStaticAnalyzer tool = MegaStaticAnalyzer(outer_circuit);
50 auto result = tool.analyze_circuit();
51 EXPECT_EQ(result.first.size(), 1);
52 EXPECT_EQ(result.second.size(), 0);
53 }
55 StaticAnalyzer tool = StaticAnalyzer(outer_circuit);
56 auto result = tool.analyze_circuit();
57 EXPECT_EQ(result.first.size(), 1);
58 EXPECT_EQ(result.second.size(), 0);
59 }
60 }
61
64 const bool run_analyzer = false)
65
66 {
67 RecursiveBuilder outer_circuit;
68
69 MergeProver merge_prover{ op_queue, settings };
70 auto merge_proof = merge_prover.construct_proof();
71
72 // Subtable values and commitments - needed for (Recursive)MergeVerifier
73 MergeCommitments merge_commitments;
74 RecursiveMergeCommitments recursive_merge_commitments;
75 auto t_current = op_queue->construct_current_ultra_ops_subtable_columns();
76 auto T_prev = op_queue->construct_previous_ultra_ops_table_columns();
77 for (size_t idx = 0; idx < InnerFlavor::NUM_WIRES; idx++) {
78 merge_commitments.t_commitments[idx] = merge_prover.pcs_commitment_key.commit(t_current[idx]);
79 merge_commitments.T_prev_commitments[idx] = merge_prover.pcs_commitment_key.commit(T_prev[idx]);
80 recursive_merge_commitments.t_commitments[idx] =
81 RecursiveMergeVerifier::Commitment::from_witness(&outer_circuit, merge_commitments.t_commitments[idx]);
82 recursive_merge_commitments.T_prev_commitments[idx] = RecursiveMergeVerifier::Commitment::from_witness(
83 &outer_circuit, merge_commitments.T_prev_commitments[idx]);
84 // Removing the free witness tag, since the merge commitments in the full scheme are supposed to
85 // be fiat-shamirred earlier
86 recursive_merge_commitments.t_commitments[idx].unset_free_witness_tag();
87 recursive_merge_commitments.T_prev_commitments[idx].unset_free_witness_tag();
88 }
89
90 // Create a recursive merge verification circuit for the merge proof
92 RecursiveMergeVerifier verifier{ settings, merge_transcript };
93 const stdlib::Proof<RecursiveBuilder> stdlib_merge_proof(outer_circuit, merge_proof);
94 [[maybe_unused]] auto [pairing_points, merged_commitments, reduction_succeeded] =
95 verifier.reduce_to_pairing_check(stdlib_merge_proof, recursive_merge_commitments);
96
97 // Check for a failure flag in the recursive verifier circuit
98 EXPECT_FALSE(outer_circuit.failed());
99 if (run_analyzer) {
100 analyze_circuit(outer_circuit);
101 }
102 }
103
105 {
106 auto op_queue = std::make_shared<ECCOpQueue>();
107
108 InnerBuilder circuit{ op_queue };
110 prove_and_verify_merge(op_queue);
111
112 InnerBuilder circuit2{ op_queue };
114 prove_and_verify_merge(op_queue);
115
116 InnerBuilder circuit3{ op_queue };
119 }
120
122 {
123 auto op_queue = std::make_shared<ECCOpQueue>();
124
125 InnerBuilder circuit{ op_queue };
127 prove_and_verify_merge(op_queue);
128
129 InnerBuilder circuit2{ op_queue };
131 prove_and_verify_merge(op_queue);
132
133 InnerBuilder circuit3{ op_queue };
136 }
137};
138
139using Builder = testing::Types<MegaCircuitBuilder>;
140
142
144{
145 TestFixture::test_recursive_merge_verification_prepend();
146};
147
149{
150 TestFixture::test_recursive_merge_verification_append();
151};
152
153} // 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
A ProverInstance is normally constructed from a finalized circuit and it contains all the information...
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::pair< std::vector< ConnectedComponent >, std::unordered_set< uint32_t > > analyze_circuit(bool filter_cc=true)
this functions was made for more convenient testing process
Definition graph.cpp:1756
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:14
StaticAnalyzer_< bb::fr, bb::MegaCircuitBuilder > MegaStaticAnalyzer
Definition graph.hpp:186
UltraStaticAnalyzer StaticAnalyzer
Definition graph.hpp:187
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13