hd_wallet

Struct Slip10

source
pub struct Slip10;
Expand description

SLIP10 HD wallet derivation

Performs HD derivation as defined in the spec. Only supports secp256k1 and secp256r1 curves.

§Limitations

We do not support SLIP10 instantiated with ed25519 or curve25519 due to the limitations. Ed25519 and curve25519 are special-cases in SLIP10 standard, they only support hardened derivation, and they operate on EdDSA and X25519 private keys instead of elliptic points and scalars as in other cases. This library only supports HD derivations in which secret keys are represented as scalars and public keys as points, see ExtendedSecretKey and ExtendedPublicKey.

If you need HD derivation on Ed25519 curve, we recommend using Edwards HD derivation, which supports both hardened and non-hardened derivation.

§Master key derivation from the seed

slip10::derive_master_key can be used to derive a master key from the seed as defined in the spec.

§Example

Derive a master key from the seed, and then derive a child key m/1H/10:

use hd_wallet::{HdWallet, Slip10, curves::Secp256k1};

let seed = b"16-64 bytes of high entropy".as_slice();
let master_key = hd_wallet::slip10::derive_master_key::<Secp256k1>(seed)?;
let master_key_pair = hd_wallet::ExtendedKeyPair::from(master_key);

let child_key_pair = Slip10::derive_child_key_pair_with_path(
    &master_key_pair,
    [1 + hd_wallet::H, 10],
);

§SLIP10-like derivation

SLIP10 is only defined for a few curves, but it can be extended to support any curve. See Slip10Like if you need other curves than is supported by SLIP10.

Auto Trait Implementations§

§

impl Freeze for Slip10

§

impl RefUnwindSafe for Slip10

§

impl Send for Slip10

§

impl Sync for Slip10

§

impl Unpin for Slip10

§

impl UnwindSafe for Slip10

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<E, S> HdWallet<E> for S
where E: Curve, S: DeriveShift<E>,

source§

fn derive_child_public_key( parent_public_key: &ExtendedPublicKey<E>, child_index: NonHardenedIndex, ) -> ExtendedPublicKey<E>

Derives child extended public key from parent extended public key Read more
source§

fn derive_child_key_pair( parent_key: &ExtendedKeyPair<E>, child_index: impl Into<ChildIndex>, ) -> ExtendedKeyPair<E>

Derives child key pair (extended secret key + public key) from parent key pair Read more
source§

fn try_derive_child_key_pair_with_path<Err>( parent_key: &ExtendedKeyPair<E>, path: impl IntoIterator<Item = Result<impl Into<ChildIndex>, Err>>, ) -> Result<ExtendedKeyPair<E>, Err>

Derives a child key pair with specified derivation path from parent key pair Read more
source§

fn derive_child_key_pair_with_path( parent_key: &ExtendedKeyPair<E>, path: impl IntoIterator<Item = impl Into<ChildIndex>>, ) -> ExtendedKeyPair<E>

Derives a child key pair with specified derivation path from parent key pair Read more
source§

fn try_derive_child_public_key_with_path<Err>( parent_public_key: &ExtendedPublicKey<E>, path: impl IntoIterator<Item = Result<NonHardenedIndex, Err>>, ) -> Result<ExtendedPublicKey<E>, Err>

Derives a child public key with specified derivation path Read more
source§

fn derive_child_public_key_with_path( parent_public_key: &ExtendedPublicKey<E>, path: impl IntoIterator<Item = NonHardenedIndex>, ) -> ExtendedPublicKey<E>

Derives a child public key with specified derivation path Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

source§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.