nam-tiny-hderive

Crates.ionam-tiny-hderive
lib.rsnam-tiny-hderive
version0.3.1-nam.1
created_at2025-01-15 13:56:05.131794+00
updated_at2025-09-10 09:28:49.046327+00
description(Namada fork) Tiny BIP44/BIP32 derivation for BIP39 seeds
homepagehttps://github.com/maciejhirsz/tiny-hderive
repositoryhttps://github.com/anoma/tiny-hderive
max_upload_size
id1517563
size70,391
Heliax (github:anoma:heliax)

documentation

https://docs.rs/tiny-hderive

README

tiny-hderive

A library for deriving secp256k1 secret keys from BIP39 seeds, using BIP32 crypto and BIP44 path formats.

use tiny_hderive::bip32::ExtendedPrivKey;

// Seed should be generated from your BIP39 phrase first!
let seed: &[u8] = &[42; 64];
let ext = ExtendedPrivKey::derive(seed, "m/44'/60'/0'/0/0").unwrap();

// Byte array of the secp256k1 secret key that can be used with Bitcoin or Ethereum.
assert_eq!(&ext.secret(), b"\x98\x84\xbf\x56\x24\xfa\xdd\x7f\xb2\x80\x4c\xfb\x0c\xb6\xf7\x1f\x28\x9e\x21\x1f\xcf\x0d\xe8\x36\xa3\x84\x17\x57\xda\xd9\x70\xd0");

// Deriving child keys from base one is also possible
use tiny_hderive::bip44::ChildNumber;
use std::str::FromStr;

let base_ext = ExtendedPrivKey::derive(seed, "m/44'/60'/0'/0").unwrap();
// child_ext is a key which is derived from this path: m/44'/60'/0'/0/0
let child_ext = base_ext.child(ChildNumber::from_str("0").unwrap()).unwrap();

assert_eq!(ext, child_ext);
Commit count: 23

cargo fmt