bring back @noble/curves instead of @noble/secp256k1.

fixes https://github.com/nbd-wtf/nostr-tools/issues/196#issuecomment-1537549606
This commit is contained in:
Paul Miller
2023-04-14 16:26:33 +00:00
committed by fiatjaf
parent ac7598b5e3
commit 03cc18d53b
11 changed files with 268 additions and 253 deletions

View File

@@ -1,4 +1,5 @@
import * as secp256k1 from '@noble/secp256k1'
import {schnorr} from '@noble/curves/secp256k1'
import {bytesToHex} from '@noble/hashes/utils'
import {sha256} from '@noble/hashes/sha256'
import {Event} from './event'
@@ -36,8 +37,8 @@ export function createDelegation(
utf8Encoder.encode(`nostr:delegation:${parameters.pubkey}:${cond}`)
)
let sig = secp256k1.utils.bytesToHex(
secp256k1.schnorr.signSync(sighash, privateKey)
let sig = bytesToHex(
schnorr.sign(sighash, privateKey)
)
return {
@@ -84,7 +85,7 @@ export function getDelegator(event: Event<number>): string | null {
let sighash = sha256(
utf8Encoder.encode(`nostr:delegation:${event.pubkey}:${cond}`)
)
if (!secp256k1.schnorr.verifySync(sig, sighash, pubkey)) return null
if (!schnorr.verify(sig, sighash, pubkey)) return null
return pubkey
}