Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
taniasaleem committed Jul 11, 2024
1 parent fa43965 commit 45dc27c
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 35 deletions.
56 changes: 28 additions & 28 deletions tss/src/dkg.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! # Distributed Key Generation (DKG) Module
//! The DKG module is responsible for managing the Distributed Key Generation process, which allows a set of participants to collectively generate a shared secret key. This process involves multiple rounds of communication and ensures that no single participant has access to the entire secret key. The module supports handling messages, committing to secret shares, and transitioning through different stages of the DKG process.
//!
//!
//!
//!
use frost_evm::frost_secp256k1::Signature;
use frost_evm::keys::dkg::*;
use frost_evm::keys::{
Expand All @@ -13,7 +13,7 @@ use serde::{Deserialize, Serialize};
use std::collections::{BTreeSet, HashMap};

/// Defines different actions that can occur during the DKG process:
///
///
/// - Commit: Send a commitment with a proof.
/// - Send: Send messages to other participants.
/// - Complete: Completion of the DKG process with a key package and commitment.
Expand Down Expand Up @@ -49,16 +49,16 @@ pub struct Dkg {

impl Dkg {
/// Creates a new instance of the DKG state machine.
///
/// ### Arguments
///
/// * `id` - The identifier of the current participant.
/// * `members` - A set of identifiers for all participants.
/// * `threshold` - The threshold number of participants needed to reconstruct the secret.
///
/// ### Returns
///
/// A new `Dkg` instance.
///
/// ### Arguments
///
/// * `id` - The identifier of the current participant.
/// * `members` - A set of identifiers for all participants.
/// * `threshold` - The threshold number of participants needed to reconstruct the secret.
///
/// ### Returns
///
/// A new `Dkg` instance.
pub fn new(id: Identifier, members: BTreeSet<Identifier>, threshold: u16) -> Self {
// Ensures the current participant is in the members set.
debug_assert!(members.contains(&id));
Expand All @@ -74,29 +74,29 @@ impl Dkg {
}

/// Handles the receipt of a commitment from another participant.
///
/// ### Arguments
///
/// * `commitment` - The commitment received from another participant.
///
/// ### Arguments
///
/// * `commitment` - The commitment received from another participant.
pub fn on_commit(&mut self, commitment: VerifiableSecretSharingCommitment) {
self.commitment = Some(commitment);
}

/// Handles the receipt of a message from another participant.
///
/// ### Arguments
///
/// * `peer` - The identifier of the peer who sent the message.
/// * `msg` - The message received from the peer.
/// Handles the receipt of a message from another participant.
///
/// ### Arguments
///
/// * `peer` - The identifier of the peer who sent the message.
/// * `msg` - The message received from the peer.
pub fn on_message(&mut self, peer: Identifier, msg: DkgMessage) {
self.round2_packages.insert(peer, msg.0);
}

/// Determines the next action to be taken in the DKG process.
///
/// ### Returns
///
/// An optional `DkgAction` representing the next action to be taken.
///
/// ### Returns
///
/// An optional `DkgAction` representing the next action to be taken.
pub fn next_action(&mut self) -> Option<DkgAction> {
// Check if the secret package is already initialized. If not, perform the first part of the DKG process.
let Some(secret_package) = self.secret_package.as_ref() else {
Expand Down Expand Up @@ -145,7 +145,7 @@ impl Dkg {
.fold(SigningShare::new(Scalar::ZERO), |acc, e| {
SigningShare::new(acc.to_scalar() + e.to_scalar())
});
// Create a secret share and corresponding key package.
// Create a secret share and corresponding key package.
let secret_share = SecretShare::new(self.id, signing_share, commitment.clone());
let key_package = match KeyPackage::try_from(secret_share) {
Ok(key_package) => key_package,
Expand Down
4 changes: 2 additions & 2 deletions tss/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#![allow(clippy::large_enum_variant)]
//!
//! # Threshold Signature Scheme (TSS)
//! # Threshold Signature Scheme (TSS)
//! The TSS (Threshold Signature Scheme) module handles cryptographic operations related to distributed key generation (DKG) and signature generation using the Roast protocol. This flowchart illustrates the key states and actions within the TSS module.
//!
//!
#![doc = simple_mermaid::mermaid!("../docs/tss.mmd")]

use crate::dkg::{Dkg, DkgAction, DkgMessage};
Expand Down
9 changes: 4 additions & 5 deletions tss/src/roast.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
//! # Roast Module Documentation
//! The Roast module implements a state machine for managing the Robust Online Asynchronous Schnorr Threshold (ROAST) protocol. This protocol allows a distributed set of signers to collaboratively generate Schnorr signatures in a secure and robust manner, ensuring that the signature process can continue even if some participants fail to respond or act maliciously.
//!
//!
//! ## Overview
//! The main components of the Roast module include:
//!
//!
//! - 'RoastSigner': Manages the signing process for a single participant.
//! - 'RoastCoordinator': Coordinates the signing process, ensuring that enough participants have committed to generate a signature.
//! - 'RoastSession': Manages a single signing session, tracking commitments and signature shares.
//! - 'Roast': The main state machine that brings together the RoastSigner and RoastCoordinator to manage the overall ROAST protocol.
//!
//!
use frost_evm::{
keys::{KeyPackage, PublicKeyPackage},
round1::{self, SigningCommitments, SigningNonces},
Expand Down Expand Up @@ -232,7 +232,6 @@ pub enum RoastAction {
Complete([u8; 32], Signature),
}


/// The main state machine that manages the overall ROAST protocol by integrating ['RoastSigner'] and ['RoastCoordinator'].
pub struct Roast {
signer: RoastSigner,
Expand Down Expand Up @@ -264,7 +263,7 @@ impl Roast {
self.signer.set_data(data);
}

/// Handles an incoming message from a peer.
/// Handles an incoming message from a peer.
pub fn on_message(&mut self, peer: Identifier, msg: RoastMessage) {
match msg {
RoastMessage::Commit(commitment) => {
Expand Down

0 comments on commit 45dc27c

Please sign in to comment.