diff --git a/src/key.rs b/src/key.rs index ef45f2d..962d710 100644 --- a/src/key.rs +++ b/src/key.rs @@ -100,8 +100,8 @@ pub const ONE_KEY: SecretKey = SecretKey(constants::ONE); /// ``` /// [`bincode`]: https://docs.rs/bincode /// [`cbor`]: https://docs.rs/cbor -#[derive(Copy, Clone, PartialEq, Eq, Debug, Hash)] -#[cfg_attr(fuzzing, derive(PartialOrd, Ord))] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(fuzzing, derive(PartialOrd, Ord, PartialEq, Eq, Hash))] #[repr(transparent)] pub struct PublicKey(ffi::PublicKey); @@ -814,6 +814,24 @@ impl Ord for PublicKey { } } +#[cfg(not(fuzzing))] +impl PartialEq for PublicKey { + fn eq(&self, other: &Self) -> bool { + self.cmp(other) == core::cmp::Ordering::Equal + } +} + +#[cfg(not(fuzzing))] +impl Eq for PublicKey {} + +#[cfg(not(fuzzing))] +impl core::hash::Hash for PublicKey { + fn hash(&self, state: &mut H) { + let ser = self.serialize(); + ser.hash(state); + } +} + /// Opaque data structure that holds a keypair consisting of a secret and a public key. /// /// # Serde support