Trait Keypair
pub trait Keypair: Sized + ConstantTimeEq {
type SecretLen: ArrayLength;
type Public: BytesRepresentable + Clone + PartialEq;
// Required methods
fn random() -> Self;
fn from_secret(bytes: &[u8]) -> Result<Self, CryptoError>;
fn secret(&self) -> &SecretValue<Self::SecretLen>;
fn public(&self) -> &Self::Public;
// Provided method
fn unzip(self) -> (SecretValue<Self::SecretLen>, Self::Public) { ... }
}
Expand description
Represents a generic key pair The keypair contains a private key and public key. Must be comparable in constant time and zeroized on drop.
Required Associated Types§
type SecretLen: ArrayLength
type SecretLen: ArrayLength
Represents the type of the private (secret) key
Required Methods§
fn random() -> Self
fn random() -> Self
Generates a new random keypair.
fn from_secret(bytes: &[u8]) -> Result<Self, CryptoError>
fn from_secret(bytes: &[u8]) -> Result<Self, CryptoError>
Creates a keypair from the given secret key.
Provided Methods§
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.