pub trait SignatureVerifier<PK: SignaturePublicKey<PK_LEN>, const PK_LEN: usize, const SIG_LEN: usize>: Sized {
// Required methods
fn verify(
pk: &PK,
msg: &[u8],
ctx: Option<&[u8]>,
sig: &[u8],
) -> Result<(), SignatureError>;
fn verify_init(pk: &PK, ctx: Option<&[u8]>) -> Result<Self, SignatureError>;
fn verify_update(&mut self, msg_chunk: &[u8]);
fn verify_final(self, sig: &[u8]) -> Result<(), SignatureError>;
}Expand description
A digital signature algorithm is defined as a set of three operations: key generation, signing, and verification.
This trait represents the verification operations performed by the holder of the verification public key.
Keygen and signing operations are performed by the corresponding Signer trait.
There are several reasons for this split: first is architectural; some complex algorithms may
benefit from having the signature generation and verification implementations split into separate modules.
Second is for compliance: sometimes a policy soft-deprecates an algorithm so that new signatures
can no longer be created, but existing signatures can still be verified. Splitting the traits
makes this policy easier to enforce.
Here we statically-size the arrays used to encode public keys, private keys, and signature values because this allows us to safely remove runtime checks for array lengths, which overall reduces the fallibility of the library. This design choice could make this trait complicated to apply to a signature algorithm that do not have fixed sizes for the encodings of these objects.
Required Methods§
Sourcefn verify(
pk: &PK,
msg: &[u8],
ctx: Option<&[u8]>,
sig: &[u8],
) -> Result<(), SignatureError>
fn verify( pk: &PK, msg: &[u8], ctx: Option<&[u8]>, sig: &[u8], ) -> Result<(), SignatureError>
On success, returns Ok(())
On failure, returns Err(SignatureError::SignatureVerificationFailed); may also return other types of SignatureError as appropriate (such as for invalid-length inputs).
Sourcefn verify_init(pk: &PK, ctx: Option<&[u8]>) -> Result<Self, SignatureError>
fn verify_init(pk: &PK, ctx: Option<&[u8]>) -> Result<Self, SignatureError>
streaming verification API
Sourcefn verify_update(&mut self, msg_chunk: &[u8])
fn verify_update(&mut self, msg_chunk: &[u8])
Update the verifier with the next chunk of data. This can be called multiple times.
Sourcefn verify_final(self, sig: &[u8]) -> Result<(), SignatureError>
fn verify_final(self, sig: &[u8]) -> Result<(), SignatureError>
On success, returns Ok(())
On failure, returns Err(SignatureError::SignatureVerificationFailed); may also return other types of SignatureError as appropriate (such as for invalid-length inputs).
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.