bip0032
Another Rust implementation of BIP-0032 standard.
Support curves and features
| Curve | Feature | Backends | Hardened | Non-hardened (private) | Non-hardened (public) | Serialization |
|---|---|---|---|---|---|---|
| secp256k1 | k256 | secp256k1 | libsecp256k1 |
k256, secp256k1, libsecp256k1 | yes | yes | yes | yes |
Usage
Seed material is typically derived from a BIP-0039 mnemonic (for example, via bip0039).
use ;
let mnemonic = generate;
let seed = mnemonic.to_seed;
The examples below assume the seed from above.
- Private parent key -> private child key (supports hardened).
use ;
let master = new.unwrap;
let path: DerivationPath = "m/0H/1".parse.unwrap;
let child = master.derive_path.unwrap;
let xprv = child
.encode_with
.unwrap
.to_string;
- Private parent key -> public child key.
use ;
let master = new.unwrap;
let path: DerivationPath = "m/0H/1".parse.unwrap;
let child = master.derive_path.unwrap;
let xpub = child
.public_key
.encode_with
.unwrap
.to_string;
- Public parent key -> public child key (non-hardened only).
use ;
let parent_xpub = "xpub661MyMwAqRbcFtXgS5sYJABqqG9YLmC4Q1Rdap9gSE8NqtwybGhePY2gZ29ESFjqJoCu1Rupje8YtGqsefD265TMg7usUDFdp6W1EGMcet8";
let parent: = parent_xpub.parse.unwrap;
let path: DerivationPath = "m/0/1".parse.unwrap;
let child = parent.derive_path.unwrap;
let xpub = child
.encode_with
.unwrap
.to_string;
- Public parent key -> private child key: impossible (BIP-0032 does not allow it).
SLIP-0010 (optional)
SLIP-0010 support is available behind the slip10 feature.
See SLIP-0010.md for details, examples, and the feature matrix.
Documentation
See documentation and examples at https://docs.rs/bip0032.
Features
- Derivation path parsing with hardened suffixes (
',h,H) - Extended key Base58Check encoding/decoding (xpub/xprv)
- Multiple secp256k1 backends
k256(by default)secp256k1libsecp256k1
- Optional SLIP-0010 support
- secp256k1 (compatible with BIP32)
- NIST P-256 (a.k.a. secp256r1, prime256v1) (
p256) - ed25519 (
ed25519-dalek)
- Support
no_stdenvironment
Performance
See benchmarks for more details
Alternatives
License
This project is licensed under the Apache License, Version 2.0 - see the LICENSE file for details.