From 1d6a46eb6d42eb3d4685535bcc8bfa1c3afe2133 Mon Sep 17 00:00:00 2001 From: Andrew Poelstra Date: Thu, 8 Dec 2022 14:20:51 +0000 Subject: [PATCH] change bitcoin-hashes feature gates to bitcoin_hashes Fixes #562. --- src/key.rs | 6 +++--- src/lib.rs | 20 ++++++++++---------- src/secret.rs | 4 ++-- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/key.rs b/src/key.rs index 10cabbe..0ada090 100644 --- a/src/key.rs +++ b/src/key.rs @@ -31,7 +31,7 @@ use crate::Error::{self, InvalidPublicKey, InvalidPublicKeySum, InvalidSecretKey use crate::{constants, from_hex, Scalar, Secp256k1, Signing, Verification}; #[cfg(feature = "global-context")] use crate::{ecdsa, Message, SECP256K1}; -#[cfg(feature = "bitcoin-hashes")] +#[cfg(feature = "bitcoin_hashes")] use crate::{hashes, ThirtyTwoByteHash}; /// Secret 256-bit key used as `x` in an ECDSA signature. @@ -284,7 +284,7 @@ impl SecretKey { /// assert_eq!(sk1, sk2); /// # } /// ``` - #[cfg(feature = "bitcoin-hashes")] + #[cfg(feature = "bitcoin_hashes")] #[cfg_attr(docsrs, doc(cfg(feature = "bitcoin-hashes")))] #[inline] pub fn from_hashed_data(data: &[u8]) -> Self { @@ -383,7 +383,7 @@ impl SecretKey { } } -#[cfg(feature = "bitcoin-hashes")] +#[cfg(feature = "bitcoin_hashes")] impl From for SecretKey { /// Converts a 32-byte hash directly to a secret key without error paths. fn from(t: T) -> SecretKey { diff --git a/src/lib.rs b/src/lib.rs index 125c60c..22e879e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -140,8 +140,8 @@ //! * `alloc` - use the `alloc` standard Rust library to provide heap allocations. //! * `rand` - use `rand` library to provide random generator (e.g. to generate keys). //! * `rand-std` - use `rand` library with its `std` feature enabled. (Implies `rand`.) -//! * `bitcoin-hashes` - use the `bitcoin-hashes` library. -//! * `bitcoin-hashes-std` - use the `bitcoin-hashes` library with its `std` feature enabled (implies `bitcoin-hashes`). +//! * `bitcoin-hashes` - use the `bitcoin_hashes` library. +//! * `bitcoin-hashes-std` - use the `bitcoin_hashes` library with its `std` feature enabled (implies `bitcoin-hashes`). //! * `recovery` - enable functions that can compute the public key from signature. //! * `lowmemory` - optimize the library for low-memory environments. //! * `global-context` - enable use of global secp256k1 context (implies `std`). @@ -183,7 +183,7 @@ use core::marker::PhantomData; use core::ptr::NonNull; use core::{fmt, mem, str}; -#[cfg(feature = "bitcoin-hashes")] +#[cfg(feature = "bitcoin_hashes")] #[cfg_attr(docsrs, doc(cfg(feature = "bitcoin-hashes")))] pub use bitcoin_hashes as hashes; #[cfg(feature = "global-context")] @@ -200,7 +200,7 @@ pub use serde; pub use crate::context::*; use crate::ffi::types::AlignedType; use crate::ffi::CPtr; -#[cfg(feature = "bitcoin-hashes")] +#[cfg(feature = "bitcoin_hashes")] use crate::hashes::Hash; pub use crate::key::{PublicKey, SecretKey, *}; pub use crate::scalar::Scalar; @@ -213,19 +213,19 @@ pub trait ThirtyTwoByteHash { fn into_32(self) -> [u8; 32]; } -#[cfg(feature = "bitcoin-hashes")] +#[cfg(feature = "bitcoin_hashes")] #[cfg_attr(docsrs, doc(cfg(feature = "bitcoin-hashes")))] impl ThirtyTwoByteHash for hashes::sha256::Hash { fn into_32(self) -> [u8; 32] { self.into_inner() } } -#[cfg(feature = "bitcoin-hashes")] +#[cfg(feature = "bitcoin_hashes")] #[cfg_attr(docsrs, doc(cfg(feature = "bitcoin-hashes")))] impl ThirtyTwoByteHash for hashes::sha256d::Hash { fn into_32(self) -> [u8; 32] { self.into_inner() } } -#[cfg(feature = "bitcoin-hashes")] +#[cfg(feature = "bitcoin_hashes")] #[cfg_attr(docsrs, doc(cfg(feature = "bitcoin-hashes")))] impl ThirtyTwoByteHash for hashes::sha256t::Hash { fn into_32(self) -> [u8; 32] { self.into_inner() } @@ -263,7 +263,7 @@ impl Message { /// # Examples /// /// ``` - /// # #[cfg(feature = "bitcoin-hashes")] { + /// # #[cfg(feature = "bitcoin_hashes")] { /// use secp256k1::hashes::{sha256, Hash}; /// use secp256k1::Message; /// @@ -274,7 +274,7 @@ impl Message { /// assert_eq!(m1, m2); /// # } /// ``` - #[cfg(feature = "bitcoin-hashes")] + #[cfg(feature = "bitcoin_hashes")] #[cfg_attr(docsrs, doc(cfg(feature = "bitcoin-hashes")))] pub fn from_hashed_data(data: &[u8]) -> Self { ::hash(data).into() @@ -1037,7 +1037,7 @@ mod tests { assert!(SECP256K1.verify_ecdsa(&msg, &sig, &pk).is_ok()); } - #[cfg(feature = "bitcoin-hashes")] + #[cfg(feature = "bitcoin_hashes")] #[test] fn test_from_hash() { use crate::hashes::{self, Hash}; diff --git a/src/secret.rs b/src/secret.rs index e0f3797..93951bc 100644 --- a/src/secret.rs +++ b/src/secret.rs @@ -45,7 +45,7 @@ macro_rules! impl_display_secret { } } - #[cfg(all(not(feature = "std"), feature = "bitcoin-hashes"))] + #[cfg(all(not(feature = "std"), feature = "bitcoin_hashes"))] impl ::core::fmt::Debug for $thing { fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { use crate::hashes::{sha256, Hash, HashEngine}; @@ -63,7 +63,7 @@ macro_rules! impl_display_secret { } } - #[cfg(all(not(feature = "std"), not(feature = "bitcoin-hashes")))] + #[cfg(all(not(feature = "std"), not(feature = "bitcoin_hashes")))] impl ::core::fmt::Debug for $thing { fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { write!(f, "")