diff --git a/Cargo.lock b/Cargo.lock index 07bfdfa96..c027e0b23 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4548,7 +4548,6 @@ dependencies = [ [[package]] name = "frost-core" version = "1.0.0-rc.0" -source = "git+https://github.com/LIT-Protocol/frost.git#1be134913acd67a63a8568b305abaceff520b1e9" dependencies = [ "byteorder", "const-crc32", @@ -4567,6 +4566,18 @@ dependencies = [ "zeroize", ] +[[package]] +name = "frost-ed25519" +version = "1.0.0-rc.0" +dependencies = [ + "curve25519-dalek-ml", + "document-features", + "frost-core 1.0.0-rc.0", + "frost-rerandomized", + "rand_core 0.6.4", + "sha2 0.10.8", +] + [[package]] name = "frost-ed25519" version = "1.0.0-rc.0" @@ -4581,16 +4592,15 @@ dependencies = [ ] [[package]] -name = "frost-ed25519" +name = "frost-ed448" version = "1.0.0-rc.0" -source = "git+https://github.com/LIT-Protocol/frost.git#1be134913acd67a63a8568b305abaceff520b1e9" dependencies = [ - "curve25519-dalek-ml", "document-features", + "ed448-goldilocks-plus 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)", "frost-core 1.0.0-rc.0", "frost-rerandomized", "rand_core 0.6.4", - "sha2 0.10.8", + "sha3 0.10.8", ] [[package]] @@ -4607,16 +4617,15 @@ dependencies = [ ] [[package]] -name = "frost-ed448" +name = "frost-p256" version = "1.0.0-rc.0" -source = "git+https://github.com/LIT-Protocol/frost.git#1be134913acd67a63a8568b305abaceff520b1e9" dependencies = [ "document-features", - "ed448-goldilocks-plus 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)", "frost-core 1.0.0-rc.0", "frost-rerandomized", + "p256 0.13.2", "rand_core 0.6.4", - "sha3 0.10.8", + "sha2 0.10.8", ] [[package]] @@ -4633,14 +4642,13 @@ dependencies = [ ] [[package]] -name = "frost-p256" +name = "frost-p384" version = "1.0.0-rc.0" -source = "git+https://github.com/LIT-Protocol/frost.git#1be134913acd67a63a8568b305abaceff520b1e9" dependencies = [ "document-features", "frost-core 1.0.0-rc.0", "frost-rerandomized", - "p256 0.13.2", + "p384", "rand_core 0.6.4", "sha2 0.10.8", ] @@ -4659,27 +4667,25 @@ dependencies = [ ] [[package]] -name = "frost-p384" +name = "frost-rerandomized" version = "1.0.0-rc.0" -source = "git+https://github.com/LIT-Protocol/frost.git#1be134913acd67a63a8568b305abaceff520b1e9" dependencies = [ + "derive-getters", "document-features", "frost-core 1.0.0-rc.0", - "frost-rerandomized", - "p384", "rand_core 0.6.4", - "sha2 0.10.8", ] [[package]] -name = "frost-rerandomized" +name = "frost-ristretto255" version = "1.0.0-rc.0" -source = "git+https://github.com/LIT-Protocol/frost.git#1be134913acd67a63a8568b305abaceff520b1e9" dependencies = [ - "derive-getters", + "curve25519-dalek 4.1.1", "document-features", "frost-core 1.0.0-rc.0", + "frost-rerandomized", "rand_core 0.6.4", + "sha2 0.10.8", ] [[package]] @@ -4696,14 +4702,13 @@ dependencies = [ ] [[package]] -name = "frost-ristretto255" +name = "frost-secp256k1" version = "1.0.0-rc.0" -source = "git+https://github.com/LIT-Protocol/frost.git#1be134913acd67a63a8568b305abaceff520b1e9" dependencies = [ - "curve25519-dalek 4.1.1", "document-features", "frost-core 1.0.0-rc.0", "frost-rerandomized", + "k256", "rand_core 0.6.4", "sha2 0.10.8", ] @@ -4721,19 +4726,6 @@ dependencies = [ "subtle", ] -[[package]] -name = "frost-secp256k1" -version = "1.0.0-rc.0" -source = "git+https://github.com/LIT-Protocol/frost.git#1be134913acd67a63a8568b305abaceff520b1e9" -dependencies = [ - "document-features", - "frost-core 1.0.0-rc.0", - "frost-rerandomized", - "k256", - "rand_core 0.6.4", - "sha2 0.10.8", -] - [[package]] name = "fs-err" version = "2.11.0" @@ -16638,13 +16630,13 @@ dependencies = [ "digest 0.10.7", "frame-support", "frost-core 1.0.0-rc.0", - "frost-ed25519 1.0.0-rc.0 (git+https://github.com/LIT-Protocol/frost.git)", - "frost-ed448 1.0.0-rc.0 (git+https://github.com/LIT-Protocol/frost.git)", - "frost-p256 1.0.0-rc.0 (git+https://github.com/LIT-Protocol/frost.git)", - "frost-p384 1.0.0-rc.0 (git+https://github.com/LIT-Protocol/frost.git)", + "frost-ed25519 1.0.0-rc.0", + "frost-ed448 1.0.0-rc.0", + "frost-p256 1.0.0-rc.0", + "frost-p384 1.0.0-rc.0", "frost-rerandomized", - "frost-ristretto255 1.0.0-rc.0 (git+https://github.com/LIT-Protocol/frost.git)", - "frost-secp256k1 1.0.0-rc.0 (git+https://github.com/LIT-Protocol/frost.git)", + "frost-ristretto255 1.0.0-rc.0", + "frost-secp256k1 1.0.0-rc.0", "futures", "gadget-common", "gadget-core", diff --git a/Cargo.toml b/Cargo.toml index d8b32d459..437ebb679 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -41,14 +41,22 @@ round-based = { git = "https://github.com/webb-tools/round-based-protocol", feat curv = { package = "curv-kzen", version = "0.10.0" } dfns-cggmp21 = { package = "cggmp21", version = "0.1.1", default-features = false } udigest = { version = "0.1", features = ["std", "derive"]} -frost-core = { git = "https://github.com/LIT-Protocol/frost.git" } -frost-ed25519 = { git = "https://github.com/LIT-Protocol/frost.git" } -frost-ed448 = { git = "https://github.com/LIT-Protocol/frost.git" } -frost-p256 = { git = "https://github.com/LIT-Protocol/frost.git" } -frost-p384 = { git = "https://github.com/LIT-Protocol/frost.git" } -frost-ristretto255 = { git = "https://github.com/LIT-Protocol/frost.git" } -frost-secp256k1 = { git = "https://github.com/LIT-Protocol/frost.git" } -frost-rerandomized = { git = "https://github.com/LIT-Protocol/frost.git" } +# frost-core = { git = "https://github.com/LIT-Protocol/frost.git" } +# frost-ed25519 = { git = "https://github.com/LIT-Protocol/frost.git" } +# frost-ed448 = { git = "https://github.com/LIT-Protocol/frost.git" } +# frost-p256 = { git = "https://github.com/LIT-Protocol/frost.git" } +# frost-p384 = { git = "https://github.com/LIT-Protocol/frost.git" } +# frost-ristretto255 = { git = "https://github.com/LIT-Protocol/frost.git" } +# frost-secp256k1 = { git = "https://github.com/LIT-Protocol/frost.git" } +# frost-rerandomized = { git = "https://github.com/LIT-Protocol/frost.git" } +frost-core = { path = "../frost/frost-core" } +frost-ed25519 = { path = "../frost/frost-ed25519" } +frost-ed448 = { path = "../frost/frost-ed448" } +frost-p256 = { path = "../frost/frost-p256" } +frost-p384 = { path = "../frost/frost-p384" } +frost-ristretto255 = { path = "../frost/frost-ristretto255" } +frost-secp256k1 = { path = "../frost/frost-secp256k1" } +frost-rerandomized = { path = "../frost/frost-rerandomized" } bls12_381_plus = "0.8.13" sp-core = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" } diff --git a/protocols/zcash-frost/Cargo.toml b/protocols/zcash-frost/Cargo.toml index 9ccb4007a..4c857b5da 100644 --- a/protocols/zcash-frost/Cargo.toml +++ b/protocols/zcash-frost/Cargo.toml @@ -23,7 +23,7 @@ rand_chacha = { version = "0.3", default-features = false } dfns-cggmp21 = { workspace = true } udigest = { workspace = true } -frost-core = { workspace = true } +frost-core = { workspace = true, features = ["cheater-detection"] } frost-ed25519 = { workspace = true } frost-ed448 = { workspace = true } frost-p256 = { workspace = true } diff --git a/protocols/zcash-frost/src/rounds/errors.rs b/protocols/zcash-frost/src/rounds/errors.rs deleted file mode 100644 index 18abec701..000000000 --- a/protocols/zcash-frost/src/rounds/errors.rs +++ /dev/null @@ -1,43 +0,0 @@ -use std::convert::Infallible; - -use round_based::rounds_router::{ - errors::{self as router_error, CompleteRoundError}, - simple_store::RoundInputError, -}; -use thiserror::Error; - -pub type BoxedError = Box; - -#[derive(Debug, Error)] -pub enum IoError { - #[error("send message")] - SendMessage(#[source] BoxedError), - #[error("receive message")] - ReceiveMessage(#[source] BoxedError), - #[error("got eof while recieving messages")] - ReceiveMessageEof, - #[error("route received message (possibly malicious behavior)")] - RouteReceivedError(router_error::CompleteRoundError), -} - -impl IoError { - pub fn send_message(err: E) -> Self { - Self::SendMessage(Box::new(err)) - } - - pub fn receive_message( - err: CompleteRoundError, - ) -> Self { - match err { - CompleteRoundError::Io(router_error::IoError::Io(e)) => { - Self::ReceiveMessage(Box::new(e)) - } - CompleteRoundError::Io(router_error::IoError::UnexpectedEof) => Self::ReceiveMessageEof, - - CompleteRoundError::ProcessMessage(e) => { - Self::RouteReceivedError(CompleteRoundError::ProcessMessage(e)) - } - CompleteRoundError::Other(e) => Self::RouteReceivedError(CompleteRoundError::Other(e)), - } - } -} diff --git a/protocols/zcash-frost/src/rounds/keygen.rs b/protocols/zcash-frost/src/rounds/keygen.rs index 62e30a692..a82247c28 100644 --- a/protocols/zcash-frost/src/rounds/keygen.rs +++ b/protocols/zcash-frost/src/rounds/keygen.rs @@ -18,7 +18,7 @@ use round_based::{ use serde::{Deserialize, Serialize}; use tangle_primitives::roles::ThresholdSignatureRoleType; -use super::{errors::IoError, KeygenAborted, KeygenError, Reason}; +use super::{IoError, KeygenAborted, KeygenError, Reason}; /// Message of key generation protocol #[derive(ProtocolMessage, Clone, Serialize, Deserialize)] @@ -90,6 +90,7 @@ where tracer.round_begins(); tracer.stage("Compute round 1 dkg secret package"); + println!("Keygen | i: {}, t: {}, n: {}", i, t, n); let (round1_secret_package, round1_package) = dkg_part1(i + 1, t, n, role, rng).map_err(|e| { KeygenError(Reason::KeygenFailure(KeygenAborted::FrostError { @@ -116,7 +117,7 @@ where .complete(round1) .await .map_err(|e| KeygenError(Reason::IoError(IoError::receive_message(e))))? - .into_vec_including_me(my_round1_msg) + .into_vec_including_me(my_round1_msg.clone()) .into_iter() .map(|msg| { round1::Package::deserialize(&msg.msg) @@ -124,7 +125,7 @@ where }) .collect(); tracer.msgs_received(); - + println!("Keygen | i: {}, my_package: {:#?}", i, round1_package); tracer.stage("Compute round 2 dkg secret package"); let round1_packages_map: BTreeMap, round1::Package> = round1_packages .iter() @@ -137,7 +138,7 @@ where }) .filter(|(inx, _)| *inx != Identifier::try_from(i + 1).unwrap()) .collect(); - + println!("Keygen | round1_packages_map: {:#?}", round1_packages_map); let (round2_secret_package, round2_packages_map) = dkg_part2(role, round1_secret_package, &round1_packages_map).map_err(|e| { KeygenError(Reason::KeygenFailure(KeygenAborted::FrostError { diff --git a/protocols/zcash-frost/src/rounds/mod.rs b/protocols/zcash-frost/src/rounds/mod.rs index 3be817228..f62eb3801 100644 --- a/protocols/zcash-frost/src/rounds/mod.rs +++ b/protocols/zcash-frost/src/rounds/mod.rs @@ -1,95 +1,143 @@ use frost_core::Ciphersuite; -use frost_ed25519::Ed25519Sha512; -use frost_ed448::Ed448Shake256; -use frost_p256::P256Sha256; -use frost_p384::P384Sha384; -use frost_ristretto255::Ristretto255Sha512; -use frost_secp256k1::Secp256K1Sha256; +use round_based::rounds_router::{ + errors::{self as router_error, CompleteRoundError}, + simple_store::RoundInputError, +}; +use std::convert::Infallible; use thiserror::Error; -use self::errors::IoError; - -pub mod errors; pub mod keygen; pub mod sign; -/// Keygen protocol error +pub type BoxedError = Box; + #[derive(Debug, Error)] -#[error("keygen protocol is failed to complete")] -pub struct KeygenError(#[source] Reason); +pub enum IoError { + #[error("send message")] + SendMessage(#[source] BoxedError), + #[error("receive message")] + ReceiveMessage(#[source] BoxedError), + #[error("got eof while recieving messages")] + ReceiveMessageEof, + #[error("route received message (possibly malicious behavior)")] + RouteReceivedError(router_error::CompleteRoundError), +} -macro_rules! impl_keygen_error_from { - ($ciphersuite:ty) => { - impl From> for KeygenError<$ciphersuite> { - fn from(err: KeygenAborted<$ciphersuite>) -> Self { - KeygenError(Reason::KeygenFailure(err)) +impl IoError { + pub fn send_message(err: E) -> Self { + Self::SendMessage(Box::new(err)) + } + + pub fn receive_message( + err: CompleteRoundError, + ) -> Self { + match err { + CompleteRoundError::Io(router_error::IoError::Io(e)) => { + Self::ReceiveMessage(Box::new(e)) } - } + CompleteRoundError::Io(router_error::IoError::UnexpectedEof) => Self::ReceiveMessageEof, - impl From for KeygenError<$ciphersuite> { - fn from(err: IoError) -> Self { - KeygenError(Reason::IoError(err)) + CompleteRoundError::ProcessMessage(e) => { + Self::RouteReceivedError(CompleteRoundError::ProcessMessage(e)) } + CompleteRoundError::Other(e) => Self::RouteReceivedError(CompleteRoundError::Other(e)), } - }; + } } -impl_keygen_error_from!(Ed25519Sha512); -impl_keygen_error_from!(P256Sha256); -impl_keygen_error_from!(P384Sha384); -impl_keygen_error_from!(Ristretto255Sha512); -impl_keygen_error_from!(Secp256K1Sha256); -impl_keygen_error_from!(Ed448Shake256); +/// Error indicating that protocol was aborted by malicious party +#[derive(Debug, Error)] +enum KeygenAborted { + #[error("Frost keygen error")] + FrostError { + parties: Vec, + error: frost_core::Error, + }, +} /// Sign protocol error #[derive(Debug, Error)] +enum SignAborted { + #[error("Frost sign error")] + FrostError { + parties: Vec, + error: frost_core::Error, + }, + #[error("Invalid frost protocol")] + InvalidFrostProtocol, +} + +/// Keygen protocol error +#[derive(Debug, Error)] #[error("keygen protocol is failed to complete")] -pub struct SignError(#[source] Reason); +pub struct KeygenError(#[source] Reason); -macro_rules! impl_sign_error_from { - ($ciphersuite:ty) => { - impl From> for SignError<$ciphersuite> { - fn from(err: SignAborted<$ciphersuite>) -> Self { - SignError(Reason::SignFailure(err)) +impl From> for KeygenError { + fn from(err: frost_core::Error) -> Self { + match err { + frost_core::Error::::InvalidProofOfKnowledge { culprit } => { + let culprit_bytes: Vec = culprit.serialize().as_ref().to_vec(); + let culprit = u16::from_le_bytes([culprit_bytes[0], culprit_bytes[1]]); + KeygenError(Reason::KeygenFailure(KeygenAborted::FrostError { + parties: vec![culprit], + error: err, + })) } + _ => KeygenError(Reason::KeygenFailure(KeygenAborted::FrostError { + parties: vec![], + error: err, + })), } + } +} - impl From for SignError<$ciphersuite> { - fn from(err: IoError) -> Self { - SignError(Reason::IoError(err)) - } - } - }; +impl From for KeygenError { + fn from(err: IoError) -> Self { + KeygenError(Reason::IoError(err)) + } } -impl_sign_error_from!(Ed25519Sha512); -impl_sign_error_from!(P256Sha256); -impl_sign_error_from!(P384Sha384); -impl_sign_error_from!(Ristretto255Sha512); -impl_sign_error_from!(Secp256K1Sha256); -impl_sign_error_from!(Ed448Shake256); +impl From> for KeygenError { + fn from(err: KeygenAborted) -> Self { + KeygenError(Reason::KeygenFailure(err)) + } +} -/// Repair protocol error +/// Sign protocol error #[derive(Debug, Error)] -#[error("repair protocol is failed to complete")] -pub struct RepairError(Reason); - -macro_rules! impl_repair_error_from { - ($ciphersuite:ty) => { - impl From for RepairError<$ciphersuite> { - fn from(err: IoError) -> Self { - RepairError(Reason::IoError(err)) +#[error("keygen protocol is failed to complete")] +pub struct SignError(#[source] Reason); + +impl From> for SignError { + fn from(err: frost_core::Error) -> Self { + match err { + frost_core::Error::::InvalidSignatureShare { culprit } => { + let culprit_bytes: Vec = culprit.serialize().as_ref().to_vec(); + let culprit = u16::from_le_bytes([culprit_bytes[0], culprit_bytes[1]]); + SignError(Reason::SignFailure(SignAborted::FrostError { + parties: vec![culprit], + error: err, + })) } + _ => SignError(Reason::SignFailure(SignAborted::FrostError { + parties: vec![], + error: err, + })), } - }; + } } -impl_repair_error_from!(Ed25519Sha512); -impl_repair_error_from!(P256Sha256); -impl_repair_error_from!(P384Sha384); -impl_repair_error_from!(Ristretto255Sha512); -impl_repair_error_from!(Secp256K1Sha256); -impl_repair_error_from!(Ed448Shake256); +impl From for SignError { + fn from(err: IoError) -> Self { + SignError(Reason::IoError(err)) + } +} + +impl From> for SignError { + fn from(err: SignAborted) -> Self { + SignError(Reason::SignFailure(err)) + } +} #[derive(Debug, Error)] enum Reason { @@ -111,23 +159,3 @@ enum Reason { #[error("unknown error")] SerializationError, } - -/// Error indicating that protocol was aborted by malicious party -#[derive(Debug, Error)] -enum KeygenAborted { - #[error("Frost keygen error")] - FrostError { - parties: Vec, - error: frost_core::Error, - }, -} - -/// Sign protocol error -#[derive(Debug, Error)] -enum SignAborted { - #[error("Frost sign error")] - FrostError { - parties: Vec, - error: frost_core::Error, - }, -} diff --git a/protocols/zcash-frost/src/rounds/sign.rs b/protocols/zcash-frost/src/rounds/sign.rs index 6597a60c7..e27e12051 100644 --- a/protocols/zcash-frost/src/rounds/sign.rs +++ b/protocols/zcash-frost/src/rounds/sign.rs @@ -14,8 +14,7 @@ use serde::{Deserialize, Serialize}; use std::collections::BTreeMap; use tangle_primitives::roles::ThresholdSignatureRoleType; -use super::errors::IoError; -use super::{Reason, SignAborted, SignError}; +use super::{IoError, Reason, SignAborted, SignError}; /// Message of key generation protocol #[derive(ProtocolMessage, Clone, Serialize, Deserialize)] @@ -28,7 +27,7 @@ pub enum Msg { } /// Message from round 1 -#[derive(Clone, Serialize, Deserialize, udigest::Digestable)] +#[derive(Clone, Debug, Serialize, Deserialize, udigest::Digestable)] #[serde(bound = "")] #[udigest(bound = "")] #[udigest(tag = "zcash.frost.sign.threshold.round1")] @@ -36,7 +35,7 @@ pub struct MsgRound1 { pub msg: Vec, } /// Message from round 2 -#[derive(Clone, Serialize, Deserialize, udigest::Digestable)] +#[derive(Clone, Debug, Serialize, Deserialize, udigest::Digestable)] #[serde(bound = "")] #[udigest(bound = "")] #[udigest(tag = "zcash.frost.sign.threshold.round2")] @@ -81,14 +80,20 @@ where tracer.send_msg(); tracer.stage("Generate nonces and commitments for Round 1"); - let (nonces, commitments) = participant_round1(role, &frost_keyshare.0, rng); + let (nonces, commitments) = participant_round1(role, &frost_keyshare.0, rng)?; let my_round1_msg = MsgRound1 { msg: commitments.serialize().unwrap_or_default(), }; + println!( + " for party {:?}: <{:#?}, {:#?}>", + i, + frost_keyshare.0.identifier(), + commitments + ); outgoings .send(Outgoing::broadcast(Msg::Round1(my_round1_msg.clone()))) .await - .map_err(|e| SignError(Reason::IoError(IoError::send_message(e))))?; + .map_err(IoError::send_message)?; tracer.msg_sent(); // Round 2 @@ -98,20 +103,25 @@ where let round1_msgs: Vec = rounds .complete(round1) .await - .map_err(|e| SignError(Reason::IoError(IoError::receive_message(e))))? + .map_err(IoError::receive_message)? .into_vec_including_me(my_round1_msg); - let round1_signing_commitments: BTreeMap, SigningCommitments> = round1_msgs + let round1_signing_commitments = round1_msgs .into_iter() .enumerate() .map(|(party_inx, msg)| { - let msg = SigningCommitments::::deserialize(&msg.msg) - .unwrap_or_else(|_| panic!("Failed to deserialize round 1 signing commitments")); let participant_identifier = Identifier::::try_from((party_inx + 1) as u16) .expect("Failed to convert party index to identifier"); + let msg = SigningCommitments::::deserialize(&msg.msg) + .unwrap_or_else(|_| panic!("Failed to deserialize round 1 signing commitments")); (participant_identifier, msg) }) .collect(); + + println!( + "Received signing commitments: {:#?}", + round1_signing_commitments + ); tracer.msgs_received(); tracer.send_msg(); @@ -125,7 +135,7 @@ where msg: signature_share.serialize().as_ref().to_vec(), }))) .await - .map_err(|e| SignError(Reason::IoError(IoError::send_message(e))))?; + .map_err(IoError::send_message)?; tracer.msg_sent(); // Aggregation / output round @@ -158,13 +168,7 @@ where &signing_package, &round2_signature_shares, &frost_keyshare.1, - ) - .map_err(|e| { - SignError(Reason::SignFailure(SignAborted::FrostError { - parties: vec![], - error: e, - })) - })?; + )?; if frost_keyshare .1 @@ -185,21 +189,30 @@ where }) } -/// Participant generates nonces and commitments for Round 1. -fn participant_round1( - role: ThresholdSignatureRoleType, - key_package: &KeyPackage, - rng: &mut R, -) -> (SigningNonces, SigningCommitments) { +fn validate_role(role: ThresholdSignatureRoleType) -> Result<(), SignError> { match role { ThresholdSignatureRoleType::ZcashFrostEd25519 + | ThresholdSignatureRoleType::ZcashFrostEd448 + | ThresholdSignatureRoleType::ZcashFrostSecp256k1 | ThresholdSignatureRoleType::ZcashFrostP256 - | ThresholdSignatureRoleType::ZcashFrostRistretto255 - | ThresholdSignatureRoleType::ZcashFrostSecp256k1 => {} - _ => panic!("Invalid role"), + | ThresholdSignatureRoleType::ZcashFrostP384 + | ThresholdSignatureRoleType::ZcashFrostRistretto255 => {} + _ => Err(SignError(Reason::SignFailure( + SignAborted::InvalidFrostProtocol, + )))?, }; - round1::commit(key_package.signing_share(), rng) + Ok(()) +} + +/// Participant generates nonces and commitments for Round 1. +fn participant_round1( + role: ThresholdSignatureRoleType, + key_package: &KeyPackage, + rng: &mut R, +) -> Result<(SigningNonces, SigningCommitments), SignError> { + validate_role::(role)?; + Ok(round1::commit(key_package.signing_share(), rng)) } /// Participant produces their signature share using the `SigningPackage` and their `SigningNonces` from Round 1. @@ -209,19 +222,7 @@ fn participant_round2( nonces: &SigningNonces, key_package: &KeyPackage, ) -> Result, SignError> { - match role { - ThresholdSignatureRoleType::ZcashFrostEd25519 - | ThresholdSignatureRoleType::ZcashFrostP256 - | ThresholdSignatureRoleType::ZcashFrostRistretto255 - | ThresholdSignatureRoleType::ZcashFrostSecp256k1 => {} - _ => panic!("Invalid role"), - }; - - println!("Min signers: {:?}", key_package.min_signers()); - println!( - "Signing package commits: {:?}", - signing_package.signing_commitments().len() - ); + validate_role::(role)?; round2::sign(signing_package, nonces, key_package).map_err(|e| { SignError(Reason::SignFailure(SignAborted::FrostError { parties: vec![],