This crate provides a basic implementation of BIP32, BIP49, and BIP84. It can be easily adapted to support other networks, using the paramaterizable encoder.
Typically, users will want to use the
which are available at the crate root. If key derivations are unknown, use the
XPriv objects instead. These may be deserialized using a network-specific
Encoder from the
Useful traits will need to be imported from the
We also provide a
prelude module with everything you need to get started.
- This crate is NOT designed to be used in adversarial environments.
- This crate has NOT had a comprehensive security review.
use coins_bip32::prelude::*; let digest = coins_core::Hash256::default(); let xpriv_str = "xprv9s21ZrQH143K3QTDL4LXw2F7HEK3wJUD2nW2nRk4stbPy6cq3jPPqjiChkVvvNKmPGJxWUtg6LnF5kejMRNNU3TGtRBeJgk33yuGBxrMPHi".to_owned(); let xpriv: XPriv = xpriv_str.parse().unwrap(); let child_xpriv = xpriv.derive_child(33)?; let sig: RecoverableSignature = child_xpriv.sign_digest(digest.clone()); // Signing key types are associated with verifying key types. You can always derive a pubkey let child_xpub = child_xpriv.verify_key(); child_xpub.verify_digest(digest.clone(), &sig); MainnetEncoder::xpub_to_base58(&child_xpub)?;
Provides keys that are coupled with their derivation path
Elliptic Curve Digital Signature Algorithm (ECDSA).
Network-differentiated encoders for extended keys.
Quickstart types and traits
Extended keys and related functionality
Errors for this library
The hardened derivation flag. Keys at or above this index are hardened.