Skip to content

Commit 3be46fa

Browse files
authoredOct 23, 2024
Merge pull request #115 from LFDT-Lockness/update-hd-wallet
Use `hd-wallet` instead of `slip-10`
2 parents 9c737b4 + 0ea8785 commit 3be46fa

26 files changed

+261
-179
lines changed
 

‎Cargo.lock

+19-19
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Cargo.toml

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ exclude = [
1111
]
1212

1313
[workspace.dependencies]
14-
cggmp21 = { version = "0.4", path = "cggmp21" }
15-
cggmp21-keygen = { version = "0.3", path = "cggmp21-keygen" }
16-
key-share = { version = "0.4", path = "key-share", default-features = false }
14+
cggmp21 = { version = "0.5", path = "cggmp21" }
15+
cggmp21-keygen = { version = "0.4", path = "cggmp21-keygen" }
16+
key-share = { version = "0.5", path = "key-share", default-features = false }
1717

1818
generic-ec = { version = "0.4.1", default-features = false }
1919
generic-ec-zkp = { version = "0.4.1", default-features = false }
@@ -41,6 +41,6 @@ serde_with = { version = "2", default-features = false }
4141
serde_json = "1"
4242
hex = { version = "0.4", default-features = false }
4343

44-
slip-10 = { version = "0.4", default-features = false }
44+
hd-wallet = { version = "0.5", default-features = false }
4545

4646
generic-tests = "0.1"

‎cggmp21-keygen/CHANGELOG.md

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

3+
## v0.4.0
4+
* BREAKING: use `hd-wallet` crate for HD support instead of `slip-10` [#115]
5+
* BREAKING: rename `hd-wallets` feature into `hd-wallet` [#115]
6+
* Update `key-share` to v0.5
7+
8+
[#115]: https://github.com/LFDT-Lockness/cggmp21/pull/115
9+
310
## v0.3.2
411
* Update links in the documentation and crate settings after moving the repo [#113]
512

‎cggmp21-keygen/Cargo.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "cggmp21-keygen"
3-
version = "0.3.2"
3+
version = "0.4.0"
44
edition = "2021"
55
license = "MIT OR Apache-2.0"
66
description = "UC-secure DKG implementation based on CGGMP21 paper"
@@ -12,7 +12,7 @@ keywords = ["mpc", "dkg", "threshold-signatures", "tss"]
1212

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

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

3737
std = ["thiserror", "key-share/std", "udigest/std", "round-based/std"]
38-
hd-wallets = ["slip-10", "key-share/hd-wallets"]
38+
hd-wallet = ["dep:hd-wallet", "key-share/hd-wallet"]
3939
state-machine = ["round-based/state-machine"]

‎cggmp21-keygen/src/lib.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ pub struct GenericKeygenBuilder<'a, E: Curve, M, L: SecurityLevel, D: Digest> {
9494
optional_t: M,
9595
execution_id: ExecutionId<'a>,
9696
tracer: Option<&'a mut dyn Tracer>,
97-
#[cfg(feature = "hd-wallets")]
97+
#[cfg(feature = "hd-wallet")]
9898
hd_enabled: bool,
9999
_params: core::marker::PhantomData<(E, L, D)>,
100100
}
@@ -121,7 +121,7 @@ where
121121
reliable_broadcast_enforced: true,
122122
execution_id: eid,
123123
tracer: None,
124-
#[cfg(feature = "hd-wallets")]
124+
#[cfg(feature = "hd-wallet")]
125125
hd_enabled: true,
126126
_params: core::marker::PhantomData,
127127
}
@@ -143,7 +143,7 @@ where
143143
reliable_broadcast_enforced: self.reliable_broadcast_enforced,
144144
execution_id: self.execution_id,
145145
tracer: self.tracer,
146-
#[cfg(feature = "hd-wallets")]
146+
#[cfg(feature = "hd-wallet")]
147147
hd_enabled: self.hd_enabled,
148148
_params: core::marker::PhantomData,
149149
}
@@ -160,7 +160,7 @@ where
160160
reliable_broadcast_enforced: self.reliable_broadcast_enforced,
161161
execution_id: self.execution_id,
162162
tracer: self.tracer,
163-
#[cfg(feature = "hd-wallets")]
163+
#[cfg(feature = "hd-wallet")]
164164
hd_enabled: self.hd_enabled,
165165
_params: core::marker::PhantomData,
166166
}
@@ -178,7 +178,7 @@ where
178178
reliable_broadcast_enforced: self.reliable_broadcast_enforced,
179179
execution_id: self.execution_id,
180180
tracer: self.tracer,
181-
#[cfg(feature = "hd-wallets")]
181+
#[cfg(feature = "hd-wallet")]
182182
hd_enabled: self.hd_enabled,
183183
_params: core::marker::PhantomData,
184184
}
@@ -198,7 +198,7 @@ where
198198
}
199199
}
200200

201-
#[cfg(feature = "hd-wallets")]
201+
#[cfg(feature = "hd-wallet")]
202202
/// Specifies whether HD derivation is enabled for a key
203203
pub fn hd_wallet(mut self, v: bool) -> Self {
204204
self.hd_enabled = v;
@@ -226,7 +226,7 @@ where
226226
self.execution_id,
227227
rng,
228228
party,
229-
#[cfg(feature = "hd-wallets")]
229+
#[cfg(feature = "hd-wallet")]
230230
self.hd_enabled,
231231
)
232232
.await
@@ -271,7 +271,7 @@ where
271271
self.execution_id,
272272
rng,
273273
party,
274-
#[cfg(feature = "hd-wallets")]
274+
#[cfg(feature = "hd-wallet")]
275275
self.hd_enabled,
276276
)
277277
.await
@@ -344,7 +344,7 @@ enum KeygenAborted {
344344
InvalidDataSize { parties: Vec<u16> },
345345
#[displaydoc("round1 wasn't reliable")]
346346
Round1NotReliable(Vec<(PartyIndex, MsgId)>),
347-
#[cfg(feature = "hd-wallets")]
347+
#[cfg(feature = "hd-wallet")]
348348
#[displaydoc("party did not generate chain code: {0:?}")]
349349
MissingChainCode(Vec<utils::AbortBlame>),
350350
}
@@ -356,7 +356,7 @@ enum Bug {
356356
InvalidKeyShare(#[cfg_attr(feature = "std", source)] InvalidCoreShare),
357357
#[displaydoc("unexpected zero value")]
358358
NonZeroScalar,
359-
#[cfg(feature = "hd-wallets")]
359+
#[cfg(feature = "hd-wallet")]
360360
#[displaydoc("chain code is missing although we checked that it should be present")]
361361
NoChainCode,
362362
#[displaydoc("key share of one of the signers is zero - probability of that is negligible")]

‎cggmp21-keygen/src/non_threshold.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ pub struct MsgRound2<E: Curve, L: SecurityLevel> {
6666
/// $A_i$
6767
pub sch_commit: schnorr_pok::Commit<E>,
6868
/// Party contribution to chain code
69-
#[cfg(feature = "hd-wallets")]
69+
#[cfg(feature = "hd-wallet")]
7070
#[serde_as(as = "Option<utils::HexOrBin>")]
7171
#[udigest(as = Option<udigest::Bytes>)]
72-
pub chain_code: Option<slip_10::ChainCode>,
72+
pub chain_code: Option<hd_wallet::ChainCode>,
7373
/// $u_i$
7474
#[serde(with = "hex::serde")]
7575
#[udigest(as_bytes)]
@@ -127,7 +127,7 @@ pub async fn run_keygen<E, R, M, L, D>(
127127
sid: ExecutionId<'_>,
128128
rng: &mut R,
129129
party: M,
130-
#[cfg(feature = "hd-wallets")] hd_enabled: bool,
130+
#[cfg(feature = "hd-wallet")] hd_enabled: bool,
131131
) -> Result<CoreKeyShare<E>, KeygenError>
132132
where
133133
E: Curve,
@@ -159,9 +159,9 @@ where
159159
let mut rid = L::Rid::default();
160160
rng.fill_bytes(rid.as_mut());
161161

162-
#[cfg(feature = "hd-wallets")]
162+
#[cfg(feature = "hd-wallet")]
163163
let chain_code_local = if hd_enabled {
164-
let mut chain_code = slip_10::ChainCode::default();
164+
let mut chain_code = hd_wallet::ChainCode::default();
165165
rng.fill_bytes(&mut chain_code);
166166
Some(chain_code)
167167
} else {
@@ -176,7 +176,7 @@ where
176176
rid,
177177
X: X_i,
178178
sch_commit,
179-
#[cfg(feature = "hd-wallets")]
179+
#[cfg(feature = "hd-wallet")]
180180
chain_code: chain_code_local,
181181
decommit: {
182182
let mut nonce = L::Rid::default();
@@ -278,15 +278,15 @@ where
278278
return Err(KeygenAborted::InvalidDecommitment(blame).into());
279279
}
280280

281-
#[cfg(feature = "hd-wallets")]
281+
#[cfg(feature = "hd-wallet")]
282282
let chain_code = if hd_enabled {
283283
tracer.stage("Calculate chain_code");
284284
let blame = utils::collect_simple_blame(&decommitments, |decom| decom.chain_code.is_none());
285285
if !blame.is_empty() {
286286
return Err(KeygenAborted::MissingChainCode(blame).into());
287287
}
288288
Some(decommitments.iter_including_me(&my_decommitment).try_fold(
289-
slip_10::ChainCode::default(),
289+
hd_wallet::ChainCode::default(),
290290
|acc, decom| {
291291
Ok::<_, Bug>(utils::xor_array(
292292
acc,
@@ -366,7 +366,7 @@ where
366366
.map(|d| d.X)
367367
.collect(),
368368
vss_setup: None,
369-
#[cfg(feature = "hd-wallets")]
369+
#[cfg(feature = "hd-wallet")]
370370
chain_code,
371371
},
372372
x: x_i,

‎cggmp21-keygen/src/threshold.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,10 @@ pub struct MsgRound2Broad<E: Curve, L: SecurityLevel> {
6969
/// $A_i$
7070
pub sch_commit: schnorr_pok::Commit<E>,
7171
/// Party contribution to chain code
72-
#[cfg(feature = "hd-wallets")]
72+
#[cfg(feature = "hd-wallet")]
7373
#[serde_as(as = "Option<utils::HexOrBin>")]
7474
#[udigest(as = Option<udigest::Bytes>)]
75-
pub chain_code: Option<slip_10::ChainCode>,
75+
pub chain_code: Option<hd_wallet::ChainCode>,
7676
/// $u_i$
7777
#[serde(with = "hex::serde")]
7878
#[udigest(as_bytes)]
@@ -141,7 +141,7 @@ pub async fn run_threshold_keygen<E, R, M, L, D>(
141141
sid: ExecutionId<'_>,
142142
rng: &mut R,
143143
party: M,
144-
#[cfg(feature = "hd-wallets")] hd_enabled: bool,
144+
#[cfg(feature = "hd-wallet")] hd_enabled: bool,
145145
) -> Result<CoreKeyShare<E>, KeygenError>
146146
where
147147
E: Curve,
@@ -183,9 +183,9 @@ where
183183
.collect::<Vec<_>>();
184184
debug_assert_eq!(sigmas.len(), usize::from(n));
185185

186-
#[cfg(feature = "hd-wallets")]
186+
#[cfg(feature = "hd-wallet")]
187187
let chain_code_local = if hd_enabled {
188-
let mut chain_code = slip_10::ChainCode::default();
188+
let mut chain_code = hd_wallet::ChainCode::default();
189189
rng.fill_bytes(&mut chain_code);
190190
Some(chain_code)
191191
} else {
@@ -197,7 +197,7 @@ where
197197
rid,
198198
F: F.clone(),
199199
sch_commit: h,
200-
#[cfg(feature = "hd-wallets")]
200+
#[cfg(feature = "hd-wallet")]
201201
chain_code: chain_code_local,
202202
decommit: {
203203
let mut nonce = L::Rid::default();
@@ -343,15 +343,15 @@ where
343343
.iter_including_me(&my_decommitment)
344344
.map(|d| &d.rid)
345345
.fold(L::Rid::default(), utils::xor_array);
346-
#[cfg(feature = "hd-wallets")]
346+
#[cfg(feature = "hd-wallet")]
347347
let chain_code = if hd_enabled {
348348
tracer.stage("Compute chain_code");
349349
let blame = utils::collect_simple_blame(&decommitments, |decom| decom.chain_code.is_none());
350350
if !blame.is_empty() {
351351
return Err(KeygenAborted::MissingChainCode(blame).into());
352352
}
353353
Some(decommitments.iter_including_me(&my_decommitment).try_fold(
354-
slip_10::ChainCode::default(),
354+
hd_wallet::ChainCode::default(),
355355
|acc, decom| {
356356
Ok::<_, Bug>(utils::xor_array(
357357
acc,
@@ -449,7 +449,7 @@ where
449449
min_signers: t,
450450
I: key_shares_indexes,
451451
}),
452-
#[cfg(feature = "hd-wallets")]
452+
#[cfg(feature = "hd-wallet")]
453453
chain_code,
454454
},
455455
x: sigma,

0 commit comments

Comments
 (0)