Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use hd-wallet instead of slip-10 #115

Merged
merged 5 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 18 additions & 19 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ exclude = [
]

[workspace.dependencies]
cggmp21 = { version = "0.4", path = "cggmp21" }
cggmp21-keygen = { version = "0.3", path = "cggmp21-keygen" }
key-share = { version = "0.4", path = "key-share", default-features = false }
cggmp21 = { version = "0.5", path = "cggmp21" }
cggmp21-keygen = { version = "0.4", path = "cggmp21-keygen" }
key-share = { version = "0.5", path = "key-share", default-features = false }

generic-ec = { version = "0.4.1", default-features = false }
generic-ec-zkp = { version = "0.4.1", default-features = false }
Expand Down Expand Up @@ -41,6 +41,6 @@ serde_with = { version = "2", default-features = false }
serde_json = "1"
hex = { version = "0.4", default-features = false }

slip-10 = { version = "0.4", default-features = false }
hd-wallet = { version = "0.5", git = "https://github.com/LFDT-Lockness/slip-10", branch = "eddsa-support", default-features = false }
survived marked this conversation as resolved.
Show resolved Hide resolved

generic-tests = "0.1"
7 changes: 7 additions & 0 deletions cggmp21-keygen/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## v0.4.0
* BREAKING: use `hd-wallet` crate for HD support instead of `slip-10` [#115]
* BREAKING: rename `hd-wallets` feature into `hd-wallet` [#115]
* Update `key-share` to v0.5

[#115]: https://github.com/LFDT-Lockness/cggmp21/pull/115

## v0.3.2
* Update links in the documentation and crate settings after moving the repo [#113]

Expand Down
6 changes: 3 additions & 3 deletions cggmp21-keygen/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cggmp21-keygen"
version = "0.3.2"
version = "0.4.0"
edition = "2021"
license = "MIT OR Apache-2.0"
description = "UC-secure DKG implementation based on CGGMP21 paper"
Expand All @@ -12,7 +12,7 @@ keywords = ["mpc", "dkg", "threshold-signatures", "tss"]

[dependencies]
key-share = { workspace = true, features = ["serde"] }
slip-10 = { workspace = true, optional = true }
hd-wallet = { workspace = true, optional = true }

generic-ec = { workspace = true, features = ["serde", "udigest", "hash-to-scalar"] }
generic-ec-zkp = { workspace = true, features = ["serde", "udigest"] }
Expand All @@ -35,5 +35,5 @@ thiserror = { workspace = true, optional = true }
default = ["std"]

std = ["thiserror", "key-share/std", "udigest/std", "round-based/std"]
hd-wallets = ["slip-10", "key-share/hd-wallets"]
hd-wallet = ["dep:hd-wallet", "key-share/hd-wallet"]
state-machine = ["round-based/state-machine"]
20 changes: 10 additions & 10 deletions cggmp21-keygen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ pub struct GenericKeygenBuilder<'a, E: Curve, M, L: SecurityLevel, D: Digest> {
optional_t: M,
execution_id: ExecutionId<'a>,
tracer: Option<&'a mut dyn Tracer>,
#[cfg(feature = "hd-wallets")]
#[cfg(feature = "hd-wallet")]
hd_enabled: bool,
_params: core::marker::PhantomData<(E, L, D)>,
}
Expand All @@ -121,7 +121,7 @@ where
reliable_broadcast_enforced: true,
execution_id: eid,
tracer: None,
#[cfg(feature = "hd-wallets")]
#[cfg(feature = "hd-wallet")]
hd_enabled: true,
_params: core::marker::PhantomData,
}
Expand All @@ -143,7 +143,7 @@ where
reliable_broadcast_enforced: self.reliable_broadcast_enforced,
execution_id: self.execution_id,
tracer: self.tracer,
#[cfg(feature = "hd-wallets")]
#[cfg(feature = "hd-wallet")]
hd_enabled: self.hd_enabled,
_params: core::marker::PhantomData,
}
Expand All @@ -160,7 +160,7 @@ where
reliable_broadcast_enforced: self.reliable_broadcast_enforced,
execution_id: self.execution_id,
tracer: self.tracer,
#[cfg(feature = "hd-wallets")]
#[cfg(feature = "hd-wallet")]
hd_enabled: self.hd_enabled,
_params: core::marker::PhantomData,
}
Expand All @@ -178,7 +178,7 @@ where
reliable_broadcast_enforced: self.reliable_broadcast_enforced,
execution_id: self.execution_id,
tracer: self.tracer,
#[cfg(feature = "hd-wallets")]
#[cfg(feature = "hd-wallet")]
hd_enabled: self.hd_enabled,
_params: core::marker::PhantomData,
}
Expand All @@ -198,7 +198,7 @@ where
}
}

#[cfg(feature = "hd-wallets")]
#[cfg(feature = "hd-wallet")]
/// Specifies whether HD derivation is enabled for a key
pub fn hd_wallet(mut self, v: bool) -> Self {
self.hd_enabled = v;
Expand Down Expand Up @@ -226,7 +226,7 @@ where
self.execution_id,
rng,
party,
#[cfg(feature = "hd-wallets")]
#[cfg(feature = "hd-wallet")]
self.hd_enabled,
)
.await
Expand Down Expand Up @@ -271,7 +271,7 @@ where
self.execution_id,
rng,
party,
#[cfg(feature = "hd-wallets")]
#[cfg(feature = "hd-wallet")]
self.hd_enabled,
)
.await
Expand Down Expand Up @@ -344,7 +344,7 @@ enum KeygenAborted {
InvalidDataSize { parties: Vec<u16> },
#[displaydoc("round1 wasn't reliable")]
Round1NotReliable(Vec<(PartyIndex, MsgId)>),
#[cfg(feature = "hd-wallets")]
#[cfg(feature = "hd-wallet")]
#[displaydoc("party did not generate chain code: {0:?}")]
MissingChainCode(Vec<utils::AbortBlame>),
}
Expand All @@ -356,7 +356,7 @@ enum Bug {
InvalidKeyShare(#[cfg_attr(feature = "std", source)] InvalidCoreShare),
#[displaydoc("unexpected zero value")]
NonZeroScalar,
#[cfg(feature = "hd-wallets")]
#[cfg(feature = "hd-wallet")]
#[displaydoc("chain code is missing although we checked that it should be present")]
NoChainCode,
#[displaydoc("key share of one of the signers is zero - probability of that is negligible")]
Expand Down
18 changes: 9 additions & 9 deletions cggmp21-keygen/src/non_threshold.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ pub struct MsgRound2<E: Curve, L: SecurityLevel> {
/// $A_i$
pub sch_commit: schnorr_pok::Commit<E>,
/// Party contribution to chain code
#[cfg(feature = "hd-wallets")]
#[cfg(feature = "hd-wallet")]
#[serde_as(as = "Option<utils::HexOrBin>")]
#[udigest(as = Option<udigest::Bytes>)]
pub chain_code: Option<slip_10::ChainCode>,
pub chain_code: Option<hd_wallet::ChainCode>,
/// $u_i$
#[serde(with = "hex::serde")]
#[udigest(as_bytes)]
Expand Down Expand Up @@ -127,7 +127,7 @@ pub async fn run_keygen<E, R, M, L, D>(
sid: ExecutionId<'_>,
rng: &mut R,
party: M,
#[cfg(feature = "hd-wallets")] hd_enabled: bool,
#[cfg(feature = "hd-wallet")] hd_enabled: bool,
) -> Result<CoreKeyShare<E>, KeygenError>
where
E: Curve,
Expand Down Expand Up @@ -159,9 +159,9 @@ where
let mut rid = L::Rid::default();
rng.fill_bytes(rid.as_mut());

#[cfg(feature = "hd-wallets")]
#[cfg(feature = "hd-wallet")]
let chain_code_local = if hd_enabled {
let mut chain_code = slip_10::ChainCode::default();
let mut chain_code = hd_wallet::ChainCode::default();
rng.fill_bytes(&mut chain_code);
Some(chain_code)
} else {
Expand All @@ -176,7 +176,7 @@ where
rid,
X: X_i,
sch_commit,
#[cfg(feature = "hd-wallets")]
#[cfg(feature = "hd-wallet")]
chain_code: chain_code_local,
decommit: {
let mut nonce = L::Rid::default();
Expand Down Expand Up @@ -278,15 +278,15 @@ where
return Err(KeygenAborted::InvalidDecommitment(blame).into());
}

#[cfg(feature = "hd-wallets")]
#[cfg(feature = "hd-wallet")]
let chain_code = if hd_enabled {
tracer.stage("Calculate chain_code");
let blame = utils::collect_simple_blame(&decommitments, |decom| decom.chain_code.is_none());
if !blame.is_empty() {
return Err(KeygenAborted::MissingChainCode(blame).into());
}
Some(decommitments.iter_including_me(&my_decommitment).try_fold(
slip_10::ChainCode::default(),
hd_wallet::ChainCode::default(),
|acc, decom| {
Ok::<_, Bug>(utils::xor_array(
acc,
Expand Down Expand Up @@ -366,7 +366,7 @@ where
.map(|d| d.X)
.collect(),
vss_setup: None,
#[cfg(feature = "hd-wallets")]
#[cfg(feature = "hd-wallet")]
chain_code,
},
x: x_i,
Expand Down
18 changes: 9 additions & 9 deletions cggmp21-keygen/src/threshold.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ pub struct MsgRound2Broad<E: Curve, L: SecurityLevel> {
/// $A_i$
pub sch_commit: schnorr_pok::Commit<E>,
/// Party contribution to chain code
#[cfg(feature = "hd-wallets")]
#[cfg(feature = "hd-wallet")]
#[serde_as(as = "Option<utils::HexOrBin>")]
#[udigest(as = Option<udigest::Bytes>)]
pub chain_code: Option<slip_10::ChainCode>,
pub chain_code: Option<hd_wallet::ChainCode>,
/// $u_i$
#[serde(with = "hex::serde")]
#[udigest(as_bytes)]
Expand Down Expand Up @@ -141,7 +141,7 @@ pub async fn run_threshold_keygen<E, R, M, L, D>(
sid: ExecutionId<'_>,
rng: &mut R,
party: M,
#[cfg(feature = "hd-wallets")] hd_enabled: bool,
#[cfg(feature = "hd-wallet")] hd_enabled: bool,
) -> Result<CoreKeyShare<E>, KeygenError>
where
E: Curve,
Expand Down Expand Up @@ -183,9 +183,9 @@ where
.collect::<Vec<_>>();
debug_assert_eq!(sigmas.len(), usize::from(n));

#[cfg(feature = "hd-wallets")]
#[cfg(feature = "hd-wallet")]
let chain_code_local = if hd_enabled {
let mut chain_code = slip_10::ChainCode::default();
let mut chain_code = hd_wallet::ChainCode::default();
rng.fill_bytes(&mut chain_code);
Some(chain_code)
} else {
Expand All @@ -197,7 +197,7 @@ where
rid,
F: F.clone(),
sch_commit: h,
#[cfg(feature = "hd-wallets")]
#[cfg(feature = "hd-wallet")]
chain_code: chain_code_local,
decommit: {
let mut nonce = L::Rid::default();
Expand Down Expand Up @@ -343,15 +343,15 @@ where
.iter_including_me(&my_decommitment)
.map(|d| &d.rid)
.fold(L::Rid::default(), utils::xor_array);
#[cfg(feature = "hd-wallets")]
#[cfg(feature = "hd-wallet")]
let chain_code = if hd_enabled {
tracer.stage("Compute chain_code");
let blame = utils::collect_simple_blame(&decommitments, |decom| decom.chain_code.is_none());
if !blame.is_empty() {
return Err(KeygenAborted::MissingChainCode(blame).into());
}
Some(decommitments.iter_including_me(&my_decommitment).try_fold(
slip_10::ChainCode::default(),
hd_wallet::ChainCode::default(),
|acc, decom| {
Ok::<_, Bug>(utils::xor_array(
acc,
Expand Down Expand Up @@ -449,7 +449,7 @@ where
min_signers: t,
I: key_shares_indexes,
}),
#[cfg(feature = "hd-wallets")]
#[cfg(feature = "hd-wallet")]
chain_code,
},
x: sigma,
Expand Down
Loading
Loading