Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
client_ivc_recursive_verifier.test.cpp
Go to the documentation of this file.
7
9class ClientIVCRecursionTests : public testing::Test {
10 public:
18 using MockCircuitProducer = PrivateFunctionExecutionMockCircuitProducer;
21
22 static constexpr TraceSettings trace_settings{ AZTEC_TRACE_STRUCTURE };
23
25
30
35 static ClientIVCProverOutput construct_client_ivc_prover_output(const size_t num_app_circuits = 1)
36 {
37 // Construct and accumulate a series of mocked private function execution circuits
38 MockCircuitProducer circuit_producer{ num_app_circuits };
39 const size_t NUM_CIRCUITS = circuit_producer.total_num_circuits;
40 ClientIVC ivc{ NUM_CIRCUITS, trace_settings };
41
42 for (size_t idx = 0; idx < NUM_CIRCUITS; ++idx) {
43 circuit_producer.construct_and_accumulate_next_circuit(ivc);
44 }
45
46 return { ivc.prove(), ivc.get_vk() };
47 }
48};
49
54TEST_F(ClientIVCRecursionTests, NativeVerification)
55{
56 auto [proof, vk] = construct_client_ivc_prover_output();
57
58 // Confirm that the IVC proof can be natively verified
59 EXPECT_TRUE(ClientIVC::verify(proof, vk));
60}
61
67{
68 using CIVCRecVerifierOutput = ClientIVCRecursiveVerifier::Output;
69
70 // Generate a genuine ClientIVC prover output
71 auto [proof, vk] = construct_client_ivc_prover_output();
72
73 // Construct the ClientIVC recursive verifier
75 ClientIVCVerifier verifier{ &builder, vk.mega };
76
77 // Generate the recursive verification circuit
78 StdlibProof stdlib_proof(builder, proof);
79 CIVCRecVerifierOutput output = verifier.verify(stdlib_proof);
80
81 EXPECT_EQ(builder.failed(), false) << builder.err();
82
83 EXPECT_TRUE(CircuitChecker::check(builder));
84
85 // Print the number of gates post finalization
86 info("Recursive Verifier: finalized num gates = ", builder.num_gates);
87}
88
90{
91 using CIVCRecVerifierOutput = ClientIVCRecursiveVerifier::Output;
92
93 // Generate a genuine ClientIVC prover output
94 auto [proof, vk] = construct_client_ivc_prover_output();
95
96 // Construct the ClientIVC recursive verifier
97 Builder tube_builder;
98 ClientIVCVerifier verifier{ &tube_builder, vk.mega };
99
100 // Generate the recursive verification circuit
101 StdlibProof stdlib_proof(tube_builder, proof);
102 CIVCRecVerifierOutput client_ivc_rec_verifier_output = verifier.verify(stdlib_proof);
103
104 {
105 // IO
106 RollupIO inputs;
107 inputs.pairing_inputs = client_ivc_rec_verifier_output.points_accumulator;
108 inputs.ipa_claim = client_ivc_rec_verifier_output.opening_claim;
109 inputs.set_public();
110 }
111
112 // The tube only calls an IPA recursive verifier once, so we can just add this IPA proof
113 tube_builder.ipa_proof = client_ivc_rec_verifier_output.ipa_proof.get_value();
114
115 info("ClientIVC Recursive Verifier: num prefinalized gates = ", tube_builder.num_gates);
116
117 EXPECT_EQ(tube_builder.failed(), false) << tube_builder.err();
118
119 // EXPECT_TRUE(CircuitChecker::check(tube_builder));
120
121 // Construct and verify a proof for the ClientIVC Recursive Verifier circuit
122 auto proving_key = std::make_shared<DeciderProvingKey_<NativeFlavor>>(tube_builder);
123 auto native_vk_with_ipa = std::make_shared<NativeFlavor::VerificationKey>(proving_key->get_precomputed());
124 UltraProver_<NativeFlavor> tube_prover{ proving_key, native_vk_with_ipa };
125 // Prove the CIVCRecursiveVerifier circuit
126 auto native_tube_proof = tube_prover.construct_proof();
127
128 // Natively verify the tube proof
129 VerifierCommitmentKey<curve::Grumpkin> ipa_verification_key(1 << CONST_ECCVM_LOG_N);
130 UltraVerifier_<NativeFlavor> native_verifier(native_vk_with_ipa, ipa_verification_key);
131 bool native_result =
132 native_verifier.template verify_proof<bb::RollupIO>(native_tube_proof, tube_prover.proving_key->ipa_proof)
133 .result;
134 EXPECT_TRUE(native_result);
135
136 // Construct a base rollup circuit that recursively verifies the tube proof and forwards the IPA proof.
137 Builder base_builder;
138 auto tube_vk = std::make_shared<NativeFlavor::VerificationKey>(proving_key->get_precomputed());
139 auto stdlib_tube_vk_and_hash = std::make_shared<RollupFlavor::VKAndHash>(base_builder, tube_vk);
140 stdlib::Proof<Builder> base_tube_proof(base_builder, native_tube_proof);
141 UltraRecursiveVerifier base_verifier{ &base_builder, stdlib_tube_vk_and_hash };
142 UltraRecursiveVerifierOutput<Builder> output = base_verifier.template verify_proof<RollupIO>(base_tube_proof);
143 info("Tube UH Recursive Verifier: num prefinalized gates = ", base_builder.num_gates);
144
145 {
146 // IO
147 RollupIO inputs;
148 inputs.pairing_inputs = output.points_accumulator;
149 inputs.ipa_claim = output.ipa_claim;
150 inputs.set_public();
151 }
152
153 base_builder.ipa_proof = tube_prover.proving_key->ipa_proof;
154 EXPECT_EQ(base_builder.failed(), false) << base_builder.err();
155 EXPECT_TRUE(CircuitChecker::check(base_builder));
156
157 // Natively verify the IPA proof for the base rollup circuit
158 auto base_proving_key = std::make_shared<DeciderProvingKey_<NativeFlavor>>(base_builder);
159 auto ipa_transcript = std::make_shared<NativeTranscript>();
160 ipa_transcript->load_proof(base_proving_key->ipa_proof);
162 ipa_verification_key, output.ipa_claim.get_native_opening_claim(), ipa_transcript);
163}
164
165// Ensure that the Client IVC Recursive Verifier Circuit does not depend on the Client IVC input
166TEST_F(ClientIVCRecursionTests, TubeVKIndependentOfInputCircuits)
167{
168 // Retrieves the trace blocks (each consisting of a specific gate) from the recursive verifier circuit
169 auto get_blocks = [](size_t num_app_circuits)
171 auto [proof, ivc_vk] = construct_client_ivc_prover_output(num_app_circuits);
172
173 Builder tube_builder;
174 ClientIVCVerifier verifier{ &tube_builder, ivc_vk.mega };
175
176 StdlibProof stdlib_proof(tube_builder, proof);
177 auto client_ivc_rec_verifier_output = verifier.verify(stdlib_proof);
178
179 // IO
180 RollupIO inputs;
181 inputs.pairing_inputs = client_ivc_rec_verifier_output.points_accumulator;
182 inputs.ipa_claim = client_ivc_rec_verifier_output.opening_claim;
183 inputs.set_public();
184
185 // The tube only calls an IPA recursive verifier once, so we can just add this IPA proof
186 tube_builder.ipa_proof = client_ivc_rec_verifier_output.ipa_proof.get_value();
187
188 info("ClientIVC Recursive Verifier: num prefinalized gates = ", tube_builder.num_gates);
189
190 EXPECT_EQ(tube_builder.failed(), false) << tube_builder.err();
191
192 // Construct and verify a proof for the ClientIVC Recursive Verifier circuit
193 auto proving_key = std::make_shared<DeciderProvingKey_<NativeFlavor>>(tube_builder);
194
195 auto tube_vk = std::make_shared<NativeFlavor::VerificationKey>(proving_key->get_precomputed());
196
197 return { tube_builder.blocks, tube_vk };
198 };
199
200 auto [blocks_4, verification_key_4] = get_blocks(/*num_app_circuits=*/1);
201 auto [blocks_5, verification_key_5] = get_blocks(/*num_app_circuits=*/2);
202
203 compare_ultra_blocks_and_verification_keys<NativeFlavor>({ blocks_4, blocks_5 },
204 { verification_key_4, verification_key_5 });
205}
206} // namespace bb::stdlib::recursion::honk
const std::string & err() const
The IVC scheme used by the aztec client for private function execution.
static bool verify(const Proof &proof, const VerificationKey &vk)
IPA (inner product argument) commitment scheme class.
Definition ipa.hpp:95
static bool check(const Builder &circuit)
Check the witness satisifies the circuit.
The recursive counterpart to the "native" UltraRollupFlavor.
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 ClientIVCProverOutput construct_client_ivc_prover_output(const size_t num_app_circuits=1)
Construct a genuine ClientIVC prover output based on accumulation of an arbitrary set of mock circuit...
The data that is propagated on the public inputs of a rollup circuit.
void set_public()
Set each IO component to be a public input of the underlying circuit.
void info(Args... args)
Definition log.hpp:70
AluTraceBuilder builder
Definition alu.test.cpp:123
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.
UltraCircuitBuilder_< UltraExecutionTraceBlocks > UltraCircuitBuilder
VerifierCommitmentKey< Curve > vk
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
A full proof for the IVC scheme containing a Mega proof showing correctness of the hiding circuit (wh...