Skip to content

Commit b1bbad7

Browse files
authored
update FROST (#67)
1 parent eec9f7c commit b1bbad7

8 files changed

+57
-24
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
Entries are listed in reverse chronological order.
44

5+
## 0.5.1
6+
7+
* MSRV is now 1.65.0
8+
* Refactor & optimize the NAF (#63)
9+
* Updated `frost-rerandomized` to 0.6.0 (#67)
10+
511
## 0.5.0
612

713
* Add Pallas and Jubjub ciphersuites and FROST support (#33)

Cargo.toml

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
[package]
22
name = "reddsa"
33
edition = "2021"
4-
rust-version = "1.60"
4+
rust-version = "1.65"
55
# When releasing to crates.io:
66
# - Update CHANGELOG.md
77
# - Create git tag.
8-
version = "0.5.0"
8+
version = "0.5.1"
99
authors = [
1010
"Henry de Valence <[email protected]>",
1111
"Deirdre Connolly <[email protected]>",
@@ -33,7 +33,7 @@ pasta_curves = { version = "0.5", default-features = false }
3333
rand_core = { version = "0.6", default-features = false }
3434
serde = { version = "1", optional = true, features = ["derive"] }
3535
thiserror = { version = "1.0", optional = true }
36-
frost-rerandomized = { version = "0.2", optional = true }
36+
frost-rerandomized = { version = "0.6.0", optional = true }
3737

3838
[dependencies.zeroize]
3939
version = "1"
@@ -50,7 +50,7 @@ proptest = "1.0"
5050
rand = "0.8"
5151
rand_chacha = "0.3"
5252
serde_json = "1.0"
53-
frost-rerandomized = { version = "0.2", features=["test-impl"] }
53+
frost-rerandomized = { version = "0.6.0", features=["test-impl"] }
5454
num-bigint = "0.4.3"
5555
num-traits = "0.2.15"
5656

rust-toolchain

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.60.0
1+
1.65.0

src/frost/redjubjub.rs

+12-5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
#![allow(non_snake_case)]
33
#![deny(missing_docs)]
44

5+
use std::collections::HashMap;
6+
57
use group::GroupEncoding;
68
#[cfg(feature = "alloc")]
79
use group::{ff::Field as FFField, ff::PrimeField};
@@ -115,6 +117,8 @@ impl Group for JubjubGroup {
115117
pub struct JubjubBlake2b512;
116118

117119
impl Ciphersuite for JubjubBlake2b512 {
120+
const ID: &'static str = "FROST(Jubjub, BLAKE2b-512)";
121+
118122
type Group = JubjubGroup;
119123

120124
type HashOutput = [u8; 64];
@@ -180,14 +184,18 @@ pub mod keys {
180184

181185
use super::*;
182186

187+
/// The identifier list to use when generating key shares.
188+
pub type IdentifierList<'a> = frost::keys::IdentifierList<'a, J>;
189+
183190
/// Allows all participants' keys to be generated using a central, trusted
184191
/// dealer.
185-
pub fn keygen_with_dealer<RNG: RngCore + CryptoRng>(
192+
pub fn generate_with_dealer<RNG: RngCore + CryptoRng>(
186193
max_signers: u16,
187194
min_signers: u16,
195+
identifiers: IdentifierList,
188196
mut rng: RNG,
189197
) -> Result<(HashMap<Identifier, SecretShare>, PublicKeyPackage), Error> {
190-
frost::keys::keygen_with_dealer(max_signers, min_signers, &mut rng)
198+
frost::keys::generate_with_dealer(max_signers, min_signers, identifiers, &mut rng)
191199
}
192200

193201
/// Secret and public key material generated by a dealer performing
@@ -237,14 +245,13 @@ pub mod round1 {
237245
/// Generates the signing nonces and commitments to be used in the signing
238246
/// operation.
239247
pub fn commit<RNG>(
240-
participant_identifier: frost::Identifier<J>,
241248
secret: &SigningShare<J>,
242249
rng: &mut RNG,
243250
) -> (SigningNonces, SigningCommitments)
244251
where
245252
RNG: CryptoRng + RngCore,
246253
{
247-
frost::round1::commit::<J, RNG>(participant_identifier, secret, rng)
254+
frost::round1::commit::<J, RNG>(secret, rng)
248255
}
249256
}
250257

@@ -307,7 +314,7 @@ pub type Signature = frost_rerandomized::frost_core::Signature<J>;
307314
/// service attack due to publishing an invalid signature.
308315
pub fn aggregate(
309316
signing_package: &round2::SigningPackage,
310-
signature_shares: &[round2::SignatureShare],
317+
signature_shares: &HashMap<Identifier, round2::SignatureShare>,
311318
pubkeys: &keys::PublicKeyPackage,
312319
randomized_params: &RandomizedParams<J>,
313320
) -> Result<Signature, Error> {

src/frost/redpallas.rs

+12-5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
#![allow(non_snake_case)]
33
#![deny(missing_docs)]
44

5+
use std::collections::HashMap;
6+
57
use group::GroupEncoding;
68
#[cfg(feature = "alloc")]
79
use group::{ff::Field as FFField, ff::PrimeField, Group as FFGroup};
@@ -117,6 +119,8 @@ impl Group for PallasGroup {
117119
pub struct PallasBlake2b512;
118120

119121
impl Ciphersuite for PallasBlake2b512 {
122+
const ID: &'static str = "FROST(Pallas, BLAKE2b-512)";
123+
120124
type Group = PallasGroup;
121125

122126
type HashOutput = [u8; 64];
@@ -182,14 +186,18 @@ pub mod keys {
182186

183187
use super::*;
184188

189+
/// The identifier list to use when generating key shares.
190+
pub type IdentifierList<'a> = frost::keys::IdentifierList<'a, P>;
191+
185192
/// Allows all participants' keys to be generated using a central, trusted
186193
/// dealer.
187-
pub fn keygen_with_dealer<RNG: RngCore + CryptoRng>(
194+
pub fn generate_with_dealer<RNG: RngCore + CryptoRng>(
188195
max_signers: u16,
189196
min_signers: u16,
197+
identifiers: IdentifierList,
190198
mut rng: RNG,
191199
) -> Result<(HashMap<Identifier, SecretShare>, PublicKeyPackage), Error> {
192-
frost::keys::keygen_with_dealer(max_signers, min_signers, &mut rng)
200+
frost::keys::generate_with_dealer(max_signers, min_signers, identifiers, &mut rng)
193201
}
194202

195203
/// Secret and public key material generated by a dealer performing
@@ -239,14 +247,13 @@ pub mod round1 {
239247
/// Generates the signing nonces and commitments to be used in the signing
240248
/// operation.
241249
pub fn commit<RNG>(
242-
participant_identifier: frost::Identifier<P>,
243250
secret: &SigningShare<P>,
244251
rng: &mut RNG,
245252
) -> (SigningNonces, SigningCommitments)
246253
where
247254
RNG: CryptoRng + RngCore,
248255
{
249-
frost::round1::commit::<P, RNG>(participant_identifier, secret, rng)
256+
frost::round1::commit::<P, RNG>(secret, rng)
250257
}
251258
}
252259

@@ -309,7 +316,7 @@ pub type Signature = frost_rerandomized::frost_core::Signature<P>;
309316
/// service attack due to publishing an invalid signature.
310317
pub fn aggregate(
311318
signing_package: &round2::SigningPackage,
312-
signature_shares: &[round2::SignatureShare],
319+
signature_shares: &HashMap<Identifier, round2::SignatureShare>,
313320
pubkeys: &keys::PublicKeyPackage,
314321
randomized_params: &RandomizedParams<P>,
315322
) -> Result<Signature, Error> {

src/orchard/tests.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use std::println;
2+
13
use crate::scalar_mul::{self, VartimeMultiscalarMul};
24
use alloc::vec::Vec;
35
use group::ff::Field;
@@ -30,7 +32,6 @@ fn orchard_binding_basepoint() {
3032
#[allow(dead_code)]
3133
fn gen_pallas_test_vectors() {
3234
use group::Group;
33-
use std::println;
3435

3536
let rng = thread_rng();
3637

tests/frost_redjubjub.rs

+10-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ use reddsa::{frost::redjubjub::JubjubBlake2b512, sapling};
99
fn check_sign_with_dealer() {
1010
let rng = thread_rng();
1111

12-
frost_rerandomized::frost_core::tests::check_sign_with_dealer::<JubjubBlake2b512, _>(rng);
12+
frost_rerandomized::frost_core::tests::ciphersuite_generic::check_sign_with_dealer::<
13+
JubjubBlake2b512,
14+
_,
15+
>(rng);
1316
}
1417

1518
#[test]
@@ -23,11 +26,11 @@ fn check_randomized_sign_with_dealer() {
2326
// public key (interoperability test)
2427

2528
let sig = {
26-
let bytes: [u8; 64] = group_signature.to_bytes().as_ref().try_into().unwrap();
29+
let bytes: [u8; 64] = group_signature.serialize().as_ref().try_into().unwrap();
2730
reddsa::Signature::<sapling::SpendAuth>::from(bytes)
2831
};
2932
let pk_bytes = {
30-
let bytes: [u8; 32] = group_pubkey.to_bytes().as_ref().try_into().unwrap();
33+
let bytes: [u8; 32] = group_pubkey.serialize().as_ref().try_into().unwrap();
3134
reddsa::VerificationKeyBytes::<sapling::SpendAuth>::from(bytes)
3235
};
3336

@@ -43,7 +46,10 @@ fn check_randomized_sign_with_dealer() {
4346
fn check_sign_with_dkg() {
4447
let rng = thread_rng();
4548

46-
frost_rerandomized::frost_core::tests::check_sign_with_dkg::<JubjubBlake2b512, _>(rng);
49+
frost_rerandomized::frost_core::tests::ciphersuite_generic::check_sign_with_dkg::<
50+
JubjubBlake2b512,
51+
_,
52+
>(rng);
4753
}
4854

4955
#[test]

tests/frost_redpallas.rs

+10-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ use reddsa::{frost::redpallas::PallasBlake2b512, orchard};
99
fn check_sign_with_dealer() {
1010
let rng = thread_rng();
1111

12-
frost_rerandomized::frost_core::tests::check_sign_with_dealer::<PallasBlake2b512, _>(rng);
12+
frost_rerandomized::frost_core::tests::ciphersuite_generic::check_sign_with_dealer::<
13+
PallasBlake2b512,
14+
_,
15+
>(rng);
1316
}
1417

1518
#[test]
@@ -23,11 +26,11 @@ fn check_randomized_sign_with_dealer() {
2326
// public key (interoperability test)
2427

2528
let sig = {
26-
let bytes: [u8; 64] = group_signature.to_bytes().as_ref().try_into().unwrap();
29+
let bytes: [u8; 64] = group_signature.serialize().as_ref().try_into().unwrap();
2730
reddsa::Signature::<orchard::SpendAuth>::from(bytes)
2831
};
2932
let pk_bytes = {
30-
let bytes: [u8; 32] = group_pubkey.to_bytes().as_ref().try_into().unwrap();
33+
let bytes: [u8; 32] = group_pubkey.serialize().as_ref().try_into().unwrap();
3134
reddsa::VerificationKeyBytes::<orchard::SpendAuth>::from(bytes)
3235
};
3336

@@ -43,7 +46,10 @@ fn check_randomized_sign_with_dealer() {
4346
fn check_sign_with_dkg() {
4447
let rng = thread_rng();
4548

46-
frost_rerandomized::frost_core::tests::check_sign_with_dkg::<PallasBlake2b512, _>(rng);
49+
frost_rerandomized::frost_core::tests::ciphersuite_generic::check_sign_with_dkg::<
50+
PallasBlake2b512,
51+
_,
52+
>(rng);
4753
}
4854

4955
#[test]

0 commit comments

Comments
 (0)