Struct ExtendedPrivateKey

Source
pub struct ExtendedPrivateKey<K: PrivateKey> { /* private fields */ }
Expand description

Extended private keys derived using BIP32.

Generic around a PrivateKey type. When the secp256k1 feature of this crate is enabled, the XPrv type provides a convenient alias for extended ECDSA/secp256k1 private keys.

Implementations§

Source§

impl<K> ExtendedPrivateKey<K>
where K: PrivateKey,

Source

pub const MAX_DEPTH: Depth = 255u8

Maximum derivation depth.

Source

pub fn derive_from_path<S>(seed: S, path: &DerivationPath) -> Result<Self>
where S: AsRef<[u8]>,

Available on crate feature alloc only.

Derive a child key from the given DerivationPath.

Source

pub fn new<S>(seed: S) -> Result<Self>
where S: AsRef<[u8]>,

Create the root extended key for the given seed value.

Source

pub fn derive_child(&self, child_number: ChildNumber) -> Result<Self>

Derive a child key for a particular ChildNumber.

Source

pub fn private_key(&self) -> &K

Borrow the derived private key value.

Source

pub fn public_key(&self) -> ExtendedPublicKey<K::PublicKey>

Serialize the derived public key as bytes.

Source

pub fn attrs(&self) -> &ExtendedKeyAttrs

Get attributes for this key such as depth, parent fingerprint, child number, and chain code.

Source

pub fn to_bytes(&self) -> PrivateKeyBytes

Serialize the raw private key as a byte array.

Source

pub fn to_extended_key(&self, prefix: Prefix) -> ExtendedKey

Serialize this key as an ExtendedKey.

Source

pub fn to_string(&self, prefix: Prefix) -> Zeroizing<String>

Available on crate feature alloc only.

Serialize this key as a self-Zeroizing String.

Trait Implementations§

Source§

impl<K: Clone + PrivateKey> Clone for ExtendedPrivateKey<K>

Source§

fn clone(&self) -> ExtendedPrivateKey<K>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<K> ConstantTimeEq for ExtendedPrivateKey<K>
where K: PrivateKey,

Source§

fn ct_eq(&self, other: &Self) -> Choice

Determine if two items are equal. Read more
Source§

impl<K> Debug for ExtendedPrivateKey<K>
where K: PrivateKey,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<K> From<&ExtendedPrivateKey<K>> for ExtendedPublicKey<K::PublicKey>
where K: PrivateKey,

Source§

fn from(xprv: &ExtendedPrivateKey<K>) -> ExtendedPublicKey<K::PublicKey>

Converts to this type from the input type.
Source§

impl From<&ExtendedPrivateKey<SigningKey<Secp256k1>>> for SigningKey

Available on crate feature secp256k1 only.
Source§

fn from(xprv: &XPrv) -> SigningKey

Converts to this type from the input type.
Source§

impl From<ExtendedPrivateKey<SigningKey<Secp256k1>>> for SigningKey

Available on crate feature secp256k1 only.
Source§

fn from(xprv: XPrv) -> SigningKey

Converts to this type from the input type.
Source§

impl<K> FromStr for ExtendedPrivateKey<K>
where K: PrivateKey,

Source§

type Err = Error

The associated error which can be returned from parsing.
Source§

fn from_str(xprv: &str) -> Result<Self>

Parses a string s to return a value of this type. Read more
Source§

impl<K> PartialEq for ExtendedPrivateKey<K>
where K: PrivateKey,

NOTE: uses ConstantTimeEq internally

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<K> TryFrom<ExtendedKey> for ExtendedPrivateKey<K>
where K: PrivateKey,

Source§

type Error = Error

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

fn try_from(extended_key: ExtendedKey) -> Result<ExtendedPrivateKey<K>>

Performs the conversion.
Source§

impl<K> Eq for ExtendedPrivateKey<K>
where K: PrivateKey,

NOTE: uses ConstantTimeEq internally

Auto Trait Implementations§

§

impl<K> Freeze for ExtendedPrivateKey<K>
where K: Freeze,

§

impl<K> RefUnwindSafe for ExtendedPrivateKey<K>
where K: RefUnwindSafe,

§

impl<K> Send for ExtendedPrivateKey<K>
where K: Send,

§

impl<K> Sync for ExtendedPrivateKey<K>
where K: Sync,

§

impl<K> Unpin for ExtendedPrivateKey<K>
where K: Unpin,

§

impl<K> UnwindSafe for ExtendedPrivateKey<K>
where K: UnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.