Trait SignatureSerialize

Source
pub trait SignatureSerialize: Signature {
    const PUBLIC_KEY_SIZE: usize;
    const SECRET_KEY_SIZE: usize;
    const SIGNATURE_SIZE: usize;

    // Required methods
    fn serialize_public_key(key: &Self::PublicKey) -> Vec<u8> ;
    fn deserialize_public_key(bytes: &[u8]) -> Result<Self::PublicKey>;
    fn serialize_secret_key(key: &Self::SecretKey) -> Zeroizing<Vec<u8>>;
    fn deserialize_secret_key(bytes: &[u8]) -> Result<Self::SecretKey>;
    fn serialize_signature(sig: &Self::SignatureData) -> Vec<u8> ;
    fn deserialize_signature(bytes: &[u8]) -> Result<Self::SignatureData>;
}
Expand description

Optional trait for signature algorithms that support key serialization

This trait should only be implemented for algorithms where key import/export is safe and well-defined.

Required Associated Constants§

Source

const PUBLIC_KEY_SIZE: usize

Size of serialized public keys in bytes

Source

const SECRET_KEY_SIZE: usize

Size of serialized secret keys in bytes

Source

const SIGNATURE_SIZE: usize

Size of serialized signatures in bytes

Required Methods§

Source

fn serialize_public_key(key: &Self::PublicKey) -> Vec<u8>

Export a public key to bytes

Source

fn deserialize_public_key(bytes: &[u8]) -> Result<Self::PublicKey>

Import a public key from bytes

§Errors

Returns an error if the bytes are malformed or invalid

Source

fn serialize_secret_key(key: &Self::SecretKey) -> Zeroizing<Vec<u8>>

Export a secret key to bytes

§Security Warning

The returned bytes contain sensitive key material and must be handled with appropriate care. The Zeroizing wrapper ensures the bytes are cleared from memory when dropped.

Source

fn deserialize_secret_key(bytes: &[u8]) -> Result<Self::SecretKey>

Import a secret key from bytes

§Security Requirements
  • Input bytes should be zeroized after use
  • Implementation must validate the key format
§Errors

Returns an error if the bytes are malformed or invalid

Source

fn serialize_signature(sig: &Self::SignatureData) -> Vec<u8>

Export a signature to bytes

Source

fn deserialize_signature(bytes: &[u8]) -> Result<Self::SignatureData>

Import a signature from bytes

§Errors

Returns an error if the bytes are malformed or invalid

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§