Add method to get keys from seed directly

This commit is contained in:
William Oldham 2024-03-11 20:31:40 +00:00
parent 852e6ff324
commit ba2f3fd359

View file

@ -21,9 +21,7 @@ export function verifyValidMnemonic(mnemonic: string) {
return validateMnemonic(mnemonic, wordlist);
}
export async function keysFromMnemonic(mnemonic: string): Promise<Keys> {
const seed = await seedFromMnemonic(mnemonic);
export async function keysFromSeed(seed: Uint8Array): Promise<Keys> {
const { privateKey, publicKey } = forge.pki.ed25519.generateKeyPair({
seed,
});
@ -35,6 +33,12 @@ export async function keysFromMnemonic(mnemonic: string): Promise<Keys> {
};
}
export async function keysFromMnemonic(mnemonic: string): Promise<Keys> {
const seed = await seedFromMnemonic(mnemonic);
return keysFromSeed(seed);
}
export function genMnemonic(): string {
return generateMnemonic(wordlist);
}