pub struct Key<K, P> {
key: K,
path: DerivationPath<P>,
derivation_scheme: DerivationScheme,
}
Expand description
convenient wrapper around the Key
.
Fields§
§key: K
§path: DerivationPath<P>
§derivation_scheme: DerivationScheme
Implementations§
source§impl Key<XPub, Bip44<Address>>
impl Key<XPub, Bip44<Address>>
pub fn address_single(&self, discrimination: Discrimination) -> Address
pub fn address_account(&self, discrimination: Discrimination) -> Address
pub fn address_group( &self, discrimination: Discrimination, group: PublicKey<Ed25519> ) -> Address
source§impl<K, P> Key<K, P>
impl<K, P> Key<K, P>
sourcepub fn new_unchecked(
key: K,
path: DerivationPath<P>,
derivation_scheme: DerivationScheme
) -> Self
pub fn new_unchecked( key: K, path: DerivationPath<P>, derivation_scheme: DerivationScheme ) -> Self
create a Key
with the given component
does not guarantee that the derivation path is actually the one that lead to this key derivation.
pub fn coerce_unchecked<Q>(self) -> Key<K, Q>
source§impl<P> Key<XPrv, P>
impl<P> Key<XPrv, P>
sourcepub fn public(&self) -> Key<XPub, P>
pub fn public(&self) -> Key<XPub, P>
retrieve the associated public key of the given private key
sourcepub fn sign<T, B>(&self, message: B) -> Signature<T>where
B: AsRef<[u8]>,
pub fn sign<T, B>(&self, message: B) -> Signature<T>where B: AsRef<[u8]>,
create a signature for the given message and associate the given type T
to the signature type.
sourcepub fn verify<T, B>(&self, message: B, signature: &Signature<T>) -> boolwhere
B: AsRef<[u8]>,
pub fn verify<T, B>(&self, message: B, signature: &Signature<T>) -> boolwhere B: AsRef<[u8]>,
verify the signature with the private key for the given message
sourcepub fn chain_code(&self) -> [u8; 32]
pub fn chain_code(&self) -> [u8; 32]
get key’s chain code
sourcepub(crate) fn derive_unchecked<Q>(&self, derivation: Derivation) -> Key<XPrv, Q>
pub(crate) fn derive_unchecked<Q>(&self, derivation: Derivation) -> Key<XPrv, Q>
derive the private key against the given derivation index and scheme
sourcepub(crate) fn derive_path_unchecked<'a, Q, I>(
&'a self,
derivation_path: I
) -> Key<XPrv, Q>where
I: IntoIterator<Item = &'a Derivation>,
pub(crate) fn derive_path_unchecked<'a, Q, I>( &'a self, derivation_path: I ) -> Key<XPrv, Q>where I: IntoIterator<Item = &'a Derivation>,
derive the private key against the given derivation index and scheme
source§impl<P> Key<XPub, P>
impl<P> Key<XPub, P>
sourcepub fn verify<T, B>(&self, message: B, signature: &Signature<T>) -> boolwhere
B: AsRef<[u8]>,
pub fn verify<T, B>(&self, message: B, signature: &Signature<T>) -> boolwhere B: AsRef<[u8]>,
verify the signature with the public key for the given message
sourcepub fn public_key_slice(&self) -> &[u8] ⓘ
pub fn public_key_slice(&self) -> &[u8] ⓘ
get the public key content without revealing the chaincode.
pub fn public_key(&self) -> &XPub
pub fn pk(&self) -> PublicKey<Ed25519>
sourcepub(crate) fn derive_unchecked<Q>(
&self,
derivation: SoftDerivation
) -> Key<XPub, Q>
pub(crate) fn derive_unchecked<Q>( &self, derivation: SoftDerivation ) -> Key<XPub, Q>
derive the private key against the given derivation index and scheme
Trait Implementations§
Auto Trait Implementations§
impl<K, P> RefUnwindSafe for Key<K, P>where K: RefUnwindSafe, P: RefUnwindSafe,
impl<K, P> Send for Key<K, P>where K: Send, P: Send,
impl<K, P> Sync for Key<K, P>where K: Sync, P: Sync,
impl<K, P> Unpin for Key<K, P>where K: Unpin, P: Unpin,
impl<K, P> UnwindSafe for Key<K, P>where K: UnwindSafe, P: UnwindSafe,
Blanket Implementations§
§impl<T> Base32Len for Twhere
T: AsRef<[u8]>,
impl<T> Base32Len for Twhere T: AsRef<[u8]>,
§fn base32_len(&self) -> usize
fn base32_len(&self) -> usize
Calculate the base32 serialized length
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> ToHex for Twhere
T: AsRef<[u8]>,
impl<T> ToHex for Twhere T: AsRef<[u8]>,
source§fn encode_hex<U>(&self) -> Uwhere
U: FromIterator<char>,
fn encode_hex<U>(&self) -> Uwhere U: FromIterator<char>,
Encode the hex strict representing
self
into the result. Lower case
letters are used (e.g. f9b4ca
)source§fn encode_hex_upper<U>(&self) -> Uwhere
U: FromIterator<char>,
fn encode_hex_upper<U>(&self) -> Uwhere U: FromIterator<char>,
Encode the hex strict representing
self
into the result. Upper case
letters are used (e.g. F9B4CA
)