4 个版本 (2 个破坏性)

0.3.0 2021年1月22日
0.2.1 2019年6月28日
0.2.0 2019年3月11日
0.1.0 2019年2月20日

#bip39 中排名 7

Download history 3045/week @ 2024-03-14 2444/week @ 2024-03-21 2062/week @ 2024-03-28 1331/week @ 2024-04-04 1633/week @ 2024-04-11 1448/week @ 2024-04-18 2201/week @ 2024-04-25 1380/week @ 2024-05-02 1921/week @ 2024-05-09 1460/week @ 2024-05-16 754/week @ 2024-05-23 775/week @ 2024-05-30 961/week @ 2024-06-06 942/week @ 2024-06-13 902/week @ 2024-06-20 800/week @ 2024-06-27

每月下载 3,731
用于 6 crates

GPL-3.0 许可证

17KB
223

tiny-hderive

一个用于从BIP39种子派生secp256k1密钥库的库,使用BIP32加密和BIP44路径格式。

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);

lib.rs:

tiny-hderive

一个用于从BIP39种子派生secp256k1密钥库的库,使用BIP32加密和BIP44路径格式。

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");

依赖项

~1.5MB
~24K SLoC