Trait coins_bip32::derived::DerivedKey
source · pub trait DerivedKey {
// Required method
fn derivation(&self) -> &KeyDerivation;
// Provided methods
fn same_root<K: DerivedKey>(&self, other: &K) -> bool { ... }
fn is_possible_ancestor_of<K: DerivedKey>(&self, other: &K) -> bool { ... }
fn path_to_descendant<K: DerivedKey>(
&self,
other: &K,
) -> Option<DerivationPath> { ... }
}
Expand description
Derived keys are keys coupled with their derivation. We use this trait to check ancestry relationships between keys.
Required Methods§
sourcefn derivation(&self) -> &KeyDerivation
fn derivation(&self) -> &KeyDerivation
Return this key’s derivation
Provided Methods§
sourcefn same_root<K: DerivedKey>(&self, other: &K) -> bool
fn same_root<K: DerivedKey>(&self, other: &K) -> bool
true
if the keys share a root fingerprint, false
otherwise. Note that on key
fingerprints, which may collide accidentally, or be intentionally collided.
sourcefn is_possible_ancestor_of<K: DerivedKey>(&self, other: &K) -> bool
fn is_possible_ancestor_of<K: DerivedKey>(&self, other: &K) -> bool
true
if this key is a possible ancestor of the argument, false
otherwise.
Warning: this check is cheap, but imprecise. It simply compares the root fingerprints
(which may collide) and checks that self.path
is a prefix of other.path
. This may be
deliberately foold by an attacker. For a precise check, use
DerivedXPriv::is_private_ancestor_of()
or
DerivedXPub::is_public_ancestor_of()
sourcefn path_to_descendant<K: DerivedKey>(&self, other: &K) -> Option<DerivationPath>
fn path_to_descendant<K: DerivedKey>(&self, other: &K) -> Option<DerivationPath>
Returns the path to the descendant, or None
if the argument is definitely not a
descendant.
This is useful for determining the path to reach some descendant from some ancestor.