pub struct ExtendedPrivKey {
pub network: Network,
pub depth: u8,
pub parent_fingerprint: Fingerprint,
pub child_number: ChildNumber,
pub private_key: SecretKey,
pub chain_code: ChainCode,
}Expand description
Extended private key
Fields§
§network: NetworkThe network this key is to be used on
depth: u8How many derivations this key is from the master (which is 0)
parent_fingerprint: FingerprintFingerprint of the parent key (0 for master)
child_number: ChildNumberChild number of the key used to derive from parent (0 for master)
private_key: SecretKeyPrivate key
chain_code: ChainCodeChain code
Implementations§
Source§impl ExtendedPrivKey
impl ExtendedPrivKey
Sourcepub fn new_master(
network: Network,
seed: &[u8],
) -> Result<ExtendedPrivKey, Error>
pub fn new_master( network: Network, seed: &[u8], ) -> Result<ExtendedPrivKey, Error>
Construct a new master key from a seed value
Sourcepub fn to_priv(&self) -> PrivateKey
pub fn to_priv(&self) -> PrivateKey
Constructs ECDSA compressed private key matching internal secret key representation.
Sourcepub fn to_keypair<C: Signing>(&self, secp: &Secp256k1<C>) -> KeyPair
pub fn to_keypair<C: Signing>(&self, secp: &Secp256k1<C>) -> KeyPair
Constructs BIP340 keypair for Schnorr signatures and Taproot use matching the internal secret key representation.
Sourcepub fn derive_priv<C: Signing, P: AsRef<[ChildNumber]>>(
&self,
secp: &Secp256k1<C>,
path: &P,
) -> Result<ExtendedPrivKey, Error>
pub fn derive_priv<C: Signing, P: AsRef<[ChildNumber]>>( &self, secp: &Secp256k1<C>, path: &P, ) -> Result<ExtendedPrivKey, Error>
Attempts to derive an extended private key from a path.
The path argument can be both of type DerivationPath or Vec<ChildNumber>.
Sourcepub fn ckd_priv<C: Signing>(
&self,
secp: &Secp256k1<C>,
i: ChildNumber,
) -> Result<ExtendedPrivKey, Error>
pub fn ckd_priv<C: Signing>( &self, secp: &Secp256k1<C>, i: ChildNumber, ) -> Result<ExtendedPrivKey, Error>
Private->Private child key derivation
Sourcepub fn decode(data: &[u8]) -> Result<ExtendedPrivKey, Error>
pub fn decode(data: &[u8]) -> Result<ExtendedPrivKey, Error>
Decoding extended private key from binary data according to BIP 32
Sourcepub fn identifier<C: Signing>(&self, secp: &Secp256k1<C>) -> XpubIdentifier
pub fn identifier<C: Signing>(&self, secp: &Secp256k1<C>) -> XpubIdentifier
Returns the HASH160 of the public key belonging to the xpriv
Sourcepub fn fingerprint<C: Signing>(&self, secp: &Secp256k1<C>) -> Fingerprint
pub fn fingerprint<C: Signing>(&self, secp: &Secp256k1<C>) -> Fingerprint
Returns the first four bytes of the identifier
Trait Implementations§
Source§impl Clone for ExtendedPrivKey
impl Clone for ExtendedPrivKey
Source§fn clone(&self) -> ExtendedPrivKey
fn clone(&self) -> ExtendedPrivKey
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ExtendedPrivKey
impl Debug for ExtendedPrivKey
Source§impl<'de> Deserialize<'de> for ExtendedPrivKey
Available on crate feature serde only.
impl<'de> Deserialize<'de> for ExtendedPrivKey
serde only.Source§fn deserialize<D>(deserializer: D) -> Result<ExtendedPrivKey, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<ExtendedPrivKey, D::Error>where
D: Deserializer<'de>,
Source§impl Display for ExtendedPrivKey
impl Display for ExtendedPrivKey
Source§impl FromStr for ExtendedPrivKey
impl FromStr for ExtendedPrivKey
Source§impl PartialEq for ExtendedPrivKey
impl PartialEq for ExtendedPrivKey
Source§impl<'de> Serialize for ExtendedPrivKey
Available on crate feature serde only.
impl<'de> Serialize for ExtendedPrivKey
serde only.