Skip to content

Commit 659926c

Browse files
committed
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
1 parent fb676dc commit 659926c

File tree

1 file changed

+0
-35
lines changed

1 file changed

+0
-35
lines changed

src/lib.rs

-35
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,6 @@ use core::{fmt, mem, str};
176176

177177
#[cfg(feature = "global-context")]
178178
pub use context::global::SECP256K1;
179-
#[cfg(feature = "hashes")]
180-
use hashes::Hash;
181179
#[cfg(feature = "rand")]
182180
pub use rand;
183181
pub use secp256k1_sys as ffi;
@@ -198,21 +196,6 @@ pub trait ThirtyTwoByteHash {
198196
fn into_32(self) -> [u8; 32];
199197
}
200198

201-
#[cfg(feature = "hashes")]
202-
impl ThirtyTwoByteHash for hashes::sha256::Hash {
203-
fn into_32(self) -> [u8; 32] { self.to_byte_array() }
204-
}
205-
206-
#[cfg(feature = "hashes")]
207-
impl ThirtyTwoByteHash for hashes::sha256d::Hash {
208-
fn into_32(self) -> [u8; 32] { self.to_byte_array() }
209-
}
210-
211-
#[cfg(feature = "hashes")]
212-
impl<T: hashes::sha256t::Tag> ThirtyTwoByteHash for hashes::sha256t::Hash<T> {
213-
fn into_32(self) -> [u8; 32] { self.to_byte_array() }
214-
}
215-
216199
/// A (hashed) message input to an ECDSA signature.
217200
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
218201
pub struct Message([u8; constants::MESSAGE_SIZE]);
@@ -1038,24 +1021,6 @@ mod tests {
10381021
let sig = SECP256K1.sign_ecdsa(&msg, &sk);
10391022
assert!(SECP256K1.verify_ecdsa(&msg, &sig, &pk).is_ok());
10401023
}
1041-
1042-
#[cfg(feature = "hashes")]
1043-
#[test]
1044-
fn test_from_hash() {
1045-
use hashes::{sha256, sha256d, Hash};
1046-
1047-
let test_bytes = "Hello world!".as_bytes();
1048-
1049-
let hash = sha256::Hash::hash(test_bytes);
1050-
let msg = Message::from(hash);
1051-
assert_eq!(msg.0, hash.to_byte_array());
1052-
assert_eq!(msg, Message::from_hashed_data::<hashes::sha256::Hash>(test_bytes));
1053-
1054-
let hash = sha256d::Hash::hash(test_bytes);
1055-
let msg = Message::from(hash);
1056-
assert_eq!(msg.0, hash.to_byte_array());
1057-
assert_eq!(msg, Message::from_hashed_data::<hashes::sha256d::Hash>(test_bytes));
1058-
}
10591024
}
10601025

10611026
#[cfg(bench)]

0 commit comments

Comments
 (0)