Skip to content

Commit b85b6a1

Browse files
committed
rename hdk
1 parent 7026535 commit b85b6a1

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

solution/key_tool_box/hierarchical_deterministic_key/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ description = "Library of Hierarchical Deterministic Key (HDK) solution."
1111
[dependencies]
1212
hex = "0.3"
1313
rand = "0.7"
14-
wagyu-model = "0.6.3"
15-
wagyu_lib = { package = "wagyu-bitcoin", version = "0.6.3" }
14+
wagyu-model = { package = "h-wagyu-model", version = "0.6.3" }
15+
wagyu_lib = { package = "wagyu-hdk", version = "0.6.4" }
1616
wedpr_l_macros = "1.0.0"
1717
wedpr_l_utils = "1.0.0"
1818

solution/key_tool_box/hierarchical_deterministic_key/src/hdk.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
//! Core functions of hierarchical deterministic key (HDK)
44
55
use wagyu_lib::{
6-
wordlist, BitcoinDerivationPath, BitcoinExtendedPrivateKey,
7-
BitcoinMnemonic, Mainnet,
6+
wordlist, HdkDerivationPath, HdkExtendedPrivateKey,
7+
HdkMnemonic, Mainnet,
88
};
99
use wagyu_model::{
1010
mnemonic::Mnemonic, ExtendedPrivateKey, MnemonicCount, MnemonicExtended,
@@ -22,7 +22,7 @@ use wedpr_s_protos::generated::hdk::ExtendedKeyPair;
2222
pub fn create_mnemonic_en(word_count: u8) -> Result<String, WedprError> {
2323
let rng = &mut StdRng::from_entropy();
2424
let mnemonic =
25-
match BitcoinMnemonic::<Mainnet, wordlist::English>::new_with_count(
25+
match HdkMnemonic::<Mainnet, wordlist::English>::new_with_count(
2626
rng, word_count,
2727
) {
2828
Ok(v) => v,
@@ -44,7 +44,7 @@ pub fn create_master_key_en(
4444
mnemonic_str: &str,
4545
) -> Result<Vec<u8>, WedprError> {
4646
let mnemonic =
47-
match BitcoinMnemonic::<Mainnet, wordlist::English>::from_phrase(
47+
match HdkMnemonic::<Mainnet, wordlist::English>::from_phrase(
4848
mnemonic_str,
4949
) {
5050
Ok(v) => v,
@@ -98,7 +98,7 @@ pub fn derive_extended_key(
9898
},
9999
};
100100
let master_key =
101-
match BitcoinExtendedPrivateKey::<Mainnet>::from_str(master_key_str) {
101+
match HdkExtendedPrivateKey::<Mainnet>::from_str(master_key_str) {
102102
Ok(v) => v,
103103
Err(_) => {
104104
wedpr_println!(
@@ -110,7 +110,7 @@ pub fn derive_extended_key(
110110
};
111111

112112
let derivation_path =
113-
match BitcoinDerivationPath::from_str(&key_derivation_path) {
113+
match HdkDerivationPath::from_str(&key_derivation_path) {
114114
Ok(v) => v,
115115
Err(_) => {
116116
wedpr_println!(
@@ -132,10 +132,9 @@ pub fn derive_extended_key(
132132
return Err(WedprError::FormatError);
133133
},
134134
};
135-
let private_key_hex = extended_private_key
135+
let private_key_hex = hex::encode(extended_private_key
136136
.to_private_key()
137-
.to_secp256k1_secret_key()
138-
.to_string();
137+
.to_secp256k1_secret_key().serialize());
139138

140139
let extended_private_key_bytes = match decode_hex_string(&private_key_hex) {
141140
Ok(v) => v,
@@ -151,7 +150,8 @@ pub fn derive_extended_key(
151150
let extended_public_key_uncompress_bytes = extended_private_key
152151
.to_public_key()
153152
.to_secp256k1_public_key()
154-
.serialize_uncompressed();
153+
.serialize();
154+
// .serialize_uncompressed();
155155

156156
// TODO: Replace with a better way to initialize PB if available.
157157
Ok(ExtendedKeyPair {

0 commit comments

Comments
 (0)