6
6
equalsBytes ,
7
7
setLengthLeft ,
8
8
} from '@ethereumjs/util'
9
- import { bls12_381 } from 'ethereum-cryptography/bls.js '
9
+ import { bls12_381 } from '@noble/curves/bls12-381 '
10
10
11
11
import { ERROR , EvmError } from '../../exceptions.js'
12
12
@@ -21,17 +21,8 @@ import {
21
21
} from './constants.js'
22
22
23
23
import type { EVMBLSInterface } from '../../types.js'
24
-
25
- // Copied from @noble /curves/bls12-381 (only local declaration)
26
- type Fp2 = {
27
- c0 : bigint
28
- c1 : bigint
29
- }
30
- // Copied from @noble /curves/abstract/curve.ts (not exported in ethereum-cryptography)
31
- type AffinePoint < T > = {
32
- x : T
33
- y : T
34
- } & { z ?: never ; t ?: never }
24
+ import type { Fp2 } from '@noble/curves/abstract/tower'
25
+ import type { AffinePoint } from '@noble/curves/abstract/weierstrass'
35
26
36
27
const G1_ZERO = bls12_381 . G1 . ProjectivePoint . ZERO
37
28
const G2_ZERO = bls12_381 . G2 . ProjectivePoint . ZERO
@@ -58,7 +49,7 @@ function BLS12_381_ToFp2Point(fpXCoordinate: Uint8Array, fpYCoordinate: Uint8Arr
58
49
* @returns Noble G1 point
59
50
*/
60
51
function BLS12_381_ToG1Point ( input : Uint8Array , verifyOrder = true ) {
61
- if ( equalsBytes ( input , BLS_G1_INFINITY_POINT_BYTES ) ) {
52
+ if ( equalsBytes ( input , BLS_G1_INFINITY_POINT_BYTES ) === true ) {
62
53
return G1_ZERO
63
54
}
64
55
@@ -96,7 +87,7 @@ function BLS12_381_FromG1Point(input: AffinePoint<bigint>): Uint8Array {
96
87
* @returns Noble G2 point
97
88
*/
98
89
function BLS12_381_ToG2Point ( input : Uint8Array , verifyOrder = true ) {
99
- if ( equalsBytes ( input , BLS_G2_INFINITY_POINT_BYTES ) ) {
90
+ if ( equalsBytes ( input , BLS_G2_INFINITY_POINT_BYTES ) === true ) {
100
91
return G2_ZERO
101
92
}
102
93
0 commit comments