1
- use crate :: {
2
- aggregation:: decoder:: WORKED_EXAMPLE ,
3
- blob:: BatchData ,
4
- witgen:: { zstd_encode, MultiBlockProcessResult } ,
5
- LOG_DEGREE , PI_CHAIN_ID , PI_CURRENT_BATCH_HASH , PI_CURRENT_STATE_ROOT ,
6
- PI_CURRENT_WITHDRAW_ROOT , PI_PARENT_BATCH_HASH , PI_PARENT_STATE_ROOT ,
7
- } ;
8
1
use ark_std:: { end_timer, start_timer} ;
9
- use halo2_base:: { Context , ContextParams } ;
10
-
11
- #[ cfg( not( feature = "disable_proof_aggregation" ) ) ]
12
- use halo2_ecc:: { ecc:: EccChip , fields:: fp:: FpConfig } ;
13
-
14
2
use halo2_proofs:: {
15
3
circuit:: { Layouter , SimpleFloorPlanner , Value } ,
16
4
halo2curves:: bn256:: { Bn256 , Fr , G1Affine } ,
@@ -19,34 +7,34 @@ use halo2_proofs::{
19
7
} ;
20
8
use itertools:: Itertools ;
21
9
use rand:: Rng ;
22
- #[ cfg( not( feature = "disable_proof_aggregation" ) ) ]
23
- use std:: rc:: Rc ;
24
- use std:: { env, fs:: File } ;
25
-
26
- #[ cfg( not( feature = "disable_proof_aggregation" ) ) ]
27
- use snark_verifier:: loader:: halo2:: { halo2_ecc:: halo2_base:: AssignedValue , Halo2Loader } ;
28
- use snark_verifier:: pcs:: kzg:: KzgSuccinctVerifyingKey ;
29
- #[ cfg( not( feature = "disable_proof_aggregation" ) ) ]
30
10
use snark_verifier:: {
31
- loader:: halo2:: halo2_ecc:: halo2_base,
32
- pcs:: kzg:: { Bdfg21 , Kzg } ,
11
+ loader:: halo2:: {
12
+ halo2_ecc:: {
13
+ ecc:: EccChip ,
14
+ fields:: fp:: FpConfig ,
15
+ halo2_base:: { AssignedValue , Context , ContextParams } ,
16
+ } ,
17
+ Halo2Loader ,
18
+ } ,
19
+ pcs:: kzg:: { Bdfg21 , Kzg , KzgSuccinctVerifyingKey } ,
33
20
} ;
34
- #[ cfg( not( feature = "disable_proof_aggregation" ) ) ]
35
- use snark_verifier_sdk:: { aggregate, flatten_accumulator} ;
36
- use snark_verifier_sdk:: { CircuitExt , Snark , SnarkWitness } ;
21
+ use snark_verifier_sdk:: { aggregate, flatten_accumulator, CircuitExt , Snark , SnarkWitness } ;
22
+ use std:: { env, fs:: File , rc:: Rc } ;
37
23
use zkevm_circuits:: util:: Challenges ;
38
24
39
25
use crate :: {
40
- aggregation:: witgen:: process,
26
+ aggregation:: { decoder :: WORKED_EXAMPLE , witgen:: process, BatchCircuitConfig } ,
41
27
batch:: BatchHash ,
28
+ blob:: BatchData ,
42
29
constants:: { ACC_LEN , DIGEST_LEN } ,
43
30
core:: { assign_batch_hashes, extract_proof_and_instances_with_pairing_check} ,
44
31
util:: parse_hash_digest_cells,
45
- AssignedBarycentricEvaluationConfig , ConfigParams ,
32
+ witgen:: { zstd_encode, MultiBlockProcessResult } ,
33
+ AssignedBarycentricEvaluationConfig , ConfigParams , LOG_DEGREE , PI_CHAIN_ID ,
34
+ PI_CURRENT_BATCH_HASH , PI_CURRENT_STATE_ROOT , PI_CURRENT_WITHDRAW_ROOT , PI_PARENT_BATCH_HASH ,
35
+ PI_PARENT_STATE_ROOT ,
46
36
} ;
47
37
48
- use super :: BatchCircuitConfig ;
49
-
50
38
/// Batch circuit, the chunk aggregation routine below recursion circuit
51
39
#[ derive( Clone ) ]
52
40
pub struct BatchCircuit < const N_SNARKS : usize > {
@@ -186,47 +174,10 @@ impl<const N_SNARKS: usize> Circuit<Fr> for BatchCircuit<N_SNARKS> {
186
174
. range ( )
187
175
. load_lookup_table ( & mut layouter)
188
176
. expect ( "load range lookup table" ) ;
177
+
189
178
// ==============================================
190
179
// Step 1: snark aggregation circuit
191
180
// ==============================================
192
- #[ cfg( feature = "disable_proof_aggregation" ) ]
193
- let barycentric = {
194
- let mut first_pass = halo2_base:: SKIP_FIRST_PASS ;
195
- layouter. assign_region (
196
- || "barycentric evaluation" ,
197
- |region| {
198
- if first_pass {
199
- first_pass = false ;
200
- return Ok ( AssignedBarycentricEvaluationConfig :: default ( ) ) ;
201
- }
202
-
203
- let mut ctx = Context :: new (
204
- region,
205
- ContextParams {
206
- max_rows : config. flex_gate ( ) . max_rows ,
207
- num_context_ids : 1 ,
208
- fixed_columns : config. flex_gate ( ) . constants . clone ( ) ,
209
- } ,
210
- ) ;
211
-
212
- let barycentric = config. barycentric . assign (
213
- & mut ctx,
214
- & self . batch_hash . point_evaluation_assignments . coefficients ,
215
- self . batch_hash
216
- . point_evaluation_assignments
217
- . challenge_digest ,
218
- self . batch_hash . point_evaluation_assignments . evaluation ,
219
- ) ;
220
-
221
- config. barycentric . scalar . range . finalize ( & mut ctx) ;
222
- ctx. print_stats ( & [ "barycentric evaluation" ] ) ;
223
-
224
- Ok ( barycentric)
225
- } ,
226
- ) ?
227
- } ;
228
-
229
- #[ cfg( not( feature = "disable_proof_aggregation" ) ) ]
230
181
let ( accumulator_instances, snark_inputs, barycentric) = {
231
182
use halo2_proofs:: halo2curves:: bn256:: Fq ;
232
183
let mut first_pass = halo2_base:: SKIP_FIRST_PASS ;
@@ -375,21 +326,13 @@ impl<const N_SNARKS: usize> Circuit<Fr> for BatchCircuit<N_SNARKS> {
375
326
} ;
376
327
377
328
// Extract digests
378
- #[ cfg( feature = "disable_proof_aggregation" ) ]
379
- let ( _batch_hash_digest, _chunk_pi_hash_digests, _potential_batch_data_hash_digest) =
380
- parse_hash_digest_cells :: < N_SNARKS > ( & assigned_batch_hash. hash_output ) ;
381
-
382
- #[ cfg( not( feature = "disable_proof_aggregation" ) ) ]
383
329
let ( _batch_hash_digest, chunk_pi_hash_digests, _potential_batch_data_hash_digest) =
384
330
parse_hash_digest_cells :: < N_SNARKS > ( & assigned_batch_hash. hash_output ) ;
385
331
386
332
// ========================================================================
387
333
// step 2.a: check accumulator including public inputs to the snarks
388
334
// ========================================================================
389
- #[ cfg( not( feature = "disable_proof_aggregation" ) ) ]
390
335
let mut first_pass = halo2_base:: SKIP_FIRST_PASS ;
391
-
392
- #[ cfg( not( feature = "disable_proof_aggregation" ) ) ]
393
336
layouter. assign_region (
394
337
|| "BatchCircuit: Chunk PI" ,
395
338
|mut region| -> Result < ( ) , Error > {
@@ -424,7 +367,6 @@ impl<const N_SNARKS: usize> Circuit<Fr> for BatchCircuit<N_SNARKS> {
424
367
} ,
425
368
) ?;
426
369
427
- #[ cfg( not( feature = "disable_proof_aggregation" ) ) ]
428
370
{
429
371
assert ! ( accumulator_instances. len( ) == ACC_LEN ) ;
430
372
for ( i, v) in accumulator_instances. iter ( ) . enumerate ( ) {
0 commit comments