1
0
mirror of https://github.com/scsibug/nostr-rs-relay.git synced 2025-07-31 00:18:27 -04:00

fix: panic on malformed signature

This commit is contained in:
Wspsxing
2023-09-04 17:56:54 +08:00
committed by Greg Heartsfield
parent 34c8b04926
commit 7a77c459bb

@@ -355,7 +355,7 @@ impl Event {
return Err(EventInvalidId); return Err(EventInvalidId);
} }
// * validate the message digest (sig) using the pubkey & computed sha256 message hash. // * validate the message digest (sig) using the pubkey & computed sha256 message hash.
let sig = schnorr::Signature::from_str(&self.sig).unwrap(); let sig = schnorr::Signature::from_str(&self.sig).map_err(|_| EventInvalidSignature)?;
if let Ok(msg) = secp256k1::Message::from_slice(digest.as_ref()) { if let Ok(msg) = secp256k1::Message::from_slice(digest.as_ref()) {
if let Ok(pubkey) = XOnlyPublicKey::from_str(&self.pubkey) { if let Ok(pubkey) = XOnlyPublicKey::from_str(&self.pubkey) {
SECP.verify_schnorr(&sig, &msg, &pubkey) SECP.verify_schnorr(&sig, &msg, &pubkey)