mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-07-09 15:49:56 +02:00
fix CheckSignature(): we were parsing the pubkey with the ECDSA function instead of Schnorr.
This commit is contained in:
2
event.go
2
event.go
@ -75,7 +75,7 @@ func (evt Event) CheckSignature() (bool, error) {
|
|||||||
return false, fmt.Errorf("event pubkey '%s' is invalid hex: %w", evt.PubKey, err)
|
return false, fmt.Errorf("event pubkey '%s' is invalid hex: %w", evt.PubKey, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
pubkey, err := btcec.ParsePubKey(pk)
|
pubkey, err := schnorr.ParsePubKey(pk)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, fmt.Errorf("event has invalid pubkey '%s': %w", evt.PubKey, err)
|
return false, fmt.Errorf("event has invalid pubkey '%s': %w", evt.PubKey, err)
|
||||||
}
|
}
|
||||||
|
@ -142,8 +142,13 @@ func (r *RelayPool) Add(url string, policy RelayPoolPolicy) error {
|
|||||||
json.Unmarshal(jsonMessage[2], &event)
|
json.Unmarshal(jsonMessage[2], &event)
|
||||||
|
|
||||||
// check signature of all received events, ignore invalid
|
// check signature of all received events, ignore invalid
|
||||||
ok, _ := event.CheckSignature()
|
ok, err := event.CheckSignature()
|
||||||
if !ok {
|
if !ok {
|
||||||
|
errmsg := ""
|
||||||
|
if err != nil {
|
||||||
|
errmsg = err.Error()
|
||||||
|
}
|
||||||
|
log.Printf("bad signature: %s", errmsg)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user