mirror of
https://github.com/nbd-wtf/nostr-tools.git
synced 2025-12-08 16:28:49 +00:00
17 lines
451 B
JavaScript
17 lines
451 B
JavaScript
import createHmac from 'create-hmac'
|
|
import * as bip39 from 'bip39'
|
|
|
|
export function privateKeyFromSeed(seed) {
|
|
let hmac = createHmac('sha512', Buffer.from('Nostr seed', 'utf8'))
|
|
hmac.update(seed)
|
|
return hmac.digest().slice(0, 32).toString('hex')
|
|
}
|
|
|
|
export function seedFromWords(mnemonic) {
|
|
return bip39.mnemonicToSeedSync(mnemonic)
|
|
}
|
|
|
|
export function generateSeedWords() {
|
|
return bip39.entropyToMnemonic(randomBytes(16).toString('hex'))
|
|
}
|