Struct sapio_bitcoin::util::bip32::ExtendedPrivKey
source · [−]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: Network
The network this key is to be used on
depth: u8
How many derivations this key is from the master (which is 0)
parent_fingerprint: Fingerprint
Fingerprint of the parent key (0 for master)
child_number: ChildNumber
Child number of the key used to derive from parent (0 for master)
private_key: SecretKey
Private key
chain_code: ChainCode
Chain code
Implementations
sourceimpl 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
sourceimpl Clone for ExtendedPrivKey
impl Clone for ExtendedPrivKey
sourcefn clone(&self) -> ExtendedPrivKey
fn clone(&self) -> ExtendedPrivKey
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for ExtendedPrivKey
impl Debug for ExtendedPrivKey
sourceimpl<'de> Deserialize<'de> for ExtendedPrivKey
This is supported on crate feature serde
only.
impl<'de> Deserialize<'de> for ExtendedPrivKey
serde
only.sourcefn 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>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl Display for ExtendedPrivKey
impl Display for ExtendedPrivKey
sourceimpl FromStr for ExtendedPrivKey
impl FromStr for ExtendedPrivKey
sourceimpl PartialEq<ExtendedPrivKey> for ExtendedPrivKey
impl PartialEq<ExtendedPrivKey> for ExtendedPrivKey
sourcefn eq(&self, other: &ExtendedPrivKey) -> bool
fn eq(&self, other: &ExtendedPrivKey) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &ExtendedPrivKey) -> bool
fn ne(&self, other: &ExtendedPrivKey) -> bool
This method tests for !=
.
sourceimpl<'de> Serialize for ExtendedPrivKey
This is supported on crate feature serde
only.
impl<'de> Serialize for ExtendedPrivKey
serde
only.impl Copy for ExtendedPrivKey
impl Eq for ExtendedPrivKey
impl StructuralEq for ExtendedPrivKey
impl StructuralPartialEq for ExtendedPrivKey
Auto Trait Implementations
impl RefUnwindSafe for ExtendedPrivKey
impl Send for ExtendedPrivKey
impl Sync for ExtendedPrivKey
impl Unpin for ExtendedPrivKey
impl UnwindSafe for ExtendedPrivKey
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more