Skip to content

Commit e4d55d3

Browse files
authored
Update ethereum-cryptography (#3859)
* upgrade eth-crypto to 3.1 * use noble/curves in evm * Remove duplicate type
1 parent 3e22e7d commit e4d55d3

File tree

14 files changed

+136
-78
lines changed

14 files changed

+136
-78
lines changed

package-lock.json

Lines changed: 115 additions & 44 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/block/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"@ethereumjs/mpt": "^7.0.0-alpha.1",
4848
"@ethereumjs/tx": "^6.0.0-alpha.1",
4949
"@ethereumjs/util": "^10.0.0-alpha.1",
50-
"ethereum-cryptography": "^3.0.0"
50+
"ethereum-cryptography": "^3.1.0"
5151
},
5252
"devDependencies": {
5353
"@paulmillr/trusted-setups": "^0.1.2",

packages/client/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
"connect": "^3.7.0",
7373
"cors": "^2.8.5",
7474
"debug": "^4.3.3",
75-
"ethereum-cryptography": "^3.0.0",
75+
"ethereum-cryptography": "^3.1.0",
7676
"eventemitter3": "^5.0.1",
7777
"jayson": "^4.0.0",
7878
"level": "^8.0.0",

packages/devp2p/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
"@ethereumjs/util": "^10.0.0-alpha.1",
6363
"@scure/base": "^1.1.7",
6464
"debug": "^4.3.3",
65-
"ethereum-cryptography": "^3.0.0",
65+
"ethereum-cryptography": "^3.1.0",
6666
"eventemitter3": "^5.0.1",
6767
"lru-cache": "10.1.0",
6868
"scanf": "1.1.2",

packages/ethash/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"@ethereumjs/rlp": "^6.0.0-alpha.1",
4545
"@ethereumjs/util": "^10.0.0-alpha.1",
4646
"bigint-crypto-utils": "^3.2.2",
47-
"ethereum-cryptography": "^3.0.0"
47+
"ethereum-cryptography": "^3.1.0"
4848
},
4949
"devDependencies": {
5050
"@ethereumjs/common": "^5.0.0-alpha.1"

packages/evm/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,10 @@
4949
"@ethereumjs/common": "^5.0.0-alpha.1",
5050
"@ethereumjs/statemanager": "^3.0.0-alpha.1",
5151
"@ethereumjs/util": "^10.0.0-alpha.1",
52+
"@noble/curves": "^1.8.1",
5253
"@types/debug": "^4.1.9",
5354
"debug": "^4.3.3",
54-
"ethereum-cryptography": "^3.0.0",
55+
"ethereum-cryptography": "^3.1.0",
5556
"eventemitter3": "^5.0.1"
5657
},
5758
"devDependencies": {

packages/evm/src/precompiles/bls12_381/noble.ts

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
equalsBytes,
77
setLengthLeft,
88
} from '@ethereumjs/util'
9-
import { bls12_381 } from 'ethereum-cryptography/bls.js'
9+
import { bls12_381 } from '@noble/curves/bls12-381'
1010

1111
import { ERROR, EvmError } from '../../exceptions.js'
1212

@@ -21,17 +21,8 @@ import {
2121
} from './constants.js'
2222

2323
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'
3526

3627
const G1_ZERO = bls12_381.G1.ProjectivePoint.ZERO
3728
const G2_ZERO = bls12_381.G2.ProjectivePoint.ZERO
@@ -58,7 +49,7 @@ function BLS12_381_ToFp2Point(fpXCoordinate: Uint8Array, fpYCoordinate: Uint8Arr
5849
* @returns Noble G1 point
5950
*/
6051
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) {
6253
return G1_ZERO
6354
}
6455

@@ -96,7 +87,7 @@ function BLS12_381_FromG1Point(input: AffinePoint<bigint>): Uint8Array {
9687
* @returns Noble G2 point
9788
*/
9889
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) {
10091
return G2_ZERO
10192
}
10293

0 commit comments

Comments
 (0)