Skip to content

Commit bfc0c89

Browse files
committed
rename keys::{Secret, Public} to SecretShareValue, PublicVerificationShare
1 parent 87bc9d4 commit bfc0c89

File tree

7 files changed

+48
-43
lines changed

7 files changed

+48
-43
lines changed

frost-core/src/frost/keys.rs

Lines changed: 33 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ use zeroize::{DefaultIsZeroes, Zeroize};
1313

1414
use crate::{frost::Identifier, Ciphersuite, Error, Field, Group, Scalar, VerifyingKey};
1515

16-
/// A secret scalar value representing a signer's secret key.
16+
/// A secret scalar value representing a signer's secret share.
1717
#[derive(Clone, Copy, PartialEq, Eq)]
18-
pub struct Secret<C: Ciphersuite>(pub(crate) Scalar<C>);
18+
pub struct SecretShareValue<C: Ciphersuite>(pub(crate) Scalar<C>);
1919

20-
impl<C> Secret<C>
20+
impl<C> SecretShareValue<C>
2121
where
2222
C: Ciphersuite,
2323
{
@@ -45,7 +45,7 @@ where
4545
}
4646
}
4747

48-
impl<C> Debug for Secret<C>
48+
impl<C> Debug for SecretShareValue<C>
4949
where
5050
C: Ciphersuite,
5151
{
@@ -56,7 +56,7 @@ where
5656
}
5757
}
5858

59-
impl<C> Default for Secret<C>
59+
impl<C> Default for SecretShareValue<C>
6060
where
6161
C: Ciphersuite,
6262
{
@@ -66,7 +66,7 @@ where
6666
}
6767

6868
// 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 {}
7070

7171
// impl<C> Drop for Secret<C>
7272
// where
@@ -77,18 +77,18 @@ impl<C> DefaultIsZeroes for Secret<C> where C: Ciphersuite {}
7777
// }
7878
// }
7979

80-
impl<C> From<&Secret<C>> for VerifyingKey<C>
80+
impl<C> From<&SecretShareValue<C>> for VerifyingKey<C>
8181
where
8282
C: Ciphersuite,
8383
{
84-
fn from(secret: &Secret<C>) -> Self {
84+
fn from(secret: &SecretShareValue<C>) -> Self {
8585
let element = <C::Group as Group>::generator() * secret.0;
8686

8787
VerifyingKey { element }
8888
}
8989
}
9090

91-
impl<C> FromHex for Secret<C>
91+
impl<C> FromHex for SecretShareValue<C>
9292
where
9393
C: Ciphersuite,
9494
{
@@ -103,13 +103,13 @@ where
103103
}
104104
}
105105

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.
107107
#[derive(Copy, Clone, PartialEq, Eq)]
108-
pub struct Public<C>(pub(super) <C::Group as Group>::Element)
108+
pub struct PublicVerificationShare<C>(pub(super) <C::Group as Group>::Element)
109109
where
110110
C: Ciphersuite;
111111

112-
impl<C> Public<C>
112+
impl<C> PublicVerificationShare<C>
113113
where
114114
C: Ciphersuite,
115115
{
@@ -124,7 +124,7 @@ where
124124
}
125125
}
126126

127-
impl<C> Debug for Public<C>
127+
impl<C> Debug for PublicVerificationShare<C>
128128
where
129129
C: Ciphersuite,
130130
{
@@ -135,12 +135,12 @@ where
135135
}
136136
}
137137

138-
impl<C> From<Secret<C>> for Public<C>
138+
impl<C> From<SecretShareValue<C>> for PublicVerificationShare<C>
139139
where
140140
C: Ciphersuite,
141141
{
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>)
144144
}
145145
}
146146

@@ -180,7 +180,7 @@ pub struct SecretShare<C: Ciphersuite> {
180180
/// The participant identifier of this [`SecretShare`].
181181
pub identifier: Identifier<C>,
182182
/// Secret Key.
183-
pub value: Secret<C>,
183+
pub value: SecretShareValue<C>,
184184
/// The commitments to be distributed among signers.
185185
pub commitment: VerifiableSecretSharingCommitment<C>,
186186
}
@@ -190,7 +190,7 @@ where
190190
C: Ciphersuite,
191191
{
192192
/// Gets the inner [`Secret`] share value.
193-
pub fn secret(&self) -> &Secret<C> {
193+
pub fn secret(&self) -> &SecretShareValue<C> {
194194
&self.value
195195
}
196196

@@ -237,7 +237,7 @@ pub struct SharePackage<C: Ciphersuite> {
237237
/// This participant's secret share.
238238
pub secret_share: SecretShare<C>,
239239
/// This participant's public key.
240-
pub public: Public<C>,
240+
pub public: PublicVerificationShare<C>,
241241
/// The public signing key that represents the entire group.
242242
pub group_public: VerifyingKey<C>,
243243
}
@@ -262,11 +262,11 @@ pub fn keygen_with_dealer<C: Ciphersuite, R: RngCore + CryptoRng>(
262262
let mut bytes = [0; 64];
263263
rng.fill_bytes(&mut bytes);
264264

265-
let secret = Secret::random(&mut rng);
265+
let secret = SecretShareValue::random(&mut rng);
266266
let group_public = VerifyingKey::from(&secret);
267267
let secret_shares = generate_secret_shares(&secret, num_signers, threshold, rng)?;
268268
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>> =
270270
HashMap::with_capacity(num_signers as usize);
271271

272272
for secret_share in secret_shares {
@@ -302,9 +302,9 @@ pub struct KeyPackage<C: Ciphersuite> {
302302
/// Denotes the participant identifier each secret share key package is owned by.
303303
pub identifier: Identifier<C>,
304304
/// This participant's secret share.
305-
pub secret_share: Secret<C>,
305+
pub secret_share: SecretShareValue<C>,
306306
/// This participant's public key.
307-
pub public: Public<C>,
307+
pub public: PublicVerificationShare<C>,
308308
/// The public signing key that represents the entire group.
309309
pub group_public: VerifyingKey<C>,
310310
}
@@ -319,12 +319,12 @@ where
319319
}
320320

321321
/// 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> {
323323
&self.secret_share
324324
}
325325

326326
/// 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> {
328328
&self.public
329329
}
330330

@@ -369,7 +369,7 @@ pub struct PublicKeyPackage<C: Ciphersuite> {
369369
/// correct view of participants' public keys to perform verification before
370370
/// publishing a signature. `signer_pubkeys` represents all signers for a
371371
/// signing operation.
372-
pub signer_pubkeys: HashMap<Identifier<C>, Public<C>>,
372+
pub signer_pubkeys: HashMap<Identifier<C>, PublicVerificationShare<C>>,
373373
/// The joint public key for the entire group.
374374
pub group_public: VerifyingKey<C>,
375375
}
@@ -394,7 +394,7 @@ pub struct PublicKeyPackage<C: Ciphersuite> {
394394
///
395395
/// [`secret_key_shard`]: https://www.ietf.org/archive/id/draft-irtf-cfrg-frost-03.html#appendix-B.1
396396
pub fn generate_secret_shares<C: Ciphersuite, R: RngCore + CryptoRng>(
397-
secret: &Secret<C>,
397+
secret: &SecretShareValue<C>,
398398
numshares: u8,
399399
threshold: u8,
400400
mut rng: R,
@@ -456,7 +456,7 @@ pub fn generate_secret_shares<C: Ciphersuite, R: RngCore + CryptoRng>(
456456

457457
secret_shares.push(SecretShare {
458458
identifier: id,
459-
value: Secret(value),
459+
value: SecretShareValue(value),
460460
commitment: commitment.clone(),
461461
});
462462
}
@@ -467,7 +467,7 @@ pub fn generate_secret_shares<C: Ciphersuite, R: RngCore + CryptoRng>(
467467
/// Recompute the secret from t-of-n secret shares using Lagrange interpolation.
468468
pub fn reconstruct_secret<C: Ciphersuite>(
469469
secret_shares: Vec<SecretShare<C>>,
470-
) -> Result<Secret<C>, &'static str> {
470+
) -> Result<SecretShareValue<C>, &'static str> {
471471
if secret_shares.is_empty() {
472472
return Err("No secret_shares provided");
473473
}
@@ -512,5 +512,8 @@ pub fn reconstruct_secret<C: Ciphersuite>(
512512
secret = secret + (lagrange_coefficient * secret_share.value.0);
513513
}
514514

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+
)
516519
}

frost-core/src/frost/round1.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use zeroize::Zeroize;
88

99
use crate::{frost, Ciphersuite, Error, Field, Group};
1010

11-
use super::{keys::Secret, Identifier};
11+
use super::{keys::SecretShareValue, Identifier};
1212

1313
/// A scalar that is a signing nonce.
1414
#[derive(Clone, PartialEq, Eq, Zeroize)]
@@ -28,7 +28,7 @@ where
2828
/// An implementation of `nonce_generate(secret)` from the [spec].
2929
///
3030
/// [spec]: https://www.ietf.org/archive/id/draft-irtf-cfrg-frost-05.html#name-nonce-generation
31-
pub fn new<R>(secret: &Secret<C>, rng: &mut R) -> Self
31+
pub fn new<R>(secret: &SecretShareValue<C>, rng: &mut R) -> Self
3232
where
3333
R: CryptoRng + RngCore,
3434
{
@@ -167,7 +167,7 @@ where
167167
///
168168
/// Each participant generates signing nonces before performing a signing
169169
/// operation.
170-
pub fn new<R>(secret: &Secret<C>, rng: &mut R) -> Self
170+
pub fn new<R>(secret: &SecretShareValue<C>, rng: &mut R) -> Self
171171
where
172172
R: CryptoRng + RngCore,
173173
{
@@ -301,7 +301,7 @@ pub(super) fn encode_group_commitments<C: Ciphersuite>(
301301
pub fn preprocess<C, R>(
302302
num_nonces: u8,
303303
participant_identifier: Identifier<C>,
304-
secret: &Secret<C>,
304+
secret: &SecretShareValue<C>,
305305
rng: &mut R,
306306
) -> (Vec<SigningNonces<C>>, Vec<SigningCommitments<C>>)
307307
where
@@ -331,7 +331,7 @@ where
331331
/// [`commit`]: https://www.ietf.org/archive/id/draft-irtf-cfrg-frost-05.html#section-5.1
332332
pub fn commit<C, R>(
333333
participant_identifier: Identifier<C>,
334-
secret: &Secret<C>,
334+
secret: &SecretShareValue<C>,
335335
rng: &mut R,
336336
) -> (SigningNonces<C>, SigningCommitments<C>)
337337
where

frost-core/src/frost/round2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ where
8484
pub fn verify(
8585
&self,
8686
group_commitment_share: &round1::GroupCommitmentShare<C>,
87-
public_key: &frost::keys::Public<C>,
87+
public_key: &frost::keys::PublicVerificationShare<C>,
8888
lambda_i: <<C::Group as Group>::Field as Field>::Scalar,
8989
challenge: &Challenge<C>,
9090
) -> Result<(), &'static str> {

frost-core/src/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pub mod vectors;
1111

1212
/// Test share generation with a Ciphersuite
1313
pub fn check_share_generation<C: Ciphersuite + PartialEq, R: RngCore + CryptoRng>(mut rng: R) {
14-
let secret = frost::keys::Secret::<C>::random(&mut rng);
14+
let secret = frost::keys::SecretShareValue::<C>::random(&mut rng);
1515

1616
let secret_shares = frost::keys::generate_secret_shares(&secret, 5, 3, rng).unwrap();
1717

frost-core/src/tests/vectors.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ pub fn parse_test_vectors<C: Ciphersuite>(
4141
VerifyingKey::<C>::from_hex(inputs["group_public_key"].as_str().unwrap()).unwrap();
4242

4343
for (i, secret_share) in possible_signers {
44-
let secret = Secret::<C>::from_hex(secret_share["signer_share"].as_str().unwrap()).unwrap();
44+
let secret =
45+
SecretShareValue::<C>::from_hex(secret_share["signer_share"].as_str().unwrap())
46+
.unwrap();
4547
let signer_public = secret.into();
4648

4749
let key_package = KeyPackage::<C> {
@@ -162,7 +164,7 @@ where
162164
for key_package in key_packages.values() {
163165
assert_eq!(
164166
*key_package.public(),
165-
frost::keys::Public::from(*key_package.secret_share())
167+
frost::keys::PublicVerificationShare::from(*key_package.secret_share())
166168
);
167169
}
168170

frost-p256/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ pub mod keys {
229229

230230
///
231231
pub mod round1 {
232-
use frost_core::frost::keys::Secret;
232+
use frost_core::frost::keys::SecretShareValue;
233233

234234
use super::*;
235235
///
@@ -241,7 +241,7 @@ pub mod round1 {
241241
///
242242
pub fn commit<RNG>(
243243
participant_identifier: frost::Identifier<P>,
244-
secret: &Secret<P>,
244+
secret: &SecretShareValue<P>,
245245
rng: &mut RNG,
246246
) -> (SigningNonces, SigningCommitments)
247247
where

frost-ristretto255/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ pub mod keys {
210210

211211
///
212212
pub mod round1 {
213-
use frost_core::frost::keys::Secret;
213+
use frost_core::frost::keys::SecretShareValue;
214214

215215
use super::*;
216216
///
@@ -222,7 +222,7 @@ pub mod round1 {
222222
///
223223
pub fn commit<RNG>(
224224
participant_identifier: frost::Identifier<R>,
225-
secret: &Secret<R>,
225+
secret: &SecretShareValue<R>,
226226
rng: &mut RNG,
227227
) -> (SigningNonces, SigningCommitments)
228228
where

0 commit comments

Comments
 (0)