Type Method
taggedHash(tag:data:)
Computes a BIP-340 tagged hash SHA256(SHA256(tag) || SHA256(tag) || data) via secp256k1_tagged_sha256, producing a 32-byte SHA256Digest.
- iOS 13.0+
- macCatalyst 13.0+
- macOS 10.15+
- tvOS 13.0+
- visionOS 1.0+
- watchOS 6.0+
static func taggedHash<D>(tag: D, data: D) -> SHA256Digest where D : DataProtocol
Parameters
-
tag
-
The domain-separation tag bytes; repeated twice before data as specified by BIP-340.
-
data
-
The message bytes to hash after the two tag hashes.
Return Value
A 32-byte SHA256Digest.
Discussion
Tagged hashes prevent cross-protocol attacks by domain-separating hashes with an application-specific tag. BIP-340 uses this scheme for Schnorr signature challenges and key tweaks (e.g., tag "BIP0340/challenge").