Skip to content

Commit aea1ac3

Browse files
committed
update from_resharing conversion
1 parent eb6ac25 commit aea1ac3

File tree

1 file changed

+28
-5
lines changed

1 file changed

+28
-5
lines changed

timeboost-types/src/decryption.rs

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,12 @@ use serde::{Deserialize, Serialize};
66
use std::collections::{BTreeMap, btree_map};
77
use timeboost_crypto::{
88
DecryptionScheme,
9+
feldman::FeldmanVssPublicParam,
910
prelude::{DkgEncKey, Vess, Vss},
10-
traits::{dkg::VerifiableSecretSharing, threshold_enc::ThresholdEncScheme},
11+
traits::{
12+
dkg::{KeyResharing, VerifiableSecretSharing},
13+
threshold_enc::ThresholdEncScheme,
14+
},
1115
vess::VessError,
1216
};
1317

@@ -63,6 +67,29 @@ impl DecryptionKey {
6367
Self::from_single_dkg(committee_size, node_idx, agg_key_share, &agg_comm)
6468
}
6569

70+
/// Construct all key material for the threshold decryption from Key resharing.
71+
pub fn from_resharing<I>(
72+
old_committee: &Committee,
73+
new_committee: &Committee,
74+
recv_node_idx: usize,
75+
dealings: I,
76+
) -> anyhow::Result<Self>
77+
where
78+
I: ExactSizeIterator<
79+
Item = (
80+
usize,
81+
<Vss as VerifiableSecretSharing>::SecretShare,
82+
<Vss as VerifiableSecretSharing>::Commitment,
83+
),
84+
> + Clone,
85+
{
86+
let old_pp = FeldmanVssPublicParam::from(old_committee);
87+
let new_pp = FeldmanVssPublicParam::from(new_committee);
88+
89+
let (new_share, new_comm) = Vss::combine(&old_pp, &new_pp, recv_node_idx, dealings)?;
90+
Self::from_single_dkg(new_pp.num_nodes(), recv_node_idx, new_share, &new_comm)
91+
}
92+
6693
/// inner routine to construct from a single (aggregated or interpolated) DKG output,
6794
/// shared in both DKG and resharing logic.
6895
fn from_single_dkg(
@@ -89,10 +116,6 @@ impl DecryptionKey {
89116
Ok(Self::new(pk, combkey, prikey))
90117
}
91118

92-
pub fn from_resharing() -> anyhow::Result<Self> {
93-
todo!("after #406 merged, invoked FeldmanVss.combine(), then from_single_dkg()")
94-
}
95-
96119
pub fn pubkey(&self) -> &PublicKey {
97120
&self.pubkey
98121
}

0 commit comments

Comments
 (0)