Skip to content

Commit 3eda0f7

Browse files
authored
Merge of #1001
2 parents 3ed40ad + d377b6d commit 3eda0f7

File tree

9 files changed

+154
-154
lines changed

9 files changed

+154
-154
lines changed

frost-core/CHANGELOG.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,15 @@ Entries are listed in reverse chronological order.
2222
before calling the function (recreate it with `PublicKeyPackage::new()`).
2323
The latter was simply redundant.
2424
* Refactored the `frost_core::keys::repairable` module:
25-
* `repair_share_step_1()` now takes a `KeyPackage` and returns a map with
26-
a new `Delta` type instead of a raw `Scalar`
27-
* `repair_share_step_2()` now takes the `Delta` type and returns a new `Sigma`
28-
type instead of a raw `Scalar`
29-
* `repair_share_step_3()` now takes the `Sigma` type and a `PublicKeyPackage`
30-
instead of `VerifiableSecretSharingCommitment`; and returns a `KeyPackage`
31-
instead of `SecretShare`.
25+
* `repair_share_step_1()` was renamed to `repair_share_part1()` and now takes
26+
a `KeyPackage` and returns a map with a new `Delta` type instead of a raw
27+
`Scalar`
28+
* `repair_share_step_2()` was renamed to `repair_share_part2()` and now takes
29+
the `Delta` type and returns a new `Sigma` type instead of a raw `Scalar`
30+
* `repair_share_step_3()` was renamed to `repair_share_part3()` and now takes
31+
the `Sigma` type and a `PublicKeyPackage` instead of
32+
`VerifiableSecretSharingCommitment`; and returns a `KeyPackage` instead of
33+
`SecretShare`.
3234
* These changes provide more type safety and are make it more useful since
3335
`SecretPackage`s are not expected to be stored
3436

frost-core/src/keys/repairable.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
//!
1010
//! - Participants need to agree somehow on who are going to be the `helpers`
1111
//! for the repair, and which participant is going to repair their share.
12-
//! - Each helper runs `repair_share_step_1`, generating a set of `delta` values
12+
//! - Each helper runs `repair_share_part1`, generating a set of `delta` values
1313
//! to be sent to each helper (including themselves).
14-
//! - Each helper runs `repair_share_step_2`, passing the received `delta`
14+
//! - Each helper runs `repair_share_part2`, passing the received `delta`
1515
//! values, generating a `sigma` value to be sent to the participant repairing
1616
//! their share.
17-
//! - The participant repairing their share runs `repair_share_step_3`, passing
17+
//! - The participant repairing their share runs `repair_share_part3`, passing
1818
//! all the received `sigma` values, recovering their lost `KeyPackage`. (They
1919
//! will also need the `PublicKeyPackage` for this step which could be
2020
//! provided by any of the helpers).
@@ -32,7 +32,7 @@ use crate::{
3232

3333
use super::{generate_coefficients, SigningShare};
3434

35-
/// A delta value which is the output of step 1 of RTS.
35+
/// A delta value which is the output of part 1 of RTS.
3636
#[derive(Clone, Copy, PartialEq, Eq)]
3737
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
3838
#[cfg_attr(feature = "serde", serde(bound = "C: Ciphersuite"))]
@@ -68,7 +68,7 @@ where
6868
}
6969
}
7070

71-
/// A sigma value which is the output of step 2 of RTS.
71+
/// A sigma value which is the output of part 2 of RTS.
7272
#[derive(Clone, Copy, PartialEq, Eq)]
7373
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
7474
#[cfg_attr(feature = "serde", serde(bound = "C: Ciphersuite"))]
@@ -104,14 +104,14 @@ where
104104
}
105105
}
106106

107-
/// Step 1 of RTS.
107+
/// Part 1 of RTS.
108108
///
109109
/// Generates the "delta" values from the helper with `key_package_i` to send to
110110
/// `helpers` (which includes the helper with `key_package_i`), to help
111111
/// `participant` recover their share.
112112
///
113113
/// Returns a BTreeMap mapping which value should be sent to which participant.
114-
pub fn repair_share_step_1<C: Ciphersuite, R: RngCore + CryptoRng>(
114+
pub fn repair_share_part1<C: Ciphersuite, R: RngCore + CryptoRng>(
115115
helpers: &[Identifier<C>],
116116
key_package_i: &KeyPackage<C>,
117117
rng: &mut R,
@@ -169,11 +169,11 @@ fn compute_last_random_value<C: Ciphersuite>(
169169
Ok(out)
170170
}
171171

172-
/// Step 2 of RTS.
172+
/// Part 2 of RTS.
173173
///
174174
/// Generates the "sigma" value from all `deltas` received from all helpers.
175175
/// The "sigma" value must be sent to the participant repairing their share.
176-
pub fn repair_share_step_2<C: Ciphersuite>(deltas: &[Delta<C>]) -> Sigma<C> {
176+
pub fn repair_share_part2<C: Ciphersuite>(deltas: &[Delta<C>]) -> Sigma<C> {
177177
let mut sigma_j = <<C::Group as Group>::Field>::zero();
178178

179179
for d in deltas {
@@ -183,7 +183,7 @@ pub fn repair_share_step_2<C: Ciphersuite>(deltas: &[Delta<C>]) -> Sigma<C> {
183183
Sigma::new(sigma_j)
184184
}
185185

186-
/// Step 3 of RTS.
186+
/// Part 3 of RTS.
187187
///
188188
/// The participant with the given `identifier` recovers their `KeyPackage`
189189
/// with the "sigma" values received from all helpers and the `PublicKeyPackage`
@@ -192,7 +192,7 @@ pub fn repair_share_step_2<C: Ciphersuite>(deltas: &[Delta<C>]) -> Sigma<C> {
192192
/// Returns an error if the `min_signers` field is not set in the `PublicKeyPackage`.
193193
/// This happens for `PublicKeyPackage`s created before the 3.0.0 release;
194194
/// in that case, the user should set the `min_signers` field manually.
195-
pub fn repair_share_step_3<C: Ciphersuite>(
195+
pub fn repair_share_part3<C: Ciphersuite>(
196196
sigmas: &[Sigma<C>],
197197
identifier: Identifier<C>,
198198
public_key_package: &PublicKeyPackage<C>,

frost-core/src/tests/repairable.rs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use crate::keys::KeyPackage;
1212
use crate::{
1313
compute_lagrange_coefficient,
1414
keys::{
15-
repairable::{repair_share_step_1, repair_share_step_2, repair_share_step_3},
15+
repairable::{repair_share_part1, repair_share_part2, repair_share_part3},
1616
PublicKeyPackage, SecretShare,
1717
},
1818
Ciphersuite, Error, Field, Group, Identifier,
@@ -62,33 +62,33 @@ pub fn check_rts<C: Ciphersuite, R: RngCore + CryptoRng>(mut rng: R) {
6262
// Each helper generates random values for each helper
6363

6464
let helper_1_deltas =
65-
repair_share_step_1(&helpers, helper_1, &mut rng, participant.identifier).unwrap();
65+
repair_share_part1(&helpers, helper_1, &mut rng, participant.identifier).unwrap();
6666
let helper_4_deltas =
67-
repair_share_step_1(&helpers, helper_4, &mut rng, participant.identifier).unwrap();
67+
repair_share_part1(&helpers, helper_4, &mut rng, participant.identifier).unwrap();
6868
let helper_5_deltas =
69-
repair_share_step_1(&helpers, helper_5, &mut rng, participant.identifier).unwrap();
69+
repair_share_part1(&helpers, helper_5, &mut rng, participant.identifier).unwrap();
7070

7171
// Each helper calculates their sigma from the random values received from the other helpers
7272

73-
let helper_1_sigma: Sigma<C> = repair_share_step_2::<C>(&[
73+
let helper_1_sigma: Sigma<C> = repair_share_part2::<C>(&[
7474
helper_1_deltas[&helpers[0]],
7575
helper_4_deltas[&helpers[0]],
7676
helper_5_deltas[&helpers[0]],
7777
]);
78-
let helper_4_sigma: Sigma<C> = repair_share_step_2::<C>(&[
78+
let helper_4_sigma: Sigma<C> = repair_share_part2::<C>(&[
7979
helper_1_deltas[&helpers[1]],
8080
helper_4_deltas[&helpers[1]],
8181
helper_5_deltas[&helpers[1]],
8282
]);
83-
let helper_5_sigma: Sigma<C> = repair_share_step_2::<C>(&[
83+
let helper_5_sigma: Sigma<C> = repair_share_part2::<C>(&[
8484
helper_1_deltas[&helpers[2]],
8585
helper_4_deltas[&helpers[2]],
8686
helper_5_deltas[&helpers[2]],
8787
]);
8888

8989
// The participant wishing to recover their share sums the sigmas sent from all helpers
9090

91-
let participant_recovered_share = repair_share_step_3(
91+
let participant_recovered_share = repair_share_part3(
9292
&[helper_1_sigma, helper_4_sigma, helper_5_sigma],
9393
participant.identifier,
9494
&public_key_package,
@@ -108,8 +108,8 @@ fn generate_scalar_from_byte_string<C: Ciphersuite>(
108108
out.unwrap()
109109
}
110110

111-
/// Test repair_share_step_1
112-
pub fn check_repair_share_step_1<C: Ciphersuite, R: RngCore + CryptoRng>(mut rng: R) {
111+
/// Test repair_share_part1
112+
pub fn check_repair_share_part1<C: Ciphersuite, R: RngCore + CryptoRng>(mut rng: R) {
113113
// Compute shares
114114

115115
let max_signers = 5;
@@ -142,7 +142,7 @@ pub fn check_repair_share_step_1<C: Ciphersuite, R: RngCore + CryptoRng>(mut rng
142142
];
143143

144144
// Generate deltas for helper 4
145-
let deltas = repair_share_step_1(&helpers, helper_4, &mut rng, participant.identifier).unwrap();
145+
let deltas = repair_share_part1(&helpers, helper_4, &mut rng, participant.identifier).unwrap();
146146

147147
let lagrange_coefficient = compute_lagrange_coefficient(
148148
&helpers.iter().cloned().collect(),
@@ -161,8 +161,8 @@ pub fn check_repair_share_step_1<C: Ciphersuite, R: RngCore + CryptoRng>(mut rng
161161
assert!(lhs == rhs)
162162
}
163163

164-
/// Test repair_share_step_2
165-
pub fn check_repair_share_step_2<C: Ciphersuite>(repair_share_helpers: &Value) {
164+
/// Test repair_share_part2
165+
pub fn check_repair_share_part2<C: Ciphersuite>(repair_share_helpers: &Value) {
166166
let values = &repair_share_helpers["scalar_generation"];
167167

168168
let value_1 = Delta::new(generate_scalar_from_byte_string::<C>(
@@ -174,7 +174,7 @@ pub fn check_repair_share_step_2<C: Ciphersuite>(repair_share_helpers: &Value) {
174174
let value_3 = Delta::new(generate_scalar_from_byte_string::<C>(
175175
values["random_scalar_3"].as_str().unwrap(),
176176
));
177-
let expected = repair_share_step_2::<C>(&[value_1, value_2, value_3]);
177+
let expected = repair_share_part2::<C>(&[value_1, value_2, value_3]);
178178

179179
let actual = Sigma::new(generate_scalar_from_byte_string::<C>(
180180
values["random_scalar_sum"].as_str().unwrap(),
@@ -183,8 +183,8 @@ pub fn check_repair_share_step_2<C: Ciphersuite>(repair_share_helpers: &Value) {
183183
assert!(actual == expected);
184184
}
185185

186-
/// Test repair_share
187-
pub fn check_repair_share_step_3<C: Ciphersuite, R: RngCore + CryptoRng>(
186+
/// Test repair_share_part3
187+
pub fn check_repair_share_part3<C: Ciphersuite, R: RngCore + CryptoRng>(
188188
mut rng: R,
189189
repair_share_helpers: &Value,
190190
) {
@@ -217,7 +217,7 @@ pub fn check_repair_share_step_3<C: Ciphersuite, R: RngCore + CryptoRng>(
217217
sigmas["sigma_4"].as_str().unwrap(),
218218
));
219219

220-
let actual = repair_share_step_3::<C>(
220+
let actual = repair_share_part3::<C>(
221221
&[sigma_1, sigma_2, sigma_3, sigma_4],
222222
Identifier::try_from(2).unwrap(),
223223
&public_key_package,
@@ -230,8 +230,8 @@ pub fn check_repair_share_step_3<C: Ciphersuite, R: RngCore + CryptoRng>(
230230
assert!(expected == actual.signing_share().to_scalar());
231231
}
232232

233-
/// Test repair share step 1 fails with invalid numbers of signers.
234-
pub fn check_repair_share_step_1_fails_with_invalid_min_signers<
233+
/// Test repair share part 1 fails with invalid numbers of signers.
234+
pub fn check_repair_share_part1_fails_with_invalid_min_signers<
235235
C: Ciphersuite,
236236
R: RngCore + CryptoRng,
237237
>(
@@ -255,7 +255,7 @@ pub fn check_repair_share_step_1_fails_with_invalid_min_signers<
255255

256256
let helper = Identifier::try_from(3).unwrap();
257257

258-
let out = repair_share_step_1(
258+
let out = repair_share_part1(
259259
&[helper],
260260
&key_packages[&helper],
261261
&mut rng,

frost-ed25519/src/keys/repairable.rs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,37 +13,37 @@ use crate::keys::{KeyPackage, PublicKeyPackage};
1313
use crate::{frost, Ciphersuite, CryptoRng, Identifier, RngCore};
1414
use crate::{Ed25519Sha512, Error};
1515

16-
/// A delta value which is the output of step 1 of RTS.
16+
/// A delta value which is the output of part 1 of RTS.
1717
pub type Delta = frost::keys::repairable::Delta<Ed25519Sha512>;
1818

19-
/// A sigma value which is the output of step 2 of RTS.
19+
/// A sigma value which is the output of part 2 of RTS.
2020
pub type Sigma = frost::keys::repairable::Sigma<Ed25519Sha512>;
2121

22-
/// Step 1 of RTS.
22+
/// Part 1 of RTS.
2323
///
2424
/// Generates the "delta" values from the helper with `key_package_i` to send to
2525
/// `helpers` (which includes the helper with `key_package_i`), to help
2626
/// `participant` recover their share.
2727
///
2828
/// Returns a BTreeMap mapping which value should be sent to which participant.
29-
pub fn repair_share_step_1<C: Ciphersuite, R: RngCore + CryptoRng>(
29+
pub fn repair_share_part1<C: Ciphersuite, R: RngCore + CryptoRng>(
3030
helpers: &[Identifier],
3131
key_package_i: &KeyPackage,
3232
rng: &mut R,
3333
participant: Identifier,
3434
) -> Result<BTreeMap<Identifier, Delta>, Error> {
35-
frost::keys::repairable::repair_share_step_1(helpers, key_package_i, rng, participant)
35+
frost::keys::repairable::repair_share_part1(helpers, key_package_i, rng, participant)
3636
}
3737

38-
/// Step 2 of RTS.
38+
/// Part 2 of RTS.
3939
///
4040
/// Generates the "sigma" value from all `deltas` received from all helpers.
4141
/// The "sigma" value must be sent to the participant repairing their share.
42-
pub fn repair_share_step_2(deltas: &[Delta]) -> Sigma {
43-
frost::keys::repairable::repair_share_step_2::<Ed25519Sha512>(deltas)
42+
pub fn repair_share_part2(deltas: &[Delta]) -> Sigma {
43+
frost::keys::repairable::repair_share_part2::<Ed25519Sha512>(deltas)
4444
}
4545

46-
/// Step 3 of RTS.
46+
/// Part 3 of RTS.
4747
///
4848
/// The participant with the given `identifier` recovers their `KeyPackage`
4949
/// with the "sigma" values received from all helpers and the `PublicKeyPackage`
@@ -52,12 +52,12 @@ pub fn repair_share_step_2(deltas: &[Delta]) -> Sigma {
5252
/// Returns an error if the `min_signers` field is not set in the `PublicKeyPackage`.
5353
/// This happens for `PublicKeyPackage`s created before the 3.0.0 release;
5454
/// in that case, the user should set the `min_signers` field manually.
55-
pub fn repair_share_step_3(
55+
pub fn repair_share_part3(
5656
sigmas: &[Sigma],
5757
identifier: Identifier,
5858
public_key_package: &PublicKeyPackage,
5959
) -> Result<KeyPackage, Error> {
60-
frost::keys::repairable::repair_share_step_3(sigmas, identifier, public_key_package)
60+
frost::keys::repairable::repair_share_part3(sigmas, identifier, public_key_package)
6161
}
6262

6363
#[cfg(test)]
@@ -76,30 +76,30 @@ mod tests {
7676
}
7777

7878
#[test]
79-
fn check_repair_share_step_1() {
79+
fn check_repair_share_part1() {
8080
let rng = rand::rngs::OsRng;
8181

82-
frost_core::tests::repairable::check_repair_share_step_1::<Ed25519Sha512, _>(rng);
82+
frost_core::tests::repairable::check_repair_share_part1::<Ed25519Sha512, _>(rng);
8383
}
8484

8585
#[test]
86-
fn check_repair_share_step_2() {
87-
frost_core::tests::repairable::check_repair_share_step_2::<Ed25519Sha512>(&REPAIR_SHARE);
86+
fn check_repair_share_part2() {
87+
frost_core::tests::repairable::check_repair_share_part2::<Ed25519Sha512>(&REPAIR_SHARE);
8888
}
8989

9090
#[test]
91-
fn check_repair_share_step_3() {
91+
fn check_repair_share_part3() {
9292
let rng = rand::rngs::OsRng;
93-
frost_core::tests::repairable::check_repair_share_step_3::<Ed25519Sha512, _>(
93+
frost_core::tests::repairable::check_repair_share_part3::<Ed25519Sha512, _>(
9494
rng,
9595
&REPAIR_SHARE,
9696
);
9797
}
9898

9999
#[test]
100-
fn check_repair_share_step_1_fails_with_invalid_min_signers() {
100+
fn check_repair_share_part1_fails_with_invalid_min_signers() {
101101
let rng = rand::rngs::OsRng;
102-
frost_core::tests::repairable::check_repair_share_step_1_fails_with_invalid_min_signers::<
102+
frost_core::tests::repairable::check_repair_share_part1_fails_with_invalid_min_signers::<
103103
Ed25519Sha512,
104104
_,
105105
>(rng);

0 commit comments

Comments
 (0)