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.
12
13using namespace cdg;
14
16
24template <class RecursiveBuilder> class BoomerangRecursiveMergeVerifierTest : public testing::Test {
25
26 // Types for recursive verifier circuit
30
31 // Define types relevant for inner circuit
35
36 // Define additional types for testing purposes
43
44 public:
46
47 static void analyze_circuit(RecursiveBuilder& outer_circuit)
48 {
49 if constexpr (IsMegaBuilder<RecursiveBuilder>) {
50 MegaStaticAnalyzer tool = MegaStaticAnalyzer(outer_circuit);
51 auto result = tool.analyze_circuit();
52 EXPECT_EQ(result.first.size(), 1);
53 EXPECT_EQ(result.second.size(), 0);
54 }
56 StaticAnalyzer tool = StaticAnalyzer(outer_circuit);
57 auto result = tool.analyze_circuit();
58 EXPECT_EQ(result.first.size(), 1);
59 EXPECT_EQ(result.second.size(), 0);
60 }
61 }
62
65 const bool run_analyzer = false)
66
67 {
68 RecursiveBuilder outer_circuit;
69
70 MergeProver merge_prover{ op_queue, 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
92 RecursiveMergeVerifier verifier{ &outer_circuit, settings };
93 verifier.transcript->enable_manifest();
94 const stdlib::Proof<RecursiveBuilder> stdlib_merge_proof(outer_circuit, merge_proof);
95 [[maybe_unused]] auto [pairing_points, recursive_merged_table_commitments] =
96 verifier.verify_proof(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.
BB_PROFILE MergeProof construct_proof()
std::vector< FF > MergeProof
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)
MergeRecursiveVerifier_< RecursiveBuilder >::TableCommitments RecursiveTableCommitments
std::pair< std::vector< ConnectedComponent >, std::unordered_set< uint32_t > > analyze_circuit()
Definition graph.cpp:1659
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:12
StaticAnalyzer_< bb::fr, bb::MegaCircuitBuilder > MegaStaticAnalyzer
Definition graph.hpp:183
UltraStaticAnalyzer StaticAnalyzer
Definition graph.hpp:184
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13