SecretKey

Trait SecretKey 

Source
pub trait SecretKey: Send + Sync {
    type PublicKey: PublicKey;

    // Required methods
    fn new() -> Self;
    fn to_bytes(&self) -> Vec<u8> ;
    fn from_bytes(bytes: impl AsRef<[u8]>) -> Result<Self, KeyPairError>
       where Self: Sized;
    fn to_hex(&self) -> String;
    fn from_hex(hex: &str) -> Result<Self, KeyPairError>
       where Self: Sized;
    fn pubkey(&self) -> Self::PublicKey;
}

Required Associated Types§

Required Methods§

Source

fn new() -> Self

Generates a new secret key.

Source

fn to_bytes(&self) -> Vec<u8>

Converts the secret key to a byte vector.

Source

fn from_bytes(bytes: impl AsRef<[u8]>) -> Result<Self, KeyPairError>
where Self: Sized,

Creates a secret key from a byte slice.

Source

fn to_hex(&self) -> String

Converts the secret key to a hexadecimal string.

Source

fn from_hex(hex: &str) -> Result<Self, KeyPairError>
where Self: Sized,

Creates a secret key from a hexadecimal string.

Source

fn pubkey(&self) -> Self::PublicKey

Returns the corresponding public key.

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§