add nip06.

This commit is contained in:
fiatjaf
2021-12-11 19:28:00 -03:00
parent 57b9bac9b1
commit 7447524028
4 changed files with 22 additions and 4 deletions

16
nip06.js Normal file
View File

@@ -0,0 +1,16 @@
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'))
}