pub struct Xpriv {
pub network: NetworkKind,
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: NetworkKindThe 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 Xpriv
impl Xpriv
Sourcepub fn new_master(
network: impl Into<NetworkKind>,
seed: &[u8],
) -> Result<Xpriv, Error>
pub fn new_master( network: impl Into<NetworkKind>, seed: &[u8], ) -> Result<Xpriv, 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<Xpriv, Error>
pub fn derive_priv<C: Signing, P: AsRef<[ChildNumber]>>( &self, secp: &Secp256k1<C>, path: &P, ) -> Result<Xpriv, 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 decode(data: &[u8]) -> Result<Xpriv, Error>
pub fn decode(data: &[u8]) -> Result<Xpriv, Error>
Decoding extended private key from binary data according to BIP 32
Sourcepub fn identifier<C: Signing>(&self, secp: &Secp256k1<C>) -> XKeyIdentifier
pub fn identifier<C: Signing>(&self, secp: &Secp256k1<C>) -> XKeyIdentifier
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<'de> Deserialize<'de> for Xpriv
impl<'de> Deserialize<'de> for Xpriv
Source§fn deserialize<D>(deserializer: D) -> Result<Xpriv, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Xpriv, D::Error>where
D: Deserializer<'de>,
Source§impl GetKey for Xpriv
impl GetKey for Xpriv
Source§type Error = GetKeyError
type Error = GetKeyError
Source§fn get_key<C: Signing>(
&self,
key_request: KeyRequest,
secp: &Secp256k1<C>,
) -> Result<Option<PrivateKey>, Self::Error>
fn get_key<C: Signing>( &self, key_request: KeyRequest, secp: &Secp256k1<C>, ) -> Result<Option<PrivateKey>, Self::Error>
key_request. Read more