Don't expose external API to hex representation of mnemoic

This commit is contained in:
adamritter 2022-12-23 12:39:19 +00:00 committed by fiatjaf
parent ac698ef67d
commit c7b26fdba2
1 changed files with 2 additions and 6 deletions

View File

@ -7,17 +7,13 @@ import {
} from '@scure/bip39'
import {HDKey} from '@scure/bip32'
export function privateKeyFromSeed(seed: string): string {
let root = HDKey.fromMasterSeed(secp256k1.utils.hexToBytes(seed))
export function privateKeyFromSeedWords(mnemonic: string): string {
let root = HDKey.fromMasterSeed(mnemonicToSeedSync(mnemonic))
let privateKey = root.derive(`m/44'/1237'/0'/0/0`).privateKey
if (!privateKey) throw new Error('could not derive private key')
return secp256k1.utils.bytesToHex(privateKey)
}
export function seedFromWords(mnemonic: string): string {
return secp256k1.utils.bytesToHex(mnemonicToSeedSync(mnemonic))
}
export function generateSeedWords(): string {
return generateMnemonic(wordlist)
}