From 32360a465720acf438515766afec3c7451b59b75 Mon Sep 17 00:00:00 2001 From: fiatjaf Date: Fri, 2 May 2025 18:46:48 -0300 Subject: [PATCH] fix libsecp256k1 VerifySignature() method. --- signature_libsecp256k1.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/signature_libsecp256k1.go b/signature_libsecp256k1.go index 9c20698..5617ecb 100644 --- a/signature_libsecp256k1.go +++ b/signature_libsecp256k1.go @@ -27,22 +27,21 @@ import ( "crypto/rand" "crypto/sha256" "errors" - "fmt" "unsafe" "github.com/btcsuite/btcd/btcec/v2/schnorr" ) -func (evt Event) CheckSignature() (bool, error) { +func (evt Event) VerifySignature() bool { msg := sha256.Sum256(evt.Serialize()) var xonly C.secp256k1_xonly_pubkey if C.secp256k1_xonly_pubkey_parse(globalSecp256k1Context, &xonly, (*C.uchar)(unsafe.Pointer(&evt.PubKey[0]))) != 1 { - return false, fmt.Errorf("failed to parse xonly pubkey") + return false } res := C.secp256k1_schnorrsig_verify(globalSecp256k1Context, (*C.uchar)(unsafe.Pointer(&evt.Sig[0])), (*C.uchar)(unsafe.Pointer(&msg[0])), 32, &xonly) - return res == 1, nil + return res == 1 } // Sign signs an event with a given privateKey.