Allow inspection of signature verification failures
This commit is contained in:
parent
7889c7603d
commit
251f974b50
|
@ -61,16 +61,18 @@ impl Signature {
|
|||
Self(GenericArray::clone_from_slice(&signature_slice))
|
||||
}
|
||||
|
||||
pub(self) fn verify_verbose(
|
||||
&self,
|
||||
pubkey_bytes: &[u8],
|
||||
message_bytes: &[u8],
|
||||
) -> Result<(), ed25519_dalek::SignatureError> {
|
||||
let publickey = ed25519_dalek::PublicKey::from_bytes(pubkey_bytes)?;
|
||||
let signature = self.0.as_slice().try_into()?;
|
||||
publickey.verify_strict(message_bytes, &signature)
|
||||
}
|
||||
|
||||
pub fn verify(&self, pubkey_bytes: &[u8], message_bytes: &[u8]) -> bool {
|
||||
let pubkey = ed25519_dalek::PublicKey::from_bytes(pubkey_bytes);
|
||||
let signature = self.0.as_slice().try_into();
|
||||
if pubkey.is_err() || signature.is_err() {
|
||||
return false;
|
||||
}
|
||||
pubkey
|
||||
.unwrap()
|
||||
.verify_strict(message_bytes, &signature.unwrap())
|
||||
.is_ok()
|
||||
self.verify_verbose(pubkey_bytes, message_bytes).is_ok()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue