Skip to content

Commit

Permalink
Add Eq to ciphersuite
Browse files Browse the repository at this point in the history
Signed-off-by: Denis Varlakov <[email protected]>
  • Loading branch information
survived committed Dec 13, 2024
1 parent a84a69a commit fcfc796
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 20 deletions.
10 changes: 2 additions & 8 deletions givre/src/ciphersuite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub use secp256k1::Secp256k1;
/// For the details, refer to [Section 6] of the draft
///
/// [Section 6]: https://www.ietf.org/archive/id/draft-irtf-cfrg-frost-15.html#name-ciphersuites
pub trait Ciphersuite: Sized + Clone + Copy + core::fmt::Debug {
pub trait Ciphersuite: Sized + Clone + Copy + Eq + core::fmt::Debug {
/// Name of the ciphersuite, also known as `contextString` in the draft
const NAME: &'static str;

Expand Down Expand Up @@ -238,7 +238,7 @@ impl<C: Ciphersuite, T: AdditionalEntropy<C>> AdditionalEntropy<C> for &T {
///
/// Point that satisfies [`Ciphersuite::is_normalized`]. Can wrap both `Point<E>` and
/// `NonZero<Point<E>>`.
#[derive(Debug, Clone, Copy)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct NormalizedPoint<C, P>(P, core::marker::PhantomData<C>);

impl<C: Ciphersuite, P: AsRef<Point<C::Curve>>> NormalizedPoint<C, P> {
Expand Down Expand Up @@ -287,12 +287,6 @@ where
self.0.as_ref()
}
}
impl<C, P: core::cmp::PartialEq> core::cmp::PartialEq for NormalizedPoint<C, P> {
fn eq(&self, other: &Self) -> bool {
self.0 == other.0
}
}
impl<C, P: core::cmp::Eq> core::cmp::Eq for NormalizedPoint<C, P> {}

#[cfg(feature = "serde")]
impl<C, P: serde::Serialize> serde::Serialize for NormalizedPoint<C, P> {
Expand Down
2 changes: 1 addition & 1 deletion givre/src/ciphersuite/bitcoin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use super::{Ciphersuite, Secp256k1};
/// FROST ciphersuite that outputs [BIP-340] compliant signatures
///
/// [BIP-340]: https://github.com/bitcoin/bips/blob/master/bip-0340.mediawiki
#[derive(Debug, Clone, Copy)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct Bitcoin;

impl Ciphersuite for Bitcoin {
Expand Down
2 changes: 1 addition & 1 deletion givre/src/ciphersuite/ed25519.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use generic_ec::{NonZero, Point};
use crate::Ciphersuite;

/// FROST(Ed25519, SHA-512) ciphersuite that produces Ed25519-compliant signatures
#[derive(Debug, Clone, Copy)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct Ed25519;

impl Ciphersuite for Ed25519 {
Expand Down
2 changes: 1 addition & 1 deletion givre/src/ciphersuite/secp256k1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use generic_ec::{NonZero, Point};
use crate::Ciphersuite;

/// FROST(secp256k1, SHA-256) ciphersuite
#[derive(Debug, Clone, Copy)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct Secp256k1;

impl Ciphersuite for Secp256k1 {
Expand Down
10 changes: 1 addition & 9 deletions givre/src/signing/aggregate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use crate::{ciphersuite::NormalizedPoint, Ciphersuite, SignerIndex};

use super::{round1::PublicCommitments, round2::SigShare, utils};

#[derive(Debug, Clone, Copy)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[cfg_attr(
feature = "serde",
derive(serde::Serialize, serde::Deserialize),
Expand Down Expand Up @@ -86,14 +86,6 @@ impl<C: Ciphersuite> Signature<C> {
}
}

impl<C: Ciphersuite> PartialEq for Signature<C> {
fn eq(&self, other: &Self) -> bool {
let Signature { r, z } = self;
*r == other.r && *z == other.z
}
}
impl<C: Ciphersuite> Eq for Signature<C> {}

/// Aggregation options
///
/// Like [`aggregate`] but allows to specify additional options like the HD derivation path
Expand Down

0 comments on commit fcfc796

Please sign in to comment.