Crate rustywallet_hd

Crate rustywallet_hd 

Source
Expand description

§rustywallet-hd

BIP32/BIP44/BIP85 Hierarchical Deterministic wallet for cryptocurrency key derivation.

This crate provides functionality to:

  • Create master keys from seeds
  • Derive child keys using BIP32 derivation
  • Support BIP44 standard paths
  • Export/import extended keys (xprv/xpub)
  • BIP85 deterministic entropy derivation

§Example

use rustywallet_hd::prelude::*;

// Create master key from seed (64 bytes, typically from mnemonic)
let seed = [0u8; 64];
let master = ExtendedPrivateKey::from_seed(&seed, Network::Mainnet).unwrap();

// Derive BIP44 Bitcoin path: m/44'/0'/0'/0/0
let path = DerivationPath::bip44_bitcoin(0, 0, 0);
let child = master.derive_path(&path).unwrap();

// Get keys
let private_key = child.private_key().unwrap();
let public_key = child.public_key();

// Export as xprv/xpub
let xprv = child.to_xprv();
let xpub = child.extended_public_key().to_xpub();

§BIP85 - Deterministic Entropy

use rustywallet_hd::{ExtendedPrivateKey, Network, Bip85, derive_bip85_mnemonic};

let seed = [0u8; 64];
let master = ExtendedPrivateKey::from_seed(&seed, Network::Mainnet).unwrap();

// Derive child mnemonic entropy (12 words, index 0)
let entropy = derive_bip85_mnemonic(&master, 12, 0).unwrap();
assert_eq!(entropy.len(), 16); // 128 bits for 12 words

// Or use Bip85 struct for more options
let bip85 = Bip85::new(master.clone());
let child_master = bip85.derive_child_master(0, Network::Mainnet).unwrap();

§BIP44 Paths

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

Bitcoin:  m/44'/0'/0'/0/0
Ethereum: m/44'/60'/0'/0/0

§Security

  • Private keys and chain codes are zeroized on drop
  • Debug output masks sensitive data
  • Hardened derivation prevents public key derivation

Re-exports§

pub use error::HdError;
pub use extended_key::ExtendedPrivateKey;
pub use extended_key::ExtendedPublicKey;
pub use network::Network;
pub use path::ChildNumber;
pub use path::DerivationPath;
pub use bip85::Bip85;
pub use bip85::derive_bip85_mnemonic;
pub use bip85::derive_bip85_master;
pub use bip85::app as bip85_app;
pub use bip85::language as bip85_language;

Modules§

bip85
BIP85 - Deterministic Entropy From BIP32 Keychains
error
Error types for HD wallet operations.
extended_key
Extended key types for BIP32 HD wallets.
network
Network types and version bytes for extended keys.
path
BIP32 derivation path parsing and manipulation.
prelude
Convenient re-exports for common usage.