Skip to content

Commit 1b96fd0

Browse files
committed
Fix vulnerabilities
1 parent efeb730 commit 1b96fd0

File tree

14 files changed

+398
-1097
lines changed

14 files changed

+398
-1097
lines changed

package-lock.json

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

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"chai-as-promised": "^8.0.2",
2323
"chai-spies": "^1.1.0",
2424
"globals": "^15.4.0",
25-
"mocha": "11.7.2",
25+
"mocha": "11.7.5",
2626
"prettier": "^3.3.2",
2727
"tsx": "^4.16.2",
2828
"turbo": "^2.0.6",
@@ -37,7 +37,8 @@
3737
"wrap-ansi": "9.0.2",
3838
"ansi-styles": "6.2.3",
3939
"supports-color": "10.2.2",
40-
"log-symbols": "7.0.1"
40+
"log-symbols": "7.0.1",
41+
"diff": "8.0.3"
4142
},
4243
"workspaces": [
4344
"packages/*"

packages/avalanche/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@
3636
"@avalabs/avalanchejs": "^4.0.5",
3737
"@chorus-one/signer": "^1.0.0",
3838
"@chorus-one/utils": "^1.0.0",
39+
"@noble/curves": "^1.9.2",
3940
"@noble/hashes": "^1.4.0",
4041
"ethers": "^6.13.0",
41-
"secp256k1": "^5.0.0",
4242
"bignumber.js": "^9.1.2"
4343
}
4444
}

packages/avalanche/src/tx.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
import { secp256k1 as avalancheSecp256k1, utils } from '@avalabs/avalanchejs'
22
import { checkMaxDecimalPlaces } from '@chorus-one/utils'
33
import { Context } from '@avalabs/avalanchejs'
4-
import secp256k1 from 'secp256k1'
4+
import { secp256k1 } from '@noble/curves/secp256k1'
55
import { AvalancheAddressSet } from './types.d'
66
import { BigNumber } from 'bignumber.js'
77

88
/** @ignore */
99
export function publicKeyToAddress (pk: Uint8Array, hrp: string): AvalancheAddressSet {
10-
const pkUncompressed = secp256k1.publicKeyConvert(pk, false)
10+
// Convert public key using @noble/curves
11+
const point = secp256k1.Point.fromHex(pk)
12+
const pkUncompressed = point.toBytes(false)
1113

1214
// NOTE: avalanchejs publicKeyBytesToAddress expects compressed public key!!! (otherwise you get wrong address)
13-
const pkCompressed = secp256k1.publicKeyConvert(pkUncompressed, true)
15+
const pkCompressed = point.toBytes(true)
1416

1517
// generate C-Chain and P-Chain addresses
1618
const addrBytes = avalancheSecp256k1.publicKeyBytesToAddress(pkCompressed)

packages/cosmos/package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@
3434
"dependencies": {
3535
"@chorus-one/signer": "^1.0.0",
3636
"@chorus-one/utils": "^1.0.2",
37-
"@cosmjs/amino": "^0.33.1",
38-
"@cosmjs/crypto": "^0.33.1",
39-
"@cosmjs/encoding": "^0.33.1",
40-
"@cosmjs/math": "^0.33.1",
41-
"@cosmjs/proto-signing": "^0.33.1",
42-
"@cosmjs/stargate": "^0.33.1",
37+
"@cosmjs/amino": "^0.38.1",
38+
"@cosmjs/crypto": "^0.38.1",
39+
"@cosmjs/encoding": "^0.38.1",
40+
"@cosmjs/math": "^0.38.1",
41+
"@cosmjs/proto-signing": "^0.38.1",
42+
"@cosmjs/stargate": "^0.38.1",
43+
"@noble/curves": "^1.9.2",
4344
"bignumber.js": "^9.1.2",
44-
"cosmjs-types": "^0.9.0",
45-
"secp256k1": "^5.0.0"
45+
"cosmjs-types": "^0.9.0"
4646
}
4747
}

packages/cosmos/src/client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { connectComet, CometClient } from '@cosmjs/tendermint-rpc'
1919

2020
/** @ignore */
2121
export class CosmosClient extends StargateClient {
22-
static async create (tmClient: CometClient, options: StargateClientOptions): Promise<CosmosClient> {
22+
static create (tmClient: CometClient, options: StargateClientOptions): CosmosClient {
2323
return new CosmosClient(tmClient, options)
2424
}
2525

packages/cosmos/src/tx.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import type { Signature, Signer } from '@chorus-one/signer'
3030
import type { CosmosNetworkConfig, CosmosSigningData } from './types'
3131
import { Sha256, keccak256, Secp256k1 } from '@cosmjs/crypto'
3232

33-
import secp256k1 from 'secp256k1'
33+
import { secp256k1 } from '@noble/curves/secp256k1'
3434
import { SafeJSONStringify, checkMaxDecimalPlaces } from '@chorus-one/utils'
3535
import { CosmosClient } from './client'
3636
import BigNumber from 'bignumber.js'
@@ -380,14 +380,18 @@ export async function getEthermintAccount (lcdUrl: string, address: string): Pro
380380

381381
/** @ignore */
382382
export function publicKeyToAddress (pk: Uint8Array, bechPrefix: string): string {
383-
const pkCompressed = secp256k1.publicKeyConvert(pk, true)
383+
// Convert public key to compressed format using @noble/curves
384+
const point = secp256k1.Point.fromHex(pk)
385+
const pkCompressed = point.toBytes(true)
384386

385387
return toBech32(bechPrefix, rawSecp256k1PubkeyToRawAddress(pkCompressed))
386388
}
387389

388390
/** @ignore */
389391
export function publicKeyToEthBasedAddress (pk: Uint8Array, bechPrefix: string): string {
390-
const pkUncompressed = secp256k1.publicKeyConvert(pk, false)
392+
// Convert public key to uncompressed format using @noble/curves
393+
const point = secp256k1.Point.fromHex(pk)
394+
const pkUncompressed = point.toBytes(false)
391395

392396
const hash = keccak256(pkUncompressed.subarray(1))
393397
const ethAddress = hash.slice(-20)

packages/ethereum/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@
3838
"dependencies": {
3939
"@chorus-one/signer": "^1.0.0",
4040
"@chorus-one/utils": "^1.0.2",
41+
"@noble/curves": "^1.9.2",
4142
"decimal.js": "^10.4.3",
42-
"secp256k1": "^5.0.0",
4343
"viem": "^2.28.0"
4444
},
4545
"type": "module",

packages/ethereum/src/staker.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { Signer } from '@chorus-one/signer'
2-
import secp256k1 from 'secp256k1'
2+
import { secp256k1 } from '@noble/curves/secp256k1'
33
import {
44
Chain,
55
createWalletClient,
@@ -67,7 +67,9 @@ export class EthereumStaker {
6767
static getAddressDerivationFn =
6868
() =>
6969
async (publicKey: Uint8Array): Promise<Array<string>> => {
70-
const pkUncompressed = secp256k1.publicKeyConvert(publicKey, false)
70+
// Convert public key to uncompressed format using @noble/curves
71+
const point = secp256k1.Point.fromHex(publicKey)
72+
const pkUncompressed = point.toBytes(false)
7173
const hash = keccak256(pkUncompressed.subarray(1))
7274
const ethAddress = hash.slice(-40)
7375
return [ethAddress]

packages/hyperliquid/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"dependencies": {
3737
"@chorus-one/signer": "^1.0.0",
3838
"@chorus-one/utils": "^1.0.2",
39-
"secp256k1": "^5.0.0",
39+
"@noble/curves": "^1.9.2",
4040
"viem": "^2.28.0",
4141
"zod": "^3.25.76"
4242
},

0 commit comments

Comments
 (0)