A Rust library and CLI tool for Bitcoin address generation and management using extended public keys (xpub). This project implements BIP32 and BIP44 specifications for hierarchical deterministic wallet address derivation.
- Extended Public Key (xpub) management
- BIP32 hierarchical deterministic address generation
- BIP44 compliant address derivation
- Command-line interface for easy address generation
- Support for legacy Bitcoin addresses (P2PKH)
The compiled binary will be available at target/release/bip-tools
cargo install --git https://github.com/blockchain-labs-inc/bip-tools.git
- Rust 1.70.0 or higher
- Cargo package manager
git clone https://github.com/blockchain-labs-inc/bip-tools.git
cd bip-tools
cargo build --release
Add this to your Cargo.toml
:
[dependencies]
bip-tools = "0.1.0"
use bip_tools::Xpub;
// Parse an xpub from its Base58 string representation
let xpub = Xpub::from_base58("xpub6CUGRUo...").unwrap();
// Generate 5 BIP44 addresses
let addresses = xpub.derive_bip44_addresses(5).unwrap();
for (i, address) in addresses.iter().enumerate() {
println!("Address {}: {}", i, address);
}
The CLI tool provides two main commands for address generation:
bip-tools bip32
Example:
cargo run bip32 "xpub6CUGRUo..." 5
bip-tools bip44
Example:
cargo run bip44 "xpub6CUGRUo..." 5
<XPUB>
: Your extended public key in Base58 format<COUNT>
: Number of addresses to generate--help
: Display help information--version
: Display version information
- Uses secp256k1 for elliptic curve operations
- Implements SHA256 and RIPEMD160 for address generation
- Base58 encoding/decoding for xpub and address formats
- HMAC-SHA512 for child key derivation
- Complete BIP32 and BIP44 compliance
- Only supports non-hardened key derivation (requires only public keys)
- Implements proper error handling for invalid inputs
- Uses secure cryptographic primitives
- No private key handling - focused on public key operations only
- Invalid xpub format
- Base58 decode errors
- Invalid derivation path
- Checksum validation failures
Benchmark results on standard hardware (Intel i5, 8GB RAM):
- Single address generation: ~0.035ms (34.907 microseconds)
- Batch of 100 addresses: ~3.57ms (3.5683 milliseconds)
- Single address generation: ~0.069ms (68.628 microseconds)
- Batch of 100 addresses: ~3.59ms (3.5930 milliseconds)
biptools/
|
|── docs/
│ ├── CHANGELOG.md # Version history and release notes
│ ├── CODE_OF_CONDUCT.md # Community behavior standards and guidelines
│ ├── CONTRIBUTING.md # Development workflow and contribution rules
│ └── SECURITY.md # Security policies and vulnerability reporting
├── src/
│ ├── lib.rs # Core library implementation (Xpub struct and functionality)
│ └── main.rs # CLI implementation
├── tests/
│ ├── bip32_vectors.rs # Test vectors and validation tests for BIP32 standard
│ └── bip44_vectors.rs # Test vectors and validation tests for BIP44 standard
├── Cargo.toml # Project dependencies and metadata
└── README.md # This file
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
- Clone the repository
- Install Rust and Cargo
- Run tests:
cargo test
- Build project:
cargo build
Run the test suite:
cargo test
- Bitcoin Core developers for BIP specifications
- Rust Crypto community for cryptographic primitives
- Clap developers for the CLI framework
For support, custom development, and consulting services, please contact: Email: [email protected]