@@ -13,11 +13,11 @@ use zeroize::{DefaultIsZeroes, Zeroize};
13
13
14
14
use crate :: { frost:: Identifier , Ciphersuite , Error , Field , Group , Scalar , VerifyingKey } ;
15
15
16
- /// A secret scalar value representing a signer's secret key .
16
+ /// A secret scalar value representing a signer's secret share .
17
17
#[ derive( Clone , Copy , PartialEq ) ]
18
- pub struct Secret < C : Ciphersuite > ( pub ( crate ) Scalar < C > ) ;
18
+ pub struct SecretShareValue < C : Ciphersuite > ( pub ( crate ) Scalar < C > ) ;
19
19
20
- impl < C > Secret < C >
20
+ impl < C > SecretShareValue < C >
21
21
where
22
22
C : Ciphersuite ,
23
23
{
45
45
}
46
46
}
47
47
48
- impl < C > Debug for Secret < C >
48
+ impl < C > Debug for SecretShareValue < C >
49
49
where
50
50
C : Ciphersuite ,
51
51
{
56
56
}
57
57
}
58
58
59
- impl < C > Default for Secret < C >
59
+ impl < C > Default for SecretShareValue < C >
60
60
where
61
61
C : Ciphersuite ,
62
62
{
66
66
}
67
67
68
68
// Implements [`Zeroize`] by overwriting a value with the [`Default::default()`] value
69
- impl < C > DefaultIsZeroes for Secret < C > where C : Ciphersuite { }
69
+ impl < C > DefaultIsZeroes for SecretShareValue < C > where C : Ciphersuite { }
70
70
71
71
// impl<C> Drop for Secret<C>
72
72
// where
@@ -77,18 +77,18 @@ impl<C> DefaultIsZeroes for Secret<C> where C: Ciphersuite {}
77
77
// }
78
78
// }
79
79
80
- impl < C > From < & Secret < C > > for VerifyingKey < C >
80
+ impl < C > From < & SecretShareValue < C > > for VerifyingKey < C >
81
81
where
82
82
C : Ciphersuite ,
83
83
{
84
- fn from ( secret : & Secret < C > ) -> Self {
84
+ fn from ( secret : & SecretShareValue < C > ) -> Self {
85
85
let element = <C :: Group as Group >:: generator ( ) * secret. 0 ;
86
86
87
87
VerifyingKey { element }
88
88
}
89
89
}
90
90
91
- impl < C > FromHex for Secret < C >
91
+ impl < C > FromHex for SecretShareValue < C >
92
92
where
93
93
C : Ciphersuite ,
94
94
{
@@ -103,13 +103,13 @@ where
103
103
}
104
104
}
105
105
106
- /// A public group element that represents a single signer's public key .
106
+ /// A public group element that represents a single signer's public verification share .
107
107
#[ derive( Copy , Clone , PartialEq ) ]
108
- pub struct Public < C > ( pub ( super ) <C :: Group as Group >:: Element )
108
+ pub struct PublicVerificationShare < C > ( pub ( super ) <C :: Group as Group >:: Element )
109
109
where
110
110
C : Ciphersuite ;
111
111
112
- impl < C > Public < C >
112
+ impl < C > PublicVerificationShare < C >
113
113
where
114
114
C : Ciphersuite ,
115
115
{
@@ -124,7 +124,7 @@ where
124
124
}
125
125
}
126
126
127
- impl < C > Debug for Public < C >
127
+ impl < C > Debug for PublicVerificationShare < C >
128
128
where
129
129
C : Ciphersuite ,
130
130
{
@@ -135,12 +135,12 @@ where
135
135
}
136
136
}
137
137
138
- impl < C > From < Secret < C > > for Public < C >
138
+ impl < C > From < SecretShareValue < C > > for PublicVerificationShare < C >
139
139
where
140
140
C : Ciphersuite ,
141
141
{
142
- fn from ( secret : Secret < C > ) -> Public < C > {
143
- Public ( <C :: Group as Group >:: generator ( ) * secret. 0 as Scalar < C > )
142
+ fn from ( secret : SecretShareValue < C > ) -> PublicVerificationShare < C > {
143
+ PublicVerificationShare ( <C :: Group as Group >:: generator ( ) * secret. 0 as Scalar < C > )
144
144
}
145
145
}
146
146
@@ -180,7 +180,7 @@ pub struct SecretShare<C: Ciphersuite> {
180
180
/// The participant identifier of this [`SecretShare`].
181
181
pub identifier : Identifier < C > ,
182
182
/// Secret Key.
183
- pub value : Secret < C > ,
183
+ pub value : SecretShareValue < C > ,
184
184
/// The commitments to be distributed among signers.
185
185
pub commitment : VerifiableSecretSharingCommitment < C > ,
186
186
}
@@ -190,7 +190,7 @@ where
190
190
C : Ciphersuite ,
191
191
{
192
192
/// Gets the inner [`Secret`] share value.
193
- pub fn secret ( & self ) -> & Secret < C > {
193
+ pub fn secret ( & self ) -> & SecretShareValue < C > {
194
194
& self . value
195
195
}
196
196
@@ -237,7 +237,7 @@ pub struct SharePackage<C: Ciphersuite> {
237
237
/// This participant's secret share.
238
238
pub secret_share : SecretShare < C > ,
239
239
/// This participant's public key.
240
- pub public : Public < C > ,
240
+ pub public : PublicVerificationShare < C > ,
241
241
/// The public signing key that represents the entire group.
242
242
pub group_public : VerifyingKey < C > ,
243
243
}
@@ -262,11 +262,11 @@ pub fn keygen_with_dealer<C: Ciphersuite, R: RngCore + CryptoRng>(
262
262
let mut bytes = [ 0 ; 64 ] ;
263
263
rng. fill_bytes ( & mut bytes) ;
264
264
265
- let secret = Secret :: random ( & mut rng) ;
265
+ let secret = SecretShareValue :: random ( & mut rng) ;
266
266
let group_public = VerifyingKey :: from ( & secret) ;
267
267
let secret_shares = generate_secret_shares ( & secret, num_signers, threshold, rng) ?;
268
268
let mut share_packages: Vec < SharePackage < C > > = Vec :: with_capacity ( num_signers as usize ) ;
269
- let mut signer_pubkeys: HashMap < Identifier < C > , Public < C > > =
269
+ let mut signer_pubkeys: HashMap < Identifier < C > , PublicVerificationShare < C > > =
270
270
HashMap :: with_capacity ( num_signers as usize ) ;
271
271
272
272
for secret_share in secret_shares {
@@ -302,9 +302,9 @@ pub struct KeyPackage<C: Ciphersuite> {
302
302
/// Denotes the participant identifier each secret share key package is owned by.
303
303
pub identifier : Identifier < C > ,
304
304
/// This participant's secret share.
305
- pub secret_share : Secret < C > ,
305
+ pub secret_share : SecretShareValue < C > ,
306
306
/// This participant's public key.
307
- pub public : Public < C > ,
307
+ pub public : PublicVerificationShare < C > ,
308
308
/// The public signing key that represents the entire group.
309
309
pub group_public : VerifyingKey < C > ,
310
310
}
@@ -319,12 +319,12 @@ where
319
319
}
320
320
321
321
/// Gets the participant's [`Secret`] share associated with this [`KeyPackage`].
322
- pub fn secret_share ( & self ) -> & Secret < C > {
322
+ pub fn secret_share ( & self ) -> & SecretShareValue < C > {
323
323
& self . secret_share
324
324
}
325
325
326
326
/// Gets the participant's [`Public`] key associated with this [`Secret`] share in this [`KeyPackage`].
327
- pub fn public ( & self ) -> & Public < C > {
327
+ pub fn public ( & self ) -> & PublicVerificationShare < C > {
328
328
& self . public
329
329
}
330
330
@@ -369,7 +369,7 @@ pub struct PublicKeyPackage<C: Ciphersuite> {
369
369
/// correct view of participants' public keys to perform verification before
370
370
/// publishing a signature. `signer_pubkeys` represents all signers for a
371
371
/// signing operation.
372
- pub signer_pubkeys : HashMap < Identifier < C > , Public < C > > ,
372
+ pub signer_pubkeys : HashMap < Identifier < C > , PublicVerificationShare < C > > ,
373
373
/// The joint public key for the entire group.
374
374
pub group_public : VerifyingKey < C > ,
375
375
}
@@ -394,7 +394,7 @@ pub struct PublicKeyPackage<C: Ciphersuite> {
394
394
///
395
395
/// [`secret_key_shard`]: https://www.ietf.org/archive/id/draft-irtf-cfrg-frost-03.html#appendix-B.1
396
396
pub fn generate_secret_shares < C : Ciphersuite , R : RngCore + CryptoRng > (
397
- secret : & Secret < C > ,
397
+ secret : & SecretShareValue < C > ,
398
398
numshares : u8 ,
399
399
threshold : u8 ,
400
400
mut rng : R ,
@@ -456,7 +456,7 @@ pub fn generate_secret_shares<C: Ciphersuite, R: RngCore + CryptoRng>(
456
456
457
457
secret_shares. push ( SecretShare {
458
458
identifier : id,
459
- value : Secret ( value) ,
459
+ value : SecretShareValue ( value) ,
460
460
commitment : commitment. clone ( ) ,
461
461
} ) ;
462
462
}
@@ -467,7 +467,7 @@ pub fn generate_secret_shares<C: Ciphersuite, R: RngCore + CryptoRng>(
467
467
/// Recompute the secret from t-of-n secret shares using Lagrange interpolation.
468
468
pub fn reconstruct_secret < C : Ciphersuite > (
469
469
secret_shares : Vec < SecretShare < C > > ,
470
- ) -> Result < Secret < C > , & ' static str > {
470
+ ) -> Result < SecretShareValue < C > , & ' static str > {
471
471
if secret_shares. is_empty ( ) {
472
472
return Err ( "No secret_shares provided" ) ;
473
473
}
@@ -512,5 +512,8 @@ pub fn reconstruct_secret<C: Ciphersuite>(
512
512
secret = secret + ( lagrange_coefficient * secret_share. value . 0 ) ;
513
513
}
514
514
515
- Ok ( Secret :: from_bytes ( <<C :: Group as Group >:: Field as Field >:: serialize ( & secret) ) . unwrap ( ) )
515
+ Ok (
516
+ SecretShareValue :: from_bytes ( <<C :: Group as Group >:: Field as Field >:: serialize ( & secret) )
517
+ . unwrap ( ) ,
518
+ )
516
519
}
0 commit comments