hopr_lib

Trait Keypair

Source
pub trait Keypair:
    Sized
    + ConstantTimeEq
    + ZeroizeOnDrop {
    type SecretLen: ArrayLength<u8>;
    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§

Source

type SecretLen: ArrayLength<u8>

Represents the type of the private (secret) key

Source

type Public: BytesRepresentable + Clone + PartialEq

Represents the type of the public key

Required Methods§

Source

fn random() -> Self

Generates a new random keypair.

Source

fn from_secret(bytes: &[u8]) -> Result<Self, CryptoError>

Creates a keypair from the given secret key.

Source

fn secret(&self) -> &SecretValue<Self::SecretLen>

Returns the private (secret) part of the keypair

Source

fn public(&self) -> &Self::Public

Returns the public part of the keypair

Provided Methods§

Source

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.

Implementors§