| Crates.io | bip39-rusty |
| lib.rs | bip39-rusty |
| version | 0.1.0 |
| created_at | 2025-01-23 00:33:56.589808+00 |
| updated_at | 2025-01-23 00:33:56.589808+00 |
| description | Bip39 implementation mnemonic system in rust |
| homepage | https://github.com/ERoydev/bip39-rusty |
| repository | https://github.com/ERoydev/bip39-rusty |
| max_upload_size | |
| id | 1527299 |
| size | 289,473 |
This repository contains a custom implementation of the BIP-39 standard in Rust. The implementation allows for the generation of mnemonic phrases based on entropy, checksum, and wordlists. It supports multiple languages and mnemonic types (128-bit and 256-bit entropy). I Developed this to simplify using the bip39 more easily in rust than the current bip39 that i found. The code is easy to understand and well documented, feel free to suggest improvements :)
Clone the repository:
git clone https://github.com/your-username/bip39-rust.git
cd bip39-rust
Ensure you have Rust installed. If not, install it using rustup:
Build the project:
cargo build
Run the tests:
cargo test
Here is an example of how to use the library to generate a mnemonic phrase:
use bip39_rusty::{Mnemonic, Language, MnemonicType};
fn main() {
/*
Demonstrating the use of the bip39-rusty library to generate a BIP39 mnemonic phrase.
The `Mnemonic` struct expects:
- Language (e.g., Language::English)
- MnemonicType (e.g., Bits128 or Bits256)
Once created, you can use the following getter method:
- .mnemonic_phrase() => Returns the generated mnemonic phrase as a Vec<String>.
Note: If any internal error occurs during mnemonic generation,
the library will return a default Mnemonic with 256 bits and Language::English type.
*/
// Create a new mnemonic
let mnemonic = Mnemonic::new(Language::English, MnemonicType::Bits256);
// Display the mnemonic phrases
println!("Generated Mnemonic Phrase: {:?}", mnemonic.mnemonic_phrase());
// validate the checksum
let validation_result = mnemonic.validate_checksum();
match validation_result {
Ok(value) => {
println!("Its valid")
}
Err(e) => {
println!("Not valid")
}
}
}
lang: Language for the wordlist.mnemonic_type: Type of mnemonic.entropy: Generated entropy bytes.checksum: Checksum appended to entropy.mnemonic_phrase: List of words representing the mnemonic phrase.Bits128: 128-bit entropy (12 words).Bits256: 256-bit entropy (24 words).pub enum Language {
ChineseSimplified,
ChineseTraditional,
Czech,
English,
French,
Italian,
Japanese,
Korean,
Portuguese,
Spanish
}
The Language module provides predefined wordlists. Currently supported:
To add more languages, implement the wordlist in the Language module.
Contributions are welcome! If you have a feature request, bug report, or want to contribute code, please open an issue or a pull request.
git checkout -b feature-name
git commit -m "Add feature-name"
git push origin feature-name
This project is licensed under the MIT License. See the LICENSE file for more details.
Feel free to explore, modify, and use this library as per your requirements. Happy coding!