Skip to main content

SignatureAlgorithm

Trait SignatureAlgorithm 

Source
pub trait SignatureAlgorithm {
    const ALG: Algorithm;

    // Required methods
    fn generate_keypair(    ) -> Result<(Vec<u8>, Zeroizing<Vec<u8>>), AlgorithmError>;
    fn sign(secret: &[u8], msg: &[u8]) -> Result<Vec<u8>, AlgorithmError>;
    fn verify(
        public: &[u8],
        msg: &[u8],
        sig: &[u8],
    ) -> Result<(), AlgorithmError>;

    // Provided method
    fn derive_keypair(
        secret: &[u8],
    ) -> Result<(Vec<u8>, Zeroizing<Vec<u8>>), AlgorithmError> { ... }
}
Expand description

Adapter contract for a detached-signature algorithm.

Required Associated Constants§

Source

const ALG: Algorithm

The algorithm selector this adapter implements.

Required Methods§

Source

fn generate_keypair() -> Result<(Vec<u8>, Zeroizing<Vec<u8>>), AlgorithmError>

Generate a keypair, returning (public_key, secret_key); the secret zeroizes on drop.

Source

fn sign(secret: &[u8], msg: &[u8]) -> Result<Vec<u8>, AlgorithmError>

Sign msg with secret, returning the detached signature bytes.

Source

fn verify(public: &[u8], msg: &[u8], sig: &[u8]) -> Result<(), AlgorithmError>

Verify sig over msg against public; invalid signatures fail closed.

Provided Methods§

Source

fn derive_keypair( secret: &[u8], ) -> Result<(Vec<u8>, Zeroizing<Vec<u8>>), AlgorithmError>

Reconstruct a keypair from existing secret material.

Algorithms define the exact secret shape: Ed25519, ML-DSA, and similar seed-form keys import a seed, while elliptic-curve algorithms import a private scalar. This path is not password-based key generation.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§