From 52efe010264bdd5978111e148190359b9383d53e Mon Sep 17 00:00:00 2001
From: Piotr Roslaniec
Date: Tue, 31 Oct 2023 14:11:41 +0100
Subject: [PATCH] feat(ferveo): derive eq in DkgPublicKey
---
ferveo-common/src/keypair.rs | 12 ++----------
ferveo/src/api.rs | 2 +-
ferveo/src/dkg.rs | 2 +-
ferveo/src/validator.rs | 2 +-
4 files changed, 5 insertions(+), 13 deletions(-)
diff --git a/ferveo-common/src/keypair.rs b/ferveo-common/src/keypair.rs
index 485241b3..9b251125 100644
--- a/ferveo-common/src/keypair.rs
+++ b/ferveo-common/src/keypair.rs
@@ -61,15 +61,7 @@ impl PublicKey {
impl PartialOrd for PublicKey {
fn partial_cmp(&self, other: &Self) -> Option {
- if self.encryption_key.x() == other.encryption_key.x() {
- return self
- .encryption_key
- .y()
- .partial_cmp(&other.encryption_key.y());
- }
- self.encryption_key
- .x()
- .partial_cmp(&other.encryption_key.x())
+ Some(self.cmp(other))
}
}
@@ -102,7 +94,7 @@ pub struct Keypair {
impl PartialOrd for Keypair {
fn partial_cmp(&self, other: &Self) -> Option {
- self.decryption_key.partial_cmp(&other.decryption_key)
+ Some(self.cmp(other))
}
}
diff --git a/ferveo/src/api.rs b/ferveo/src/api.rs
index b2179ee6..3c354bcb 100644
--- a/ferveo/src/api.rs
+++ b/ferveo/src/api.rs
@@ -139,7 +139,7 @@ impl From for FerveoVariant {
}
#[serde_as]
-#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)]
+#[derive(Copy, Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
pub struct DkgPublicKey(
#[serde_as(as = "serialization::SerdeAs")] pub(crate) G1Affine,
);
diff --git a/ferveo/src/dkg.rs b/ferveo/src/dkg.rs
index 9c95d96a..3c9bdf83 100644
--- a/ferveo/src/dkg.rs
+++ b/ferveo/src/dkg.rs
@@ -28,7 +28,7 @@ pub struct DkgValidator {
impl PartialOrd for DkgValidator {
fn partial_cmp(&self, other: &Self) -> Option {
- self.share_index.partial_cmp(&other.share_index)
+ Some(self.cmp(other))
}
}
diff --git a/ferveo/src/validator.rs b/ferveo/src/validator.rs
index fba25f5c..7b014266 100644
--- a/ferveo/src/validator.rs
+++ b/ferveo/src/validator.rs
@@ -49,7 +49,7 @@ pub struct Validator {
impl PartialOrd for Validator {
fn partial_cmp(&self, other: &Self) -> Option {
- self.address.partial_cmp(&other.address)
+ Some(self.cmp(other))
}
}