Crates.io | hd-wallet |
lib.rs | hd-wallet |
version | |
source | src |
created_at | 2024-10-15 14:11:51.906408 |
updated_at | 2024-12-05 13:06:22.675031 |
description | HD wallets derivation |
homepage | |
repository | https://github.com/LFDT-Lockness/hd-wallet |
max_upload_size | |
id | 1409508 |
Cargo.toml error: | TOML parse error at line 17, column 1 | 17 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
This crate supports the following HD derivations:
To perform HD derivation, use HdWallet
trait.
Derive a master key from the seed, and then derive a child key m/1H/10:
use hd_wallet::{slip10, curves::Secp256k1};
let seed = b"16-64 bytes of high entropy".as_slice();
let master_key = slip10::derive_master_key::<Secp256k1>(seed)?;
let master_key_pair = hd_wallet::ExtendedKeyPair::from(master_key);
let child_key_pair = slip10::derive_child_key_pair_with_path(
&master_key_pair,
[1 + hd_wallet::H, 10],
);
HdWallet
trait generalizes HD derivation algorithm, you can use it with generics:
use hd_wallet::{Slip10, curves::Secp256r1};
fn derive_using_generic_algo<E: generic_ec::Curve, Hd: hd_wallet::HdWallet<E>>(
master_key: hd_wallet::ExtendedKeyPair<E>,
) -> hd_wallet::ExtendedKeyPair<E>
{
Hd::derive_child_key_pair_with_path(
&master_key,
[1 + hd_wallet::H, 10],
)
}
// Use it with any HD derivation:
let seed = b"16-64 bytes of high entropy".as_slice();
let master_key = hd_wallet::slip10::derive_master_key(seed)?;
let master_key_pair = hd_wallet::ExtendedKeyPair::from(master_key);
let child_key = derive_using_generic_algo::<Secp256r1, Slip10>(master_key_pair);
curve-secp256k1
, curve-secp256r1
, curve-ed25519
, curve-stark
add curve implementation
into the crate curves moduleall-curves
adds all curves listed aboveslip10
, edwards
, stark
add slip10
, edwards
, and stark
HD derivations respectivelyserde
adds serde::{Serialize, Deserialize}
traits implementation to the types in the libraryFeel free to reach out to us in Discord!