Skip to content

Commit cd62343

Browse files
committed
Merge #326: Bump bitcoin_hashes to version 0.10
bc42529 Rename `secp256k1::bitcoin_hashes` module to `secp256k1::hashes` (Thomas Eizinger) ae1f8f4 Bump bitcoin_hashes to version 0.10 (Thomas Eizinger) Pull request description: Requires for interoperability of the `ThirtyTwoByteHash` trait with rust-bitcoin. ACKs for top commit: apoelstra: ACK bc42529 Tree-SHA512: 85fcb284ff82b543a0c3ea2b568351b3af938a26ac42c6a975480ae97def84e4f0795105bd4572f930a7bf82654eba416cf0c5e25f62809e2ea331443ffb5807
2 parents c72e7cc + bc42529 commit cd62343

File tree

3 files changed

+20
-17
lines changed

3 files changed

+20
-17
lines changed

CHANGELOG.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Unreleased
2+
3+
* Rename `secp256k1::bitcoin_hashes` module to `secp256k1::hashes` to align with `bitcoin` crate naming.
14

25
# 0.20.3 - 2021-06-10
36

@@ -35,7 +38,7 @@
3538
# 0.18.0 - 2020-08-26
3639

3740
* Add feature-gated `bitcoin_hashes` dependency and [`ThirtyTwoByteHash` trait](https://github.com/rust-bitcoin/rust-secp256k1/pull/206/)
38-
* Add feature-gated [global static context](https://github.com/rust-bitcoin/rust-secp256k1/pull/224)
41+
* Add feature-gated [global static context](https://github.com/rust-bitcoin/rust-secp256k1/pull/224)
3942
* Allow [all-zero messages](https://github.com/rust-bitcoin/rust-secp256k1/pull/207) to be constructed
4043
* Bump rust-secp-sys to 0.2.0
4144

Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ global-context-less-secure = []
3030

3131
[dependencies]
3232
secp256k1-sys = { version = "0.4.1", default-features = false, path = "./secp256k1-sys" }
33-
bitcoin_hashes = { version = "0.9", optional = true }
33+
bitcoin_hashes = { version = "0.10", optional = true }
3434
rand = { version = "0.6", default-features = false, optional = true }
3535
serde = { version = "1.0", default-features = false, optional = true }
3636

@@ -39,7 +39,7 @@ serde = { version = "1.0", default-features = false, optional = true }
3939
rand = "0.6"
4040
rand_core = "0.4"
4141
serde_test = "1.0"
42-
bitcoin_hashes = "0.9"
42+
bitcoin_hashes = "0.10"
4343

4444
[target.wasm32-unknown-unknown.dev-dependencies]
4545
wasm-bindgen-test = "0.3"

src/lib.rs

+14-14
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
//! # #[cfg(all(feature="rand", feature="bitcoin_hashes"))] {
4141
//! use secp256k1::rand::rngs::OsRng;
4242
//! use secp256k1::{Secp256k1, Message};
43-
//! use secp256k1::bitcoin_hashes::sha256;
43+
//! use secp256k1::hashes::sha256;
4444
//!
4545
//! let secp = Secp256k1::new();
4646
//! let mut rng = OsRng::new().expect("OsRng");
@@ -126,7 +126,7 @@
126126
pub extern crate secp256k1_sys;
127127
pub use secp256k1_sys as ffi;
128128

129-
#[cfg(feature = "bitcoin_hashes")] pub extern crate bitcoin_hashes;
129+
#[cfg(feature = "bitcoin_hashes")] pub extern crate bitcoin_hashes as hashes;
130130
#[cfg(all(test, feature = "unstable"))] extern crate test;
131131
#[cfg(any(test, feature = "rand"))] pub extern crate rand;
132132
#[cfg(any(test))] extern crate rand_core;
@@ -163,7 +163,7 @@ use ffi::{CPtr, types::AlignedType};
163163
pub use context::global::SECP256K1;
164164

165165
#[cfg(feature = "bitcoin_hashes")]
166-
use bitcoin_hashes::Hash;
166+
use hashes::Hash;
167167

168168
/// An ECDSA signature
169169
#[derive(Copy, Clone, PartialEq, Eq)]
@@ -212,21 +212,21 @@ pub trait ThirtyTwoByteHash {
212212
}
213213

214214
#[cfg(feature = "bitcoin_hashes")]
215-
impl ThirtyTwoByteHash for bitcoin_hashes::sha256::Hash {
215+
impl ThirtyTwoByteHash for hashes::sha256::Hash {
216216
fn into_32(self) -> [u8; 32] {
217217
self.into_inner()
218218
}
219219
}
220220

221221
#[cfg(feature = "bitcoin_hashes")]
222-
impl ThirtyTwoByteHash for bitcoin_hashes::sha256d::Hash {
222+
impl ThirtyTwoByteHash for hashes::sha256d::Hash {
223223
fn into_32(self) -> [u8; 32] {
224224
self.into_inner()
225225
}
226226
}
227227

228228
#[cfg(feature = "bitcoin_hashes")]
229-
impl<T: bitcoin_hashes::sha256t::Tag> ThirtyTwoByteHash for bitcoin_hashes::sha256t::Hash<T> {
229+
impl<T: hashes::sha256t::Tag> ThirtyTwoByteHash for hashes::sha256t::Hash<T> {
230230
fn into_32(self) -> [u8; 32] {
231231
self.into_inner()
232232
}
@@ -497,8 +497,8 @@ impl Message {
497497
/// assert_eq!(m1, m2);
498498
/// ```
499499
#[cfg(feature = "bitcoin_hashes")]
500-
pub fn from_hashed_data<H: ThirtyTwoByteHash + bitcoin_hashes::Hash>(data: &[u8]) -> Self {
501-
<H as bitcoin_hashes::Hash>::hash(data).into()
500+
pub fn from_hashed_data<H: ThirtyTwoByteHash + hashes::Hash>(data: &[u8]) -> Self {
501+
<H as hashes::Hash>::hash(data).into()
502502
}
503503
}
504504

@@ -1291,25 +1291,25 @@ mod tests {
12911291
#[cfg(feature = "bitcoin_hashes")]
12921292
#[test]
12931293
fn test_from_hash() {
1294-
use bitcoin_hashes;
1295-
use bitcoin_hashes::Hash;
1294+
use hashes;
1295+
use hashes::Hash;
12961296

12971297
let test_bytes = "Hello world!".as_bytes();
12981298

1299-
let hash = bitcoin_hashes::sha256::Hash::hash(test_bytes);
1299+
let hash = hashes::sha256::Hash::hash(test_bytes);
13001300
let msg = Message::from(hash);
13011301
assert_eq!(msg.0, hash.into_inner());
13021302
assert_eq!(
13031303
msg,
1304-
Message::from_hashed_data::<bitcoin_hashes::sha256::Hash>(test_bytes)
1304+
Message::from_hashed_data::<hashes::sha256::Hash>(test_bytes)
13051305
);
13061306

1307-
let hash = bitcoin_hashes::sha256d::Hash::hash(test_bytes);
1307+
let hash = hashes::sha256d::Hash::hash(test_bytes);
13081308
let msg = Message::from(hash);
13091309
assert_eq!(msg.0, hash.into_inner());
13101310
assert_eq!(
13111311
msg,
1312-
Message::from_hashed_data::<bitcoin_hashes::sha256d::Hash>(test_bytes)
1312+
Message::from_hashed_data::<hashes::sha256d::Hash>(test_bytes)
13131313
);
13141314
}
13151315
}

0 commit comments

Comments
 (0)