mirror of
https://github.com/nbd-wtf/nostr-tools.git
synced 2025-12-11 09:38:51 +00:00
add nip06.
This commit is contained in:
16
nip06.js
Normal file
16
nip06.js
Normal 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'))
|
||||
}
|
||||
Reference in New Issue
Block a user