pqbip39
A no_std compatible Rust implementation of the BIP-39 mnemonic code standard for generating and validating mnemonic phrases used in cryptocurrency wallets.
Features
- Supports 12 to 33-word mnemonic phrases
- Generates seeds from mnemonics using PBKDF2
- Validates checksums and word counts
- Converts between entropy and mnemonic phrases
- Compatible with
no_stdenvironments - Optional
stdandzeroizefeatures
Installation
Add the following to your Cargo.toml:
[]
= "0.1.0"
Usage
Generating a Mnemonic
use ;
use OsRng;
const EN_WORDS: = ;
let mut rng = OsRng;
let mnemonic = generate.unwrap;
println!; // e.g., "abandon ability able ..."
Parsing a Mnemonic
use Mnemonic;
const EN_WORDS: = ;
let phrase = "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about";
let mnemonic = parse_str.unwrap;
Converting to Seed
let seed = mnemonic.to_seed.unwrap;
Converting to Entropy
let entropy: = mnemonic.to_entropy.collect;
Features
std: Enablesstdlibrary features like Unicode normalization (default).zeroize: Adds secure zeroing of sensitive data.
To disable std (for no_std):
[]
= { = "0.1.0", = false }
Testing
Run tests with:
The library includes comprehensive tests for entropy conversion, checksum validation, and PBKDF2 seed generation, including BIP-39 test vectors.
License
MIT