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

View File

@ -355,7 +355,7 @@ impl Event {
return Err(EventInvalidId);
}
// * 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(pubkey) = XOnlyPublicKey::from_str(&self.pubkey) {
SECP.verify_schnorr(&sig, &msg, &pubkey)