2828//! trigger any assertion failures in the upstream library.
2929//!
3030//! ```rust
31- //! # #[cfg(all(feature = "rand-std", feature = "bitcoin- hashes-std"))] {
31+ //! # #[cfg(all(feature = "rand-std", feature = "hashes-std"))] {
3232//! use secp256k1::rand::rngs::OsRng;
3333//! use secp256k1::{Secp256k1, Message};
3434//! use secp256k1::hashes::sha256;
4545//! If the "global-context" feature is enabled you have access to an alternate API.
4646//!
4747//! ```rust
48- //! # #[cfg(all(feature = "global-context", feature = "bitcoin- hashes-std", feature = "rand-std"))] {
48+ //! # #[cfg(all(feature = "global-context", feature = "hashes-std", feature = "rand-std"))] {
4949//! use secp256k1::{generate_keypair, Message};
5050//! use secp256k1::hashes::sha256;
5151//!
5757//! # }
5858//! ```
5959//!
60- //! The above code requires `rust-secp256k1` to be compiled with the `rand-std` and `bitcoin- hashes-std`
60+ //! The above code requires `rust-secp256k1` to be compiled with the `rand-std` and `hashes-std`
6161//! feature enabled, to get access to [`generate_keypair`](struct.Secp256k1.html#method.generate_keypair)
6262//! Alternately, keys and messages can be parsed from slices, like
6363//!
6969//! let secret_key = SecretKey::from_slice(&[0xcd; 32]).expect("32 bytes, within curve order");
7070//! let public_key = PublicKey::from_secret_key(&secp, &secret_key);
7171//! // This is unsafe unless the supplied byte slice is the output of a cryptographic hash function.
72- //! // See the above example for how to use this library together with `bitcoin- hashes-std`.
72+ //! // See the above example for how to use this library together with `hashes-std`.
7373//! let message = Message::from_digest_slice(&[0xab; 32]).expect("32 bytes");
7474//!
7575//! let sig = secp.sign_ecdsa(&message, &secret_key);
127127//! * `alloc` - use the `alloc` standard Rust library to provide heap allocations.
128128//! * `rand` - use `rand` library to provide random generator (e.g. to generate keys).
129129//! * `rand-std` - use `rand` library with its `std` feature enabled. (Implies `rand`.)
130- //! * `bitcoin- hashes` - use the `bitcoin_hashes ` library.
131- //! * `bitcoin- hashes-std` - use the `bitcoin_hashes ` library with its `std` feature enabled (implies `bitcoin- hashes`).
130+ //! * `hashes` - use the `hashes ` library.
131+ //! * `hashes-std` - use the `hashes ` library with its `std` feature enabled (implies `hashes`).
132132//! * `recovery` - enable functions that can compute the public key from signature.
133133//! * `lowmemory` - optimize the library for low-memory environments.
134134//! * `global-context` - enable use of global secp256k1 context (implies `std`).
@@ -151,6 +151,9 @@ extern crate core;
151151#[ cfg( bench) ]
152152extern crate test;
153153
154+ #[ cfg( feature = "hashes" ) ]
155+ pub extern crate hashes;
156+
154157#[ macro_use]
155158mod macros;
156159#[ macro_use]
@@ -170,10 +173,10 @@ use core::marker::PhantomData;
170173use core:: ptr:: NonNull ;
171174use core:: { fmt, mem, str} ;
172175
173- #[ cfg( feature = "bitcoin_hashes" ) ]
174- pub use bitcoin_hashes as hashes;
175176#[ cfg( feature = "global-context" ) ]
176177pub use context:: global:: SECP256K1 ;
178+ #[ cfg( feature = "hashes" ) ]
179+ use hashes:: Hash ;
177180#[ cfg( feature = "rand" ) ]
178181pub use rand;
179182pub use secp256k1_sys as ffi;
@@ -183,8 +186,6 @@ pub use serde;
183186pub use crate :: context:: * ;
184187use crate :: ffi:: types:: AlignedType ;
185188use crate :: ffi:: CPtr ;
186- #[ cfg( feature = "bitcoin_hashes" ) ]
187- use crate :: hashes:: Hash ;
188189pub use crate :: key:: { PublicKey , SecretKey , * } ;
189190pub use crate :: scalar:: Scalar ;
190191
@@ -196,17 +197,17 @@ pub trait ThirtyTwoByteHash {
196197 fn into_32 ( self ) -> [ u8 ; 32 ] ;
197198}
198199
199- #[ cfg( feature = "bitcoin_hashes " ) ]
200+ #[ cfg( feature = "hashes " ) ]
200201impl ThirtyTwoByteHash for hashes:: sha256:: Hash {
201202 fn into_32 ( self ) -> [ u8 ; 32 ] { self . to_byte_array ( ) }
202203}
203204
204- #[ cfg( feature = "bitcoin_hashes " ) ]
205+ #[ cfg( feature = "hashes " ) ]
205206impl ThirtyTwoByteHash for hashes:: sha256d:: Hash {
206207 fn into_32 ( self ) -> [ u8 ; 32 ] { self . to_byte_array ( ) }
207208}
208209
209- #[ cfg( feature = "bitcoin_hashes " ) ]
210+ #[ cfg( feature = "hashes " ) ]
210211impl < T : hashes:: sha256t:: Tag > ThirtyTwoByteHash for hashes:: sha256t:: Hash < T > {
211212 fn into_32 ( self ) -> [ u8 ; 32 ] { self . to_byte_array ( ) }
212213}
@@ -268,12 +269,12 @@ impl Message {
268269
269270 /// Constructs a [`Message`] by hashing `data` with hash algorithm `H`.
270271 ///
271- /// Requires the feature `bitcoin- hashes` to be enabled.
272+ /// Requires the feature `hashes` to be enabled.
272273 ///
273274 /// # Examples
274275 ///
275276 /// ```
276- /// # #[cfg(feature = "bitcoin_hashes ")] {
277+ /// # #[cfg(feature = "hashes ")] {
277278 /// use secp256k1::hashes::{sha256, Hash};
278279 /// use secp256k1::Message;
279280 ///
@@ -284,7 +285,7 @@ impl Message {
284285 /// assert_eq!(m1, m2);
285286 /// # }
286287 /// ```
287- #[ cfg( feature = "bitcoin_hashes " ) ]
288+ #[ cfg( feature = "hashes " ) ]
288289 pub fn from_hashed_data < H : ThirtyTwoByteHash + hashes:: Hash > ( data : & [ u8 ] ) -> Self {
289290 <H as hashes:: Hash >:: hash ( data) . into ( )
290291 }
@@ -1042,19 +1043,19 @@ mod tests {
10421043 assert ! ( SECP256K1 . verify_ecdsa( & msg, & sig, & pk) . is_ok( ) ) ;
10431044 }
10441045
1045- #[ cfg( feature = "bitcoin_hashes " ) ]
1046+ #[ cfg( feature = "hashes " ) ]
10461047 #[ test]
10471048 fn test_from_hash ( ) {
1048- use crate :: hashes:: { self , Hash } ;
1049+ use hashes:: { sha256 , sha256d , Hash } ;
10491050
10501051 let test_bytes = "Hello world!" . as_bytes ( ) ;
10511052
1052- let hash = hashes :: sha256:: Hash :: hash ( test_bytes) ;
1053+ let hash = sha256:: Hash :: hash ( test_bytes) ;
10531054 let msg = Message :: from ( hash) ;
10541055 assert_eq ! ( msg. 0 , hash. to_byte_array( ) ) ;
10551056 assert_eq ! ( msg, Message :: from_hashed_data:: <hashes:: sha256:: Hash >( test_bytes) ) ;
10561057
1057- let hash = hashes :: sha256d:: Hash :: hash ( test_bytes) ;
1058+ let hash = sha256d:: Hash :: hash ( test_bytes) ;
10581059 let msg = Message :: from ( hash) ;
10591060 assert_eq ! ( msg. 0 , hash. to_byte_array( ) ) ;
10601061 assert_eq ! ( msg, Message :: from_hashed_data:: <hashes:: sha256d:: Hash >( test_bytes) ) ;
0 commit comments