Struct hdkeygen::key::Key

source ·
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<XPrv, Bip44<Root>>

source

pub fn purpose(&self, derivation: HardDerivation) -> Key<XPrv, Bip44<Purpose>>

source

pub fn bip44(&self) -> Key<XPrv, Bip44<Purpose>>

source

pub fn chimeric_bip44(&self) -> Key<XPrv, Bip44<Purpose>>

source§

impl Key<XPrv, Bip44<Purpose>>

source

pub fn coin_type( &self, derivation: HardDerivation ) -> Key<XPrv, Bip44<CoinType>>

source

pub fn cardano(&self) -> Key<XPrv, Bip44<CoinType>>

source§

impl Key<XPrv, Bip44<CoinType>>

source

pub fn account(&self, derivation: HardDerivation) -> Key<XPrv, Bip44<Account>>

source§

impl<K> Key<K, Bip44<Account>>

source

const EXTERNAL: SoftDerivation = DerivationPath<Bip44<bip44::Account>>::EXTERNAL

source

const INTERNAL: SoftDerivation = DerivationPath<Bip44<bip44::Account>>::INTERNAL

source

const ACCOUNT: SoftDerivation = DerivationPath<Bip44<bip44::Account>>::ACCOUNT

source

pub fn id(&self) -> HardDerivation

source§

impl Key<XPrv, Bip44<Account>>

source

pub fn change(&self, derivation: SoftDerivation) -> Key<XPrv, Bip44<Change>>

source

pub fn external(&self) -> Key<XPrv, Bip44<Change>>

source

pub fn internal(&self) -> Key<XPrv, Bip44<Change>>

source

pub fn account(&self) -> Key<XPrv, Bip44<Change>>

source§

impl Key<XPub, Bip44<Account>>

source

pub fn change(&self, derivation: SoftDerivation) -> Key<XPub, Bip44<Change>>

source

pub fn external(&self) -> Key<XPub, Bip44<Change>>

source

pub fn internal(&self) -> Key<XPub, Bip44<Change>>

source

pub fn account(&self) -> Key<XPub, Bip44<Change>>

source§

impl Key<XPrv, Bip44<Change>>

source

pub fn address(&self, derivation: SoftDerivation) -> Key<XPrv, Bip44<Address>>

source§

impl Key<XPub, Bip44<Change>>

source

pub fn address(&self, derivation: SoftDerivation) -> Key<XPub, Bip44<Address>>

source

pub fn addresses( &self, range: SoftDerivationRange ) -> KeyRange<'_, XPub, SoftDerivationRange, Bip44<Change>, Bip44<Address>>

source§

impl Key<XPub, Bip44<Address>>

source

pub fn address_single(&self, discrimination: Discrimination) -> Address

source

pub fn address_account(&self, discrimination: Discrimination) -> Address

source

pub fn address_group( &self, discrimination: Discrimination, group: PublicKey<Ed25519> ) -> Address

source§

impl<K, P> Key<K, P>

source

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.

source

pub fn path(&self) -> &DerivationPath<P>

get the derivation path that lead to this key

source

pub fn coerce_unchecked<Q>(self) -> Key<K, Q>

source§

impl<P> Key<XPrv, P>

source

pub fn public(&self) -> Key<XPub, P>

retrieve the associated public key of the given private key

source

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.

source

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

source

pub fn chain_code(&self) -> [u8; 32]

get key’s chain code

source

pub(crate) fn derive_unchecked<Q>(&self, derivation: Derivation) -> Key<XPrv, Q>

derive the private key against the given derivation index and scheme

source

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>

source

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

source

pub fn public_key_slice(&self) -> &[u8]

get the public key content without revealing the chaincode.

source

pub fn public_key(&self) -> &XPub

source

pub fn pk(&self) -> PublicKey<Ed25519>

source

pub(crate) fn derive_unchecked<Q>( &self, derivation: SoftDerivation ) -> Key<XPub, Q>

derive the private key against the given derivation index and scheme

source§

impl<P> Key<SecretKey<Ed25519Extended>, P>

source

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.

source

pub fn pk(&self) -> PublicKey<Ed25519>

source§

impl Key<XPrv, Rindex<Root>>

source

pub fn key( &self, derivation_path: &DerivationPath<Rindex<Address>> ) -> Key<XPrv, Rindex<Address>>

source

pub fn hd_key(&self) -> HdKey

get an address recovering object, this object can be used to check the ownership of addresses

Trait Implementations§

source§

impl<K, P> AsRef<K> for Key<K, P>

source§

fn as_ref(&self) -> &K

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<K: Clone, P> Clone for Key<K, P>

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<K, P> Debug for Key<K, P>where K: Debug,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<P> Display for Key<XPrv, P>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<P> Display for Key<XPub, P>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Base32Len for Twhere T: AsRef<[u8]>,

§

fn base32_len(&self) -> usize

Calculate the base32 serialized length
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<'f, T> CheckBase32<Vec<u5, Global>> for Twhere T: AsRef<[u8]>,

§

type Err = Error

Error type if conversion fails
§

fn check_base32( self ) -> Result<Vec<u5, Global>, <T as CheckBase32<Vec<u5, Global>>>::Err>

Check if all values are in range and return array-like struct of u5 values
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
§

impl<T> ToBase32 for Twhere T: AsRef<[u8]>,

§

fn write_base32<W>(&self, writer: &mut W) -> Result<(), <W as WriteBase32>::Err>where W: WriteBase32,

Encode as base32 and write it to the supplied writer Implementations shouldn’t allocate.
§

fn to_base32(&self) -> Vec<u5, Global>

Convert Self to base32 vector
source§

impl<T> ToHex for Twhere T: AsRef<[u8]>,

source§

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>,

Encode the hex strict representing self into the result. Upper case letters are used (e.g. F9B4CA)
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V