libsecp256k1: use a static global context and add verification tests.

This commit is contained in:
fiatjaf
2024-05-29 15:40:57 -03:00
parent 427bfc7a4b
commit 31e0645afe
4 changed files with 34 additions and 25 deletions

View File

@@ -8,7 +8,7 @@ import (
"github.com/nbd-wtf/go-nostr"
)
func (c *Context) CheckSignature(evt *nostr.Event) (bool, error) {
func CheckSignature(evt *nostr.Event) (bool, error) {
var pk [32]byte
_, err := hex.Decode(pk[:], []byte(evt.PubKey))
if err != nil {
@@ -22,5 +22,5 @@ func (c *Context) CheckSignature(evt *nostr.Event) (bool, error) {
}
msg := sha256.Sum256(evt.Serialize())
return c.Verify(msg, sig, pk), nil
return Verify(msg, sig, pk), nil
}