mirror of
https://github.com/nbd-wtf/nostr-tools.git
synced 2025-12-08 16:28:49 +00:00
'Buffer' wasn't imported initially and was causing issues when I tried to use generatePrivateKey in a client I am building. not sure why Branle has no error, maybe I am doing something wrong?
11 lines
318 B
JavaScript
11 lines
318 B
JavaScript
import * as secp256k1 from '@noble/secp256k1'
|
|
import {Buffer} from 'buffer'
|
|
|
|
export function generatePrivateKey() {
|
|
return Buffer.from(secp256k1.utils.randomPrivateKey()).toString('hex')
|
|
}
|
|
|
|
export function getPublicKey(privateKey) {
|
|
return Buffer.from(secp256k1.schnorr.getPublicKey(privateKey)).toString('hex')
|
|
}
|