diff --git a/secp256k1-sys/src/lib.rs b/secp256k1-sys/src/lib.rs index bbe30eb..b4b1cf9 100644 --- a/secp256k1-sys/src/lib.rs +++ b/secp256k1-sys/src/lib.rs @@ -133,6 +133,7 @@ impl SchnorrSigExtraParams { /// Library-internal representation of a Secp256k1 public key #[repr(C)] #[derive(Copy, Clone)] +#[cfg_attr(fuzzing, derive(PartialEq, Eq, PartialOrd, Ord, Hash))] pub struct PublicKey([c_uchar; 64]); impl_array_newtype!(PublicKey, c_uchar, 64); impl_raw_debug!(PublicKey); @@ -227,6 +228,7 @@ impl core::hash::Hash for PublicKey { /// Library-internal representation of a Secp256k1 signature #[repr(C)] #[derive(Copy, Clone)] +#[cfg_attr(fuzzing, derive(PartialEq, Eq, PartialOrd, Ord, Hash))] pub struct Signature([c_uchar; 64]); impl_array_newtype!(Signature, c_uchar, 64); impl_raw_debug!(Signature); @@ -315,6 +317,7 @@ impl core::hash::Hash for Signature { #[repr(C)] #[derive(Copy, Clone)] +#[cfg_attr(fuzzing, derive(PartialEq, Eq, PartialOrd, Ord, Hash))] pub struct XOnlyPublicKey([c_uchar; 64]); impl_array_newtype!(XOnlyPublicKey, c_uchar, 64); impl_raw_debug!(XOnlyPublicKey); @@ -404,6 +407,7 @@ impl core::hash::Hash for XOnlyPublicKey { #[repr(C)] #[derive(Copy, Clone)] +#[cfg_attr(fuzzing, derive(PartialEq, Eq, PartialOrd, Ord, Hash))] pub struct KeyPair([c_uchar; 96]); impl_array_newtype!(KeyPair, c_uchar, 96); impl_raw_debug!(KeyPair); diff --git a/secp256k1-sys/src/macros.rs b/secp256k1-sys/src/macros.rs index 35734fc..3f97245 100644 --- a/secp256k1-sys/src/macros.rs +++ b/secp256k1-sys/src/macros.rs @@ -45,42 +45,6 @@ macro_rules! impl_array_newtype { } } - // We cannot derive these traits because Rust 1.41.1 requires `std::array::LengthAtMost32`. - - #[cfg(fuzzing)] - impl PartialEq for $thing { - #[inline] - fn eq(&self, other: &$thing) -> bool { - &self[..] == &other[..] - } - } - - #[cfg(fuzzing)] - impl Eq for $thing {} - - #[cfg(fuzzing)] - impl core::hash::Hash for $thing { - fn hash(&self, state: &mut H) { - (&self[..]).hash(state) - } - } - - #[cfg(fuzzing)] - impl PartialOrd for $thing { - #[inline] - fn partial_cmp(&self, other: &$thing) -> Option { - self[..].partial_cmp(&other[..]) - } - } - - #[cfg(fuzzing)] - impl Ord for $thing { - #[inline] - fn cmp(&self, other: &$thing) -> core::cmp::Ordering { - self[..].cmp(&other[..]) - } - } - impl AsRef<[$ty; $len]> for $thing { #[inline] /// Gets a reference to the underlying array diff --git a/secp256k1-sys/src/recovery.rs b/secp256k1-sys/src/recovery.rs index 606c3b1..637cbe5 100644 --- a/secp256k1-sys/src/recovery.rs +++ b/secp256k1-sys/src/recovery.rs @@ -22,6 +22,7 @@ use core::fmt; /// Library-internal representation of a Secp256k1 signature + recovery ID #[repr(C)] #[derive(Copy, Clone)] +#[cfg_attr(fuzzing, derive(PartialEq, Eq, PartialOrd, Ord, Hash))] pub struct RecoverableSignature([c_uchar; 65]); impl_array_newtype!(RecoverableSignature, c_uchar, 65);