@@ -4,8 +4,8 @@ use super::{
4
4
utils:: extract_scalar_input,
5
5
} ;
6
6
use crate :: bls12_381_const:: {
7
- DISCOUNT_TABLE_G2_MSM , G2_ADD_ADDRESS , G2_ADD_BASE_GAS_FEE , G2_ADD_INPUT_LENGTH ,
8
- G2_INPUT_ITEM_LENGTH , NBITS , SCALAR_LENGTH ,
7
+ DISCOUNT_TABLE_G2_MSM , G2_INPUT_ITEM_LENGTH , G2_MSM_ADDRESS , G2_MSM_BASE_GAS_FEE ,
8
+ G2_MSM_INPUT_LENGTH , NBITS , SCALAR_LENGTH ,
9
9
} ;
10
10
use crate :: { u64_to_address, PrecompileWithAddress } ;
11
11
use crate :: { PrecompileError , PrecompileOutput , PrecompileResult } ;
@@ -14,7 +14,7 @@ use primitives::Bytes;
14
14
15
15
/// [EIP-2537](https://eips.ethereum.org/EIPS/eip-2537#specification) BLS12_G2MSM precompile.
16
16
pub const PRECOMPILE : PrecompileWithAddress =
17
- PrecompileWithAddress ( u64_to_address ( G2_ADD_ADDRESS ) , g2_msm) ;
17
+ PrecompileWithAddress ( u64_to_address ( G2_MSM_ADDRESS ) , g2_msm) ;
18
18
19
19
/// Implements EIP-2537 G2MSM precompile.
20
20
/// G2 multi-scalar-multiplication call expects `288*k` bytes as an input that is interpreted
@@ -26,24 +26,24 @@ pub const PRECOMPILE: PrecompileWithAddress =
26
26
/// See also: <https://eips.ethereum.org/EIPS/eip-2537#abi-for-g2-multiexponentiation>
27
27
pub ( super ) fn g2_msm ( input : & Bytes , gas_limit : u64 ) -> PrecompileResult {
28
28
let input_len = input. len ( ) ;
29
- if input_len == 0 || input_len % G2_ADD_INPUT_LENGTH != 0 {
29
+ if input_len == 0 || input_len % G2_MSM_INPUT_LENGTH != 0 {
30
30
return Err ( PrecompileError :: Other ( format ! (
31
31
"G2MSM input length should be multiple of {}, was {}" ,
32
- G2_ADD_INPUT_LENGTH , input_len
32
+ G2_MSM_INPUT_LENGTH , input_len
33
33
) )
34
34
. into ( ) ) ;
35
35
}
36
36
37
- let k = input_len / G2_ADD_INPUT_LENGTH ;
38
- let required_gas = msm_required_gas ( k, & DISCOUNT_TABLE_G2_MSM , G2_ADD_BASE_GAS_FEE ) ;
37
+ let k = input_len / G2_MSM_INPUT_LENGTH ;
38
+ let required_gas = msm_required_gas ( k, & DISCOUNT_TABLE_G2_MSM , G2_MSM_BASE_GAS_FEE ) ;
39
39
if required_gas > gas_limit {
40
40
return Err ( PrecompileError :: OutOfGas . into ( ) ) ;
41
41
}
42
42
43
43
let mut g2_points: Vec < blst_p2 > = Vec :: with_capacity ( k) ;
44
44
let mut scalars: Vec < u8 > = Vec :: with_capacity ( k * SCALAR_LENGTH ) ;
45
45
for i in 0 ..k {
46
- let slice = & input[ i * G2_ADD_INPUT_LENGTH ..i * G2_ADD_INPUT_LENGTH + G2_INPUT_ITEM_LENGTH ] ;
46
+ let slice = & input[ i * G2_MSM_INPUT_LENGTH ..i * G2_MSM_INPUT_LENGTH + G2_INPUT_ITEM_LENGTH ] ;
47
47
// BLST batch API for p2_affines blows up when you pass it a point at infinity, so we must
48
48
// filter points at infinity (and their corresponding scalars) from the input.
49
49
if slice. iter ( ) . all ( |i| * i == 0 ) {
@@ -63,8 +63,8 @@ pub(super) fn g2_msm(input: &Bytes, gas_limit: u64) -> PrecompileResult {
63
63
64
64
scalars. extend_from_slice (
65
65
& extract_scalar_input (
66
- & input[ i * G2_ADD_INPUT_LENGTH + G2_INPUT_ITEM_LENGTH
67
- ..i * G2_ADD_INPUT_LENGTH + G2_INPUT_ITEM_LENGTH + SCALAR_LENGTH ] ,
66
+ & input[ i * G2_MSM_INPUT_LENGTH + G2_INPUT_ITEM_LENGTH
67
+ ..i * G2_MSM_INPUT_LENGTH + G2_INPUT_ITEM_LENGTH + SCALAR_LENGTH ] ,
68
68
) ?
69
69
. b ,
70
70
) ;
0 commit comments