@@ -21,6 +21,8 @@ use crate::{
21
21
utils::reader::Reader ,
22
22
};
23
23
24
+ use std::hash:: {poseidon2 , poseidon2_permutation };
25
+
24
26
pub struct AvmCircuitPublicInputs {
25
27
///////////////////////////////////
26
28
// Inputs.
@@ -180,6 +182,37 @@ pub struct AvmProofData {
180
182
pub vk_data : VkData <AVM_VERIFICATION_KEY_LENGTH_IN_FIELDS >,
181
183
}
182
184
185
+ // The number of columns for the AVM recursive verifier we want to fake, i.e., the resulting
186
+ // verify() routine below will create a similar number of gates as a real AVM recursive verifier
187
+ // with the number of columns set by this constant.
188
+ pub global DUMMY_AVM_VERIFIER_NUM_COLUMNS : u32 = 2200 ;
189
+
190
+ // Current AVM recursive verifier has 9500 gates per column.
191
+ // Note that the addition of a single column in AVM recursive verifier incurs 8500 gates.
192
+ // (some additional costs are due to lookups, relations, ...).
193
+ // 78 gates per Poseidon permutation
194
+ // 9500/78 = 121.8
195
+ pub global DUMMY_AVM_VERIFIER_NUM_ITERATIONS : u32 = DUMMY_AVM_VERIFIER_NUM_COLUMNS * 122 ;
196
+
197
+ // Warning: This is a fake avm recursive verification whose sole goal is to reproduce a similar
198
+ // computational effort (number of gates) as the real recursive verifier.
199
+ // TODO(#8470): Replace with the real AVM recursive verifier
200
+ impl AvmProofData {
201
+ pub fn fake_verify (self ) {
202
+ let mut input_hash = poseidon2::Poseidon2 ::hash (
203
+ [self .public_inputs .transaction_fee , self .proof .fields [0 ], self .vk_data .vk .key [0 ]],
204
+ 3 ,
205
+ );
206
+
207
+ let mut result : [Field ; 4 ] = [input_hash , 0 , 0 , 0 ];
208
+ for i in 0 ..DUMMY_AVM_VERIFIER_NUM_ITERATIONS {
209
+ result = poseidon2_permutation (result , 4 );
210
+ }
211
+
212
+ assert (!result [0 ].lt (1 ));
213
+ }
214
+ }
215
+
183
216
impl Verifiable for AvmProofData {
184
217
fn verify (self ) {
185
218
// TODO(#8470)
0 commit comments