From 659926cad347ea3f9ed2f4e925777fb5af60e637 Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Wed, 27 Mar 2024 06:12:57 +1100 Subject: [PATCH] Remove impls of ThirtyTwoByteHash for `hashes` types These impls make using secp with hashes and bitcoin difficult during upgrade, or if different versions of the libs get pulled in for any reason. Since we do not use these impls in `rust-bitcoin` (we implement the trait manually for sighash types) lets just remove them for now. Note the implementations were a previous attempt at fixing this problem, we refereed to it as the "dependency hole" because secp the repository is outside of `rust-bitcoin` repo but `hashes` and `bitcoin` are in it. Close: #673 --- src/lib.rs | 35 ----------------------------------- 1 file changed, 35 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 9a092b526..ddc36a632 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -176,8 +176,6 @@ use core::{fmt, mem, str}; #[cfg(feature = "global-context")] pub use context::global::SECP256K1; -#[cfg(feature = "hashes")] -use hashes::Hash; #[cfg(feature = "rand")] pub use rand; pub use secp256k1_sys as ffi; @@ -198,21 +196,6 @@ pub trait ThirtyTwoByteHash { fn into_32(self) -> [u8; 32]; } -#[cfg(feature = "hashes")] -impl ThirtyTwoByteHash for hashes::sha256::Hash { - fn into_32(self) -> [u8; 32] { self.to_byte_array() } -} - -#[cfg(feature = "hashes")] -impl ThirtyTwoByteHash for hashes::sha256d::Hash { - fn into_32(self) -> [u8; 32] { self.to_byte_array() } -} - -#[cfg(feature = "hashes")] -impl ThirtyTwoByteHash for hashes::sha256t::Hash { - fn into_32(self) -> [u8; 32] { self.to_byte_array() } -} - /// A (hashed) message input to an ECDSA signature. #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct Message([u8; constants::MESSAGE_SIZE]); @@ -1038,24 +1021,6 @@ mod tests { let sig = SECP256K1.sign_ecdsa(&msg, &sk); assert!(SECP256K1.verify_ecdsa(&msg, &sig, &pk).is_ok()); } - - #[cfg(feature = "hashes")] - #[test] - fn test_from_hash() { - use hashes::{sha256, sha256d, Hash}; - - let test_bytes = "Hello world!".as_bytes(); - - let hash = sha256::Hash::hash(test_bytes); - let msg = Message::from(hash); - assert_eq!(msg.0, hash.to_byte_array()); - assert_eq!(msg, Message::from_hashed_data::(test_bytes)); - - let hash = sha256d::Hash::hash(test_bytes); - let msg = Message::from(hash); - assert_eq!(msg.0, hash.to_byte_array()); - assert_eq!(msg, Message::from_hashed_data::(test_bytes)); - } } #[cfg(bench)]