move dkg module to its own file; update and refactor gendoc (#196)
* move dkg module to its own file; update and refactor gendoc * pin curve25519-dalek for now due to breaking changes
This commit is contained in:
parent
2967cae5e4
commit
665ab512e2
|
@ -31,7 +31,7 @@ proptest-derive = { version = "0.3", optional = true }
|
|||
serde_json = { version = "1.0", optional = true }
|
||||
|
||||
[dev-dependencies]
|
||||
curve25519-dalek = { version = "4.0.0-pre.1", features = ["serde"] }
|
||||
curve25519-dalek = { version = "=4.0.0-pre.1", features = ["serde"] }
|
||||
lazy_static = "1.4"
|
||||
proptest = "1.0"
|
||||
rand = "0.8"
|
||||
|
|
|
@ -22,7 +22,7 @@ description = "A Schnorr signature scheme over the prime-order Ristretto group t
|
|||
features = ["nightly"]
|
||||
|
||||
[dependencies]
|
||||
curve25519-dalek = { version = "4.0.0-pre.1", features = ["serde"] }
|
||||
curve25519-dalek = { version = "=4.0.0-pre.1", features = ["serde"] }
|
||||
frost-core = { path = "../frost-core", features = ["test-impl"] }
|
||||
frost-ristretto255 = { path = "../frost-ristretto255" }
|
||||
rand_core = "0.6"
|
||||
|
|
|
@ -0,0 +1,77 @@
|
|||
#![doc = include_str!("../../dkg.md")]
|
||||
use super::*;
|
||||
|
||||
/// The secret package that must be kept in memory by the participant
|
||||
/// between the first and second parts of the DKG protocol (round 1).
|
||||
///
|
||||
/// # Security
|
||||
///
|
||||
/// This package MUST NOT be sent to other participants!
|
||||
pub type Round1SecretPackage = frost::keys::dkg::Round1SecretPackage<E>;
|
||||
|
||||
/// The package that must be broadcast by each participant to all other participants
|
||||
/// between the first and second parts of the DKG protocol (round 1).
|
||||
pub type Round1Package = frost::keys::dkg::Round1Package<E>;
|
||||
|
||||
/// The secret package that must be kept in memory by the participant
|
||||
/// between the second and third parts of the DKG protocol (round 2).
|
||||
///
|
||||
/// # Security
|
||||
///
|
||||
/// This package MUST NOT be sent to other participants!
|
||||
pub type Round2SecretPackage = frost::keys::dkg::Round2SecretPackage<E>;
|
||||
|
||||
/// A package that must be sent by each participant to some other participants
|
||||
/// in Round 2 of the DKG protocol. Note that there is one specific package
|
||||
/// for each specific recipient, in contrast to Round 1.
|
||||
///
|
||||
/// # Security
|
||||
///
|
||||
/// The package must be sent on an *confidential* and *authenticated* channel.
|
||||
pub type Round2Package = frost::keys::dkg::Round2Package<E>;
|
||||
|
||||
/// Performs the first part of the distributed key generation protocol
|
||||
/// for the given participant.
|
||||
///
|
||||
/// It returns the [`Round1SecretPackage`] that must be kept in memory
|
||||
/// by the participant for the other steps, and the [`Round1Package`] that
|
||||
/// must be sent to other participants.
|
||||
pub fn keygen_part1<R: RngCore + CryptoRng>(
|
||||
identifier: Identifier,
|
||||
max_signers: u16,
|
||||
min_signers: u16,
|
||||
mut rng: R,
|
||||
) -> Result<(Round1SecretPackage, Round1Package), Error> {
|
||||
frost::keys::dkg::keygen_part1(identifier, max_signers, min_signers, &mut rng)
|
||||
}
|
||||
|
||||
/// Performs the second part of the distributed key generation protocol
|
||||
/// for the participant holding the given [`Round1SecretPackage`],
|
||||
/// given the received [`Round1Package`]s received from the other participants.
|
||||
///
|
||||
/// It returns the [`Round2SecretPackage`] that must be kept in memory
|
||||
/// by the participant for the final step, and the [`Round2Package`]s that
|
||||
/// must be sent to other participants.
|
||||
pub fn keygen_part2(
|
||||
secret_package: Round1SecretPackage,
|
||||
round1_packages: &[Round1Package],
|
||||
) -> Result<(Round2SecretPackage, Vec<Round2Package>), Error> {
|
||||
frost::keys::dkg::keygen_part2(secret_package, round1_packages)
|
||||
}
|
||||
|
||||
/// Performs the third and final part of the distributed key generation protocol
|
||||
/// for the participant holding the given [`Round2SecretPackage`],
|
||||
/// given the received [`Round1Package`]s and [`Round2Package`]s received from
|
||||
/// the other participants.
|
||||
///
|
||||
/// It returns the [`KeyPackage`] that has the long-lived key share for the
|
||||
/// participant, and the [`PublicKeyPackage`]s that has public information
|
||||
/// about all participants; both of which are required to compute FROST
|
||||
/// signatures.
|
||||
pub fn keygen_part3(
|
||||
round2_secret_package: &Round2SecretPackage,
|
||||
round1_packages: &[Round1Package],
|
||||
round2_packages: &[Round2Package],
|
||||
) -> Result<(KeyPackage, PublicKeyPackage), Error> {
|
||||
frost::keys::dkg::keygen_part3(round2_secret_package, round1_packages, round2_packages)
|
||||
}
|
|
@ -179,85 +179,7 @@ pub mod keys {
|
|||
/// Used for verification purposes before publishing a signature.
|
||||
pub type PublicKeyPackage = frost::keys::PublicKeyPackage<E>;
|
||||
|
||||
pub mod dkg {
|
||||
#![doc = include_str!("../dkg.md")]
|
||||
use super::*;
|
||||
|
||||
/// The secret package that must be kept in memory by the participant
|
||||
/// between the first and second parts of the DKG protocol (round 1).
|
||||
///
|
||||
/// # Security
|
||||
///
|
||||
/// This package MUST NOT be sent to other participants!
|
||||
pub type Round1SecretPackage = frost::keys::dkg::Round1SecretPackage<E>;
|
||||
|
||||
/// The package that must be broadcast by each participant to all other participants
|
||||
/// between the first and second parts of the DKG protocol (round 1).
|
||||
pub type Round1Package = frost::keys::dkg::Round1Package<E>;
|
||||
|
||||
/// The secret package that must be kept in memory by the participant
|
||||
/// between the second and third parts of the DKG protocol (round 2).
|
||||
///
|
||||
/// # Security
|
||||
///
|
||||
/// This package MUST NOT be sent to other participants!
|
||||
pub type Round2SecretPackage = frost::keys::dkg::Round2SecretPackage<E>;
|
||||
|
||||
/// A package that must be sent by each participant to some other participants
|
||||
/// in Round 2 of the DKG protocol. Note that there is one specific package
|
||||
/// for each specific recipient, in contrast to Round 1.
|
||||
///
|
||||
/// # Security
|
||||
///
|
||||
/// The package must be sent on an *confidential* and *authenticated* channel.
|
||||
pub type Round2Package = frost::keys::dkg::Round2Package<E>;
|
||||
|
||||
/// Performs the first part of the distributed key generation protocol
|
||||
/// for the given participant.
|
||||
///
|
||||
/// It returns the [`Round1SecretPackage`] that must be kept in memory
|
||||
/// by the participant for the other steps, and the [`Round1Package`] that
|
||||
/// must be sent to other participants.
|
||||
pub fn keygen_part1<R: RngCore + CryptoRng>(
|
||||
identifier: Identifier,
|
||||
max_signers: u16,
|
||||
min_signers: u16,
|
||||
mut rng: R,
|
||||
) -> Result<(Round1SecretPackage, Round1Package), Error> {
|
||||
frost::keys::dkg::keygen_part1(identifier, max_signers, min_signers, &mut rng)
|
||||
}
|
||||
|
||||
/// Performs the second part of the distributed key generation protocol
|
||||
/// for the participant holding the given [`Round1SecretPackage`],
|
||||
/// given the received [`Round1Package`]s received from the other participants.
|
||||
///
|
||||
/// It returns the [`Round2SecretPackage`] that must be kept in memory
|
||||
/// by the participant for the final step, and the [`Round2Package`]s that
|
||||
/// must be sent to other participants.
|
||||
pub fn keygen_part2(
|
||||
secret_package: Round1SecretPackage,
|
||||
round1_packages: &[Round1Package],
|
||||
) -> Result<(Round2SecretPackage, Vec<Round2Package>), Error> {
|
||||
frost::keys::dkg::keygen_part2(secret_package, round1_packages)
|
||||
}
|
||||
|
||||
/// Performs the third and final part of the distributed key generation protocol
|
||||
/// for the participant holding the given [`Round2SecretPackage`],
|
||||
/// given the received [`Round1Package`]s and [`Round2Package`]s received from
|
||||
/// the other participants.
|
||||
///
|
||||
/// It returns the [`KeyPackage`] that has the long-lived key share for the
|
||||
/// participant, and the [`PublicKeyPackage`]s that has public information
|
||||
/// about all participants; both of which are required to compute FROST
|
||||
/// signatures.
|
||||
pub fn keygen_part3(
|
||||
round2_secret_package: &Round2SecretPackage,
|
||||
round1_packages: &[Round1Package],
|
||||
round2_packages: &[Round2Package],
|
||||
) -> Result<(KeyPackage, PublicKeyPackage), Error> {
|
||||
frost::keys::dkg::keygen_part3(round2_secret_package, round1_packages, round2_packages)
|
||||
}
|
||||
}
|
||||
pub mod dkg;
|
||||
}
|
||||
|
||||
/// FROST(Ed25519, SHA-512) Round 1 functionality and types.
|
||||
|
|
|
@ -0,0 +1,77 @@
|
|||
#![doc = include_str!("../../dkg.md")]
|
||||
use super::*;
|
||||
|
||||
/// The secret package that must be kept in memory by the participant
|
||||
/// between the first and second parts of the DKG protocol (round 1).
|
||||
///
|
||||
/// # Security
|
||||
///
|
||||
/// This package MUST NOT be sent to other participants!
|
||||
pub type Round1SecretPackage = frost::keys::dkg::Round1SecretPackage<E>;
|
||||
|
||||
/// The package that must be broadcast by each participant to all other participants
|
||||
/// between the first and second parts of the DKG protocol (round 1).
|
||||
pub type Round1Package = frost::keys::dkg::Round1Package<E>;
|
||||
|
||||
/// The secret package that must be kept in memory by the participant
|
||||
/// between the second and third parts of the DKG protocol (round 2).
|
||||
///
|
||||
/// # Security
|
||||
///
|
||||
/// This package MUST NOT be sent to other participants!
|
||||
pub type Round2SecretPackage = frost::keys::dkg::Round2SecretPackage<E>;
|
||||
|
||||
/// A package that must be sent by each participant to some other participants
|
||||
/// in Round 2 of the DKG protocol. Note that there is one specific package
|
||||
/// for each specific recipient, in contrast to Round 1.
|
||||
///
|
||||
/// # Security
|
||||
///
|
||||
/// The package must be sent on an *confidential* and *authenticated* channel.
|
||||
pub type Round2Package = frost::keys::dkg::Round2Package<E>;
|
||||
|
||||
/// Performs the first part of the distributed key generation protocol
|
||||
/// for the given participant.
|
||||
///
|
||||
/// It returns the [`Round1SecretPackage`] that must be kept in memory
|
||||
/// by the participant for the other steps, and the [`Round1Package`] that
|
||||
/// must be sent to other participants.
|
||||
pub fn keygen_part1<R: RngCore + CryptoRng>(
|
||||
identifier: Identifier,
|
||||
max_signers: u16,
|
||||
min_signers: u16,
|
||||
mut rng: R,
|
||||
) -> Result<(Round1SecretPackage, Round1Package), Error> {
|
||||
frost::keys::dkg::keygen_part1(identifier, max_signers, min_signers, &mut rng)
|
||||
}
|
||||
|
||||
/// Performs the second part of the distributed key generation protocol
|
||||
/// for the participant holding the given [`Round1SecretPackage`],
|
||||
/// given the received [`Round1Package`]s received from the other participants.
|
||||
///
|
||||
/// It returns the [`Round2SecretPackage`] that must be kept in memory
|
||||
/// by the participant for the final step, and the [`Round2Package`]s that
|
||||
/// must be sent to other participants.
|
||||
pub fn keygen_part2(
|
||||
secret_package: Round1SecretPackage,
|
||||
round1_packages: &[Round1Package],
|
||||
) -> Result<(Round2SecretPackage, Vec<Round2Package>), Error> {
|
||||
frost::keys::dkg::keygen_part2(secret_package, round1_packages)
|
||||
}
|
||||
|
||||
/// Performs the third and final part of the distributed key generation protocol
|
||||
/// for the participant holding the given [`Round2SecretPackage`],
|
||||
/// given the received [`Round1Package`]s and [`Round2Package`]s received from
|
||||
/// the other participants.
|
||||
///
|
||||
/// It returns the [`KeyPackage`] that has the long-lived key share for the
|
||||
/// participant, and the [`PublicKeyPackage`]s that has public information
|
||||
/// about all participants; both of which are required to compute FROST
|
||||
/// signatures.
|
||||
pub fn keygen_part3(
|
||||
round2_secret_package: &Round2SecretPackage,
|
||||
round1_packages: &[Round1Package],
|
||||
round2_packages: &[Round2Package],
|
||||
) -> Result<(KeyPackage, PublicKeyPackage), Error> {
|
||||
frost::keys::dkg::keygen_part3(round2_secret_package, round1_packages, round2_packages)
|
||||
}
|
|
@ -224,85 +224,7 @@ pub mod keys {
|
|||
/// Used for verification purposes before publishing a signature.
|
||||
pub type PublicKeyPackage = frost::keys::PublicKeyPackage<E>;
|
||||
|
||||
pub mod dkg {
|
||||
#![doc = include_str!("../dkg.md")]
|
||||
use super::*;
|
||||
|
||||
/// The secret package that must be kept in memory by the participant
|
||||
/// between the first and second parts of the DKG protocol (round 1).
|
||||
///
|
||||
/// # Security
|
||||
///
|
||||
/// This package MUST NOT be sent to other participants!
|
||||
pub type Round1SecretPackage = frost::keys::dkg::Round1SecretPackage<E>;
|
||||
|
||||
/// The package that must be broadcast by each participant to all other participants
|
||||
/// between the first and second parts of the DKG protocol (round 1).
|
||||
pub type Round1Package = frost::keys::dkg::Round1Package<E>;
|
||||
|
||||
/// The secret package that must be kept in memory by the participant
|
||||
/// between the second and third parts of the DKG protocol (round 2).
|
||||
///
|
||||
/// # Security
|
||||
///
|
||||
/// This package MUST NOT be sent to other participants!
|
||||
pub type Round2SecretPackage = frost::keys::dkg::Round2SecretPackage<E>;
|
||||
|
||||
/// A package that must be sent by each participant to some other participants
|
||||
/// in Round 2 of the DKG protocol. Note that there is one specific package
|
||||
/// for each specific recipient, in contrast to Round 1.
|
||||
///
|
||||
/// # Security
|
||||
///
|
||||
/// The package must be sent on an *confidential* and *authenticated* channel.
|
||||
pub type Round2Package = frost::keys::dkg::Round2Package<E>;
|
||||
|
||||
/// Performs the first part of the distributed key generation protocol
|
||||
/// for the given participant.
|
||||
///
|
||||
/// It returns the [`Round1SecretPackage`] that must be kept in memory
|
||||
/// by the participant for the other steps, and the [`Round1Package`] that
|
||||
/// must be sent to other participants.
|
||||
pub fn keygen_part1<R: RngCore + CryptoRng>(
|
||||
identifier: Identifier,
|
||||
max_signers: u16,
|
||||
min_signers: u16,
|
||||
mut rng: R,
|
||||
) -> Result<(Round1SecretPackage, Round1Package), Error> {
|
||||
frost::keys::dkg::keygen_part1(identifier, max_signers, min_signers, &mut rng)
|
||||
}
|
||||
|
||||
/// Performs the second part of the distributed key generation protocol
|
||||
/// for the participant holding the given [`Round1SecretPackage`],
|
||||
/// given the received [`Round1Package`]s received from the other participants.
|
||||
///
|
||||
/// It returns the [`Round2SecretPackage`] that must be kept in memory
|
||||
/// by the participant for the final step, and the [`Round2Package`]s that
|
||||
/// must be sent to other participants.
|
||||
pub fn keygen_part2(
|
||||
secret_package: Round1SecretPackage,
|
||||
round1_packages: &[Round1Package],
|
||||
) -> Result<(Round2SecretPackage, Vec<Round2Package>), Error> {
|
||||
frost::keys::dkg::keygen_part2(secret_package, round1_packages)
|
||||
}
|
||||
|
||||
/// Performs the third and final part of the distributed key generation protocol
|
||||
/// for the participant holding the given [`Round2SecretPackage`],
|
||||
/// given the received [`Round1Package`]s and [`Round2Package`]s received from
|
||||
/// the other participants.
|
||||
///
|
||||
/// It returns the [`KeyPackage`] that has the long-lived key share for the
|
||||
/// participant, and the [`PublicKeyPackage`]s that has public information
|
||||
/// about all participants; both of which are required to compute FROST
|
||||
/// signatures.
|
||||
pub fn keygen_part3(
|
||||
round2_secret_package: &Round2SecretPackage,
|
||||
round1_packages: &[Round1Package],
|
||||
round2_packages: &[Round2Package],
|
||||
) -> Result<(KeyPackage, PublicKeyPackage), Error> {
|
||||
frost::keys::dkg::keygen_part3(round2_secret_package, round1_packages, round2_packages)
|
||||
}
|
||||
}
|
||||
pub mod dkg;
|
||||
}
|
||||
|
||||
/// FROST(Ed448, SHAKE256) Round 1 functionality and types.
|
||||
|
|
|
@ -0,0 +1,77 @@
|
|||
#![doc = include_str!("../../dkg.md")]
|
||||
use super::*;
|
||||
|
||||
/// The secret package that must be kept in memory by the participant
|
||||
/// between the first and second parts of the DKG protocol (round 1).
|
||||
///
|
||||
/// # Security
|
||||
///
|
||||
/// This package MUST NOT be sent to other participants!
|
||||
pub type Round1SecretPackage = frost::keys::dkg::Round1SecretPackage<P>;
|
||||
|
||||
/// The package that must be broadcast by each participant to all other participants
|
||||
/// between the first and second parts of the DKG protocol (round 1).
|
||||
pub type Round1Package = frost::keys::dkg::Round1Package<P>;
|
||||
|
||||
/// The secret package that must be kept in memory by the participant
|
||||
/// between the second and third parts of the DKG protocol (round 2).
|
||||
///
|
||||
/// # Security
|
||||
///
|
||||
/// This package MUST NOT be sent to other participants!
|
||||
pub type Round2SecretPackage = frost::keys::dkg::Round2SecretPackage<P>;
|
||||
|
||||
/// A package that must be sent by each participant to some other participants
|
||||
/// in Round 2 of the DKG protocol. Note that there is one specific package
|
||||
/// for each specific recipient, in contrast to Round 1.
|
||||
///
|
||||
/// # Security
|
||||
///
|
||||
/// The package must be sent on an *confidential* and *authenticated* channel.
|
||||
pub type Round2Package = frost::keys::dkg::Round2Package<P>;
|
||||
|
||||
/// Performs the first part of the distributed key generation protocol
|
||||
/// for the given participant.
|
||||
///
|
||||
/// It returns the [`Round1SecretPackage`] that must be kept in memory
|
||||
/// by the participant for the other steps, and the [`Round1Package`] that
|
||||
/// must be sent to other participants.
|
||||
pub fn keygen_part1<R: RngCore + CryptoRng>(
|
||||
identifier: Identifier,
|
||||
max_signers: u16,
|
||||
min_signers: u16,
|
||||
mut rng: R,
|
||||
) -> Result<(Round1SecretPackage, Round1Package), Error> {
|
||||
frost::keys::dkg::keygen_part1(identifier, max_signers, min_signers, &mut rng)
|
||||
}
|
||||
|
||||
/// Performs the second part of the distributed key generation protocol
|
||||
/// for the participant holding the given [`Round1SecretPackage`],
|
||||
/// given the received [`Round1Package`]s received from the other participants.
|
||||
///
|
||||
/// It returns the [`Round2SecretPackage`] that must be kept in memory
|
||||
/// by the participant for the final step, and the [`Round2Package`]s that
|
||||
/// must be sent to other participants.
|
||||
pub fn keygen_part2(
|
||||
secret_package: Round1SecretPackage,
|
||||
round1_packages: &[Round1Package],
|
||||
) -> Result<(Round2SecretPackage, Vec<Round2Package>), Error> {
|
||||
frost::keys::dkg::keygen_part2(secret_package, round1_packages)
|
||||
}
|
||||
|
||||
/// Performs the third and final part of the distributed key generation protocol
|
||||
/// for the participant holding the given [`Round2SecretPackage`],
|
||||
/// given the received [`Round1Package`]s and [`Round2Package`]s received from
|
||||
/// the other participants.
|
||||
///
|
||||
/// It returns the [`KeyPackage`] that has the long-lived key share for the
|
||||
/// participant, and the [`PublicKeyPackage`]s that has public information
|
||||
/// about all participants; both of which are required to compute FROST
|
||||
/// signatures.
|
||||
pub fn keygen_part3(
|
||||
round2_secret_package: &Round2SecretPackage,
|
||||
round1_packages: &[Round1Package],
|
||||
round2_packages: &[Round2Package],
|
||||
) -> Result<(KeyPackage, PublicKeyPackage), Error> {
|
||||
frost::keys::dkg::keygen_part3(round2_secret_package, round1_packages, round2_packages)
|
||||
}
|
|
@ -260,85 +260,7 @@ pub mod keys {
|
|||
/// Used for verification purposes before publishing a signature.
|
||||
pub type PublicKeyPackage = frost::keys::PublicKeyPackage<P>;
|
||||
|
||||
pub mod dkg {
|
||||
#![doc = include_str!("../dkg.md")]
|
||||
use super::*;
|
||||
|
||||
/// The secret package that must be kept in memory by the participant
|
||||
/// between the first and second parts of the DKG protocol (round 1).
|
||||
///
|
||||
/// # Security
|
||||
///
|
||||
/// This package MUST NOT be sent to other participants!
|
||||
pub type Round1SecretPackage = frost::keys::dkg::Round1SecretPackage<P>;
|
||||
|
||||
/// The package that must be broadcast by each participant to all other participants
|
||||
/// between the first and second parts of the DKG protocol (round 1).
|
||||
pub type Round1Package = frost::keys::dkg::Round1Package<P>;
|
||||
|
||||
/// The secret package that must be kept in memory by the participant
|
||||
/// between the second and third parts of the DKG protocol (round 2).
|
||||
///
|
||||
/// # Security
|
||||
///
|
||||
/// This package MUST NOT be sent to other participants!
|
||||
pub type Round2SecretPackage = frost::keys::dkg::Round2SecretPackage<P>;
|
||||
|
||||
/// A package that must be sent by each participant to some other participants
|
||||
/// in Round 2 of the DKG protocol. Note that there is one specific package
|
||||
/// for each specific recipient, in contrast to Round 1.
|
||||
///
|
||||
/// # Security
|
||||
///
|
||||
/// The package must be sent on an *confidential* and *authenticated* channel.
|
||||
pub type Round2Package = frost::keys::dkg::Round2Package<P>;
|
||||
|
||||
/// Performs the first part of the distributed key generation protocol
|
||||
/// for the given participant.
|
||||
///
|
||||
/// It returns the [`Round1SecretPackage`] that must be kept in memory
|
||||
/// by the participant for the other steps, and the [`Round1Package`] that
|
||||
/// must be sent to other participants.
|
||||
pub fn keygen_part1<R: RngCore + CryptoRng>(
|
||||
identifier: Identifier,
|
||||
max_signers: u16,
|
||||
min_signers: u16,
|
||||
mut rng: R,
|
||||
) -> Result<(Round1SecretPackage, Round1Package), Error> {
|
||||
frost::keys::dkg::keygen_part1(identifier, max_signers, min_signers, &mut rng)
|
||||
}
|
||||
|
||||
/// Performs the second part of the distributed key generation protocol
|
||||
/// for the participant holding the given [`Round1SecretPackage`],
|
||||
/// given the received [`Round1Package`]s received from the other participants.
|
||||
///
|
||||
/// It returns the [`Round2SecretPackage`] that must be kept in memory
|
||||
/// by the participant for the final step, and the [`Round2Package`]s that
|
||||
/// must be sent to other participants.
|
||||
pub fn keygen_part2(
|
||||
secret_package: Round1SecretPackage,
|
||||
round1_packages: &[Round1Package],
|
||||
) -> Result<(Round2SecretPackage, Vec<Round2Package>), Error> {
|
||||
frost::keys::dkg::keygen_part2(secret_package, round1_packages)
|
||||
}
|
||||
|
||||
/// Performs the third and final part of the distributed key generation protocol
|
||||
/// for the participant holding the given [`Round2SecretPackage`],
|
||||
/// given the received [`Round1Package`]s and [`Round2Package`]s received from
|
||||
/// the other participants.
|
||||
///
|
||||
/// It returns the [`KeyPackage`] that has the long-lived key share for the
|
||||
/// participant, and the [`PublicKeyPackage`]s that has public information
|
||||
/// about all participants; both of which are required to compute FROST
|
||||
/// signatures.
|
||||
pub fn keygen_part3(
|
||||
round2_secret_package: &Round2SecretPackage,
|
||||
round1_packages: &[Round1Package],
|
||||
round2_packages: &[Round2Package],
|
||||
) -> Result<(KeyPackage, PublicKeyPackage), Error> {
|
||||
frost::keys::dkg::keygen_part3(round2_secret_package, round1_packages, round2_packages)
|
||||
}
|
||||
}
|
||||
pub mod dkg;
|
||||
}
|
||||
|
||||
/// FROST(P-256, SHA-256) Round 1 functionality and types.
|
||||
|
|
|
@ -18,7 +18,7 @@ description = "A Schnorr signature scheme over the prime-order Ristretto group t
|
|||
features = ["nightly"]
|
||||
|
||||
[dependencies]
|
||||
curve25519-dalek = { version = "4.0.0-pre.1", features = ["serde"] }
|
||||
curve25519-dalek = { version = "=4.0.0-pre.1", features = ["serde"] }
|
||||
frost-core = { path = "../frost-core", features = ["test-impl"] }
|
||||
rand_core = "0.6"
|
||||
sha2 = "0.10.2"
|
||||
|
|
|
@ -0,0 +1,77 @@
|
|||
#![doc = include_str!("../../dkg.md")]
|
||||
use super::*;
|
||||
|
||||
/// The secret package that must be kept in memory by the participant
|
||||
/// between the first and second parts of the DKG protocol (round 1).
|
||||
///
|
||||
/// # Security
|
||||
///
|
||||
/// This package MUST NOT be sent to other participants!
|
||||
pub type Round1SecretPackage = frost::keys::dkg::Round1SecretPackage<R>;
|
||||
|
||||
/// The package that must be broadcast by each participant to all other participants
|
||||
/// between the first and second parts of the DKG protocol (round 1).
|
||||
pub type Round1Package = frost::keys::dkg::Round1Package<R>;
|
||||
|
||||
/// The secret package that must be kept in memory by the participant
|
||||
/// between the second and third parts of the DKG protocol (round 2).
|
||||
///
|
||||
/// # Security
|
||||
///
|
||||
/// This package MUST NOT be sent to other participants!
|
||||
pub type Round2SecretPackage = frost::keys::dkg::Round2SecretPackage<R>;
|
||||
|
||||
/// A package that must be sent by each participant to some other participants
|
||||
/// in Round 2 of the DKG protocol. Note that there is one specific package
|
||||
/// for each specific recipient, in contrast to Round 1.
|
||||
///
|
||||
/// # Security
|
||||
///
|
||||
/// The package must be sent on an *confidential* and *authenticated* channel.
|
||||
pub type Round2Package = frost::keys::dkg::Round2Package<R>;
|
||||
|
||||
/// Performs the first part of the distributed key generation protocol
|
||||
/// for the given participant.
|
||||
///
|
||||
/// It returns the [`Round1SecretPackage`] that must be kept in memory
|
||||
/// by the participant for the other steps, and the [`Round1Package`] that
|
||||
/// must be sent to other participants.
|
||||
pub fn keygen_part1<R: RngCore + CryptoRng>(
|
||||
identifier: Identifier,
|
||||
max_signers: u16,
|
||||
min_signers: u16,
|
||||
mut rng: R,
|
||||
) -> Result<(Round1SecretPackage, Round1Package), Error> {
|
||||
frost::keys::dkg::keygen_part1(identifier, max_signers, min_signers, &mut rng)
|
||||
}
|
||||
|
||||
/// Performs the second part of the distributed key generation protocol
|
||||
/// for the participant holding the given [`Round1SecretPackage`],
|
||||
/// given the received [`Round1Package`]s received from the other participants.
|
||||
///
|
||||
/// It returns the [`Round2SecretPackage`] that must be kept in memory
|
||||
/// by the participant for the final step, and the [`Round2Package`]s that
|
||||
/// must be sent to other participants.
|
||||
pub fn keygen_part2(
|
||||
secret_package: Round1SecretPackage,
|
||||
round1_packages: &[Round1Package],
|
||||
) -> Result<(Round2SecretPackage, Vec<Round2Package>), Error> {
|
||||
frost::keys::dkg::keygen_part2(secret_package, round1_packages)
|
||||
}
|
||||
|
||||
/// Performs the third and final part of the distributed key generation protocol
|
||||
/// for the participant holding the given [`Round2SecretPackage`],
|
||||
/// given the received [`Round1Package`]s and [`Round2Package`]s received from
|
||||
/// the other participants.
|
||||
///
|
||||
/// It returns the [`KeyPackage`] that has the long-lived key share for the
|
||||
/// participant, and the [`PublicKeyPackage`]s that has public information
|
||||
/// about all participants; both of which are required to compute FROST
|
||||
/// signatures.
|
||||
pub fn keygen_part3(
|
||||
round2_secret_package: &Round2SecretPackage,
|
||||
round1_packages: &[Round1Package],
|
||||
round2_packages: &[Round2Package],
|
||||
) -> Result<(KeyPackage, PublicKeyPackage), Error> {
|
||||
frost::keys::dkg::keygen_part3(round2_secret_package, round1_packages, round2_packages)
|
||||
}
|
|
@ -221,85 +221,7 @@ pub mod keys {
|
|||
/// Used for verification purposes before publishing a signature.
|
||||
pub type PublicKeyPackage = frost::keys::PublicKeyPackage<R>;
|
||||
|
||||
pub mod dkg {
|
||||
#![doc = include_str!("../dkg.md")]
|
||||
use super::*;
|
||||
|
||||
/// The secret package that must be kept in memory by the participant
|
||||
/// between the first and second parts of the DKG protocol (round 1).
|
||||
///
|
||||
/// # Security
|
||||
///
|
||||
/// This package MUST NOT be sent to other participants!
|
||||
pub type Round1SecretPackage = frost::keys::dkg::Round1SecretPackage<R>;
|
||||
|
||||
/// The package that must be broadcast by each participant to all other participants
|
||||
/// between the first and second parts of the DKG protocol (round 1).
|
||||
pub type Round1Package = frost::keys::dkg::Round1Package<R>;
|
||||
|
||||
/// The secret package that must be kept in memory by the participant
|
||||
/// between the second and third parts of the DKG protocol (round 2).
|
||||
///
|
||||
/// # Security
|
||||
///
|
||||
/// This package MUST NOT be sent to other participants!
|
||||
pub type Round2SecretPackage = frost::keys::dkg::Round2SecretPackage<R>;
|
||||
|
||||
/// A package that must be sent by each participant to some other participants
|
||||
/// in Round 2 of the DKG protocol. Note that there is one specific package
|
||||
/// for each specific recipient, in contrast to Round 1.
|
||||
///
|
||||
/// # Security
|
||||
///
|
||||
/// The package must be sent on an *confidential* and *authenticated* channel.
|
||||
pub type Round2Package = frost::keys::dkg::Round2Package<R>;
|
||||
|
||||
/// Performs the first part of the distributed key generation protocol
|
||||
/// for the given participant.
|
||||
///
|
||||
/// It returns the [`Round1SecretPackage`] that must be kept in memory
|
||||
/// by the participant for the other steps, and the [`Round1Package`] that
|
||||
/// must be sent to other participants.
|
||||
pub fn keygen_part1<R: RngCore + CryptoRng>(
|
||||
identifier: Identifier,
|
||||
max_signers: u16,
|
||||
min_signers: u16,
|
||||
mut rng: R,
|
||||
) -> Result<(Round1SecretPackage, Round1Package), Error> {
|
||||
frost::keys::dkg::keygen_part1(identifier, max_signers, min_signers, &mut rng)
|
||||
}
|
||||
|
||||
/// Performs the second part of the distributed key generation protocol
|
||||
/// for the participant holding the given [`Round1SecretPackage`],
|
||||
/// given the received [`Round1Package`]s received from the other participants.
|
||||
///
|
||||
/// It returns the [`Round2SecretPackage`] that must be kept in memory
|
||||
/// by the participant for the final step, and the [`Round2Package`]s that
|
||||
/// must be sent to other participants.
|
||||
pub fn keygen_part2(
|
||||
secret_package: Round1SecretPackage,
|
||||
round1_packages: &[Round1Package],
|
||||
) -> Result<(Round2SecretPackage, Vec<Round2Package>), Error> {
|
||||
frost::keys::dkg::keygen_part2(secret_package, round1_packages)
|
||||
}
|
||||
|
||||
/// Performs the third and final part of the distributed key generation protocol
|
||||
/// for the participant holding the given [`Round2SecretPackage`],
|
||||
/// given the received [`Round1Package`]s and [`Round2Package`]s received from
|
||||
/// the other participants.
|
||||
///
|
||||
/// It returns the [`KeyPackage`] that has the long-lived key share for the
|
||||
/// participant, and the [`PublicKeyPackage`]s that has public information
|
||||
/// about all participants; both of which are required to compute FROST
|
||||
/// signatures.
|
||||
pub fn keygen_part3(
|
||||
round2_secret_package: &Round2SecretPackage,
|
||||
round1_packages: &[Round1Package],
|
||||
round2_packages: &[Round2Package],
|
||||
) -> Result<(KeyPackage, PublicKeyPackage), Error> {
|
||||
frost::keys::dkg::keygen_part3(round2_secret_package, round1_packages, round2_packages)
|
||||
}
|
||||
}
|
||||
pub mod dkg;
|
||||
}
|
||||
|
||||
/// FROST(ristretto255, SHA-512) Round 1 functionality and types.
|
||||
|
|
|
@ -0,0 +1,77 @@
|
|||
#![doc = include_str!("../../dkg.md")]
|
||||
use super::*;
|
||||
|
||||
/// The secret package that must be kept in memory by the participant
|
||||
/// between the first and second parts of the DKG protocol (round 1).
|
||||
///
|
||||
/// # Security
|
||||
///
|
||||
/// This package MUST NOT be sent to other participants!
|
||||
pub type Round1SecretPackage = frost::keys::dkg::Round1SecretPackage<S>;
|
||||
|
||||
/// The package that must be broadcast by each participant to all other participants
|
||||
/// between the first and second parts of the DKG protocol (round 1).
|
||||
pub type Round1Package = frost::keys::dkg::Round1Package<S>;
|
||||
|
||||
/// The secret package that must be kept in memory by the participant
|
||||
/// between the second and third parts of the DKG protocol (round 2).
|
||||
///
|
||||
/// # Security
|
||||
///
|
||||
/// This package MUST NOT be sent to other participants!
|
||||
pub type Round2SecretPackage = frost::keys::dkg::Round2SecretPackage<S>;
|
||||
|
||||
/// A package that must be sent by each participant to some other participants
|
||||
/// in Round 2 of the DKG protocol. Note that there is one specific package
|
||||
/// for each specific recipient, in contrast to Round 1.
|
||||
///
|
||||
/// # Security
|
||||
///
|
||||
/// The package must be sent on an *confidential* and *authenticated* channel.
|
||||
pub type Round2Package = frost::keys::dkg::Round2Package<S>;
|
||||
|
||||
/// Performs the first part of the distributed key generation protocol
|
||||
/// for the given participant.
|
||||
///
|
||||
/// It returns the [`Round1SecretPackage`] that must be kept in memory
|
||||
/// by the participant for the other steps, and the [`Round1Package`] that
|
||||
/// must be sent to other participants.
|
||||
pub fn keygen_part1<R: RngCore + CryptoRng>(
|
||||
identifier: Identifier,
|
||||
max_signers: u16,
|
||||
min_signers: u16,
|
||||
mut rng: R,
|
||||
) -> Result<(Round1SecretPackage, Round1Package), Error> {
|
||||
frost::keys::dkg::keygen_part1(identifier, max_signers, min_signers, &mut rng)
|
||||
}
|
||||
|
||||
/// Performs the second part of the distributed key generation protocol
|
||||
/// for the participant holding the given [`Round1SecretPackage`],
|
||||
/// given the received [`Round1Package`]s received from the other participants.
|
||||
///
|
||||
/// It returns the [`Round2SecretPackage`] that must be kept in memory
|
||||
/// by the participant for the final step, and the [`Round2Package`]s that
|
||||
/// must be sent to other participants.
|
||||
pub fn keygen_part2(
|
||||
secret_package: Round1SecretPackage,
|
||||
round1_packages: &[Round1Package],
|
||||
) -> Result<(Round2SecretPackage, Vec<Round2Package>), Error> {
|
||||
frost::keys::dkg::keygen_part2(secret_package, round1_packages)
|
||||
}
|
||||
|
||||
/// Performs the third and final part of the distributed key generation protocol
|
||||
/// for the participant holding the given [`Round2SecretPackage`],
|
||||
/// given the received [`Round1Package`]s and [`Round2Package`]s received from
|
||||
/// the other participants.
|
||||
///
|
||||
/// It returns the [`KeyPackage`] that has the long-lived key share for the
|
||||
/// participant, and the [`PublicKeyPackage`]s that has public information
|
||||
/// about all participants; both of which are required to compute FROST
|
||||
/// signatures.
|
||||
pub fn keygen_part3(
|
||||
round2_secret_package: &Round2SecretPackage,
|
||||
round1_packages: &[Round1Package],
|
||||
round2_packages: &[Round2Package],
|
||||
) -> Result<(KeyPackage, PublicKeyPackage), Error> {
|
||||
frost::keys::dkg::keygen_part3(round2_secret_package, round1_packages, round2_packages)
|
||||
}
|
|
@ -281,85 +281,7 @@ pub mod keys {
|
|||
/// Used for verification purposes before publishing a signature.
|
||||
pub type PublicKeyPackage = frost::keys::PublicKeyPackage<S>;
|
||||
|
||||
pub mod dkg {
|
||||
#![doc = include_str!("../dkg.md")]
|
||||
use super::*;
|
||||
|
||||
/// The secret package that must be kept in memory by the participant
|
||||
/// between the first and second parts of the DKG protocol (round 1).
|
||||
///
|
||||
/// # Security
|
||||
///
|
||||
/// This package MUST NOT be sent to other participants!
|
||||
pub type Round1SecretPackage = frost::keys::dkg::Round1SecretPackage<S>;
|
||||
|
||||
/// The package that must be broadcast by each participant to all other participants
|
||||
/// between the first and second parts of the DKG protocol (round 1).
|
||||
pub type Round1Package = frost::keys::dkg::Round1Package<S>;
|
||||
|
||||
/// The secret package that must be kept in memory by the participant
|
||||
/// between the second and third parts of the DKG protocol (round 2).
|
||||
///
|
||||
/// # Security
|
||||
///
|
||||
/// This package MUST NOT be sent to other participants!
|
||||
pub type Round2SecretPackage = frost::keys::dkg::Round2SecretPackage<S>;
|
||||
|
||||
/// A package that must be sent by each participant to some other participants
|
||||
/// in Round 2 of the DKG protocol. Note that there is one specific package
|
||||
/// for each specific recipient, in contrast to Round 1.
|
||||
///
|
||||
/// # Security
|
||||
///
|
||||
/// The package must be sent on an *confidential* and *authenticated* channel.
|
||||
pub type Round2Package = frost::keys::dkg::Round2Package<S>;
|
||||
|
||||
/// Performs the first part of the distributed key generation protocol
|
||||
/// for the given participant.
|
||||
///
|
||||
/// It returns the [`Round1SecretPackage`] that must be kept in memory
|
||||
/// by the participant for the other steps, and the [`Round1Package`] that
|
||||
/// must be sent to other participants.
|
||||
pub fn keygen_part1<R: RngCore + CryptoRng>(
|
||||
identifier: Identifier,
|
||||
max_signers: u16,
|
||||
min_signers: u16,
|
||||
mut rng: R,
|
||||
) -> Result<(Round1SecretPackage, Round1Package), Error> {
|
||||
frost::keys::dkg::keygen_part1(identifier, max_signers, min_signers, &mut rng)
|
||||
}
|
||||
|
||||
/// Performs the second part of the distributed key generation protocol
|
||||
/// for the participant holding the given [`Round1SecretPackage`],
|
||||
/// given the received [`Round1Package`]s received from the other participants.
|
||||
///
|
||||
/// It returns the [`Round2SecretPackage`] that must be kept in memory
|
||||
/// by the participant for the final step, and the [`Round2Package`]s that
|
||||
/// must be sent to other participants.
|
||||
pub fn keygen_part2(
|
||||
secret_package: Round1SecretPackage,
|
||||
round1_packages: &[Round1Package],
|
||||
) -> Result<(Round2SecretPackage, Vec<Round2Package>), Error> {
|
||||
frost::keys::dkg::keygen_part2(secret_package, round1_packages)
|
||||
}
|
||||
|
||||
/// Performs the third and final part of the distributed key generation protocol
|
||||
/// for the participant holding the given [`Round2SecretPackage`],
|
||||
/// given the received [`Round1Package`]s and [`Round2Package`]s received from
|
||||
/// the other participants.
|
||||
///
|
||||
/// It returns the [`KeyPackage`] that has the long-lived key share for the
|
||||
/// participant, and the [`PublicKeyPackage`]s that has public information
|
||||
/// about all participants; both of which are required to compute FROST
|
||||
/// signatures.
|
||||
pub fn keygen_part3(
|
||||
round2_secret_package: &Round2SecretPackage,
|
||||
round1_packages: &[Round1Package],
|
||||
round2_packages: &[Round2Package],
|
||||
) -> Result<(KeyPackage, PublicKeyPackage), Error> {
|
||||
frost::keys::dkg::keygen_part3(round2_secret_package, round1_packages, round2_packages)
|
||||
}
|
||||
}
|
||||
pub mod dkg;
|
||||
}
|
||||
|
||||
/// FROST(secp256k1, SHA-256) Round 1 functionality and types.
|
||||
|
|
|
@ -135,79 +135,71 @@ fn main() -> ExitCode {
|
|||
let mut replaced = 0;
|
||||
let check = args.len() == 2 && args[1] == "--check";
|
||||
|
||||
let docs = read_docs(
|
||||
"frost-ristretto255/src/lib.rs",
|
||||
&["Ristretto255Sha512", "Ristretto", "<R>"],
|
||||
);
|
||||
let old_suite_names_doc = &["FROST(ristretto255, SHA-512)"];
|
||||
|
||||
let original_basename = "frost-ristretto255/";
|
||||
let original_folder = "frost-ristretto255";
|
||||
let original_suite_names_code = &["Ristretto255Sha512", "Ristretto", "<R>"];
|
||||
let original_suite_names_doc = &["FROST(ristretto255, SHA-512)"];
|
||||
let original_strings = &["frost_ristretto255", "Ristretto group"];
|
||||
|
||||
// To add a new ciphersuite, just copy this call and replace the required strings.
|
||||
|
||||
replaced |= write_docs(
|
||||
&docs,
|
||||
"frost-p256/src/lib.rs",
|
||||
&["P256Sha256", "P256", "<P>"],
|
||||
old_suite_names_doc,
|
||||
&["FROST(P-256, SHA-256)"],
|
||||
let docs = read_docs("frost-ristretto255/src/lib.rs", original_suite_names_code);
|
||||
let dkg_docs = read_docs(
|
||||
"frost-ristretto255/src/keys/dkg.rs",
|
||||
original_suite_names_code,
|
||||
);
|
||||
for filename in ["README.md", "dkg.md"] {
|
||||
replaced |= copy_and_replace(
|
||||
format!("{}/{}", original_basename, filename).as_str(),
|
||||
format!("frost-p256/{}", filename).as_str(),
|
||||
original_strings,
|
||||
|
||||
// To add a new ciphersuite, just copy a tuple and replace the required strings.
|
||||
for (folder, suite_names_code, suite_names_doc, replacement_strings) in [
|
||||
(
|
||||
// The folder where the ciphersuite crate is
|
||||
"frost-p256",
|
||||
// String replacements for the strings in `original_suite_names_code`
|
||||
&["P256Sha256", "P256", "<P>"],
|
||||
// String replacements for the strings in `original_suite_names_doc`
|
||||
&["FROST(P-256, SHA-256)"],
|
||||
// String replacements for the strings in `original_strings`
|
||||
&["frost_p256", "P-256 curve"],
|
||||
);
|
||||
}
|
||||
|
||||
replaced |= write_docs(
|
||||
&docs,
|
||||
"frost-ed25519/src/lib.rs",
|
||||
&["Ed25519Sha512", "Ed25519", "<E>"],
|
||||
old_suite_names_doc,
|
||||
&["FROST(Ed25519, SHA-512)"],
|
||||
);
|
||||
for filename in ["README.md", "dkg.md"] {
|
||||
replaced |= copy_and_replace(
|
||||
format!("{}/{}", original_basename, filename).as_str(),
|
||||
format!("frost-ed25519/{}", filename).as_str(),
|
||||
original_strings,
|
||||
),
|
||||
(
|
||||
"frost-ed25519",
|
||||
&["Ed25519Sha512", "Ed25519", "<E>"],
|
||||
&["FROST(Ed25519, SHA-512)"],
|
||||
&["frost_ed25519", "Ed25519 curve"],
|
||||
);
|
||||
}
|
||||
|
||||
replaced |= write_docs(
|
||||
&docs,
|
||||
"frost-ed448/src/lib.rs",
|
||||
&["Ed448Shake256", "Ed448", "<E>"],
|
||||
old_suite_names_doc,
|
||||
&["FROST(Ed448, SHAKE256)"],
|
||||
);
|
||||
for filename in ["README.md", "dkg.md"] {
|
||||
replaced |= copy_and_replace(
|
||||
format!("{}/{}", original_basename, filename).as_str(),
|
||||
format!("frost-ed448/{}", filename).as_str(),
|
||||
original_strings,
|
||||
),
|
||||
(
|
||||
"frost-ed448",
|
||||
&["Ed448Shake256", "Ed448", "<E>"],
|
||||
&["FROST(Ed448, SHAKE256)"],
|
||||
&["frost_ed448", "Ed448 curve"],
|
||||
);
|
||||
}
|
||||
|
||||
replaced |= write_docs(
|
||||
&docs,
|
||||
"frost-secp256k1/src/lib.rs",
|
||||
&["Secp256K1Sha556", "Secp256K1", "<S>"],
|
||||
old_suite_names_doc,
|
||||
&["FROST(secp256k1, SHA-256)"],
|
||||
);
|
||||
for filename in ["README.md", "dkg.md"] {
|
||||
replaced |= copy_and_replace(
|
||||
format!("{}/{}", original_basename, filename).as_str(),
|
||||
format!("frost-secp256k1/{}", filename).as_str(),
|
||||
original_strings,
|
||||
),
|
||||
(
|
||||
"frost-secp256k1",
|
||||
&["Secp256K1Sha556", "Secp256K1", "<S>"],
|
||||
&["FROST(secp256k1, SHA-256)"],
|
||||
&["frost_secp256k1", "secp256k1 curve"],
|
||||
);
|
||||
),
|
||||
] {
|
||||
let lib_filename = format!("{}/src/lib.rs", folder);
|
||||
let dkg_filename = format!("{}/src/keys/dkg.rs", folder);
|
||||
// Copy the documentation of public items in Rust code, replacing ciphersuite-specific strings inside
|
||||
// them in the process.
|
||||
for (docs, filename) in [(&docs, lib_filename), (&dkg_docs, dkg_filename)] {
|
||||
replaced |= write_docs(
|
||||
docs,
|
||||
&filename,
|
||||
suite_names_code,
|
||||
original_suite_names_doc,
|
||||
suite_names_doc,
|
||||
);
|
||||
}
|
||||
// Copy Markdown documentation, replacing ciphersuite-specific strings inside
|
||||
// them in the process.
|
||||
for filename in ["README.md", "dkg.md"] {
|
||||
replaced |= copy_and_replace(
|
||||
format!("{}/{}", original_folder, filename).as_str(),
|
||||
format!("{}/{}", folder, filename).as_str(),
|
||||
original_strings,
|
||||
replacement_strings,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if check {
|
||||
|
|
Loading…
Reference in New Issue