Delete deprecated sha256t_hash_newtype macro

This macro is a maintenance burden. We would like to put a tag on the
hash engine but doing so would require breaking this macro anyway so
lets just delete it.
This commit is contained in:
Tobin C. Harding 2025-02-07 07:00:01 +11:00
parent 8464b1452f
commit 613fddc82b
No known key found for this signature in database
GPG Key ID: 40BF9E4C269D6607
1 changed files with 0 additions and 99 deletions

View File

@ -140,105 +140,6 @@ where
Hash::from_byte_array(sha256::Hash::from_engine(e).to_byte_array()) Hash::from_byte_array(sha256::Hash::from_engine(e).to_byte_array())
} }
/// Macro used to define a newtype tagged hash.
///
/// This macro creates two types:
///
/// * a tag struct
/// * a hash wrapper
///
/// The syntax is:
///
/// ```
/// # #[allow(deprecated)] {
/// # use bitcoin_hashes::sha256t_hash_newtype;
/// sha256t_hash_newtype! {
/// /// Optional documentation details here.
/// /// Summary is always generated.
/// pub struct FooTag = hash_str("foo");
///
/// /// A foo hash.
/// // Direction works just like the hash_newtype! macro.
/// #[hash_newtype(backward)]
/// pub struct FooHash(_);
/// }
/// # }
/// ```
///
/// The structs must be defined in this order - tag first, then hash type. `hash_str` marker
/// says the midstate should be generated by hashing the supplied string in a way described in
/// BIP-341. Alternatively, you can supply `hash_bytes` to hash raw bytes. If you have the midstate
/// already pre-computed and prefer **compiler** performance to readability you may use
/// `raw(MIDSTATE_BYTES, HASHED_BYTES_LENGTH)` instead.
///
/// Both visibility modifiers and attributes are optional and passed to inner structs (excluding
/// `#[hash_newtype(...)]`). The attributes suffer same compiler performance limitations as in
/// [`hash_newtype`] macro.
///
/// [`hash_newtype`]: crate::hash_newtype
#[macro_export]
#[deprecated(since = "0.15.0", note = "use `sha256_tag!` combined with `hash_newtype!` instead")]
macro_rules! sha256t_hash_newtype {
($(#[$($tag_attr:tt)*])* $tag_vis:vis struct $tag:ident = $constructor:tt($($tag_value:tt)+); $(#[$($hash_attr:tt)*])* $hash_vis:vis struct $hash_name:ident($(#[$($field_attr:tt)*])* _);) => {
$crate::sha256t_tag_struct!($tag_vis, $tag, stringify!($hash_name), $(#[$($tag_attr)*])*);
impl $crate::sha256t::Tag for $tag {
#[inline]
fn engine() -> $crate::sha256::HashEngine {
const MIDSTATE: $crate::sha256::Midstate = $crate::sha256t_tag_constructor!($constructor, $($tag_value)+);
$crate::sha256::HashEngine::from_midstate(MIDSTATE)
}
}
$crate::hash_newtype! {
$(#[$($hash_attr)*])*
$hash_vis struct $hash_name($(#[$($field_attr)*])* $crate::sha256t::Hash<$tag>);
}
impl $hash_name {
/// Constructs a new engine.
#[allow(unused)] // the user of macro may not need this
pub fn engine() -> <$hash_name as $crate::GeneralHash>::Engine {
<$hash_name as $crate::GeneralHash>::engine()
}
/// Produces a hash from the current state of a given engine.
#[allow(unused)] // the user of macro may not need this
pub fn from_engine(e: <$hash_name as $crate::GeneralHash>::Engine) -> Self {
<$hash_name as $crate::GeneralHash>::from_engine(e)
}
/// Hashes some bytes.
#[allow(unused)] // the user of macro may not need this
pub fn hash(data: &[u8]) -> Self {
<$hash_name as $crate::GeneralHash>::hash(data)
}
/// Hashes all the byte slices retrieved from the iterator together.
#[allow(unused)] // the user of macro may not need this
pub fn hash_byte_chunks<B, I>(byte_slices: I) -> Self
where
B: AsRef<[u8]>,
I: IntoIterator<Item = B>,
{
<$hash_name as $crate::GeneralHash>::hash_byte_chunks(byte_slices)
}
}
impl $crate::GeneralHash for $hash_name {
type Engine = <$crate::sha256t::Hash<$tag> as $crate::GeneralHash>::Engine;
fn engine() -> Self::Engine {
<$crate::sha256t::Hash<$tag> as $crate::GeneralHash>::engine()
}
fn from_engine(e: Self::Engine) -> $hash_name {
Self::from(<$crate::sha256t::Hash<$tag> as $crate::GeneralHash>::from_engine(e))
}
}
}
}
// Workaround macros being unavailable in attributes. // Workaround macros being unavailable in attributes.
#[doc(hidden)] #[doc(hidden)]
#[macro_export] #[macro_export]