diff --git a/secp256k1-sys/src/lib.rs b/secp256k1-sys/src/lib.rs index 0a961f4..4f0f0d5 100644 --- a/secp256k1-sys/src/lib.rs +++ b/secp256k1-sys/src/lib.rs @@ -36,7 +36,7 @@ pub mod types; #[cfg(feature = "recovery")] pub mod recovery; -use core::{hash, slice, ptr}; +use core::{slice, ptr}; use types::*; /// Flag for context to enable no precomputation @@ -133,12 +133,6 @@ impl PublicKey { } } -impl hash::Hash for PublicKey { - fn hash(&self, state: &mut H) { - state.write(&self.0) - } -} - /// Library-internal representation of a Secp256k1 signature #[repr(C)] pub struct Signature([c_uchar; 64]); @@ -210,12 +204,6 @@ impl XOnlyPublicKey { } } -impl hash::Hash for XOnlyPublicKey { - fn hash(&self, state: &mut H) { - state.write(&self.0) - } -} - #[repr(C)] pub struct KeyPair([c_uchar; 96]); impl_array_newtype!(KeyPair, c_uchar, 96); @@ -251,12 +239,6 @@ impl KeyPair { } } -impl hash::Hash for KeyPair { - fn hash(&self, state: &mut H) { - state.write(&self.0) - } -} - extern "C" { /// Default ECDH hash function #[cfg_attr(not(rust_secp_no_symbol_renaming), link_name = "rustsecp256k1_v0_4_1_ecdh_hash_function_default")] diff --git a/secp256k1-sys/src/macros.rs b/secp256k1-sys/src/macros.rs index 5ca0198..47f10df 100644 --- a/secp256k1-sys/src/macros.rs +++ b/secp256k1-sys/src/macros.rs @@ -61,6 +61,12 @@ macro_rules! impl_array_newtype { impl Eq for $thing {} + impl ::core::hash::Hash for $thing { + fn hash(&self, state: &mut H) { + (&self[..]).hash(state) + } + } + impl PartialOrd for $thing { #[inline] fn partial_cmp(&self, other: &$thing) -> Option<::core::cmp::Ordering> {