@@ -100,7 +100,7 @@ pub(crate) fn extract_accumulators_and_proof(
100
100
// 4. chunks are continuous: they are linked via the state roots
101
101
// 5. batch and all its chunks use a same chain id
102
102
// 6. chunk[i]'s prev_state_root == post_state_root when chunk[i] is padded
103
- // 7. chunk[i]'s data_hash == "" when chunk[i] is padded
103
+ // 7. chunk[i]'s data_hash == keccak("") when chunk[i] is padded
104
104
#[ allow( clippy:: type_complexity) ]
105
105
pub ( crate ) fn assign_batch_hashes (
106
106
config : & AggregationConfig ,
@@ -127,7 +127,7 @@ pub(crate) fn assign_batch_hashes(
127
127
// 3. batch_data_hash and chunk[i].pi_hash use a same chunk[i].data_hash when chunk[i] is not
128
128
// padded
129
129
// 6. chunk[i]'s prev_state_root == post_state_root when chunk[i] is padded
130
- // 7. chunk[i]'s data_hash == "" when chunk[i] is padded
130
+ // 7. chunk[i]'s data_hash == keccak("") when chunk[i] is padded
131
131
let num_valid_snarks = conditional_constraints (
132
132
& config. rlc_config ,
133
133
// config.flex_gate(),
@@ -405,7 +405,7 @@ fn copy_constraints(
405
405
// 1. batch_data_hash digest is reused for public input hash
406
406
// 3. batch_data_hash and chunk[i].pi_hash use a same chunk[i].data_hash when chunk[i] is not padded
407
407
// 6. chunk[i]'s prev_state_root == post_state_root when chunk[i] is padded
408
- // 7. chunk[i]'s data_hash == "" when chunk[i] is padded
408
+ // 7. chunk[i]'s data_hash == keccak("") when chunk[i] is padded
409
409
#[ allow( clippy:: too_many_arguments) ]
410
410
pub ( crate ) fn conditional_constraints (
411
411
rlc_config : & RlcConfig ,
@@ -462,11 +462,11 @@ pub(crate) fn conditional_constraints(
462
462
region. constrain_equal ( four_cell, four. cell ( ) ) ?;
463
463
four
464
464
} ;
465
- let eight = {
466
- let eight = rlc_config. load_private ( & mut region, & Fr :: from ( 8 ) , & mut offset) ?;
467
- let eight_cell = rlc_config. eight_cell ( eight . cell ( ) . region_index ) ;
468
- region. constrain_equal ( eight_cell , eight . cell ( ) ) ?;
469
- eight
465
+ let nine = {
466
+ let nine = rlc_config. load_private ( & mut region, & Fr :: from ( 9 ) , & mut offset) ?;
467
+ let nine_cell = rlc_config. nine_cell ( nine . cell ( ) . region_index ) ;
468
+ region. constrain_equal ( nine_cell , nine . cell ( ) ) ?;
469
+ nine
470
470
} ;
471
471
let flag1 = rlc_config. is_smaller_than (
472
472
& mut region,
@@ -478,7 +478,7 @@ pub(crate) fn conditional_constraints(
478
478
let not_flag3 = rlc_config. is_smaller_than (
479
479
& mut region,
480
480
& num_of_valid_snarks_cell[ 0 ] ,
481
- & eight ,
481
+ & nine ,
482
482
& mut offset,
483
483
) ?;
484
484
let flag3 = rlc_config. not ( & mut region, & not_flag3, & mut offset) ?;
@@ -511,6 +511,11 @@ pub(crate) fn conditional_constraints(
511
511
//
512
512
// 1 batch_data_hash digest is reused for public input hash
513
513
//
514
+ // the following part of the code is hard coded for the case where
515
+ // MAX_AGG_SNARKS <= 10
516
+ // in theory it may support up to 12 SNARKS (not tested)
517
+ // more SNARKs beyond 12 will require a revamp of the circuit
518
+ //
514
519
// public input hash is build as
515
520
// keccak(
516
521
// chain_id ||
@@ -519,6 +524,8 @@ pub(crate) fn conditional_constraints(
519
524
// chunk[k-1].withdraw_root ||
520
525
// batch_data_hash )
521
526
//
527
+ // batchDataHash = keccak(chunk[0].dataHash || ... || chunk[k-1].dataHash)
528
+ //
522
529
// #valid snarks | offset of data hash | flags
523
530
// 1,2,3,4 | 0 | 1, 0, 0
524
531
// 5,6,7,8 | 32 | 0, 1, 0
@@ -658,7 +665,7 @@ pub(crate) fn conditional_constraints(
658
665
}
659
666
}
660
667
661
- // 7. chunk[i]'s data_hash == "" when chunk[i] is padded
668
+ // 7. chunk[i]'s data_hash == keccak("") when chunk[i] is padded
662
669
// that means the data_hash length is 32 * number_of_valid_snarks
663
670
let const32 = rlc_config. load_private ( & mut region, & Fr :: from ( 32 ) , & mut offset) ?;
664
671
let const32_cell = rlc_config. thirty_two_cell ( const32. cell ( ) . region_index ) ;
0 commit comments