Equal branch hashes of 32-byte children have the same children up to order, or the two TapBranch preimages collide
ProvedBitcoinTapSoundnessV2.branch_eqFor 32-byte strings : tapbranchHash a b = tapbranchHash c d implies , or Collides (taggedPre "TapBranch" (branchMsg a b)) (taggedPre "TapBranch" (branchMsg c d)).
import Definitions.Def_BitcoinTapSoundnessV2 import Definitions.Def_BitcoinSer import Definitions.Def_BitcoinTaproot open BitcoinTapSoundnessV2 BitcoinSer BitcoinTaproot
theorem BitcoinTapSoundnessV2.branch_eq (a b c d : BitcoinSer.Bytes) (ha : a.length = 32) (hb : b.length = 32)
(hc : c.length = 32) (hd : d.length = 32) (h : BitcoinTaproot.tapbranchHash a b = BitcoinTaproot.tapbranchHash c d) :
((a = c ∧ b = d) ∨ (a = d ∧ b = c)) ∨
BitcoinTapSoundnessV2.Collides (BitcoinTapSoundnessV2.taggedPre "TapBranch" (BitcoinTapSoundnessV2.branchMsg a b))
(BitcoinTapSoundnessV2.taggedPre "TapBranch" (BitcoinTapSoundnessV2.branchMsg c d)) := by sorryRead-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.branch_eq
Statement. For all byte strings (finite lists of 8-bit bytes) such that
and such that
at least one of the following holds (inclusive disjunction):
-
or — the two unordered pairs and coincide as ordered pairs up to swapping; or
-
.
Unfoldings. is the bundle's executable SHA-256 (MD padding with , zeros to , 8-byte big-endian bit length; compression over 64-byte chunks from the standard initial state; eight big-endian 32-bit words out), a total function on byte strings. is the UTF-8 byte list of the string . , and (a string of length ).
is the Boolean strict lexicographic order on byte strings: , , , and is true if byte byte , false if , else . if and otherwise (so ). ; in particular by unfolding.
means : the two 128-byte strings in disjunct 2 must be distinct as byte strings and have the same SHA-256 output.
Edge cases and what is silently included. All four inputs are required to have length exactly 32; no other constraint (e.g. being a hash of anything) is imposed. When , . Disjunct 1 is an equality of byte strings, so it is satisfied e.g. whenever . Disjunct 2 is a stronger claim than the mere existence of a collision: it names the two specific preimages and and asserts they differ and hash equal. Since is by unfolding of the first of these strings and is of the second, the hypothesis already gives equal SHA-256 outputs; the content of disjunct 2 beyond the hypothesis is (the shared 64-byte prefix being identical).
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.