fix: translate seed phrase length into bits

This commit is contained in:
Derrick Hammer 2023-10-09 15:34:08 -04:00
parent c5c6b83338
commit 935675f7e8
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 20 additions and 1 deletions

View File

@ -20,6 +20,23 @@ async function seedToKey(seed: string) {
return bip39.mnemonicToSeed(seed);
}
function getStrength(wordCount: number) {
switch (wordCount) {
case 12:
return 128;
case 15:
return 160;
case 18:
return 192;
case 21:
return 224;
case 24:
return 256;
default:
throw new Error("Invalid word count");
}
}
// Extracted components
const SubmitButtonComponent = () => {
const { setVisibleComponent } = useSwitchableComponent();
@ -101,7 +118,9 @@ const SeedPhraseGenerationComponent = ({ phraseLength = 12 }) => {
const { signIn } = useLumeIndentity();
const phrases = useMemo(() => {
return bip39.generateMnemonic(wordlist, phraseLength).split(" ");
return bip39
.generateMnemonic(wordlist, getStrength(phraseLength))
.split(" ");
}, [phraseLength]);
const key = useMemo(() => {