diff --git a/frost-core/src/frost.rs b/frost-core/src/frost.rs index 4fee9e3..aaa5727 100644 --- a/frost-core/src/frost.rs +++ b/frost-core/src/frost.rs @@ -212,6 +212,7 @@ fn derive_interpolating_value( /// each signing party #[derive(Clone, Debug, PartialEq, Eq, Getters)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(bound = "C: Ciphersuite"))] #[cfg_attr(feature = "serde", serde(deny_unknown_fields))] pub struct SigningPackage { /// Serialization header @@ -301,7 +302,7 @@ where #[cfg(feature = "serialization")] impl SigningPackage where - C: Ciphersuite + serde::Serialize + for<'de> serde::Deserialize<'de>, + C: Ciphersuite, { /// Serialize the struct into a Vec. pub fn serialize(&self) -> Result, Error> { diff --git a/frost-core/src/frost/identifier.rs b/frost-core/src/frost/identifier.rs index 8febb05..9ff2bdd 100644 --- a/frost-core/src/frost/identifier.rs +++ b/frost-core/src/frost/identifier.rs @@ -17,6 +17,7 @@ use crate::ScalarSerialization; /// field, as f(0) = the shared secret. #[derive(Copy, Clone, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(bound = "C: Ciphersuite"))] #[cfg_attr(feature = "serde", serde(try_from = "ScalarSerialization"))] #[cfg_attr(feature = "serde", serde(into = "ScalarSerialization"))] pub struct Identifier(Scalar); diff --git a/frost-core/src/frost/keys.rs b/frost-core/src/frost/keys.rs index 54e54fd..e315ecd 100644 --- a/frost-core/src/frost/keys.rs +++ b/frost-core/src/frost/keys.rs @@ -49,6 +49,7 @@ pub(crate) fn default_identifiers(max_signers: u16) -> Vec(pub(crate) Scalar); @@ -146,6 +147,7 @@ where /// A public group element that represents a single signer's public verification share. #[derive(Copy, Clone, PartialEq, Eq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(bound = "C: Ciphersuite"))] #[cfg_attr(feature = "serde", serde(try_from = "ElementSerialization"))] #[cfg_attr(feature = "serde", serde(into = "ElementSerialization"))] pub struct VerifyingShare(pub(super) Element) @@ -229,6 +231,7 @@ where /// verifiable secret sharing for a Shamir secret share. #[derive(Clone, Copy, PartialEq, Eq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(bound = "C: Ciphersuite"))] #[cfg_attr(feature = "serde", serde(try_from = "ElementSerialization"))] #[cfg_attr(feature = "serde", serde(into = "ElementSerialization"))] pub struct CoefficientCommitment(pub(crate) Element); @@ -302,6 +305,7 @@ where /// ensure that they received the correct (and same) value. #[derive(Clone, Debug, PartialEq, Eq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(bound = "C: Ciphersuite"))] pub struct VerifiableSecretSharingCommitment( pub(crate) Vec>, ); @@ -350,6 +354,7 @@ where /// .into(), which under the hood also performs validation. #[derive(Clone, Debug, Zeroize, PartialEq, Eq, Getters)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(bound = "C: Ciphersuite"))] #[cfg_attr(feature = "serde", serde(deny_unknown_fields))] pub struct SecretShare { /// Serialization header @@ -416,7 +421,7 @@ where #[cfg(feature = "serialization")] impl SecretShare where - C: Ciphersuite + serde::Serialize + for<'de> serde::Deserialize<'de>, + C: Ciphersuite, { /// Serialize the struct into a Vec. pub fn serialize(&self) -> Result, Error> { @@ -567,6 +572,7 @@ fn evaluate_vss( /// [`KeyPackage`]s, which they store to later use during signing. #[derive(Clone, Debug, PartialEq, Eq, Getters, Zeroize)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(bound = "C: Ciphersuite"))] #[cfg_attr(feature = "serde", serde(deny_unknown_fields))] pub struct KeyPackage { /// Serialization header @@ -612,7 +618,7 @@ where #[cfg(feature = "serialization")] impl KeyPackage where - C: Ciphersuite + serde::Serialize + for<'de> serde::Deserialize<'de>, + C: Ciphersuite, { /// Serialize the struct into a Vec. pub fn serialize(&self) -> Result, Error> { @@ -659,6 +665,7 @@ where /// Used for verification purposes before publishing a signature. #[derive(Clone, Debug, PartialEq, Eq, Getters)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(bound = "C: Ciphersuite"))] #[cfg_attr(feature = "serde", serde(deny_unknown_fields))] pub struct PublicKeyPackage { /// Serialization header @@ -691,7 +698,7 @@ where #[cfg(feature = "serialization")] impl PublicKeyPackage where - C: Ciphersuite + serde::Serialize + for<'de> serde::Deserialize<'de>, + C: Ciphersuite, { /// Serialize the struct into a Vec. pub fn serialize(&self) -> Result, Error> { diff --git a/frost-core/src/frost/keys/dkg.rs b/frost-core/src/frost/keys/dkg.rs index 2f62730..b99f0d4 100644 --- a/frost-core/src/frost/keys/dkg.rs +++ b/frost-core/src/frost/keys/dkg.rs @@ -58,6 +58,7 @@ pub mod round1 { /// between the first and second parts of the DKG protocol (round 1). #[derive(Clone, Debug, PartialEq, Eq, Getters)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] + #[cfg_attr(feature = "serde", serde(bound = "C: Ciphersuite"))] #[cfg_attr(feature = "serde", serde(deny_unknown_fields))] pub struct Package { /// Serialization header @@ -89,7 +90,7 @@ pub mod round1 { #[cfg(feature = "serialization")] impl Package where - C: Ciphersuite + serde::Serialize + for<'de> serde::Deserialize<'de>, + C: Ciphersuite, { /// Serialize the struct into a Vec. pub fn serialize(&self) -> Result, Error> { @@ -168,6 +169,7 @@ pub mod round2 { /// The package must be sent on an *confidential* and *authenticated* channel. #[derive(Clone, Debug, PartialEq, Eq, Getters)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] + #[cfg_attr(feature = "serde", serde(bound = "C: Ciphersuite"))] #[cfg_attr(feature = "serde", serde(deny_unknown_fields))] pub struct Package { /// Serialization header @@ -193,7 +195,7 @@ pub mod round2 { #[cfg(feature = "serialization")] impl Package where - C: Ciphersuite + serde::Serialize + for<'de> serde::Deserialize<'de>, + C: Ciphersuite, { /// Serialize the struct into a Vec. pub fn serialize(&self) -> Result, Error> { diff --git a/frost-core/src/frost/round1.rs b/frost-core/src/frost/round1.rs index 5feee2f..1aba6a0 100644 --- a/frost-core/src/frost/round1.rs +++ b/frost-core/src/frost/round1.rs @@ -108,6 +108,7 @@ where /// A group element that is a commitment to a signing nonce share. #[derive(Clone, Copy, PartialEq, Eq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(bound = "C: Ciphersuite"))] #[cfg_attr(feature = "serde", serde(try_from = "ElementSerialization"))] #[cfg_attr(feature = "serde", serde(into = "ElementSerialization"))] pub struct NonceCommitment(pub(super) Element); @@ -268,6 +269,7 @@ where /// SigningCommitment can be used for exactly *one* signature. #[derive(Copy, Clone, Debug, Eq, PartialEq, Getters)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(bound = "C: Ciphersuite"))] #[cfg_attr(feature = "serde", serde(deny_unknown_fields))] pub struct SigningCommitments { /// Serialization header @@ -308,7 +310,7 @@ where #[cfg(feature = "serialization")] impl SigningCommitments where - C: Ciphersuite + serde::Serialize + for<'de> serde::Deserialize<'de>, + C: Ciphersuite, { /// Serialize the struct into a Vec. pub fn serialize(&self) -> Result, Error> { diff --git a/frost-core/src/frost/round2.rs b/frost-core/src/frost/round2.rs index a9a3021..019530a 100644 --- a/frost-core/src/frost/round2.rs +++ b/frost-core/src/frost/round2.rs @@ -16,6 +16,7 @@ use crate::ScalarSerialization; #[cfg(feature = "serde")] #[derive(Clone)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(bound = "C: Ciphersuite"))] #[cfg_attr(feature = "serde", serde(try_from = "ScalarSerialization"))] #[cfg_attr(feature = "serde", serde(into = "ScalarSerialization"))] struct SignatureShareHelper(Scalar); @@ -48,6 +49,7 @@ where /// shares into the joint signature. #[derive(Clone, Copy, Eq, PartialEq, Getters)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(bound = "C: Ciphersuite"))] #[cfg_attr(feature = "serde", serde(deny_unknown_fields))] #[cfg_attr(feature = "serde", serde(try_from = "SignatureShareSerialization"))] #[cfg_attr(feature = "serde", serde(into = "SignatureShareSerialization"))] @@ -104,6 +106,7 @@ where #[cfg(feature = "serde")] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(bound = "C: Ciphersuite"))] #[cfg_attr(feature = "serde", serde(deny_unknown_fields))] struct SignatureShareSerialization { /// Serialization header diff --git a/frost-core/src/verifying_key.rs b/frost-core/src/verifying_key.rs index 2932613..b5cb24b 100644 --- a/frost-core/src/verifying_key.rs +++ b/frost-core/src/verifying_key.rs @@ -11,6 +11,7 @@ use crate::ElementSerialization; /// A valid verifying key for Schnorr signatures over a FROST [`Ciphersuite::Group`]. #[derive(Copy, Clone, PartialEq, Eq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(bound = "C: Ciphersuite"))] #[cfg_attr(feature = "serde", serde(try_from = "ElementSerialization"))] #[cfg_attr(feature = "serde", serde(into = "ElementSerialization"))] pub struct VerifyingKey diff --git a/frost-ed25519/src/lib.rs b/frost-ed25519/src/lib.rs index a1212a6..aae0855 100644 --- a/frost-ed25519/src/lib.rs +++ b/frost-ed25519/src/lib.rs @@ -18,9 +18,6 @@ use sha2::{Digest, Sha512}; use frost_core::frost; -#[cfg(feature = "serde")] -use frost_core::serde; - #[cfg(test)] mod tests; @@ -155,8 +152,6 @@ const CONTEXT_STRING: &str = "FROST-ED25519-SHA512-v1"; /// An implementation of the FROST(Ed25519, SHA-512) ciphersuite. #[derive(Clone, Copy, PartialEq, Eq, Debug)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -#[cfg_attr(feature = "serde", serde(crate = "self::serde"))] pub struct Ed25519Sha512; impl Ciphersuite for Ed25519Sha512 { diff --git a/frost-ed448/src/lib.rs b/frost-ed448/src/lib.rs index 6cc4ee0..eddec87 100644 --- a/frost-ed448/src/lib.rs +++ b/frost-ed448/src/lib.rs @@ -19,9 +19,6 @@ use sha3::{ use frost_core::frost; -#[cfg(feature = "serde")] -use frost_core::serde; - #[cfg(test)] mod tests; @@ -150,8 +147,6 @@ const CONTEXT_STRING: &str = "FROST-ED448-SHAKE256-v1"; /// An implementation of the FROST(Ed448, SHAKE256) ciphersuite. #[derive(Clone, Copy, PartialEq, Eq, Debug)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -#[cfg_attr(feature = "serde", serde(crate = "self::serde"))] pub struct Ed448Shake256; impl Ciphersuite for Ed448Shake256 { diff --git a/frost-p256/src/lib.rs b/frost-p256/src/lib.rs index 914eecf..dc9d382 100644 --- a/frost-p256/src/lib.rs +++ b/frost-p256/src/lib.rs @@ -20,9 +20,6 @@ use sha2::{Digest, Sha256}; use frost_core::frost; -#[cfg(feature = "serde")] -use frost_core::serde; - #[cfg(test)] mod tests; @@ -175,8 +172,6 @@ const CONTEXT_STRING: &str = "FROST-P256-SHA256-v1"; /// An implementation of the FROST(P-256, SHA-256) ciphersuite. #[derive(Clone, Copy, PartialEq, Eq, Debug)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -#[cfg_attr(feature = "serde", serde(crate = "self::serde"))] pub struct P256Sha256; impl Ciphersuite for P256Sha256 { diff --git a/frost-rerandomized/src/lib.rs b/frost-rerandomized/src/lib.rs index 0e33379..3fec51c 100644 --- a/frost-rerandomized/src/lib.rs +++ b/frost-rerandomized/src/lib.rs @@ -150,6 +150,7 @@ where /// A randomizer. A random scalar which is used to randomize the key. #[derive(Copy, Clone, PartialEq, Eq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(bound = "C: Ciphersuite"))] #[cfg_attr(feature = "serde", serde(try_from = "ScalarSerialization"))] #[cfg_attr(feature = "serde", serde(into = "ScalarSerialization"))] #[cfg_attr(feature = "serde", serde(crate = "self::serde"))] diff --git a/frost-ristretto255/src/lib.rs b/frost-ristretto255/src/lib.rs index 35ebb1e..26d7362 100644 --- a/frost-ristretto255/src/lib.rs +++ b/frost-ristretto255/src/lib.rs @@ -15,9 +15,6 @@ use sha2::{Digest, Sha512}; use frost_core::frost; -#[cfg(feature = "serde")] -use frost_core::serde; - #[cfg(test)] mod tests; @@ -141,8 +138,6 @@ const CONTEXT_STRING: &str = "FROST-RISTRETTO255-SHA512-v1"; /// An implementation of the FROST(ristretto255, SHA-512) ciphersuite. #[derive(Clone, Copy, PartialEq, Eq, Debug)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -#[cfg_attr(feature = "serde", serde(crate = "self::serde"))] pub struct Ristretto255Sha512; impl Ciphersuite for Ristretto255Sha512 { diff --git a/frost-secp256k1/src/lib.rs b/frost-secp256k1/src/lib.rs index 092294e..9ecba56 100644 --- a/frost-secp256k1/src/lib.rs +++ b/frost-secp256k1/src/lib.rs @@ -21,9 +21,6 @@ use sha2::{Digest, Sha256}; use frost_core::frost; -#[cfg(feature = "serde")] -use frost_core::serde; - #[cfg(test)] mod tests; @@ -175,8 +172,6 @@ const CONTEXT_STRING: &str = "FROST-secp256k1-SHA256-v1"; /// An implementation of the FROST(secp256k1, SHA-256) ciphersuite. #[derive(Clone, Copy, PartialEq, Eq, Debug)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -#[cfg_attr(feature = "serde", serde(crate = "self::serde"))] pub struct Secp256K1Sha256; impl Ciphersuite for Secp256K1Sha256 {