Skip to main content

Keypair

Trait Keypair 

pub trait Keypair: Sized + ConstantTimeEq {
    type SecretLen: ArraySize;
    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: ArraySize

Represents the type of the private (secret) key

type Public: BytesRepresentable + Clone + PartialEq

Represents the type of the public key

Required Methods§

fn random() -> Self

Generates a new random keypair.

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

Creates a keypair from the given secret key.

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

Returns the private (secret) part of the keypair

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

Returns the public part of the keypair

Provided Methods§

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".

Implementors§

§

impl Keypair for BjjKeypair

§

type Public = BjjPublicKey

§

type SecretLen = UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>

§

impl Keypair for Bn254Keypair

§

type Public = Bn254PublicKey

§

type SecretLen = UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>

§

impl Keypair for ChainKeypair

§

type Public = PublicKey

§

type SecretLen = UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>

§

impl Keypair for OffchainKeypair

§

type Public = OffchainPublicKey

§

type SecretLen = UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>