Skip to content

Commit

Permalink
Merge pull request #567 from nomiclabs/use-ethereum-cryptography
Browse files Browse the repository at this point in the history
Use ethereum-cryptography
  • Loading branch information
alcuadrado committed May 10, 2020
2 parents 387cf4b + 0ff74cf commit d8e62fb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
3 changes: 1 addition & 2 deletions packages/buidler-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,14 @@
"@types/lru-cache": "^5.1.0",
"abort-controller": "^3.0.0",
"ansi-escapes": "^4.3.0",
"bip32": "^2.0.3",
"bip39": "^3.0.2",
"chalk": "^2.4.2",
"ci-info": "^2.0.0",
"debug": "^4.1.1",
"deepmerge": "^2.1.0",
"download": "^7.1.0",
"enquirer": "^2.3.0",
"eth-sig-util": "^2.5.2",
"ethereum-cryptography": "^0.1.2",
"ethereumjs-abi": "^0.6.8",
"ethereumjs-account": "^3.0.0",
"ethereumjs-block": "^2.2.0",
Expand Down
11 changes: 6 additions & 5 deletions packages/buidler-core/src/internal/util/keys-derivation.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { fromSeed } from "bip32";
import { mnemonicToSeedSync } from "bip39";
import { mnemonicToSeedSync } from "ethereum-cryptography/bip39";
import { HDKey } from "ethereum-cryptography/hdkey";

export function deriveKeyFromMnemonicAndPath(
mnemonic: string,
hdPath: string
): Buffer | undefined {
const seed = mnemonicToSeedSync(mnemonic);
const masterKey = fromSeed(seed);
const derived = masterKey.derivePath(hdPath);

return derived.privateKey;
const masterKey = HDKey.fromMasterSeed(seed);
const derived = masterKey.derive(hdPath);

return derived.privateKey === null ? undefined : derived.privateKey;
}

0 comments on commit d8e62fb

Please sign in to comment.