Skip to content

Commit 6baad08

Browse files
committed
hashes: remove deprecated macro
This macro provided very little savings in lines of code, and wasn't worth the obfuscation.
1 parent dca9bb0 commit 6baad08

1 file changed

Lines changed: 29 additions & 9 deletions

File tree

src/taproot.rs

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,41 @@ use crate::hashes::HashEngine as _;
2020
use crate::schnorr::{UntweakedPublicKey, TweakedPublicKey, TapTweak};
2121
use crate::Script;
2222
use std::collections::{BTreeMap, BTreeSet, BinaryHeap};
23-
use hashes::sha256t;
23+
use hashes::{sha256, sha256t};
2424
use secp256k1_zkp::{self, Secp256k1, Scalar};
2525
use crate::encode::Encodable;
2626

27-
hashes::sha256t_tag! {
28-
pub struct TapLeafTag = hash_str("TapLeaf/elements");
27+
28+
/// The tag for tapleaves.
29+
#[derive(Copy, Clone, PartialEq, Eq, Default, PartialOrd, Ord, Hash)]
30+
pub struct TapLeafTag;
31+
32+
/// The tag for tapbranches.
33+
#[derive(Copy, Clone, PartialEq, Eq, Default, PartialOrd, Ord, Hash)]
34+
pub struct TapBranchTag;
35+
36+
/// The tag for taptweaks.
37+
#[derive(Copy, Clone, PartialEq, Eq, Default, PartialOrd, Ord, Hash)]
38+
pub struct TapTweakTag;
39+
40+
/// The tag for Taproot sighashes.
41+
#[derive(Copy, Clone, PartialEq, Eq, Default, PartialOrd, Ord, Hash)]
42+
pub struct TapSighashTag;
43+
44+
impl sha256t::Tag for TapLeafTag {
45+
const MIDSTATE: sha256::Midstate = sha256::Midstate::hash_tag(b"TapLeaf/elements");
2946
}
30-
hashes::sha256t_tag! {
31-
pub struct TapBranchTag = hash_str("TapBranch/elements");
47+
48+
impl sha256t::Tag for TapBranchTag {
49+
const MIDSTATE: sha256::Midstate = sha256::Midstate::hash_tag(b"TapBranch/elements");
3250
}
33-
hashes::sha256t_tag! {
34-
pub struct TapTweakTag = hash_str("TapTweak/elements");
51+
52+
impl sha256t::Tag for TapTweakTag {
53+
const MIDSTATE: sha256::Midstate = sha256::Midstate::hash_tag(b"TapTweak/elements");
3554
}
36-
hashes::sha256t_tag! {
37-
pub struct TapSighashTag = hash_str("TapSighash/elements");
55+
56+
impl sha256t::Tag for TapSighashTag {
57+
const MIDSTATE: sha256::Midstate = sha256::Midstate::hash_tag(b"TapSighash/elements");
3858
}
3959

4060
// Taproot test vectors from BIP-341 state the hashes without any reversing

0 commit comments

Comments
 (0)