Skip to content

Commit

Permalink
update FROST
Browse files Browse the repository at this point in the history
  • Loading branch information
conradoplg committed Jul 11, 2023
1 parent 0f652cf commit c5e24a3
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 23 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

Entries are listed in reverse chronological order.

## 0.5.1

* MSRV is now 1.65.0
* Refactor & optimize the NAF (#63)
* Updated `frost-rerandomized` to 0.6.0 (#67)

## 0.5.0

* Add Pallas and Jubjub ciphersuites and FROST support (#33)
Expand Down
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "reddsa"
edition = "2021"
rust-version = "1.60"
rust-version = "1.65"
# When releasing to crates.io:
# - Update CHANGELOG.md
# - Create git tag.
Expand Down Expand Up @@ -33,7 +33,7 @@ pasta_curves = { version = "0.5", default-features = false }
rand_core = { version = "0.6", default-features = false }
serde = { version = "1", optional = true, features = ["derive"] }
thiserror = { version = "1.0", optional = true }
frost-rerandomized = { version = "0.2", optional = true }
frost-rerandomized = { version = "0.6.0", optional = true }

[dependencies.zeroize]
version = "1"
Expand All @@ -50,7 +50,7 @@ proptest = "1.0"
rand = "0.8"
rand_chacha = "0.3"
serde_json = "1.0"
frost-rerandomized = { version = "0.2", features=["test-impl"] }
frost-rerandomized = { version = "0.6.0", features=["test-impl"] }
num-bigint = "0.4.3"
num-traits = "0.2.15"

Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.60.0
1.65.0
17 changes: 12 additions & 5 deletions src/frost/redjubjub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#![allow(non_snake_case)]
#![deny(missing_docs)]

use std::collections::HashMap;

use group::GroupEncoding;
#[cfg(feature = "alloc")]
use group::{ff::Field as FFField, ff::PrimeField};
Expand Down Expand Up @@ -115,6 +117,8 @@ impl Group for JubjubGroup {
pub struct JubjubBlake2b512;

impl Ciphersuite for JubjubBlake2b512 {
const ID: &'static str = "FROST(Jubjub, BLAKE2b-512)";

type Group = JubjubGroup;

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

use super::*;

/// The identifier list to use when generating key shares.
pub type IdentifierList<'a> = frost::keys::IdentifierList<'a, J>;

/// Allows all participants' keys to be generated using a central, trusted
/// dealer.
pub fn keygen_with_dealer<RNG: RngCore + CryptoRng>(
pub fn generate_with_dealer<RNG: RngCore + CryptoRng>(
max_signers: u16,
min_signers: u16,
identifiers: IdentifierList,
mut rng: RNG,
) -> Result<(HashMap<Identifier, SecretShare>, PublicKeyPackage), Error> {
frost::keys::keygen_with_dealer(max_signers, min_signers, &mut rng)
frost::keys::generate_with_dealer(max_signers, min_signers, identifiers, &mut rng)
}

/// Secret and public key material generated by a dealer performing
Expand Down Expand Up @@ -237,14 +245,13 @@ pub mod round1 {
/// Generates the signing nonces and commitments to be used in the signing
/// operation.
pub fn commit<RNG>(
participant_identifier: frost::Identifier<J>,
secret: &SigningShare<J>,
rng: &mut RNG,
) -> (SigningNonces, SigningCommitments)
where
RNG: CryptoRng + RngCore,
{
frost::round1::commit::<J, RNG>(participant_identifier, secret, rng)
frost::round1::commit::<J, RNG>(secret, rng)
}
}

Expand Down Expand Up @@ -307,7 +314,7 @@ pub type Signature = frost_rerandomized::frost_core::Signature<J>;
/// service attack due to publishing an invalid signature.
pub fn aggregate(
signing_package: &round2::SigningPackage,
signature_shares: &[round2::SignatureShare],
signature_shares: &HashMap<Identifier, round2::SignatureShare>,
pubkeys: &keys::PublicKeyPackage,
randomized_params: &RandomizedParams<J>,
) -> Result<Signature, Error> {
Expand Down
17 changes: 12 additions & 5 deletions src/frost/redpallas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#![allow(non_snake_case)]
#![deny(missing_docs)]

use std::collections::HashMap;

use group::GroupEncoding;
#[cfg(feature = "alloc")]
use group::{ff::Field as FFField, ff::PrimeField, Group as FFGroup};
Expand Down Expand Up @@ -117,6 +119,8 @@ impl Group for PallasGroup {
pub struct PallasBlake2b512;

impl Ciphersuite for PallasBlake2b512 {
const ID: &'static str = "FROST(Pallas, BLAKE2b-512)";

type Group = PallasGroup;

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

use super::*;

/// The identifier list to use when generating key shares.
pub type IdentifierList<'a> = frost::keys::IdentifierList<'a, P>;

/// Allows all participants' keys to be generated using a central, trusted
/// dealer.
pub fn keygen_with_dealer<RNG: RngCore + CryptoRng>(
pub fn generate_with_dealer<RNG: RngCore + CryptoRng>(
max_signers: u16,
min_signers: u16,
identifiers: IdentifierList,
mut rng: RNG,
) -> Result<(HashMap<Identifier, SecretShare>, PublicKeyPackage), Error> {
frost::keys::keygen_with_dealer(max_signers, min_signers, &mut rng)
frost::keys::generate_with_dealer(max_signers, min_signers, identifiers, &mut rng)
}

/// Secret and public key material generated by a dealer performing
Expand Down Expand Up @@ -239,14 +247,13 @@ pub mod round1 {
/// Generates the signing nonces and commitments to be used in the signing
/// operation.
pub fn commit<RNG>(
participant_identifier: frost::Identifier<P>,
secret: &SigningShare<P>,
rng: &mut RNG,
) -> (SigningNonces, SigningCommitments)
where
RNG: CryptoRng + RngCore,
{
frost::round1::commit::<P, RNG>(participant_identifier, secret, rng)
frost::round1::commit::<P, RNG>(secret, rng)
}
}

Expand Down Expand Up @@ -309,7 +316,7 @@ pub type Signature = frost_rerandomized::frost_core::Signature<P>;
/// service attack due to publishing an invalid signature.
pub fn aggregate(
signing_package: &round2::SigningPackage,
signature_shares: &[round2::SignatureShare],
signature_shares: &HashMap<Identifier, round2::SignatureShare>,
pubkeys: &keys::PublicKeyPackage,
randomized_params: &RandomizedParams<P>,
) -> Result<Signature, Error> {
Expand Down
3 changes: 2 additions & 1 deletion src/orchard/tests.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::println;

use crate::scalar_mul::{self, VartimeMultiscalarMul};
use alloc::vec::Vec;
use group::ff::Field;
Expand Down Expand Up @@ -30,7 +32,6 @@ fn orchard_binding_basepoint() {
#[allow(dead_code)]
fn gen_pallas_test_vectors() {
use group::Group;
use std::println;

let rng = thread_rng();

Expand Down
14 changes: 10 additions & 4 deletions tests/frost_redjubjub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ use reddsa::{frost::redjubjub::JubjubBlake2b512, sapling};
fn check_sign_with_dealer() {
let rng = thread_rng();

frost_rerandomized::frost_core::tests::check_sign_with_dealer::<JubjubBlake2b512, _>(rng);
frost_rerandomized::frost_core::tests::ciphersuite_generic::check_sign_with_dealer::<
JubjubBlake2b512,
_,
>(rng);
}

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

let sig = {
let bytes: [u8; 64] = group_signature.to_bytes().as_ref().try_into().unwrap();
let bytes: [u8; 64] = group_signature.serialize().as_ref().try_into().unwrap();
reddsa::Signature::<sapling::SpendAuth>::from(bytes)
};
let pk_bytes = {
let bytes: [u8; 32] = group_pubkey.to_bytes().as_ref().try_into().unwrap();
let bytes: [u8; 32] = group_pubkey.serialize().as_ref().try_into().unwrap();
reddsa::VerificationKeyBytes::<sapling::SpendAuth>::from(bytes)
};

Expand All @@ -43,7 +46,10 @@ fn check_randomized_sign_with_dealer() {
fn check_sign_with_dkg() {
let rng = thread_rng();

frost_rerandomized::frost_core::tests::check_sign_with_dkg::<JubjubBlake2b512, _>(rng);
frost_rerandomized::frost_core::tests::ciphersuite_generic::check_sign_with_dkg::<
JubjubBlake2b512,
_,
>(rng);
}

#[test]
Expand Down
14 changes: 10 additions & 4 deletions tests/frost_redpallas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ use reddsa::{frost::redpallas::PallasBlake2b512, orchard};
fn check_sign_with_dealer() {
let rng = thread_rng();

frost_rerandomized::frost_core::tests::check_sign_with_dealer::<PallasBlake2b512, _>(rng);
frost_rerandomized::frost_core::tests::ciphersuite_generic::check_sign_with_dealer::<
PallasBlake2b512,
_,
>(rng);
}

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

let sig = {
let bytes: [u8; 64] = group_signature.to_bytes().as_ref().try_into().unwrap();
let bytes: [u8; 64] = group_signature.serialize().as_ref().try_into().unwrap();
reddsa::Signature::<orchard::SpendAuth>::from(bytes)
};
let pk_bytes = {
let bytes: [u8; 32] = group_pubkey.to_bytes().as_ref().try_into().unwrap();
let bytes: [u8; 32] = group_pubkey.serialize().as_ref().try_into().unwrap();
reddsa::VerificationKeyBytes::<orchard::SpendAuth>::from(bytes)
};

Expand All @@ -43,7 +46,10 @@ fn check_randomized_sign_with_dealer() {
fn check_sign_with_dkg() {
let rng = thread_rng();

frost_rerandomized::frost_core::tests::check_sign_with_dkg::<PallasBlake2b512, _>(rng);
frost_rerandomized::frost_core::tests::ciphersuite_generic::check_sign_with_dkg::<
PallasBlake2b512,
_,
>(rng);
}

#[test]
Expand Down

0 comments on commit c5e24a3

Please sign in to comment.