pqbip39

Crates.iopqbip39
lib.rspqbip39
version0.1.1
created_at2025-06-08 10:54:59.853314+00
updated_at2025-06-09 04:49:51.975626+00
descriptionA no_std compatible implementation of the BIP39 mnemonic code standard.
homepage
repositoryhttps://github.com/openzebra/pq_bip39.rs
max_upload_size
id1704779
size245,164
Rinat (hicaru)

documentation

README

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_std environments
  • Optional std and zeroize features

Installation

Add the following to your Cargo.toml:

[dependencies]
pqbip39 = "0.1.0"

Usage

Generating a Mnemonic

use pqbip39::{Mnemonic, rng::Rng};
use rand::rngs::OsRng;

const EN_WORDS: [&str; 2048] = [/* English BIP-39 wordlist */];

let mut rng = OsRng;
let mnemonic = Mnemonic::generate(&mut rng, &EN_WORDS, 12).unwrap();
println!("{}", mnemonic); // e.g., "abandon ability able ..."

Parsing a Mnemonic

use pqbip39::Mnemonic;

const EN_WORDS: [&str; 2048] = [/* English BIP-39 wordlist */];

let phrase = "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about";
let mnemonic = Mnemonic::parse_str(&EN_WORDS, phrase).unwrap();

Converting to Seed

let seed = mnemonic.to_seed("TREZOR").unwrap();

Converting to Entropy

let entropy: Vec<u8> = mnemonic.to_entropy().collect();

Features

  • std: Enables std library features like Unicode normalization (default).
  • zeroize: Adds secure zeroing of sensitive data.

To disable std (for no_std):

[dependencies]
pqbip39 = { version = "0.1.0", default-features = false }

Testing

Run tests with:

cargo test

The library includes comprehensive tests for entropy conversion, checksum validation, and PBKDF2 seed generation, including BIP-39 test vectors.

License

MIT

Repository

https://github.com/openzebra/pq_bip39.rs

Commit count: 27

cargo fmt