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
type Public: BytesRepresentable + Clone + PartialEq
type Public: BytesRepresentable + Clone + PartialEq
Represents the type of the public 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.
fn secret(&self) -> &SecretValue<Self::SecretLen>
fn secret(&self) -> &SecretValue<Self::SecretLen>
Returns the private (secret) part of the keypair
Provided Methods§
fn unzip(self) -> (SecretValue<Self::SecretLen>, Self::Public)
fn unzip(self) -> (SecretValue<Self::SecretLen>, Self::Public)
Consumes the instance and produces separated private and public parts
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.