From 3b5f3f4600c4709052089c61aa326923034a77f3 Mon Sep 17 00:00:00 2001 From: Jacinta Ferrant Date: Wed, 10 Jan 2024 13:52:51 -0500 Subject: [PATCH] Derive partial eq for a Packet struct and its descendents Signed-off-by: Jacinta Ferrant --- src/common.rs | 4 ++-- src/net.rs | 24 ++++++++++++------------ src/schnorr.rs | 2 +- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/common.rs b/src/common.rs index 57f846a9..14e6989d 100644 --- a/src/common.rs +++ b/src/common.rs @@ -20,7 +20,7 @@ use crate::{ /// A merkle root is a 256 bit hash pub type MerkleRoot = [u8; 32]; -#[derive(Clone, Debug, Deserialize, Serialize)] +#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)] /// A commitment to a polynonial, with a Schnorr proof of ownership bound to the ID pub struct PolyCommitment { /// The party ID with a schnorr proof @@ -115,7 +115,7 @@ impl Display for PublicNonce { } } -#[derive(Clone, Debug, Deserialize, Serialize)] +#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)] /// A share of the party signature with related values pub struct SignatureShare { /// The ID of the party diff --git a/src/net.rs b/src/net.rs index 7d408472..77ec4520 100644 --- a/src/net.rs +++ b/src/net.rs @@ -43,7 +43,7 @@ pub trait Signable { } } -#[derive(Clone, Serialize, Deserialize, Debug)] +#[derive(Clone, Serialize, Deserialize, Debug, PartialEq)] /// Final DKG status after receiving public and private shares pub enum DkgStatus { /// DKG completed successfully @@ -52,7 +52,7 @@ pub enum DkgStatus { Failure(String), } -#[derive(Clone, Serialize, Deserialize, Debug)] +#[derive(Clone, Serialize, Deserialize, Debug, PartialEq)] /// Encapsulation of all possible network message types pub enum Message { /// Tell signers to begin DKG by sending DKG public shares @@ -75,7 +75,7 @@ pub enum Message { SignatureShareResponse(SignatureShareResponse), } -#[derive(Clone, Serialize, Deserialize, Debug)] +#[derive(Clone, Serialize, Deserialize, Debug, PartialEq)] /// DKG begin message from coordinator to signers pub struct DkgBegin { /// DKG round ID @@ -89,7 +89,7 @@ impl Signable for DkgBegin { } } -#[derive(Clone, Serialize, Deserialize, Debug)] +#[derive(Clone, Serialize, Deserialize, Debug, PartialEq)] /// DKG public shares message from signer to all signers and coordinator pub struct DkgPublicShares { /// DKG round ID @@ -114,7 +114,7 @@ impl Signable for DkgPublicShares { } } -#[derive(Clone, Serialize, Deserialize, Debug)] +#[derive(Clone, Serialize, Deserialize, Debug, PartialEq)] /// DKG private begin message from signer to all signers and coordinator pub struct DkgPrivateBegin { /// DKG round ID @@ -133,7 +133,7 @@ impl Signable for DkgPrivateBegin { } } -#[derive(Clone, Serialize, Deserialize, Debug)] +#[derive(Clone, Serialize, Deserialize, Debug, PartialEq)] /// DKG private shares message from signer to all signers and coordinator pub struct DkgPrivateShares { /// DKG round ID @@ -160,7 +160,7 @@ impl Signable for DkgPrivateShares { } } -#[derive(Clone, Serialize, Deserialize, Debug)] +#[derive(Clone, Serialize, Deserialize, Debug, PartialEq)] /// DKG end message from signers to coordinator pub struct DkgEnd { /// DKG round ID @@ -179,7 +179,7 @@ impl Signable for DkgEnd { } } -#[derive(Clone, Serialize, Deserialize, Debug)] +#[derive(Clone, Serialize, Deserialize, Debug, PartialEq)] /// Nonce request message from coordinator to signers pub struct NonceRequest { /// DKG round ID @@ -210,7 +210,7 @@ impl Signable for NonceRequest { } } -#[derive(Clone, Serialize, Deserialize, Debug)] +#[derive(Clone, Serialize, Deserialize, Debug, PartialEq)] /// Nonce response message from signers to coordinator pub struct NonceResponse { /// DKG round ID @@ -246,7 +246,7 @@ impl Signable for NonceResponse { } } -#[derive(Clone, Serialize, Deserialize, Debug)] +#[derive(Clone, Serialize, Deserialize, Debug, PartialEq)] /// Signature share request message from coordinator to signers pub struct SignatureShareRequest { /// DKG round ID @@ -284,7 +284,7 @@ impl Signable for SignatureShareRequest { } } -#[derive(Clone, Serialize, Deserialize, Debug)] +#[derive(Clone, Serialize, Deserialize, Debug, PartialEq)] /// Signature share response message from signers to coordinator pub struct SignatureShareResponse { /// DKG round ID @@ -313,7 +313,7 @@ impl Signable for SignatureShareResponse { } } -#[derive(Serialize, Deserialize, Debug, Clone)] +#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)] /// Network packets need to be signed so they can be verified pub struct Packet { /// The message to sign diff --git a/src/schnorr.rs b/src/schnorr.rs index e0051d26..a1e32c64 100644 --- a/src/schnorr.rs +++ b/src/schnorr.rs @@ -11,7 +11,7 @@ use crate::{ }; #[allow(non_snake_case)] -#[derive(Clone, Debug, Deserialize, Serialize)] +#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)] /// ID type which encapsulates the ID and a schnorr proof of ownership of the polynomial pub struct ID { /// The ID