fedimint_client::secret

Trait RootSecretStrategy

source
pub trait RootSecretStrategy: Debug {
    type Encoding: Clone;

    // Required methods
    fn to_root_secret(secret: &Self::Encoding) -> DerivableSecret;
    fn consensus_encode(
        secret: &Self::Encoding,
        writer: &mut impl Write,
    ) -> Result<usize>;
    fn consensus_decode(
        reader: &mut impl Read,
    ) -> Result<Self::Encoding, DecodeError>;
    fn random<R>(rng: &mut R) -> Self::Encoding
       where R: RngCore + CryptoRng;
}
Expand description

Trait defining a way to generate, serialize and deserialize a root secret. It defines a Encoding associated type which represents a specific representation of a secret (e.g. a bip39, slip39, CODEX32, … struct) and then defines the methods necessary for the client to interact with it.

We use a strategy pattern (i.e. implementing the trait on a zero sized type with the actual secret struct as an associated type instead of implementing the necessary functions directly on the secret struct) to allow external implementations on third-party types without wrapping them in newtypes.

Required Associated Types§

source

type Encoding: Clone

Type representing the secret

Required Methods§

source

fn to_root_secret(secret: &Self::Encoding) -> DerivableSecret

Conversion function from the external encoding to the internal one

source

fn consensus_encode( secret: &Self::Encoding, writer: &mut impl Write, ) -> Result<usize>

Serialization function for the external encoding

source

fn consensus_decode( reader: &mut impl Read, ) -> Result<Self::Encoding, DecodeError>

Deserialization function for the external encoding

source

fn random<R>(rng: &mut R) -> Self::Encoding
where R: RngCore + CryptoRng,

Random generation function for the external secret type

Object Safety§

This trait is not object safe.

Implementors§