use u16 for number of signers (#156)

* use Identifier instead of index

* remove pub(crate) from the Identifier index

* Refreshed Identifier newtype of Scalar with traits

* Remove commented out lines

* add test vectors with indices larger than 1 byte

* add little_endian_serialize to implement Ord for Identifier

* use u16 for number of signers

* fix variable use

Co-authored-by: Deirdre Connolly <durumcrustulum@gmail.com>
This commit is contained in:
Conrado Gouvea 2022-10-26 11:41:13 -03:00 committed by GitHub
parent 33b01a7d6f
commit eca2101cf8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 20 additions and 24 deletions

View File

@ -306,8 +306,8 @@ where
///
/// [`trusted_dealer_keygen`]: https://www.ietf.org/archive/id/draft-irtf-cfrg-frost-11.html#appendix-C
pub fn keygen_with_dealer<C: Ciphersuite, R: RngCore + CryptoRng>(
num_signers: u8,
threshold: u8,
num_signers: u16,
threshold: u16,
mut rng: R,
) -> Result<(Vec<SecretShare<C>>, PublicKeyPackage<C>), &'static str> {
let mut bytes = [0; 64];
@ -466,8 +466,8 @@ pub struct PublicKeyPackage<C: Ciphersuite> {
/// Returns an error if the parameters (num_signers, threshold) are inconsistent.
pub(crate) fn generate_secret_polynomial<C: Ciphersuite>(
secret: &SharedSecret<C>,
num_signers: u8,
threshold: u8,
num_signers: u16,
threshold: u16,
mut coefficients: Vec<Scalar<C>>,
) -> Result<(Vec<Scalar<C>>, VerifiableSecretSharingCommitment<C>), &'static str> {
if threshold < 2 {
@ -521,8 +521,8 @@ pub(crate) fn generate_secret_polynomial<C: Ciphersuite>(
/// [`secret_share_shard`]: https://www.ietf.org/archive/id/draft-irtf-cfrg-frost-11.html#appendix-C.1
pub(crate) fn generate_secret_shares<C: Ciphersuite>(
secret: &SharedSecret<C>,
numshares: u8,
threshold: u8,
numshares: u16,
threshold: u16,
coefficients: Vec<Scalar<C>>,
) -> Result<Vec<SecretShare<C>>, &'static str> {
let mut secret_shares: Vec<SecretShare<C>> = Vec::with_capacity(numshares as usize);

View File

@ -43,7 +43,7 @@ pub struct Round1SecretPackage<C: Ciphersuite> {
/// The public commitment for the participant (C_i)
pub commitment: VerifiableSecretSharingCommitment<C>,
/// The total number of signers.
pub num_signers: u8,
pub num_signers: u16,
}
/// A package that must be sent by each participant to some other participants
@ -77,7 +77,7 @@ pub struct Round2SecretPackage<C: Ciphersuite> {
/// The participant's own secret share (f_i(i)).
pub secret_share: Scalar<C>,
/// The total number of signers.
pub num_signers: u8,
pub num_signers: u16,
}
/// Performs the first part of the distributed key generation protocol
@ -88,8 +88,8 @@ pub struct Round2SecretPackage<C: Ciphersuite> {
/// must be sent to other participants.
pub fn keygen_part1<C: Ciphersuite, R: RngCore + CryptoRng>(
identifier: Identifier<C>,
num_signers: u8,
threshold: u8,
num_signers: u16,
threshold: u16,
mut rng: R,
) -> Result<(Round1SecretPackage<C>, Round1Package<C>), &'static str> {
let secret: SharedSecret<C> = SharedSecret::random(&mut rng);

View File

@ -58,7 +58,7 @@ pub fn check_sign_with_dealer<C: Ciphersuite, R: RngCore + CryptoRng>(mut rng: R
}
fn check_sign<C: Ciphersuite + PartialEq, R: RngCore + CryptoRng>(
threshold: u8,
threshold: u16,
key_packages: HashMap<frost::Identifier<C>, frost::keys::KeyPackage<C>>,
mut rng: R,
pubkeys: frost::keys::PublicKeyPackage<C>,
@ -173,13 +173,9 @@ where
// In practice, each participant will perform this on their own environments.
for participant_index in 1..=numsigners {
let participant_identifier = participant_index.try_into().expect("should be nonzero");
let (secret_package, round1_package) = frost::keys::dkg::keygen_part1(
participant_identifier,
numsigners as u8,
threshold,
&mut rng,
)
.unwrap();
let (secret_package, round1_package) =
frost::keys::dkg::keygen_part1(participant_identifier, numsigners, threshold, &mut rng)
.unwrap();
// Store the participant's secret package for later use.
// In practice each participant will store it in their own environment.

View File

@ -210,8 +210,8 @@ pub fn check_sign_with_test_vectors<C: Ciphersuite>(json_vectors: &Value) {
let threshold = share_polynomial_coefficients.len() + 1;
let secret_shares = generate_secret_shares(
&secret_key,
numshares as u8,
threshold as u8,
numshares as u16,
threshold as u16,
share_polynomial_coefficients,
)
.unwrap();

View File

@ -250,8 +250,8 @@ pub mod keys {
/// Allows all participants' keys to be generated using a central, trusted
/// dealer.
pub fn keygen_with_dealer<RNG: RngCore + CryptoRng>(
num_signers: u8,
threshold: u8,
num_signers: u16,
threshold: u16,
mut rng: RNG,
) -> Result<(Vec<SecretShare>, PublicKeyPackage), &'static str> {
frost::keys::keygen_with_dealer(num_signers, threshold, &mut rng)

View File

@ -228,8 +228,8 @@ pub mod keys {
/// Allows all participants' keys to be generated using a central, trusted
/// dealer.
pub fn keygen_with_dealer<RNG: RngCore + CryptoRng>(
num_signers: u8,
threshold: u8,
num_signers: u16,
threshold: u16,
mut rng: RNG,
) -> Result<(Vec<SecretShare>, PublicKeyPackage), &'static str> {
frost::keys::keygen_with_dealer(num_signers, threshold, &mut rng)