Skip to main content

Verifier

Trait Verifier 

Source
pub trait Verifier {
    // Required method
    fn verify(&self, data: &[u8], signature: &[u8]) -> Result<bool, VctrlError>;
}
Expand description

A digital signature verifier.

Matches a Signer implementation. Given data and a signature, returns Ok(true) if the signature is valid, Ok(false) if it is not.

§Why not Result<bool, …> where false is an error?

Because an invalid signature is not a system failure – it’s an expected outcome during verification. Errors should be reserved for cases where the verifier cannot operate (e.g., missing key, corrupted key).

§Example (stub)

use libvctrl_handler::{Verifier, VctrlError};

struct StubVerifier;
impl Verifier for StubVerifier {
    fn verify(&self, data: &[u8], signature: &[u8]) -> Result<bool, VctrlError> {
        // Dummy check: signature is valid iff it equals the data.
        Ok(data == signature)
    }
}

Required Methods§

Source

fn verify(&self, data: &[u8], signature: &[u8]) -> Result<bool, VctrlError>

Verify that signature is a valid signature for data.

Returns true if the signature is valid, false otherwise.

§Errors

Returns an error if the verification process itself fails (e.g., invalid key).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§