Skip to main content

DerivedEd25519Key

Struct DerivedEd25519Key 

Source
#[non_exhaustive]
pub struct DerivedEd25519Key { /* private fields */ }
Expand description

A SLIP-0010 derived Ed25519 key pair.

Wraps the 32-byte private key plus the 32-byte chain code required for further child derivation. Both fields are held in Zeroizing and are wiped on drop. The struct is opaque — callers interact with it exclusively through the accessor methods below, which mirrors the secp256k1 sibling crate::bip32::DerivedSecp256k1Key.

Implementations§

Source§

impl DerivedEd25519Key

Source

pub fn from_seed(seed: &[u8]) -> Result<Self, DeriveError>

Derive the master key from a BIP-39 seed using SLIP-0010.

§Errors

Returns an error if the HMAC key is invalid (should not happen in practice).

Source

pub fn derive_hardened(&self, index: u32) -> Result<Self, DeriveError>

Derive a child key at a hardened index.

SLIP-0010 only supports hardened derivation for Ed25519. The hardened flag (0x8000_0000) is applied automatically.

§Errors

Returns an error if the HMAC key is invalid.

Source

pub fn derive_path(seed: &[u8], path: &str) -> Result<Self, DeriveError>

Derive a key at an arbitrary SLIP-0010 path.

Path format: m/44'/501'/0'/0'every component must be marked hardened with a trailing ' or h. SLIP-0010 only defines hardened derivation for Ed25519, so unhardened components (e.g. "m/44/0") are rejected up-front rather than silently promoted.

§Errors

Returns DeriveError::Path if the path is malformed, contains an unhardened segment, or derivation fails.

Source

pub fn to_signing_key(&self) -> SigningKey

Convert the derived private key to an Ed25519 SigningKey.

Source

pub fn verifying_key(&self) -> VerifyingKey

Derive the Ed25519 VerifyingKey (public key).

Source

pub fn private_key_bytes(&self) -> Zeroizing<[u8; 32]>

Get the 32-byte raw private key. Returned copy is zeroized on drop.

Source

pub fn private_key_hex(&self) -> Zeroizing<String>

Get the 32-byte private key as a lowercase hex string. The returned String is zeroized on drop.

Source

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

Get the 32-byte Ed25519 public key.

Source

pub fn chain_code_bytes(&self) -> Zeroizing<[u8; 32]>

Get the 32-byte chain code. Returned copy is zeroized on drop.

Callers rarely need this — it only exists for SLIP-0010 compliance testing and advanced derivation schemes.

Trait Implementations§

Source§

impl Debug for DerivedEd25519Key

Source§

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

Formats the value using the given formatter. Read more

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

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

Source§

fn vzip(self) -> V