Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/audit #93

Merged
merged 3 commits into from
Nov 8, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Update dependencies to the latest versions
joon9823 committed Nov 8, 2024
commit 2c9d331ef42fe3a8e2acc8fd4c85f2bd6f9c5b64
419 changes: 155 additions & 264 deletions package-lock.json
21 changes: 11 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -56,23 +56,24 @@
"vite-plugin-dts": "^4.2.3"
},
"dependencies": {
"@bitcoinerlab/secp256k1": "^1.1.1",
"@initia/initia.proto": "^0.2.3",
"@initia/opinit.proto": "^0.0.10",
"@ledgerhq/hw-transport": "^6.27.12",
"@ledgerhq/hw-transport-webhid": "^6.27.12",
"@ledgerhq/hw-transport-webusb": "^6.27.12",
"@mysten/bcs": "^1.0.2",
"axios": "^1.7.4",
"@ledgerhq/hw-transport": "^6.31.4",
"@ledgerhq/hw-transport-webhid": "^6.29.4",
"@ledgerhq/hw-transport-webusb": "^6.29.4",
"@mysten/bcs": "^1.1.0",
"axios": "^1.7.7",
"bech32": "^2.0.0",
"bignumber.js": "^9.1.0",
"bip32": "^2.0.6",
"bip39": "^3.0.4",
"bignumber.js": "^9.1.2",
"bip32": "^5.0.0-rc.0",
joon9823 marked this conversation as resolved.
Show resolved Hide resolved
"bip39": "^3.1.0",
"jscrypto": "^1.0.3",
"keccak256": "^1.0.6",
"ripemd160": "^2.0.2",
"secp256k1": "^5.0.0",
"secp256k1": "^5.0.1",
"semver": "^7.6.3",
"ws": "^7.5.10"
"ws": "^8.18.0"
},
"lint-staged": {
"src/**/*.{mjs|ts}": [
12 changes: 7 additions & 5 deletions src/key/MnemonicKey.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import * as bip32 from 'bip32'
import * as bip39 from 'bip39'
import ecc from '@bitcoinerlab/secp256k1'
import { BIP32Factory } from 'bip32'
import { generateMnemonic, mnemonicToSeedSync } from 'bip39'
import { RawKey } from './RawKey'

const bip32 = BIP32Factory(ecc)
export const INIT_COIN_TYPE = 118

interface MnemonicKeyOptions {
@@ -78,9 +80,9 @@ export class MnemonicKey extends RawKey {
}
let { mnemonic } = options
if (mnemonic === undefined) {
mnemonic = bip39.generateMnemonic(256)
mnemonic = generateMnemonic(256)
}
const seed: Buffer = bip39.mnemonicToSeedSync(mnemonic)
const seed: Buffer = mnemonicToSeedSync(mnemonic)
const masterKey = bip32.fromSeed(seed)
const hdPathInitia = `m/44'/${coinType}'/${account}'/0/${index}`
const initiaHD = masterKey.derivePath(hdPathInitia)
@@ -90,7 +92,7 @@ export class MnemonicKey extends RawKey {
throw new Error('Failed to derive key pair')
}

super(privateKey, eth)
super(Buffer.from(privateKey), eth)
this.mnemonic = mnemonic
}
}