diff --git a/synedrion/src/cggmp21/protocols.rs b/synedrion/src/cggmp21/protocols.rs index 00c34946..3cf11e48 100644 --- a/synedrion/src/cggmp21/protocols.rs +++ b/synedrion/src/cggmp21/protocols.rs @@ -8,11 +8,9 @@ pub(crate) mod signing; #[cfg(test)] pub(crate) mod signing_malicious; -pub use aux_gen::{AuxGenError, AuxGenProtocol}; -pub use interactive_signing::{ - InteractiveSigningInputs, InteractiveSigningProtocol, InteractiveSigningRound1, -}; -pub use key_init::{KeyInitError, KeyInitProtocol}; -pub use key_refresh::KeyRefreshProtocol; -pub use presigning::{PresigningError, PresigningProof, PresigningProtocol}; -pub use signing::{SigningProof, SigningProtocol}; +pub use aux_gen::{AuxGen, AuxGenProtocol}; +pub use interactive_signing::{InteractiveSigning, InteractiveSigningProtocol}; +pub use key_init::{KeyInit, KeyInitProtocol}; +pub use key_refresh::{KeyRefresh, KeyRefreshProtocol}; +pub use presigning::{Presigning, PresigningProtocol}; +pub use signing::{Signing, SigningProtocol}; diff --git a/synedrion/src/cggmp21/protocols/aux_gen.rs b/synedrion/src/cggmp21/protocols/aux_gen.rs index a9d70b51..fe51ff99 100644 --- a/synedrion/src/cggmp21/protocols/aux_gen.rs +++ b/synedrion/src/cggmp21/protocols/aux_gen.rs @@ -91,68 +91,33 @@ impl ProtocolError for AuxGenError { } } -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(bound(serialize = "PrmProof
: Serialize"))] -#[serde(bound(deserialize = "PrmProof
: for<'x> Deserialize<'x>"))]
-pub struct PublicData1 ,
- rho: BitVec,
- u: BitVec,
-}
-
#[derive(Debug, Clone)]
-pub struct PublicData1Precomp ,
- paillier_pk: PublicKeyPaillierPrecomputed ,
+pub struct AuxGen {
my_id: I,
other_ids: BTreeSet,
- sid_hash: HashOutput,
+ phantom: PhantomData ,
}
-impl {
- fn hash AuxGen {
+ pub fn new(my_id: I, other_ids: BTreeSet) -> Self {
+ Self {
+ my_id,
+ other_ids,
+ phantom: PhantomData,
+ }
}
}
-#[derive(Debug)]
-pub struct Round1 ,
-}
-
-pub struct AuxGenInputs {
- pub other_ids: BTreeSet,
-}
-
-impl {
- type Inputs = AuxGenInputs;
+impl {
type Protocol = AuxGenProtocol ;
- fn new(
+ fn make_round(
+ self,
rng: &mut impl CryptoRngCore,
shared_randomness: &[u8],
- id: I,
- inputs: Self::Inputs,
) -> Result ()
@@ -177,7 +142,7 @@ impl {
// Ring-Pedersen parameters ($s$, $t$) bundled in a single object.
let rp_params = RPParamsMod::random_with_secret(rng, &lambda, paillier_pk);
- let aux = (&sid_hash, &id);
+ let aux = (&sid_hash, &self.my_id);
let hat_psi = PrmProof:: ::new(rng, &paillier_sk, &lambda, &rp_params, &aux);
let rho = BitVec::random(rng, P::SECURITY_PARAMETER);
@@ -204,25 +169,71 @@ impl {
y,
tau_y,
data_precomp,
- my_id: id,
- other_ids: inputs.other_ids,
+ my_id: self.my_id,
+ other_ids: self.other_ids,
sid_hash,
};
- Ok(BoxedRound::new_dynamic(Self { context }))
+ Ok(BoxedRound::new_dynamic(Round1 { context }))
+ }
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+#[serde(bound(serialize = "PrmProof : Serialize"))]
+#[serde(bound(deserialize = "PrmProof : for<'x> Deserialize<'x>"))]
+struct PublicData1 ,
+ rho: BitVec,
+ u: BitVec,
+}
+
+#[derive(Debug, Clone)]
+struct PublicData1Precomp ,
+ paillier_pk: PublicKeyPaillierPrecomputed ,
+ my_id: I,
+ other_ids: BTreeSet,
+ sid_hash: HashOutput,
+}
+
+impl {
+ fn hash ,
+}
+
#[derive(Debug, Clone, Serialize, Deserialize)]
-pub struct Round1Message {
+struct Round1Message {
cap_v: HashOutput,
}
-pub struct Round1Payload {
+struct Round1Payload {
cap_v: HashOutput,
}
-impl {
+impl {
type Protocol = AuxGenProtocol ;
fn id(&self) -> RoundId {
@@ -296,7 +307,7 @@ impl {
}
#[derive(Debug)]
-pub struct Round2 ,
others_cap_v: BTreeMap,
}
@@ -304,15 +315,15 @@ pub struct Round2 : Serialize"))]
#[serde(bound(deserialize = "PublicData1 : for<'x> Deserialize<'x>"))]
-pub struct Round2Message ,
}
-pub struct Round2Payload ,
}
-impl {
+impl {
type Protocol = AuxGenProtocol ;
fn id(&self) -> RoundId {
@@ -414,7 +425,7 @@ impl {
}
#[derive(Debug)]
-pub struct Round3 ,
rho: BitVec,
others_data: BTreeMap>,
@@ -431,13 +442,13 @@ pub struct Round3 : for<'x> Deserialize<'x>,
FacProof : for<'x> Deserialize<'x>,
"))]
-pub struct PublicData2 , // $\psi_i$, a P^{mod} for the Paillier modulus
phi: FacProof ,
pi: SchProof,
}
-impl {
+impl {
fn new(
rng: &mut impl CryptoRngCore,
context: Context ,
@@ -468,7 +479,7 @@ impl {
#[derive(Clone, Serialize, Deserialize)]
#[serde(bound(serialize = "PublicData2 : Serialize"))]
#[serde(bound(deserialize = "PublicData2 : for<'x> Deserialize<'x>"))]
-pub struct Round3Message ,
}
@@ -617,7 +628,7 @@ mod tests {
use rand_core::{OsRng, RngCore};
use secrecy::ExposeSecret;
- use super::{AuxGenInputs, Round1};
+ use super::AuxGen;
use crate::cggmp21::TestParams;
use crate::tools::Without;
@@ -629,23 +640,21 @@ mod tests {
.iter()
.map(|signer| signer.verifying_key())
.collect:: );
+pub type InteractiveSigningProtocol =
+ ChainedProtocol >;
#[derive(Debug, Clone)]
-pub struct InteractiveSigningInputs ,
- pub aux_info: AuxInfo ,
- pub message: Scalar,
+pub struct InteractiveSigning ,
+ aux_info: AuxInfo ,
+ message: Scalar,
}
-impl<'a, P: SchemeParams, Id: PartyId> From<&'a InteractiveSigningInputs >
- for PresigningInputs
-{
- fn from(source: &'a InteractiveSigningInputs ) -> Self {
- PresigningInputs {
- key_share: source.key_share.clone(),
- aux_info: source.aux_info.clone(),
+impl {
+ fn new(message: Scalar, key_share: KeyShare , aux_info: AuxInfo ) -> Self {
+ Self {
+ message,
+ key_share,
+ aux_info,
}
}
}
-impl , PresigningData )>
- for SigningInputs
+impl {
+ type Protocol = InteractiveSigningProtocol ;
+
+ fn entry_round() -> RoundId {
+ >>::entry_round()
+ }
+
+ fn make_round(
+ self,
+ rng: &mut impl CryptoRngCore,
+ shared_randomness: &[u8],
+ ) -> Result ChainedSplit, SigningProtocol >
+ for InteractiveSigning
+where
+ P: SchemeParams,
+ I: PartyId,
{
- fn from(source: (InteractiveSigningInputs , PresigningData )) -> Self {
- let (inputs, presigning) = source;
- SigningInputs {
- message: inputs.message,
- key_share: inputs.key_share,
- aux_info: inputs.aux_info,
- presigning,
- }
+ type EntryPoint = Presigning ;
+ fn make_entry_point1(
+ self,
+ ) -> (
+ Self::EntryPoint,
+ impl ChainedJoin, SigningProtocol >,
+ ) {
+ (
+ Presigning::new(self.key_share.clone(), self.aux_info.clone()),
+ Transition {
+ message: self.message,
+ key_share: self.key_share,
+ aux_info: self.aux_info,
+ },
+ )
}
}
-impl {
- type Inputs = InteractiveSigningInputs ;
- type EntryPoint1 = presigning::Round1 ;
- type EntryPoint2 = signing::Round1 ;
+#[derive(Debug)]
+struct Transition ,
+ aux_info: AuxInfo ,
}
-pub type InteractiveSigningProtocol = ChainedProtocol = ChainedEntryPoint ChainedJoin, SigningProtocol > for Transition
+where
+ P: SchemeParams,
+ I: PartyId,
+{
+ type EntryPoint = Signing ;
+ fn make_entry_point2(
+ self,
+ presigning: {
}
}
-#[derive(Debug)]
-struct Context {
my_id: I,
- x: Scalar,
- tau: SchSecret,
- public_data: PublicData ,
- sid_hash: HashOutput,
-}
-
-#[derive(Debug)]
-pub struct Round1 ,
+ other_ids: BTreeSet,
+ phantom: PhantomData ,
}
-pub struct KeyInitInputs {
- pub other_ids: BTreeSet,
+impl KeyInit {
+ pub fn new(my_id: I, other_ids: BTreeSet) -> Self {
+ Self {
+ my_id,
+ other_ids,
+ phantom: PhantomData,
+ }
+ }
}
-impl {
- type Inputs = KeyInitInputs;
+impl {
type Protocol = KeyInitProtocol ;
- fn new(
+ fn make_round(
+ self,
rng: &mut impl CryptoRngCore,
shared_randomness: &[u8],
- id: I,
- inputs: Self::Inputs,
) -> Result ()
@@ -160,24 +156,39 @@ impl {
};
let context = Context {
- other_ids: inputs.other_ids,
- my_id: id,
+ other_ids: self.other_ids,
+ my_id: self.my_id,
x,
tau,
public_data,
sid_hash,
};
- Ok(BoxedRound::new_dynamic(Self { context }))
+ Ok(BoxedRound::new_dynamic(Round1 { context }))
}
}
+#[derive(Debug)]
+struct Context ,
+ sid_hash: HashOutput,
+}
+
+#[derive(Debug)]
+struct Round1 ,
+}
+
#[derive(Debug, Clone, Serialize, Deserialize)]
-pub struct Round1Message {
+struct Round1Message {
cap_v: HashOutput,
}
-pub struct Round1Payload {
+struct Round1Payload {
cap_v: HashOutput,
}
@@ -246,7 +257,7 @@ impl {
}
#[derive(Debug)]
-pub struct Round2 ,
others_cap_v: BTreeMap,
phantom: PhantomData ,
@@ -255,11 +266,11 @@ pub struct Round2 : Serialize"))]
#[serde(bound(deserialize = "PublicData : for<'x> Deserialize<'x>"))]
-pub struct Round2Message ,
}
-pub struct Round2Payload ,
}
@@ -343,7 +354,7 @@ impl {
}
#[derive(Debug)]
-pub struct Round3 ,
others_data: BTreeMap>,
rid: BitVec,
@@ -351,7 +362,7 @@ pub struct Round3 {
}
}
-#[derive(Debug, Clone, Serialize, Deserialize)]
-#[serde(bound(serialize = "
- PrmProof : Serialize,
- "))]
-#[serde(bound(deserialize = "
- PrmProof : for<'x> Deserialize<'x>,
- "))]
-pub struct PublicData1 ,
- rho: BitVec,
- u: BitVec,
-}
-
#[derive(Debug, Clone)]
-pub struct PublicData1Precomp ,
- paillier_pk: PublicKeyPaillierPrecomputed ,
+pub struct KeyRefresh {
my_id: I,
other_ids: BTreeSet,
- sid_hash: HashOutput,
- ids_ordering: BTreeMap,
+ phantom: PhantomData ,
}
-impl {
- fn hash KeyRefresh {
+ pub fn new(my_id: I, other_ids: BTreeSet) -> Self {
+ Self {
+ my_id,
+ other_ids,
+ phantom: PhantomData,
+ }
}
}
-#[derive(Debug)]
-pub struct Round1 ,
-}
-
-pub struct KeyRefreshInputs {
- pub other_ids: BTreeSet,
-}
-
-impl {
- type Inputs = KeyRefreshInputs;
+impl {
type Protocol = KeyRefreshProtocol ;
- fn new(
+ fn make_round(
+ self,
rng: &mut impl CryptoRngCore,
shared_randomness: &[u8],
- id: I,
- inputs: Self::Inputs,
) -> Result {
// Ring-Pedersen parameters ($s$, $t$) bundled in a single object.
let rp_params = RPParamsMod::random_with_secret(rng, &lambda, paillier_pk);
- let aux = (&sid_hash, &id);
+ let aux = (&sid_hash, &self.my_id);
let hat_psi = PrmProof:: ::new(rng, &paillier_sk, &lambda, &rp_params, &aux);
// The secrets share changes ($\tau_j$, not to be confused with $\tau$)
@@ -252,22 +208,77 @@ impl {
tau_x,
tau_y,
data_precomp,
- my_id: id,
- other_ids: inputs.other_ids,
+ my_id: self.my_id,
+ other_ids: self.other_ids,
sid_hash,
ids_ordering,
};
- Ok(BoxedRound::new_dynamic(Self { context }))
+ Ok(BoxedRound::new_dynamic(Round1 { context }))
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
-pub struct Round1Message {
+#[serde(bound(serialize = "
+ PrmProof : Serialize,
+ "))]
+#[serde(bound(deserialize = "
+ PrmProof : for<'x> Deserialize<'x>,
+ "))]
+struct PublicData1 ,
+ rho: BitVec,
+ u: BitVec,
+}
+
+#[derive(Debug, Clone)]
+struct PublicData1Precomp ,
+ paillier_pk: PublicKeyPaillierPrecomputed ,
+ my_id: I,
+ other_ids: BTreeSet,
+ sid_hash: HashOutput,
+ ids_ordering: BTreeMap,
+}
+
+impl {
+ fn hash ,
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+struct Round1Message {
cap_v: HashOutput,
}
-pub struct Round1Payload {
+struct Round1Payload {
cap_v: HashOutput,
}
@@ -345,7 +356,7 @@ impl {
}
#[derive(Debug)]
-pub struct Round2 ,
others_cap_v: BTreeMap,
}
@@ -353,11 +364,11 @@ pub struct Round2 : Serialize"))]
#[serde(bound(deserialize = "PublicData1 : for<'x> Deserialize<'x>"))]
-pub struct Round2Message ,
}
-pub struct Round2Payload ,
}
@@ -469,7 +480,7 @@ impl {
}
#[derive(Debug)]
-pub struct Round3 ,
rho: BitVec,
others_data: BTreeMap>,
@@ -488,7 +499,7 @@ pub struct Round3 : for<'x> Deserialize<'x>,
Ciphertext