mirror of
https://github.com/scsibug/nostr-rs-relay.git
synced 2024-11-09 21:29:06 -05:00
fix: do not panic when validating events with malformed pubkeys
This commit is contained in:
parent
6ca3e3ffea
commit
6502f7dcd7
10
src/event.rs
10
src/event.rs
|
@ -148,9 +148,13 @@ impl Event {
|
|||
|
||||
let sig = schnorr::Signature::from_str(&self.sig).unwrap();
|
||||
if let Ok(msg) = secp256k1::Message::from_slice(digest.as_ref()) {
|
||||
let pubkey = XOnlyPublicKey::from_str(&self.pubkey).unwrap();
|
||||
let verify = SECP.verify_schnorr(&sig, &msg, &pubkey);
|
||||
matches!(verify, Ok(()))
|
||||
if let Ok(pubkey) = XOnlyPublicKey::from_str(&self.pubkey) {
|
||||
let verify = SECP.verify_schnorr(&sig, &msg, &pubkey);
|
||||
matches!(verify, Ok(()))
|
||||
} else {
|
||||
info!("Client sent malformed pubkey");
|
||||
false
|
||||
}
|
||||
} else {
|
||||
warn!("Error converting digest to secp256k1 message");
|
||||
false
|
||||
|
|
Loading…
Reference in New Issue
Block a user