@@ -11,7 +11,6 @@ use crate::dkg::error::Error;
11
11
use crate :: dkg:: round1;
12
12
use crate :: frost;
13
13
use crate :: frost:: keys:: dkg:: round1:: Package as Round1Package ;
14
- use crate :: frost:: keys:: dkg:: round1:: SecretPackage as Round1SecretPackage ;
15
14
use crate :: frost:: keys:: dkg:: round2:: Package ;
16
15
use crate :: frost:: keys:: dkg:: round2:: SecretPackage ;
17
16
use crate :: frost:: keys:: VerifiableSecretSharingCommitment ;
@@ -258,19 +257,21 @@ impl PublicPackage {
258
257
}
259
258
260
259
pub fn round2 < ' a , P , R > (
261
- self_identity : & Identity ,
262
- round1_secret_package : & Round1SecretPackage ,
260
+ secret : & participant :: Secret ,
261
+ round1_secret_package : & [ u8 ] ,
263
262
round1_public_packages : P ,
264
263
mut csrng : R ,
265
264
) -> Result < ( Vec < u8 > , Vec < PublicPackage > ) , Error >
266
265
where
267
266
P : IntoIterator < Item = & ' a round1:: PublicPackage > ,
268
267
R : RngCore + CryptoRng ,
269
268
{
270
- let round1_public_packages = round1_public_packages. into_iter ( ) . collect :: < Vec < _ > > ( ) ;
269
+ let self_identity = secret. to_identity ( ) ;
270
+ let round1_secret_package = round1:: import_secret_package ( round1_secret_package, secret)
271
+ . map_err ( Error :: DecryptionError ) ?;
271
272
272
273
// Extract the min/max signers from the secret package
273
- let ( min_signers, max_signers) = round1:: get_secret_package_signers ( round1_secret_package) ;
274
+ let ( min_signers, max_signers) = round1:: get_secret_package_signers ( & round1_secret_package) ;
274
275
275
276
let round1_public_packages = round1_public_packages. into_iter ( ) . collect :: < Vec < _ > > ( ) ;
276
277
@@ -333,7 +334,7 @@ where
333
334
334
335
// Encrypt the secret package
335
336
let encrypted_secret_package =
336
- export_secret_package ( & round2_secret_package, self_identity, & mut csrng)
337
+ export_secret_package ( & round2_secret_package, & self_identity, & mut csrng)
337
338
. map_err ( Error :: EncryptionError ) ?;
338
339
339
340
// Convert the Identifier->Package map to an Identity->PublicPackage map
@@ -545,11 +546,8 @@ mod tests {
545
546
)
546
547
. expect ( "round 1 failed" ) ;
547
548
548
- let round1_secret_package = round1:: import_secret_package ( & round1_secret_package, & secret)
549
- . expect ( "secret package import failed" ) ;
550
-
551
549
let ( secret_package, round2_public_packages) = super :: round2 (
552
- & identity1 ,
550
+ & secret ,
553
551
& round1_secret_package,
554
552
[ & package1, & package2, & package3] ,
555
553
thread_rng ( ) ,
@@ -583,12 +581,9 @@ mod tests {
583
581
. map ( |id| round1:: round1 ( id, 2 , & identities, thread_rng ( ) ) . expect ( "dkg round 1 failed" ) )
584
582
. collect :: < Vec < _ > > ( ) ;
585
583
586
- let round1_secret_package = round1:: import_secret_package ( & round1_packages[ 0 ] . 0 , & secret)
587
- . expect ( "secret package import failed" ) ;
588
-
589
584
let result = super :: round2 (
590
- & identities [ 0 ] ,
591
- & round1_secret_package ,
585
+ & secret ,
586
+ & round1_packages [ 0 ] . 0 ,
592
587
[
593
588
& round1_packages[ 0 ] . 1 ,
594
589
& round1_packages[ 0 ] . 1 ,
@@ -618,12 +613,9 @@ mod tests {
618
613
. map ( |id| round1:: round1 ( id, 2 , & identities, thread_rng ( ) ) . expect ( "dkg round 1 failed" ) )
619
614
. collect :: < Vec < _ > > ( ) ;
620
615
621
- let round1_secret_package = round1:: import_secret_package ( & round1_packages[ 0 ] . 0 , & secret)
622
- . expect ( "secret package import failed" ) ;
623
-
624
616
let result = super :: round2 (
625
- & identities [ 0 ] ,
626
- & round1_secret_package ,
617
+ & secret ,
618
+ & round1_packages [ 0 ] . 0 ,
627
619
[ & round1_packages[ 0 ] . 1 , & round1_packages[ 1 ] . 1 ] ,
628
620
thread_rng ( ) ,
629
621
) ;
0 commit comments