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 auto prover_transcript = std::make_shared<NativeTranscript>();
70 MergeProver merge_prover{ op_queue, prover_transcript, settings };
71 auto merge_proof = merge_prover.construct_proof();
72
73 // Subtable values and commitments - needed for (Recursive)MergeVerifier
74 MergeCommitments merge_commitments;
75 RecursiveMergeCommitments recursive_merge_commitments;
76 auto t_current = op_queue->construct_current_ultra_ops_subtable_columns();
77 auto T_prev = op_queue->construct_previous_ultra_ops_table_columns();
78 for (size_t idx = 0; idx < InnerFlavor::NUM_WIRES; idx++) {
79 merge_commitments.t_commitments[idx] = merge_prover.pcs_commitment_key.commit(t_current[idx]);
80 merge_commitments.T_prev_commitments[idx] = merge_prover.pcs_commitment_key.commit(T_prev[idx]);
81 recursive_merge_commitments.t_commitments[idx] =
82 RecursiveMergeVerifier::Commitment::from_witness(&outer_circuit, merge_commitments.t_commitments[idx]);
83 recursive_merge_commitments.T_prev_commitments[idx] = RecursiveMergeVerifier::Commitment::from_witness(
84 &outer_circuit, merge_commitments.T_prev_commitments[idx]);
85 // Removing the free witness tag, since the merge commitments in the full scheme are supposed to
86 // be fiat-shamirred earlier
87 recursive_merge_commitments.t_commitments[idx].unset_free_witness_tag();
88 recursive_merge_commitments.T_prev_commitments[idx].unset_free_witness_tag();
89 }
90
91 // Create a recursive merge verification circuit for the merge proof
93 RecursiveMergeVerifier verifier{ settings, merge_transcript };
94 const stdlib::Proof<RecursiveBuilder> stdlib_merge_proof(outer_circuit, merge_proof);
95 [[maybe_unused]] auto [pairing_points, merged_commitments, reduction_succeeded] =
96 verifier.reduce_to_pairing_check(stdlib_merge_proof, recursive_merge_commitments);
97
98 // Check for a failure flag in the recursive verifier circuit
99 EXPECT_FALSE(outer_circuit.failed());
100 if (run_analyzer) {
101 analyze_circuit(outer_circuit);
102 }
103 }
104
106 {
107 auto op_queue = std::make_shared<ECCOpQueue>();
108
109 InnerBuilder circuit{ op_queue };
111 prove_and_verify_merge(op_queue);
112
113 InnerBuilder circuit2{ op_queue };
115 prove_and_verify_merge(op_queue);
116
117 InnerBuilder circuit3{ op_queue };
120 }
121
123 {
124 auto op_queue = std::make_shared<ECCOpQueue>();
125
126 InnerBuilder circuit{ op_queue };
128 prove_and_verify_merge(op_queue);
129
130 InnerBuilder circuit2{ op_queue };
132 prove_and_verify_merge(op_queue);
133
134 InnerBuilder circuit3{ op_queue };
137 }
138};
139
140using Builder = testing::Types<MegaCircuitBuilder>;
141
143
145{
146 TestFixture::test_recursive_merge_verification_prepend();
147};
148
150{
151 TestFixture::test_recursive_merge_verification_append();
152};
153
154} // 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:1805
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:20
StaticAnalyzer_< bb::fr, bb::MegaCircuitBuilder > MegaStaticAnalyzer
Definition graph.hpp:193
UltraStaticAnalyzer StaticAnalyzer
Definition graph.hpp:194
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13