@@ -276,9 +276,9 @@ pub fn do_bls12_381_aggregate_g1<
276
276
277
277
let g1s = read_region ( & memory, g1s_ptr, BLS12_381_MAX_AGGREGATE_SIZE ) ?;
278
278
279
+ let estimated_point_count = ( g1s. len ( ) / BLS12_381_G1_POINT_LEN ) as u64 ;
279
280
let gas_info = GasInfo :: with_cost (
280
- data. gas_config . bls12_381_aggregate_g1_per_point
281
- * ( g1s. len ( ) / BLS12_381_G1_POINT_LEN ) as u64 ,
281
+ data. gas_config . bls12_381_aggregate_g1_per_point * estimated_point_count,
282
282
) ;
283
283
process_gas_info ( data, & mut store, gas_info) ?;
284
284
@@ -320,9 +320,9 @@ pub fn do_bls12_381_aggregate_g2<
320
320
321
321
let g2s = read_region ( & memory, g2s_ptr, BLS12_381_MAX_AGGREGATE_SIZE ) ?;
322
322
323
+ let estimated_point_count = ( g2s. len ( ) / BLS12_381_G2_POINT_LEN ) as u64 ;
323
324
let gas_info = GasInfo :: with_cost (
324
- data. gas_config . bls12_381_aggregate_g2_per_point
325
- * ( g2s. len ( ) / BLS12_381_G2_POINT_LEN ) as u64 ,
325
+ data. gas_config . bls12_381_aggregate_g2_per_point * estimated_point_count,
326
326
) ;
327
327
process_gas_info ( data, & mut store, gas_info) ?;
328
328
@@ -369,14 +369,15 @@ pub fn do_bls12_381_pairing_equality<
369
369
let r = read_region ( & memory, r_ptr, BLS12_381_G1_POINT_LEN ) ?;
370
370
let s = read_region ( & memory, s_ptr, BLS12_381_G2_POINT_LEN ) ?;
371
371
372
- let gas_info = GasInfo :: with_cost (
373
- data. gas_config . bls12_381_pairing_equality_cost
374
- // Subtract one since the base benchmark of the pairing equality cost includes a single pair already
375
- + ( data
376
- . gas_config
377
- . bls12_381_aggregated_pairing_equality_cost_per_pair
378
- * ( ps. len ( ) / BLS12_381_G1_POINT_LEN ) as u64 ) . saturating_sub ( 1 ) ,
379
- ) ;
372
+ let estimated_point_count = ( ps. len ( ) / BLS12_381_G1_POINT_LEN ) as u64 ;
373
+ let additional_cost = data
374
+ . gas_config
375
+ . bls12_381_aggregated_pairing_equality_cost_per_pair
376
+ // Add one since we do not include any pairs in the base benchmark, and we always need to add one for the `r` and `s` pair.
377
+ * ( estimated_point_count + 1 ) ;
378
+
379
+ let gas_info =
380
+ GasInfo :: with_cost ( data. gas_config . bls12_381_pairing_equality_cost + additional_cost) ;
380
381
process_gas_info ( data, & mut store, gas_info) ?;
381
382
382
383
let code = match bls12_381_pairing_equality ( & ps, & qs, & r, & s) {
0 commit comments