Skip to content

Commit

Permalink
Remove the FRO of FROST aka the dangerous 1-round
Browse files Browse the repository at this point in the history
We could expose this behind some HAZMAT feature I guess, not sure.
  • Loading branch information
burdges committed Jul 30, 2024
1 parent f4d26d6 commit 3940595
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
5 changes: 4 additions & 1 deletion src/olaf/multisig/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ impl SigningKeypair {
/// perform the first round. Batching entails generating more than one
/// nonce/commitment pair at a time. Nonces should be stored in secret storage
/// for later use, whereas the commitments are published.
pub fn preprocess(&self, num_nonces: u8) -> (Vec<SigningNonces>, Vec<SigningCommitments>) {
///
/// TODO: Already made private, next remove Vec or make HAZMAT
fn preprocess(&self, num_nonces: u8) -> (Vec<SigningNonces>, Vec<SigningCommitments>) {
let mut rng = getrandom_or_panic();
let mut signing_nonces: Vec<SigningNonces> = Vec::with_capacity(num_nonces as usize);
let mut signing_commitments: Vec<SigningCommitments> =
Expand Down Expand Up @@ -476,6 +478,7 @@ mod tests {
aggregate(&signing_packages).unwrap();
}

// Test is likely HAZMAT
#[test]
fn test_preprocessing_frost_with_simplpedpop() {
let parameters = generate_parameters();
Expand Down
18 changes: 11 additions & 7 deletions src/olaf/multisig/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ impl BindingFactorList {
}

/// A scalar that is a signing nonce.
#[derive(Debug, Clone, ZeroizeOnDrop, PartialEq, Eq)]
#[derive(Debug, ZeroizeOnDrop, PartialEq, Eq)]
pub(super) struct Nonce(pub(super) Scalar);

impl Nonce {
Expand Down Expand Up @@ -167,13 +167,15 @@ impl Nonce {
Self(transcript.challenge_scalar(b"nonce"))
}

/* HAZMAT
fn to_bytes(&self) -> [u8; SCALAR_LENGTH] {
self.0.to_bytes()
}
fn from_bytes(bytes: [u8; SCALAR_LENGTH]) -> Self {
Nonce(Scalar::from_bytes_mod_order(bytes))
}
*/
}

/// A group element that is a commitment to a signing nonce share.
Expand Down Expand Up @@ -207,7 +209,7 @@ impl From<&Nonce> for NonceCommitment {
/// Note that [`SigningNonces`] must be used *only once* for a signing
/// operation; re-using nonces will result in leakage of a signer's long-lived
/// signing key.
#[derive(Debug, Clone, ZeroizeOnDrop, PartialEq, Eq)]
#[derive(Debug, ZeroizeOnDrop, PartialEq, Eq)]
pub struct SigningNonces {
pub(super) hiding: Nonce,
pub(super) binding: Nonce,
Expand All @@ -234,6 +236,7 @@ impl SigningNonces {
Self::from_nonces(hiding, binding)
}

/* HAZMAT
/// Serializes SigningNonces into bytes.
pub fn to_bytes(self) -> Vec<u8> {
let mut bytes = Vec::new();
Expand Down Expand Up @@ -265,6 +268,7 @@ impl SigningNonces {
Ok(Self { hiding, binding, commitments })
}
*/

/// Generates a new [`SigningNonces`] from a pair of [`Nonce`].
///
Expand Down Expand Up @@ -500,7 +504,7 @@ mod tests {
olaf::{simplpedpop::AllMessage, test_utils::generate_parameters},
Keypair, PublicKey,
};
use super::{SigningCommitments, SigningNonces, SigningPackage};
use super::{SigningCommitments, SigningPackage}; // SigningNonces

#[test]
fn test_round1_serialization() {
Expand All @@ -521,15 +525,15 @@ mod tests {

let spp_output = keypairs[0].simplpedpop_recipient_all(&all_messages).unwrap();

let (signing_nonces, signing_commitments) = spp_output.1.commit();
let (_signing_nonces, signing_commitments) = spp_output.1.commit();

let nonces_bytes = signing_nonces.clone().to_bytes();
// HAZMAT: let nonces_bytes = signing_nonces.clone().to_bytes();
let commitments_bytes = signing_commitments.clone().to_bytes();

let deserialized_nonces = SigningNonces::from_bytes(&nonces_bytes).unwrap();
// HAZMAT: let deserialized_nonces = SigningNonces::from_bytes(&nonces_bytes).unwrap();
let deserialized_commitments = SigningCommitments::from_bytes(&commitments_bytes).unwrap();

assert_eq!(signing_nonces, deserialized_nonces);
// HAZMAT: assert_eq!(signing_nonces, deserialized_nonces);
assert_eq!(signing_commitments, deserialized_commitments);
}

Expand Down

0 comments on commit 3940595

Please sign in to comment.