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<()>;
fn consensus_decode_partial(
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§
Required Methods§
Sourcefn to_root_secret(secret: &Self::Encoding) -> DerivableSecret
fn to_root_secret(secret: &Self::Encoding) -> DerivableSecret
Conversion function from the external encoding to the internal one
Sourcefn consensus_encode(
secret: &Self::Encoding,
writer: &mut impl Write,
) -> Result<()>
fn consensus_encode( secret: &Self::Encoding, writer: &mut impl Write, ) -> Result<()>
Serialization function for the external encoding
Sourcefn consensus_decode_partial(
reader: &mut impl Read,
) -> Result<Self::Encoding, DecodeError>
fn consensus_decode_partial( reader: &mut impl Read, ) -> Result<Self::Encoding, DecodeError>
Deserialization function for the external encoding
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".