Add support for bip39 with other wordlists #1804
Labels
-pr appreciated
Help Wanted
Tasks open for external contributions, suitable for independent or collaborative work.
P2 - Medium
Important but not urgent. Enhances functionality and value, scheduled after higher priorities.
We are pulling in the extra wordlists via #1803
This has been PR-ed previously in #1689 and there has been some discussion. However after giving it some thought, we could actually make this work.
part 1
wordlist
option passed to the bip39 functions, e.g. last param ofwordlist: string[] = DEFAULT_WORDLIST
-common/packages/util-crypto/src/mnemonic/bip39.ts
Line 53 in 91a2eac
common/packages/util-crypto/src/mnemonic/bip39.ts
Line 95 in 91a2eac
DEAFULT_WORDLIST
usage in these functions so bewordlist
instead.bip39.spec.ts
to ensure we are actually ok.part 2
Now the base generation is ok, but we may still use the wasm versions which doesn't have support for this. To get around it -
wordlist?: string[], onlyJs?: boolean
common/packages/util-crypto/src/mnemonic/validate.ts
Lines 22 to 23 in 91a2eac
common/packages/util-crypto/src/mnemonic/toMiniSecret.ts
Line 11 in 91a2eac
common/packages/util-crypto/src/mnemonic/toLegacySeed.ts
Line 27 in 91a2eac
common/packages/util-crypto/src/mnemonic/toEntropy.ts
Line 9 in 91a2eac
common/packages/util-crypto/src/mnemonic/generate.ts
Line 21 in 91a2eac
wordlist
the same asonlyJs
, i.e. when passed in we want to take the JS (non-WASM) route, i.e. it ties into the changes we made inbip39.ts
. This looks something like!hasBigInt || (!wordlist && !onlyJs && isReady())
and the param passed on the JS-only pathpart 3
Now we also need keyring support -
addFromMnemonic
,addFromUri
&createFromUri
incommon/packages/keyring/src/keyring.ts
Lines 201 to 223 in 8920045
The text was updated successfully, but these errors were encountered: