Skip to main content

SignatureScheme

Trait SignatureScheme 

Source
pub trait SignatureScheme {
    type PublicKey;
    type SecretKey;
    type Signature;

    // Required methods
    fn keygen() -> (Self::PublicKey, Self::SecretKey);
    fn sign(sk: &Self::SecretKey, message: &[u8]) -> Self::Signature;
    fn verify(
        pk: &Self::PublicKey,
        message: &[u8],
        sig: &Self::Signature,
    ) -> bool;
}
Expand description

Trait for digital signature schemes that produce fixed-shape keys and signatures (no per-call hash parameter).

Note: this trait is currently informational. Most signature schemes in this crate (ECDSA, EdDSA, RSA-PSS, RSA-PKCS1) take a hash function as a generic or runtime parameter and therefore do not implement this trait directly – they expose their own curve/key types and sign/verify functions. The trait is kept as the canonical “shape” of the simplest signature scheme for future extensions and for documentation purposes.

Required Associated Types§

Source

type PublicKey

Public key type for this scheme.

Source

type SecretKey

Secret key type for this scheme.

Source

type Signature

Signature type.

Required Methods§

Source

fn keygen() -> (Self::PublicKey, Self::SecretKey)

Generate a fresh key pair.

Source

fn sign(sk: &Self::SecretKey, message: &[u8]) -> Self::Signature

Sign a message.

Source

fn verify(pk: &Self::PublicKey, message: &[u8], sig: &Self::Signature) -> bool

Verify a signature against a message.

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.

Implementors§