mirror of
https://github.com/fiatjaf/khatru.git
synced 2025-03-17 21:32:55 +01:00
check id before signature and do not allow invalid ids.
This commit is contained in:
parent
591b49fe73
commit
18e4904a00
12
handlers.go
12
handlers.go
@ -116,12 +116,12 @@ func (rl *Relay) HandleWebsocket(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
// check serialization
|
||||
serialized := evt.Serialize()
|
||||
|
||||
// assign ID
|
||||
hash := sha256.Sum256(serialized)
|
||||
evt.ID = hex.EncodeToString(hash[:])
|
||||
// check id
|
||||
hash := sha256.Sum256(evt.Serialize())
|
||||
id := hex.EncodeToString(hash[:])
|
||||
if id != evt.ID {
|
||||
ws.WriteJSON(nostr.OKEnvelope{EventID: evt.ID, OK: false, Reason: "invalid: id is computed incorrectly"})
|
||||
}
|
||||
|
||||
// check signature (requires the ID to be set)
|
||||
if ok, err := evt.CheckSignature(); err != nil {
|
||||
|
Loading…
x
Reference in New Issue
Block a user