From ba2f3fd359dae3021efcfc3b6dcb07fd5dafcc8a Mon Sep 17 00:00:00 2001 From: William Oldham Date: Mon, 11 Mar 2024 20:31:40 +0000 Subject: [PATCH] Add method to get keys from seed directly --- src/backend/accounts/crypto.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/backend/accounts/crypto.ts b/src/backend/accounts/crypto.ts index 9fe51380..9e099bf2 100644 --- a/src/backend/accounts/crypto.ts +++ b/src/backend/accounts/crypto.ts @@ -21,9 +21,7 @@ export function verifyValidMnemonic(mnemonic: string) { return validateMnemonic(mnemonic, wordlist); } -export async function keysFromMnemonic(mnemonic: string): Promise { - const seed = await seedFromMnemonic(mnemonic); - +export async function keysFromSeed(seed: Uint8Array): Promise { const { privateKey, publicKey } = forge.pki.ed25519.generateKeyPair({ seed, }); @@ -35,6 +33,12 @@ export async function keysFromMnemonic(mnemonic: string): Promise { }; } +export async function keysFromMnemonic(mnemonic: string): Promise { + const seed = await seedFromMnemonic(mnemonic); + + return keysFromSeed(seed); +} + export function genMnemonic(): string { return generateMnemonic(wordlist); }