Struct DerivationInfo

Source
pub struct DerivationInfo { /* private fields */ }
Expand description

Hierarchical deterministic (HD) derivation information for wallet addresses.

DerivationInfo captures the BIP-44/ZIP-32 derivation path components for addresses in a hierarchical deterministic wallet. It specifically tracks the last two non-hardened components of an HD path:

  • Whether it’s a change address (typically 0 = external, 1 = change)
  • The address index within that chain

§Zcash Concept Relation

Zcash follows BIP-44 and ZIP-32 for hierarchical deterministic key derivation, with paths typically structured as:

m / purpose' / coin_type' / account' / change / address_index

Where:

  • purpose' is typically 44’ for transparent or 32’ for shielded
  • coin_type' is 133’ for Zcash
  • account' is the account number (hardened)
  • change is 0 for external addresses or 1 for internal (change) addresses
  • address_index is the sequential index of the address

The apostrophes (’) indicate hardened derivation, which prevents parent key compromise from affecting child keys.

§Data Preservation

During wallet migration, this information is preserved to maintain the hierarchical relationship between keys and the ability to derive the same addresses in the new wallet.

§Examples

// Create derivation info for an external address (change = 0)
// with index 5
let change = NonHardenedChildIndex::from(0u32); // external
let address_index = NonHardenedChildIndex::from(5u32);

// We need a constructor to create DerivationInfo
let derivation_info = DerivationInfo::new(change, address_index);

// The values can be retrieved for further derivation or reference
assert_eq!(u32::from(derivation_info.change()), 0);
assert_eq!(u32::from(derivation_info.address_index()), 5);

Implementations§

Source§

impl DerivationInfo

Source

pub fn new( change: NonHardenedChildIndex, address_index: NonHardenedChildIndex, ) -> Self

Creates a new DerivationInfo with the specified change and address index components.

§Arguments
  • change - The change level index (0 for external, 1 for internal/change)
  • address_index - The sequential index of the address within its chain
§Examples
// Create derivation info for an external address (change = 0)
// with index 5
let change = NonHardenedChildIndex::from(0u32);
let address_index = NonHardenedChildIndex::from(5u32);
let derivation_info = DerivationInfo::new(change, address_index);
Source

pub fn change(&self) -> NonHardenedChildIndex

Returns the change component of the derivation path.

In BIP-44/ZIP-32, the change component is:

  • 0 for external (receiving) addresses
  • 1 for internal (change) addresses
§Returns

The change index as a NonHardenedChildIndex

Source

pub fn address_index(&self) -> NonHardenedChildIndex

Returns the address index component of the derivation path.

This is the sequential index of an address within its chain (external or change). Each new address in a wallet typically increments this index.

§Returns

The address index as a NonHardenedChildIndex

Trait Implementations§

Source§

impl Clone for DerivationInfo

Source§

fn clone(&self) -> DerivationInfo

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 Debug for DerivationInfo

Source§

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

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

impl From<DerivationInfo> for Envelope

Source§

fn from(value: DerivationInfo) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for DerivationInfo

Source§

fn eq(&self, other: &DerivationInfo) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl TryFrom<Envelope> for DerivationInfo

Source§

type Error = Error

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

fn try_from(envelope: Envelope) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl Copy for DerivationInfo

Source§

impl Eq for DerivationInfo

Source§

impl StructuralPartialEq for DerivationInfo

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> EnvelopeEncodable for T
where T: Into<Envelope> + Clone,

Source§

fn into_envelope(self) -> Envelope

Converts the value into an envelope by using its Into<Envelope> implementation.

Source§

fn to_envelope(&self) -> Envelope
where Self: Clone,

Converts a reference to this value into a Gordian Envelope. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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 T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> MaybeSendSync for T