@@ -6,8 +6,12 @@ use serde::{Deserialize, Serialize};
6
6
use std:: collections:: { BTreeMap , btree_map} ;
7
7
use timeboost_crypto:: {
8
8
DecryptionScheme ,
9
+ feldman:: FeldmanVssPublicParam ,
9
10
prelude:: { DkgEncKey , Vess , Vss } ,
10
- traits:: { dkg:: VerifiableSecretSharing , threshold_enc:: ThresholdEncScheme } ,
11
+ traits:: {
12
+ dkg:: { KeyResharing , VerifiableSecretSharing } ,
13
+ threshold_enc:: ThresholdEncScheme ,
14
+ } ,
11
15
vess:: VessError ,
12
16
} ;
13
17
@@ -63,6 +67,29 @@ impl DecryptionKey {
63
67
Self :: from_single_dkg ( committee_size, node_idx, agg_key_share, & agg_comm)
64
68
}
65
69
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
+
66
93
/// inner routine to construct from a single (aggregated or interpolated) DKG output,
67
94
/// shared in both DKG and resharing logic.
68
95
fn from_single_dkg (
@@ -89,10 +116,6 @@ impl DecryptionKey {
89
116
Ok ( Self :: new ( pk, combkey, prikey) )
90
117
}
91
118
92
- pub fn from_resharing ( ) -> anyhow:: Result < Self > {
93
- todo ! ( "after #406 merged, invoked FeldmanVss.combine(), then from_single_dkg()" )
94
- }
95
-
96
119
pub fn pubkey ( & self ) -> & PublicKey {
97
120
& self . pubkey
98
121
}
0 commit comments