pub struct DerivationPath { /* private fields */ }mnemonic only.Expand description
A parsed BIP-32 / BIP-44 derivation path.
Use Self::aptos_ed25519 / Self::aptos_secp256k1 for the canonical
Aptos paths, or Self::from_str to parse a custom path of the form
m/44'/637'/0'/0'/0'.
Implementations§
Source§impl DerivationPath
impl DerivationPath
Sourcepub fn components(&self) -> &[PathComponent]
pub fn components(&self) -> &[PathComponent]
Returns the path components in order.
Sourcepub fn is_fully_hardened(&self) -> bool
pub fn is_fully_hardened(&self) -> bool
Returns true iff every component in the path is hardened.
Ed25519 derivation rejects paths that are not fully hardened.
Sourcepub fn aptos_ed25519(address_index: u32) -> AptosResult<Self>
pub fn aptos_ed25519(address_index: u32) -> AptosResult<Self>
Builds the canonical Aptos Ed25519 derivation path
m/44'/637'/0'/0'/{address_index}'.
The address_index is placed in the final (address) BIP-44 component
for backward compatibility with the pre-existing
Mnemonic::derive_ed25519_key(index) behavior. Callers needing to
vary the BIP-44 account index (the Petra/TS-SDK convention) should
construct the path explicitly via Self::from_str and pass it to
Mnemonic::derive_ed25519_key_at_path.
All five components are hardened, matching the TypeScript SDK’s
APTOS_HARDENED_REGEX.
§Errors
Returns AptosError::KeyDerivation if address_index >= 2^31
(the top bit is reserved as the BIP-32 hardened flag).
Sourcepub fn aptos_secp256k1(address_index: u32) -> AptosResult<Self>
pub fn aptos_secp256k1(address_index: u32) -> AptosResult<Self>
Builds the canonical Aptos Secp256k1 derivation path
m/44'/637'/0'/0/{address_index}.
The address_index is placed in the final (address) BIP-44 component
for symmetry with Self::aptos_ed25519. The last two indices are
non-hardened, matching the TypeScript SDK’s APTOS_BIP44_REGEX.
Callers needing to vary the BIP-44 account index should construct
the path explicitly via Self::from_str.
§Errors
Returns AptosError::KeyDerivation if address_index >= 2^31.
Sourcepub fn from_str(path: &str) -> AptosResult<Self>
pub fn from_str(path: &str) -> AptosResult<Self>
Parses a derivation path of the form m/44'/637'/0'/0'/0'.
Apostrophes (') and lowercase h are accepted as hardened markers.
The leading m/ (or M/) prefix is required.
This is a convenience wrapper around the std::str::FromStr
implementation; both produce identical results.
§Errors
Returns AptosError::KeyDerivation if the path is malformed, a
component is missing, the numeric value exceeds 2^31 - 1, or the
path is empty.
Trait Implementations§
Source§impl Clone for DerivationPath
impl Clone for DerivationPath
Source§fn clone(&self) -> DerivationPath
fn clone(&self) -> DerivationPath
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for DerivationPath
impl Debug for DerivationPath
Source§impl Display for DerivationPath
impl Display for DerivationPath
Source§impl FromStr for DerivationPath
impl FromStr for DerivationPath
Source§type Err = AptosError
type Err = AptosError
Source§impl PartialEq for DerivationPath
impl PartialEq for DerivationPath
Source§fn eq(&self, other: &DerivationPath) -> bool
fn eq(&self, other: &DerivationPath) -> bool
self and other values to be equal, and is used by ==.impl Eq for DerivationPath
impl StructuralPartialEq for DerivationPath
Auto Trait Implementations§
impl Freeze for DerivationPath
impl RefUnwindSafe for DerivationPath
impl Send for DerivationPath
impl Sync for DerivationPath
impl Unpin for DerivationPath
impl UnsafeUnpin for DerivationPath
impl UnwindSafe for DerivationPath
Blanket Implementations§
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.