pub struct XPrv(/* private fields */);
Expand description
HDWallet extended private key
Effectively this is an ed25519 extended secret key (64 bytes) followed by a chain code (32 bytes).
Implementations§
Source§impl XPrv
impl XPrv
Sourcepub fn normalize_bytes_force3rd(bytes: [u8; 96]) -> Self
pub fn normalize_bytes_force3rd(bytes: [u8; 96]) -> Self
takes the given raw bytes and perform some modifications to normalize to a valid Ed25519 extended key, but it does also force the 3rd highest bit to be cleared too.
Sourcepub fn normalize_bytes_ed25519(bytes: [u8; 96]) -> Self
pub fn normalize_bytes_ed25519(bytes: [u8; 96]) -> Self
Takes the given raw bytes and perform some modifications to normalize to a valid Ed25519 extended key. It doesn’t touch the 3rd highest bit as expected in the ed25519-bip32 paper.
Sourcepub fn is_3rd_highest_bit_clear(&self) -> bool
pub fn is_3rd_highest_bit_clear(&self) -> bool
Check if the 3rd highest bit is clear as expected from the paper
Sourcepub fn clear_3rd_highest_bit(self) -> Self
pub fn clear_3rd_highest_bit(self) -> Self
Clear the 3rd highest bit as expected from the paper setting
Sourcepub fn from_nonextended_force(bytes: &[u8; 32], chain_code: &[u8; 32]) -> Self
pub fn from_nonextended_force(bytes: &[u8; 32], chain_code: &[u8; 32]) -> Self
Takes a non-extended Ed25519 secret key and hash through SHA512 it in the same way the standard Ed25519 signature system make extended key, but also force clear the 3rd highest bit of the key instead of returning an error
Sourcepub fn from_nonextended_noforce(
bytes: &[u8; 32],
chain_code: &[u8; 32],
) -> Result<Self, ()>
pub fn from_nonextended_noforce( bytes: &[u8; 32], chain_code: &[u8; 32], ) -> Result<Self, ()>
Takes a non-extended Ed25519 secret key and hash through SHA512 it in the same way the standard Ed25519 signature system make extended key. If the 3rd highest bit is set, then return an error
bip32-ed25519 paper:
“2) We admit only those ~k such that the third highest bit of the last byte of kL is zero.”
Sourcepub fn from_extended_and_chaincode(sk: &[u8; 64], chain_code: &[u8; 32]) -> Self
pub fn from_extended_and_chaincode(sk: &[u8; 64], chain_code: &[u8; 32]) -> Self
create a XPrv
by its components (a 64 bytes extended secret key, and a 32 bytes chain code)
No verification is done on the extended secret key
Sourcepub fn from_bytes_verified(bytes: [u8; 96]) -> Result<Self, PrivateKeyError>
pub fn from_bytes_verified(bytes: [u8; 96]) -> Result<Self, PrivateKeyError>
Create a XPrv
by taking ownership of the given array
This function may returns an error if it does not have the expected format.
This function allow the 3rd highest bit to not be clear (to handle potential derived valid xprv), but self.is_3rd_highest_bit_clear() can be called to check if the 3rd highest bit is assumed to be clear or not.
pub fn from_slice_verified(bytes: &[u8]) -> Result<Self, PrivateKeyError>
Sourcepub fn verify<T>(&self, message: &[u8], signature: &Signature<T>) -> bool
pub fn verify<T>(&self, message: &[u8], signature: &Signature<T>) -> bool
verify a given signature