8 releases (4 stable)
| new 2.1.0 | Mar 6, 2026 |
|---|---|
| 2.0.0 | Feb 27, 2026 |
| 1.3.0 | Feb 11, 2026 |
| 1.0.0 | Nov 6, 2025 |
| 0.1.5 | Sep 30, 2025 |
#853 in Magic Beans
478 downloads per month
Used in 2 crates
665KB
10K
SLoC
qp-rusty-crystals-hdwallet
Hierarchical Deterministic (HD) wallet implementation for post-quantum ML-DSA keys, compatible with BIP-32, BIP-39, and BIP-44 standards.
Features
- BIP-39 Mnemonic - Generate and restore from mnemonic phrases
- BIP-32 HD Derivation - Hierarchical deterministic key derivation
- BIP-44 Compatible - Standard derivation paths
- Post-Quantum - Uses ML-DSA (Dilithium) signatures
- Hardened First 3 Levels - Require hardened
purpose',coin_type',account'; later levels optional
Standard expected derivation path
We use 44 for purpose, 189189 for coin type (Quantus), and account index for account Example: "m/44'/189189'/{account_index}'/0/0"
Usage
Add to your Cargo.toml:
[dependencies]
qp-rusty-crystals-hdwallet = "0.0.2"
qp-rusty-crystals-dilithium = "0.0.2"
Basic Example
use qp_rusty_crystals_hdwallet::{generate_mnemonic, HDLattice};
// Generate secure seed for mnemonic
let mut seed = [0u8; 32];
getrandom::getrandom(&mut seed).expect("Failed to generate seed");
// Generate a new mnemonic
let mnemonic = generate_mnemonic((&mut seed).into())?;
println!("Mnemonic: {}", mnemonic);
// Create HD wallet from mnemonic
let hd_wallet = HDLattice::from_mnemonic(&mnemonic, None)?;
// Generate master keys
let master_keys = hd_wallet.generate_keys();
// Derive child keys using BIP-44 path
let child_keys = hd_wallet.generate_derived_keys("44'/189189'/0'/0'/0'")?;
// Sign with derived keys
let message = b"Hello, quantum-safe wallet!";
let signature = child_keys.sign(message);
Derivation Paths
Standard BIP-44 derivation paths are supported:
m / purpose' / coin_type' / account' / change / address_index
Example paths:
m/44'/189189'/0'/0'/0'- First address of first accountm/44'/189189'/1'/0'/0'- First address of second accountm/44'/189189'/0'/1'/0'- First change address
Note: For security, the first three indices must be hardened (purpose', coin_type', account'). Subsequent indices (change, address_index) may be unhardened.
Why Hardened Keys Only?
Non-hardened key derivation relies on elliptic curve properties not present in lattice-based cryptography. For security, this implementation requires hardened derivation for the first three indices and permits flexibility for deeper levels.
Testing
cargo test
License
GPL-3.0 - See LICENSE for details.
Dependencies
~17MB
~251K SLoC