Tool · Hashing

Tagged hash

SHA-256 with a label, so a hash made for one job can't be reused for another

Tagged hash

SHA-256 with a label baked in, so hashes for different jobs never collide

Tag

TapTweak: Taproot tweak: the message is the internal key (and a script root, if any)

  1. Hash the tag once

    t = SHA256(“TapTweak”)

    e80fe1639c9ca050e3af1b39c143c63e429cbceb15d940fbb5c5a1f4af57c5e9

  2. Put it in front of the message, twice

    t ‖ t ‖ message = 96 bytes

    e80fe1639c9ca050e3af1b39c143c63e429cbceb15d940fbb5c5a1f4af57c5e9e80fe1639c9ca050e3af1b39c143c63e429cbceb15d940fbb5c5a1f4af57c5e979be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798

    The two copies of t fill exactly one 64-byte SHA-256 block, so software can precompute it once per tag.

  3. Hash all of it once more

    tagged = SHA256(t ‖ t ‖ message)

    Tagged hash ✓ matches taggedHash()

    3cf5216d476a5e637bf0da674e50ddf55c403270dd36494dfcca438132fa30e7

Same message, other tags

The same 32 bytes give an unrelated hash under each tag, and under plain SHA-256. That is the point: a hash made for one job can never be passed off as another.

plain SHA-256
132f39a9…70e51def
TapLeaf
94333e8b…760a3135
TapBranch
a4481a6e…b12f3de0
TapSighash
87c2b87e…ca89657a
BIP0340/challenge
d75ca81e…781add6f
Runs in your browser · nothing is sent src/lib/hash.ts · BIP-340 tags, unchanged in Pearl

What it does

Choose one of the tags Taproot and Schnorr signatures use, or type your own, and a message in hex or text. The tool builds the tagged hash in three visible steps and checks the result against the library’s own taggedHash().

How to read it

  1. Hash the tag: t = SHA256(tag). The tag is plain text, like TapTweak.
  2. Glue it on twice: t ‖ t ‖ message. The two copies fill exactly one 64-byte SHA-256 block, so software can precompute that block once per tag.
  3. Hash everything once more. That’s the tagged hash.

Open Same message, other tags to see the same bytes give an unrelated result under every other tag. That is the point of tagging: a hash computed for one purpose can never be passed off as another.

The default message is the x-only public key of private key 1. With the TapTweak tag, the result is exactly the tweak the Key forge tool shows for key 1.

Pearl specifics

Pearl keeps Bitcoin’s tags and their rules unchanged: TapTweak for the Taproot tweak, TapLeaf and TapBranch for script trees (including P2MR’s), TapSighash for the digest a Taproot signature signs, and BIP0340/challenge inside every Schnorr signature.

Under the hood

Runs entirely in your browser: nothing you type is sent anywhere. Steps 1 and 3 call SHA-256 from src/lib/hash.ts; the check calls its taggedHash(), which unit tests verify against the BIP-340/341 tag prefixes and the research test vectors.

Suggested

Up and down arrows move through the results, Enter opens one, Escape closes. Anywhere on the site, slash or Command K opens this search, and the square brackets [ and ] go to the previous and next page.