Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
fc095c4
docs: Add BIP-44 implementation task list with 34 tasks across 11 phases
abolfazlbeh Oct 23, 2025
40bcca4
Merge pull request #116 from khodpay/feature/115-create-bip-44-implem…
abolfazlbeh Oct 23, 2025
f6ce3f7
feat(bip44): Initialize BIP-44 crate structure and dependencies
abolfazlbeh Oct 23, 2025
f8306d6
Merge pull request #118 from khodpay/feature/117-create-cratesbip44-d…
abolfazlbeh Oct 23, 2025
0d93637
feat(bip44): Implement comprehensive error types with documentation a…
abolfazlbeh Oct 23, 2025
281e008
Merge pull request #120 from khodpay/feature/119-define-error-enum-wi…
abolfazlbeh Oct 23, 2025
0222de3
feat(bip44): Implement Purpose enum for BIP-44/49/84/86 standards
abolfazlbeh Oct 23, 2025
c390fce
Merge pull request #122 from khodpay/feature/121-define-and-test-purp…
abolfazlbeh Oct 23, 2025
beda5d6
feat(bip44): Implement Chain enum for external/internal address chains
abolfazlbeh Oct 23, 2025
26a544f
Merge pull request #124 from khodpay/feature/123-define-and-test-chai…
abolfazlbeh Oct 23, 2025
e731b79
feat(bip44): Implement CoinType enum with SLIP-44 registry
abolfazlbeh Oct 23, 2025
6c68ced
Merge pull request #126 from khodpay/feature/125-define-cointype-enum…
abolfazlbeh Oct 23, 2025
e19f0df
feat(bip44): Implement CoinType conversions and validation helpers
abolfazlbeh Oct 23, 2025
a69da5a
Merge pull request #128 from khodpay/feature/127-write-tests-and-impl…
abolfazlbeh Oct 23, 2025
582c62b
feat(bip44): Implement Bip44Path struct with constructor and validation
abolfazlbeh Oct 23, 2025
d221a38
Merge pull request #130 from khodpay/feature/129-define-bip44path-str…
abolfazlbeh Oct 23, 2025
8faa0a4
feat(bip44): Implement Bip44PathBuilder with fluent API
abolfazlbeh Oct 23, 2025
1f6917e
Merge pull request #132 from khodpay/feature/131-implement-bip44pathb…
abolfazlbeh Oct 23, 2025
6feb75c
feat(bip44): Implement conversion to BIP32 DerivationPath
abolfazlbeh Oct 23, 2025
fba528d
Merge pull request #134 from khodpay/feature/133-implement-and-test-c…
abolfazlbeh Oct 23, 2025
9cf06ad
feat(bip44): Implement FromStr and Display for path parsing
abolfazlbeh Oct 27, 2025
d55af92
Merge pull request #136 from khodpay/feature/135-implement-and-test-f…
abolfazlbeh Oct 27, 2025
da5f623
feat(bip44): Implement path validation and DerivationPath conversion
abolfazlbeh Oct 27, 2025
8c8aabd
Merge pull request #138 from khodpay/feature/137-implement-and-test-p…
abolfazlbeh Oct 27, 2025
d608367
feat(bip44): Implement path manipulation helpers
abolfazlbeh Oct 27, 2025
4d3af6a
Merge pull request #140 from khodpay/feature/139-implement-and-test-p…
abolfazlbeh Oct 27, 2025
7f1c0ee
feat(bip44): Define Account struct with BIP32 key wrapper
abolfazlbeh Oct 27, 2025
10efd89
Merge pull request #142 from khodpay/feature/141-define-account-struc…
abolfazlbeh Oct 27, 2025
c53e4da
feat(bip44): Implement external and internal chain derivation
abolfazlbeh Oct 27, 2025
2c0d98e
Merge pull request #144 from khodpay/feature/143-implement-and-test-d…
abolfazlbeh Oct 27, 2025
55ee95c
feat(bip44): Implement batch address derivation methods
abolfazlbeh Oct 27, 2025
f8b1333
Merge pull request #146 from khodpay/feature/145-implement-and-test-d…
abolfazlbeh Oct 27, 2025
c1807b2
feat(bip44): Implement AccountDiscovery trait and gap limit algorithm
abolfazlbeh Oct 27, 2025
5b0197c
Merge pull request #148 from khodpay/feature/147-define-accountdiscov…
abolfazlbeh Oct 27, 2025
70500b4
feat(bip44): Implement AccountScanner for account discovery
abolfazlbeh Oct 27, 2025
8b5700e
Merge pull request #150 from khodpay/feature/149-implement-accountsca…
abolfazlbeh Oct 27, 2025
e9da68f
feat(bip44): Add MockBlockchain for testing discovery
abolfazlbeh Oct 27, 2025
0eb8bf9
Merge pull request #152 from khodpay/feature/151-create-mock-blockcha…
abolfazlbeh Oct 27, 2025
69e0902
feat(bip44): Add Wallet with multi-language mnemonic support
abolfazlbeh Oct 28, 2025
bf4924b
Merge pull request #155 from khodpay/feature/153-define-wallet-struct…
abolfazlbeh Oct 28, 2025
e1defea
feat(bip44): Add account caching with multi-coin support
abolfazlbeh Oct 28, 2025
596bc55
Merge pull request #157 from khodpay/feature/156-implement-get_accoun…
abolfazlbeh Oct 28, 2025
be78d96
feat(bip44): Add WalletBuilder for fluent construction
abolfazlbeh Oct 28, 2025
9ee52d0
Merge pull request #159 from khodpay/feature/158-implement-walletbuil…
abolfazlbeh Oct 28, 2025
916e509
feat(bip44): Add AddressIterator for chain traversal
abolfazlbeh Oct 28, 2025
fd2ab36
Merge pull request #161 from khodpay/feature/160-implement-addressite…
abolfazlbeh Oct 28, 2025
b736805
feat(bip44): Add DerivedAddress with metadata
abolfazlbeh Oct 28, 2025
24431aa
Merge pull request #163 from khodpay/feature/162-implement-derivedadd…
abolfazlbeh Oct 28, 2025
3cb88d1
feat(bip44): Add serde support for serialization
abolfazlbeh Oct 28, 2025
31a9936
Merge pull request #165 from khodpay/feature/164-add-serde-dependency…
abolfazlbeh Oct 28, 2025
7945319
feat(bip44): Add AccountMetadata serialization
abolfazlbeh Oct 28, 2025
a16f105
Merge pull request #167 from khodpay/feature/166-implement-serialized…
abolfazlbeh Oct 28, 2025
093b361
test(bip44): Add comprehensive integration tests
abolfazlbeh Oct 29, 2025
5caf140
Merge pull request #169 from khodpay/feature/168-write-integration-te…
abolfazlbeh Oct 29, 2025
313ee59
test(bip44): Add BIP-44 reference test vectors
abolfazlbeh Oct 29, 2025
5059772
Merge pull request #171 from khodpay/feature/170-add-and-validate-bip…
abolfazlbeh Oct 29, 2025
131c93b
test(bip44): Add cross-compatibility and wallet scenarios
abolfazlbeh Oct 30, 2025
96a5f27
Merge pull request #173 from khodpay/feature/172-write-cross-compatib…
abolfazlbeh Oct 30, 2025
733f48a
test(bip44): Add edge case and boundary tests
abolfazlbeh Oct 30, 2025
9e8e705
Merge pull request #175 from khodpay/feature/174-add-edge-case-and-pr…
abolfazlbeh Oct 30, 2025
c2efdfb
docs(bip44): Add comprehensive API documentation
abolfazlbeh Oct 30, 2025
a4dcef1
Merge pull request #177 from khodpay/feature/176-add-comprehensive-ap…
abolfazlbeh Oct 30, 2025
b6da542
docs(bip44): Create comprehensive README.md
abolfazlbeh Oct 30, 2025
a490d85
Merge pull request #179 from khodpay/feature/178-create-readmemd-with…
abolfazlbeh Oct 30, 2025
4887d9e
feat(bip44): Add examples directory with 4 use cases
abolfazlbeh Oct 30, 2025
704bd92
Merge pull request #181 from khodpay/feature/180-create-examples-dire…
abolfazlbeh Oct 30, 2025
f8951d4
perf(bip44): Add comprehensive benchmark suite
abolfazlbeh Oct 30, 2025
542c3ea
Merge pull request #183 from khodpay/feature/182-add-benchmarks-for-k…
abolfazlbeh Oct 30, 2025
359966e
chore(bip44): Final code review and quality checks
abolfazlbeh Oct 30, 2025
5306f64
Merge pull request #185 from khodpay/feature/184-final-code-review-ru…
abolfazlbeh Oct 30, 2025
4b7da29
doc(bip44): Update README.md and CHANGELOG.md with BIP44 features
abolfazlbeh Nov 2, 2025
ad3a5e9
Merge pull request #187 from khodpay/feature/186-make-bip44-ready-for…
abolfazlbeh Nov 2, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: CI

on:
push:
branches: [ main, dev ]
branches: [ main, dev1 ]
pull_request:
branches: [ main, dev ]
branches: [ main, dev1 ]

env:
CARGO_TERM_COLOR: always
Expand Down
36 changes: 35 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,39 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.3.0] - 2024-11-02

### Added

#### BIP44 (New Crate)
- ✨ **Full BIP-44 specification implementation** - Multi-account hierarchy for deterministic wallets
- ✨ **Multi-coin support** - Bitcoin, Ethereum, Litecoin, Dogecoin, and all SLIP-44 registered coins
- ✨ **Multi-account support** - Manage multiple accounts per cryptocurrency
- ✨ **BIP standards support** - BIP-44, BIP-49, BIP-84, and BIP-86 via Purpose enum
- ✨ **Account caching** - Efficient account derivation with built-in caching mechanism
- ✨ **Builder pattern** - Fluent API for wallet construction with `WalletBuilder`
- ✨ **Type-safe paths** - Strong typing for derivation paths, chains, and coin types
- ✨ **Path parsing** - Parse and validate BIP-44 path strings (e.g., "m/44'/0'/0'/0/0")
- ✨ **Account discovery** - BIP-44 compliant gap limit checking for wallet recovery
- ✨ **Address iteration** - Iterator pattern for efficient address generation
- ✨ **Batch derivation** - Generate multiple addresses efficiently with `derive_address_range`
- ✨ **Serialization support** - Optional serde feature for persistence
- ✨ **Comprehensive testing** - 400+ tests including unit, integration, edge cases, and compatibility tests
- ✨ **Performance benchmarks** - Benchmark suite for account and address derivation
- ✨ **Complete documentation** - Full API docs with examples and usage guides

#### Features
- 🎯 **Wallet types**: Generate new wallets or recover from mnemonic phrases
- 🎯 **Chain support**: External (receiving) and internal (change) address chains
- 🎯 **Network support**: Bitcoin mainnet and testnet via BIP32 integration
- 🎯 **Memory safety**: Secure handling of sensitive key material
- 🎯 **Zero unsafe code**: 100% safe Rust implementation

#### Compatibility
- ✅ Compatible with Electrum, Ledger, Trezor, MetaMask, Trust Wallet, and Exodus
- ✅ Follows official BIP-44 specification
- ✅ Validated against standard test vectors

## [0.2.0] - 2024-10-16

### Changed
Expand Down Expand Up @@ -79,6 +112,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- ⚡ Minimal allocations
- ⚡ Zero-copy operations where possible

[Unreleased]: https://github.com/khodpay/rust-wallet/compare/v0.2.0...HEAD
[Unreleased]: https://github.com/khodpay/rust-wallet/compare/v0.3.0...HEAD
[0.3.0]: https://github.com/khodpay/rust-wallet/compare/v0.2.0...v0.3.0
[0.2.0]: https://github.com/khodpay/rust-wallet/compare/v0.1.0...v0.2.0
[0.1.0]: https://github.com/khodpay/rust-wallet/releases/tag/v0.1.0
13 changes: 13 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[workspace]
members = ["crates/bip39", "crates/bip32"]
members = ["crates/bip39", "crates/bip32", "crates/bip44"]
resolver = "2"

[workspace.package]
Expand Down
98 changes: 91 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@

[![Crates.io - bip39](https://img.shields.io/crates/v/khodpay-bip39)](https://crates.io/crates/khodpay-bip39)
[![Crates.io - bip32](https://img.shields.io/crates/v/khodpay-bip32)](https://crates.io/crates/khodpay-bip32)
[![Crates.io - bip44](https://img.shields.io/crates/v/khodpay-bip44)](https://crates.io/crates/khodpay-bip44)
[![Documentation](https://docs.rs/khodpay-bip39/badge.svg)](https://docs.rs/khodpay-bip39)
[![Documentation](https://docs.rs/khodpay-bip32/badge.svg)](https://docs.rs/khodpay-bip32)
[![Documentation](https://docs.rs/khodpay-bip44/badge.svg)](https://docs.rs/khodpay-bip44)
[![License](https://img.shields.io/badge/license-MIT%2FApache--2.0-blue.svg)](LICENSE-MIT)
[![Build Status](https://img.shields.io/github/workflow/status/khodpay/rust-wallet/CI)](https://github.com/khodpay/rust-wallet/actions)

A production-ready, type-safe Rust implementation of BIP39 and BIP32 standards for cryptocurrency wallet development.
A production-ready, type-safe Rust implementation of BIP39, BIP32, and BIP44 standards for cryptocurrency wallet development.

## 🚀 Features

Expand All @@ -29,6 +32,17 @@ A production-ready, type-safe Rust implementation of BIP39 and BIP32 standards f
- ✅ **Memory Safety** - Secure memory handling with zeroization
- ✅ **Production Ready** - Validated against official test vectors

### BIP44 - Multi-Account Hierarchy
- ✅ **Multi-Account Support** - Manage multiple accounts per cryptocurrency
- ✅ **Multi-Coin Support** - Bitcoin, Ethereum, Litecoin, Dogecoin, and more
- ✅ **BIP Standards** - Support for BIP-44, BIP-49, BIP-84, and BIP-86
- ✅ **Account Caching** - Efficient account derivation with built-in caching
- ✅ **Builder Pattern** - Fluent API for wallet construction
- ✅ **Type Safety** - Strong typing for paths, chains, and coin types
- ✅ **Gap Limit** - BIP-44 compliant account discovery
- ✅ **Serialization** - Optional serde support for persistence
- ✅ **400+ Tests** - Comprehensive test coverage including edge cases

## 📦 Installation

Add the following to your `Cargo.toml`:
Expand All @@ -37,18 +51,51 @@ Add the following to your `Cargo.toml`:
[dependencies]
khodpay-bip39 = "0.2.0"
khodpay-bip32 = "0.2.0"
khodpay-bip44 = "0.1.0"
```

Or install via cargo:

```bash
cargo add khodpay-bip39
cargo add khodpay-bip32
cargo add khodpay-bip44
```

## 🔧 Quick Start

### Generate a New Wallet
### Generate a BIP44 Multi-Coin Wallet (Recommended)

```rust
use khodpay_bip44::{Wallet, Purpose, CoinType, Language};
use khodpay_bip32::Network;

fn main() -> Result<(), Box<dyn std::error::Error>> {
// Generate a new wallet with a random mnemonic
let mut wallet = Wallet::generate(
12, // 12-word mnemonic
"", // optional passphrase
Language::English,
Network::BitcoinMainnet,
)?;

println!("Recovery phrase: {}", wallet.mnemonic());

// Get Bitcoin account (m/44'/0'/0')
let btc_account = wallet.get_account(Purpose::BIP44, CoinType::Bitcoin, 0)?;
let btc_addr = btc_account.derive_external(0)?; // m/44'/0'/0'/0/0
println!("Bitcoin address: {}", btc_addr.public_key());

// Get Ethereum account (m/44'/60'/0')
let eth_account = wallet.get_account(Purpose::BIP44, CoinType::Ethereum, 0)?;
let eth_addr = eth_account.derive_external(0)?; // m/44'/60'/0'/0/0
println!("Ethereum address: {}", eth_addr.public_key());

Ok(())
}
```

### Generate a Wallet with BIP32 (Lower Level)

```rust
use khodpay_bip39::{Mnemonic, WordCount, Language};
Expand Down Expand Up @@ -98,6 +145,28 @@ fn recover_wallet(phrase: &str) -> Result<(), Box<dyn std::error::Error>> {
}
```

### Multi-Account and SegWit Support

```rust
use khodpay_bip44::{Wallet, Purpose, CoinType};

fn multi_account_example(wallet: &mut Wallet) -> Result<(), Box<dyn std::error::Error>> {
// Multiple Bitcoin accounts
let account0 = wallet.get_account(Purpose::BIP44, CoinType::Bitcoin, 0)?;
let account1 = wallet.get_account(Purpose::BIP44, CoinType::Bitcoin, 1)?;

// Native SegWit (BIP-84)
let segwit = wallet.get_account(Purpose::BIP84, CoinType::Bitcoin, 0)?;
let segwit_addr = segwit.derive_external(0)?;

// Taproot (BIP-86)
let taproot = wallet.get_account(Purpose::BIP86, CoinType::Bitcoin, 0)?;
let taproot_addr = taproot.derive_external(0)?;

Ok(())
}
```

### Watch-Only Wallet

```rust
Expand Down Expand Up @@ -128,6 +197,7 @@ fn create_watch_only() -> Result<(), Box<dyn std::error::Error>> {

- [BIP39 API Documentation](https://docs.rs/khodpay-bip39)
- [BIP32 API Documentation](https://docs.rs/khodpay-bip32)
- [BIP44 API Documentation](https://docs.rs/khodpay-bip44)
- [Full Crate Documentation](https://docs.rs/khodpay-bip39)
- [Integration Guide](INTEGRATION_GUIDE.md)
- [Examples](examples/)
Expand All @@ -141,7 +211,11 @@ khodpay-wallet/
│ │ ├── src/
│ │ ├── tests/
│ │ └── benches/
│ └── bip32/ # BIP32 HD wallet implementation
│ ├── bip32/ # BIP32 HD wallet implementation
│ │ ├── src/
│ │ ├── tests/
│ │ └── benches/
│ └── bip44/ # BIP44 multi-account hierarchy
│ ├── src/
│ ├── tests/
│ └── benches/
Expand Down Expand Up @@ -195,7 +269,8 @@ cargo bench

- **BIP39**: 184+ tests (unit, doc, and integration)
- **BIP32**: Comprehensive test vectors from official BIP32 specification
- All test vectors from official BIP39 and BIP32 specifications
- **BIP44**: 400+ tests including integration, edge cases, and compatibility tests
- All test vectors from official BIP39, BIP32, and BIP44 specifications

## 📊 Performance

Expand All @@ -218,14 +293,19 @@ cargo bench

- [x] BIP39 implementation
- [x] BIP32 implementation
- [x] BIP44 multi-account hierarchy
- [x] BIP49 SegWit support (via BIP44 Purpose)
- [x] BIP84 Native SegWit support (via BIP44 Purpose)
- [x] BIP86 Taproot support (via BIP44 Purpose)
- [x] Multi-coin support (Bitcoin, Ethereum, Litecoin, etc.)
- [x] Account caching and discovery
- [x] Comprehensive test coverage
- [x] Documentation and examples
- [ ] BIP44 multi-coin support
- [ ] BIP49 SegWit support
- [ ] BIP84 Native SegWit support
- [ ] Hardware wallet integration examples
- [ ] Additional language support
- [ ] WASM compilation support
- [ ] Address generation utilities
- [ ] Transaction signing support

## 🤝 Contributing

Expand Down Expand Up @@ -273,6 +353,10 @@ You may choose either license for your use.
- [Bitcoin BIP39 Specification](https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki)
- [Bitcoin BIP32 Specification](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki)
- [Bitcoin BIP44 Specification](https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki)
- [Bitcoin BIP49 Specification](https://github.com/bitcoin/bips/blob/master/bip-0049.mediawiki)
- [Bitcoin BIP84 Specification](https://github.com/bitcoin/bips/blob/master/bip-0084.mediawiki)
- [Bitcoin BIP86 Specification](https://github.com/bitcoin/bips/blob/master/bip-0086.mediawiki)
- [SLIP-44 Coin Types](https://github.com/satoshilabs/slips/blob/master/slip-0044.md)

## 📞 Support

Expand Down
37 changes: 37 additions & 0 deletions crates/bip44/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[package]
name = "khodpay-bip44"
version = "0.1.0"
edition = "2021"
rust-version = "1.81"
authors = ["KhodPay Team"]
license = "MIT OR Apache-2.0"
description = "Production-ready Rust implementation of BIP44 multi-account hierarchy for deterministic wallets"
repository = "https://github.com/khodpay/rust-wallet"
documentation = "https://docs.rs/khodpay-bip44"
homepage = "https://github.com/khodpay/rust-wallet"
readme = "README.md"
keywords = ["bitcoin", "cryptocurrency", "bip44", "wallet", "hierarchical"]
categories = ["cryptography", "no-std"]

[dependencies]
khodpay-bip32 = { version = "0.2.0", path = "../bip32" }
khodpay-bip39 = { version = "0.2.0", path = "../bip39" }
thiserror = "1.0"

[dependencies.serde]
version = "1.0"
features = ["derive"]
optional = true

[dev-dependencies]
hex = "0.4"
serde_json = "1.0"
criterion = "0.5"

[[bench]]
name = "bip44_benchmarks"
harness = false

[features]
default = []
serde = ["dep:serde"]
Loading