Skip to content

Commit e2c9cad

Browse files
authored
Merge pull request #104 from dfns/key_info_epub
`key_share`: add HD-related methods to `DirtyKeyInfo`
2 parents 9b458cd + c9635c3 commit e2c9cad

File tree

3 files changed

+34
-2
lines changed

3 files changed

+34
-2
lines changed

key-share/CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## v0.4.1
4+
* Add HD-related methods to `DirtyKeyInfo` [#104]
5+
6+
[#104]: https://github.com/dfns/cggmp21/pull/104
7+
38
## v0.4.0
49
* Update `udigest` to v0.2
510
* Update `generic-ec` to v0.4

key-share/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "key-share"
3-
version = "0.4.0"
3+
version = "0.4.1"
44
edition = "2021"
55
license = "MIT OR Apache-2.0"
66
description = "Key share of any Threshold Signature Scheme (TSS)"

key-share/src/lib.rs

+28-1
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ impl<E: Curve> DirtyKeyInfo<E> {
407407
}
408408

409409
#[cfg(feature = "hd-wallets")]
410-
impl<E: Curve> DirtyCoreKeyShare<E> {
410+
impl<E: Curve> DirtyKeyInfo<E> {
411411
/// Checks whether the key is HD-capable
412412
pub fn is_hd_wallet(&self) -> bool {
413413
self.chain_code.is_some()
@@ -441,6 +441,33 @@ impl<E: Curve> DirtyCoreKeyShare<E> {
441441
}
442442
}
443443

444+
#[cfg(feature = "hd-wallets")]
445+
impl<E: Curve> DirtyCoreKeyShare<E> {
446+
/// Checks whether the key is HD-capable
447+
pub fn is_hd_wallet(&self) -> bool {
448+
(**self).is_hd_wallet()
449+
}
450+
451+
/// Returns extended public key, if HD support was enabled
452+
pub fn extended_public_key(&self) -> Option<slip_10::ExtendedPublicKey<E>> {
453+
(**self).extended_public_key()
454+
}
455+
456+
/// Derives child public key, if it's HD key
457+
pub fn derive_child_public_key<ChildIndex>(
458+
&self,
459+
derivation_path: impl IntoIterator<Item = ChildIndex>,
460+
) -> Result<
461+
slip_10::ExtendedPublicKey<E>,
462+
HdError<<ChildIndex as TryInto<slip_10::NonHardenedIndex>>::Error>,
463+
>
464+
where
465+
slip_10::NonHardenedIndex: TryFrom<ChildIndex>,
466+
{
467+
(**self).derive_child_public_key(derivation_path)
468+
}
469+
}
470+
444471
impl<E: Curve> CoreKeyShare<E> {
445472
/// Returns amount of key co-holders
446473
pub fn n(&self) -> u16 {

0 commit comments

Comments
 (0)