mirror of
https://github.com/nbd-wtf/nostr-tools.git
synced 2025-12-09 00:28:51 +00:00
remove buffer usage everywhere.
This commit is contained in:
7
nip06.ts
7
nip06.ts
@@ -1,3 +1,4 @@
|
||||
import * as secp256k1 from '@noble/secp256k1'
|
||||
import {wordlist} from '@scure/bip39/wordlists/english.js'
|
||||
import {
|
||||
generateMnemonic,
|
||||
@@ -7,14 +8,14 @@ import {
|
||||
import {HDKey} from '@scure/bip32'
|
||||
|
||||
export function privateKeyFromSeed(seed: string): string {
|
||||
let root = HDKey.fromMasterSeed(Buffer.from(seed, 'hex'))
|
||||
let root = HDKey.fromMasterSeed(secp256k1.utils.hexToBytes(seed))
|
||||
let privateKey = root.derive(`m/44'/1237'/0'/0/0`).privateKey
|
||||
if (!privateKey) throw new Error('could not derive private key')
|
||||
return Buffer.from(privateKey).toString('hex')
|
||||
return secp256k1.utils.bytesToHex(privateKey)
|
||||
}
|
||||
|
||||
export function seedFromWords(mnemonic: string): string {
|
||||
return Buffer.from(mnemonicToSeedSync(mnemonic)).toString('hex')
|
||||
return secp256k1.utils.bytesToHex(mnemonicToSeedSync(mnemonic))
|
||||
}
|
||||
|
||||
export function generateSeedWords(): string {
|
||||
|
||||
Reference in New Issue
Block a user