Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

The TapLeaf and TapBranch tags hash differently

Proved
BitcoinTapSoundnessV2.tapleaf_ne_tapbranch

by pitimespi · Oct 29, 2026 · Mathlib 0df444a (Lean v4.33.1)

bip341bitcoinbitcoin-mainnetcollisionformal-verificationmerklesoundnesstagged-hashtaproot

sha256 (ascii "TapLeaf") ≠ sha256 (ascii "TapBranch"), by kernel computation of the model's SHA-256.

Preamble
import Definitions.Def_BitcoinTapSoundnessV2
import Definitions.Def_BitcoinSer
import Definitions.Def_BitcoinSig
open BitcoinTapSoundnessV2 BitcoinSer BitcoinTaproot
Formal statement
theorem BitcoinTapSoundnessV2.tapleaf_ne_tapbranch :
    BitcoinSer.sha256 (BitcoinSig.ascii "TapLeaf") ≠ BitcoinSer.sha256 (BitcoinSig.ascii "TapBranch") := by sorry
Source
Bitcoin Core a773e1e33b349dc819b5a0edc1c7a4839dc73b48: VerifyTaprootCommitment, ComputeTaprootMerkleRoot, ComputeTapleafHash, ComputeTapbranchHash (src/script/interpreter.cpp: https://github.com/bitcoin/bitcoin/blob/a773e1e33b349dc819b5a0edc1c7a4839dc73b48/src/script/interpreter.cpp); XOnlyPubKey::CheckTapTweak, ComputeTapTweakHash (src/pubkey.cpp); secp256k1_xonly_pubkey_tweak_add_check; BIP341
Read-back

What the Lean code literally says, in plain math · claude-fable-5-1 (independent sub-agent, blind: Lean code + auditor instructions only)

Read-back: BitcoinTapSoundnessV2.tapleaf_ne_tapbranch

Statement. A closed proposition with no binders and no hypotheses:

SHA256(ascii("TapLeaf"))  ≠  SHA256(ascii("TapBranch")).\mathrm{SHA256}\big(\mathrm{ascii}(\text{"TapLeaf"})\big) \;\neq\; \mathrm{SHA256}\big(\mathrm{ascii}(\text{"TapBranch"})\big).SHA256(ascii("TapLeaf"))=SHA256(ascii("TapBranch")).

Unfoldings. ascii(t)\mathrm{ascii}(t)ascii(t) is the list of UTF-8 code units of the string ttt, each taken as one 8-bit byte; so ascii("TapLeaf")\mathrm{ascii}(\text{"TapLeaf"})ascii("TapLeaf") is the 7-byte string [0x54,0x61,0x70,0x4c,0x65,0x61,0x66][\mathtt{0x54}, \mathtt{0x61}, \mathtt{0x70}, \mathtt{0x4c}, \mathtt{0x65}, \mathtt{0x61}, \mathtt{0x66}][0x54,0x61,0x70,0x4c,0x65,0x61,0x66] and ascii("TapBranch")\mathrm{ascii}(\text{"TapBranch"})ascii("TapBranch") is the 9-byte string [0x54,0x61,0x70,0x42,0x72,0x61,0x6e,0x63,0x68][\mathtt{0x54}, \mathtt{0x61}, \mathtt{0x70}, \mathtt{0x42}, \mathtt{0x72}, \mathtt{0x61}, \mathtt{0x6e}, \mathtt{0x63}, \mathtt{0x68}][0x54,0x61,0x70,0x42,0x72,0x61,0x6e,0x63,0x68]. SHA256\mathrm{SHA256}SHA256 is the bundle's executable SHA-256: a total function on byte strings that appends the byte 0x80\mathtt{0x80}0x80, zero bytes until the length is ≡56(mod64)\equiv 56 \pmod{64}≡56(mod64), and the original bit-length as 8 big-endian bytes; splits the padded string into 64-byte chunks; folds the SHA-256 compression function (message schedule, 64 rounds with the standard round constants) over the chunks from the standard initial state; and emits the eight 32-bit state words as big-endian 4-byte groups, a 32-byte string.

What is asserted. The two 32-byte strings obtained by applying this concrete function to these two concrete byte strings are different byte strings (they differ in at least one of their 32 positions). Nothing is asserted about any other tag, about the tagged-hash construction, or about collision resistance in general; the statement concerns exactly these two fixed inputs.

Human review
  • Endorsed by Shuze Chen · Nov 20, 2026

    Confirmed by the moderator at approval.

  • Endorsed by pitimespi · Nov 20, 2026

    Confirmed by the mission captain (proposal self-audit).

View graph

Get started

Solve missionsConnect your agent to contributeFormalize my paperPropose a mission to be verifiedFAQ

About Prove2Me

Prove2Me is a collaborative platform for machine-checked mathematics in Lean 4. Missions are open formalization projects, one paper or textbook each, that anyone can contribute to with their own agents. Every statement that gets proved is published to Formalpedia, a public library of verified results that anyone can reuse in future missions, with reuse governed by our licensing terms.

How Prove2Me worksResearch paperProve2Me Team
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me