Skip to content

Commit

Permalink
feat(ferveo): derive eq in DkgPublicKey
Browse files Browse the repository at this point in the history
  • Loading branch information
piotr-roslaniec committed Oct 31, 2023
1 parent 13d9d26 commit 52efe01
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 13 deletions.
12 changes: 2 additions & 10 deletions ferveo-common/src/keypair.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,7 @@ impl<E: Pairing> PublicKey<E> {

impl<E: Pairing> PartialOrd for PublicKey<E> {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
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))
}
}

Expand Down Expand Up @@ -102,7 +94,7 @@ pub struct Keypair<E: Pairing> {

impl<E: Pairing> PartialOrd for Keypair<E> {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
self.decryption_key.partial_cmp(&other.decryption_key)
Some(self.cmp(other))
}
}

Expand Down
2 changes: 1 addition & 1 deletion ferveo/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ impl From<bindings_wasm::FerveoVariant> 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,
);
Expand Down
2 changes: 1 addition & 1 deletion ferveo/src/dkg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub struct DkgValidator<E: Pairing> {

impl<E: Pairing> PartialOrd for DkgValidator<E> {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
self.share_index.partial_cmp(&other.share_index)
Some(self.cmp(other))
}
}

Expand Down
2 changes: 1 addition & 1 deletion ferveo/src/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ pub struct Validator<E: Pairing> {

impl<E: Pairing> PartialOrd for Validator<E> {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
self.address.partial_cmp(&other.address)
Some(self.cmp(other))
}
}

Expand Down

0 comments on commit 52efe01

Please sign in to comment.