Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ include = ["/src", "!/src/test_vectors", "*.md"]
base16ct = { version = "0.2.0", default-features = false, features = ["alloc"] }
hmac = { version = "0.12.1", default-features = false, features = [] }
k256 = { version = "0.13.1", default-features = false, optional = true }
once_cell = { version = "1.18.0", default-features = false }
rand = { version = "0.8.5", optional = true, default-features = false, features = ["std_rng"] }
secp = { version = "0.4", default-features = false }
secp256k1 = { version = "0.30", optional = true, default-features = false }
Expand Down
42 changes: 21 additions & 21 deletions src/tagged_hashes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
//! assert_eq!(hash, expected);
//! ```

use once_cell::sync::Lazy;
use sha2::Sha256;
use std::sync::LazyLock;

use sha2::Digest as _;

Expand Down Expand Up @@ -107,80 +107,80 @@ const TAPROOT_TWEAK_TAG_DIGEST: [u8; 32] = [
/// ```notrust
/// sha256(b"KeyAgg list") || sha256(b"KeyAgg list")
/// ```
pub static KEYAGG_LIST_TAG_HASHER: Lazy<Sha256> =
Lazy::new(|| with_tag_hash_prefix(KEYAGG_LIST_TAG_DIGEST));
pub static KEYAGG_LIST_TAG_HASHER: LazyLock<Sha256> =
LazyLock::new(|| with_tag_hash_prefix(KEYAGG_LIST_TAG_DIGEST));

/// A `sha2::Sha256` hash engine with its state initialized to:
///
/// ```notrust
/// sha256(b"KeyAgg coefficient") || sha256(b"KeyAgg coefficient")
/// ```
pub static KEYAGG_COEFF_TAG_HASHER: Lazy<Sha256> =
Lazy::new(|| with_tag_hash_prefix(KEYAGG_COEFF_TAG_DIGEST));
pub static KEYAGG_COEFF_TAG_HASHER: LazyLock<Sha256> =
LazyLock::new(|| with_tag_hash_prefix(KEYAGG_COEFF_TAG_DIGEST));

/// A `sha2::Sha256` hash engine with its state initialized to:
///
/// ```notrust
/// sha256(b"MuSig/aux") || sha256(b"MuSig/aux")
/// ```
pub static MUSIG_AUX_TAG_HASHER: Lazy<Sha256> =
Lazy::new(|| with_tag_hash_prefix(MUSIG_AUX_TAG_DIGEST));
pub static MUSIG_AUX_TAG_HASHER: LazyLock<Sha256> =
LazyLock::new(|| with_tag_hash_prefix(MUSIG_AUX_TAG_DIGEST));

/// A `sha2::Sha256` hash engine with its state initialized to:
///
/// ```notrust
/// sha256(b"MuSig/nonce") || sha256(b"MuSig/nonce")
/// ```
pub static MUSIG_NONCE_TAG_HASHER: Lazy<Sha256> =
Lazy::new(|| with_tag_hash_prefix(MUSIG_NONCE_TAG_DIGEST));
pub static MUSIG_NONCE_TAG_HASHER: LazyLock<Sha256> =
LazyLock::new(|| with_tag_hash_prefix(MUSIG_NONCE_TAG_DIGEST));

/// A `sha2::Sha256` hash engine with its state initialized to:
///
/// ```notrust
/// sha256(b"MuSig/noncecoef") || sha256(b"MuSig/noncecoef")
/// ```
pub static MUSIG_NONCECOEF_TAG_HASHER: Lazy<Sha256> =
Lazy::new(|| with_tag_hash_prefix(MUSIG_NONCECOEF_TAG_DIGEST));
pub static MUSIG_NONCECOEF_TAG_HASHER: LazyLock<Sha256> =
LazyLock::new(|| with_tag_hash_prefix(MUSIG_NONCECOEF_TAG_DIGEST));

/// A `sha2::Sha256` hash engine with its state initialized to:
///
/// ```notrust
/// sha256(b"BIP0340/aux") || sha256(b"BIP0340/aux")
/// ```
pub static BIP0340_AUX_TAG_HASHER: Lazy<Sha256> =
Lazy::new(|| with_tag_hash_prefix(BIP0340_AUX_TAG_DIGEST));
pub static BIP0340_AUX_TAG_HASHER: LazyLock<Sha256> =
LazyLock::new(|| with_tag_hash_prefix(BIP0340_AUX_TAG_DIGEST));

/// A `sha2::Sha256` hash engine with its state initialized to:
///
/// ```notrust
/// sha256(b"BIP0340/nonce") || sha256(b"BIP0340/nonce")
/// ```
pub static BIP0340_NONCE_TAG_HASHER: Lazy<Sha256> =
Lazy::new(|| with_tag_hash_prefix(BIP0340_NONCE_TAG_DIGEST));
pub static BIP0340_NONCE_TAG_HASHER: LazyLock<Sha256> =
LazyLock::new(|| with_tag_hash_prefix(BIP0340_NONCE_TAG_DIGEST));

/// A `sha2::Sha256` hash engine with its state initialized to:
///
/// ```notrust
/// sha256(b"BIP0340/challenge") || sha256(b"BIP0340/challenge")
/// ```
pub static BIP0340_CHALLENGE_TAG_HASHER: Lazy<Sha256> =
Lazy::new(|| with_tag_hash_prefix(BIP0340_CHALLENGE_TAG_DIGEST));
pub static BIP0340_CHALLENGE_TAG_HASHER: LazyLock<Sha256> =
LazyLock::new(|| with_tag_hash_prefix(BIP0340_CHALLENGE_TAG_DIGEST));

/// A `sha2::Sha256` hash engine with its state initialized to:
///
/// ```notrust
/// sha256(b"BIP0340/batch") || sha256(b"BIP0340/batch")
/// ```
pub static BIP0340_BATCH_TAG_HASHER: Lazy<Sha256> =
Lazy::new(|| with_tag_hash_prefix(BIP0340_BATCH_TAG_DIGEST));
pub static BIP0340_BATCH_TAG_HASHER: LazyLock<Sha256> =
LazyLock::new(|| with_tag_hash_prefix(BIP0340_BATCH_TAG_DIGEST));

/// A `sha2::Sha256` hash engine with its state initialized to:
///
/// ```notrust
/// sha256(b"TapTweak") || sha256(b"TapTweak")
/// ```
pub static TAPROOT_TWEAK_TAG_HASHER: Lazy<Sha256> =
Lazy::new(|| with_tag_hash_prefix(TAPROOT_TWEAK_TAG_DIGEST));
pub static TAPROOT_TWEAK_TAG_HASHER: LazyLock<Sha256> =
LazyLock::new(|| with_tag_hash_prefix(TAPROOT_TWEAK_TAG_DIGEST));

#[cfg(test)]
mod tests {
Expand Down