pub trait Signer {
// Required methods
fn generate_keypair(&self) -> Result<KeyPair, CryptoError>;
fn sign(
&self,
secret_key: &[u8],
message: &[u8],
) -> Result<Signature, CryptoError>;
fn verify(
&self,
public_key: &[u8],
message: &[u8],
signature: &Signature,
) -> Result<bool, CryptoError>;
}Expand description
Digital signature port — ML-DSA-87.
All comparisons over signature bytes use constant-time equality.
Required Methods§
Sourcefn generate_keypair(&self) -> Result<KeyPair, CryptoError>
fn generate_keypair(&self) -> Result<KeyPair, CryptoError>
Generate a fresh signing key pair.
§Errors
Returns CryptoError::KeyGenFailed if key generation fails.
Sourcefn sign(
&self,
secret_key: &[u8],
message: &[u8],
) -> Result<Signature, CryptoError>
fn sign( &self, secret_key: &[u8], message: &[u8], ) -> Result<Signature, CryptoError>
Sign a message with the secret signing key.
§Errors
Returns CryptoError::SigningFailed on invalid key material.
Sourcefn verify(
&self,
public_key: &[u8],
message: &[u8],
signature: &Signature,
) -> Result<bool, CryptoError>
fn verify( &self, public_key: &[u8], message: &[u8], signature: &Signature, ) -> Result<bool, CryptoError>
Verify a signature against the public key and message.
Returns true when the signature is valid.
§Errors
Returns CryptoError::VerificationFailed only on implementation
errors; an invalid signature returns Ok(false).