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

Update bip39 implementation to @metamask/scure-bip39 #101

Merged
merged 4 commits into from
Jan 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@
]
},
"dependencies": {
"@metamask/scure-bip39": "^2.1.0",
"@metamask/utils": "^3.3.0",
"@noble/ed25519": "^1.6.0",
"@noble/hashes": "^1.0.0",
"@noble/secp256k1": "^1.5.5",
"@scure/base": "^1.0.0",
"@scure/bip39": "^1.0.0"
"@scure/base": "^1.0.0"
},
"devDependencies": {
"@lavamoat/allow-scripts": "^2.0.3",
Expand Down
8 changes: 6 additions & 2 deletions src/derivers/bip39.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { mnemonicToSeed } from '@metamask/scure-bip39';
import { wordlist as englishWordlist } from '@metamask/scure-bip39/dist/wordlists/english';
import { hmac } from '@noble/hashes/hmac';
import { sha512 } from '@noble/hashes/sha512';
import { mnemonicToSeed } from '@scure/bip39';

import { DeriveChildKeyArgs } from '.';
import { BIP39Node } from '../constants';
Expand Down Expand Up @@ -30,7 +31,10 @@ export async function deriveChildKey({
path,
curve,
}: DeriveChildKeyArgs): Promise<SLIP10Node> {
return createBip39KeyFromSeed(await mnemonicToSeed(path), curve);
return createBip39KeyFromSeed(
await mnemonicToSeed(path, englishWordlist),
curve,
);
}

/**
Expand Down
22 changes: 11 additions & 11 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -865,12 +865,12 @@ __metadata:
"@metamask/eslint-config-jest": ^11.0.0
"@metamask/eslint-config-nodejs": ^11.0.1
"@metamask/eslint-config-typescript": ^11.0.0
"@metamask/scure-bip39": ^2.1.0
"@metamask/utils": ^3.3.0
"@noble/ed25519": ^1.6.0
"@noble/hashes": ^1.0.0
"@noble/secp256k1": ^1.5.5
"@scure/base": ^1.0.0
"@scure/bip39": ^1.0.0
"@types/jest": ^27.0.2
"@typescript-eslint/eslint-plugin": ^5.42.1
"@typescript-eslint/parser": ^5.42.1
Expand All @@ -894,6 +894,16 @@ __metadata:
languageName: unknown
linkType: soft

"@metamask/scure-bip39@npm:^2.1.0":
version: 2.1.0
resolution: "@metamask/scure-bip39@npm:2.1.0"
dependencies:
"@noble/hashes": ~1.1.1
"@scure/base": ~1.1.0
checksum: 13e07f03077472e9b230f702cbba7848ecac752028396647ccdeedd7bc280ceb50ee15203e25603f05c4c6ca5d4dc7277825f7004beb113e1a415adc91f059f9
languageName: node
linkType: hard

"@metamask/utils@npm:^3.3.0":
version: 3.4.0
resolution: "@metamask/utils@npm:3.4.0"
Expand Down Expand Up @@ -1009,16 +1019,6 @@ __metadata:
languageName: node
linkType: hard

"@scure/bip39@npm:^1.0.0":
version: 1.1.0
resolution: "@scure/bip39@npm:1.1.0"
dependencies:
"@noble/hashes": ~1.1.1
"@scure/base": ~1.1.0
checksum: c4361406f092a45e511dc572c89f497af6665ad81cb3fd7bf78e6772f357f7ae885e129ef0b985cb3496a460b4811318f77bc61634d9b0a8446079a801b6003c
languageName: node
linkType: hard

"@sinonjs/commons@npm:^1.7.0":
version: 1.8.3
resolution: "@sinonjs/commons@npm:1.8.3"
Expand Down