Sjors Provoost

sjors@sprovoost.nl
Because an inner Merkle node always hashes exactly 64 bytes: SHA256d(left hash || right hash), 32 bytes each. A leaf hashes the witness-stripped transaction, whatever its length. The two can only be confused when the leaf preimage is also 64 bytes, since nothing in the hash says "this is a leaf" or "this is a node". A 128-byte transaction can't play that trick. No node in the tree hashes 128 bytes at once. Reading it as four hashes would give you H(H(a||b) || H(c||d)), which is not H(a||b||c||d). Making those equal means finding a SHA256 collision between inputs of different length, not just grinding a few bytes of a transaction. The same goes for 256 bytes and so on: the tree compresses pairwise, level by level, so 64 is the only length where the two interpretations meet. Other sizes do appear in the attack, just not as the ambiguous part. In the SPV case, the fake transaction whose txid sits in one half of the 64-byte transaction can be any size. In the block malleability case, it's again a 64-byte inner node preimage (two txids) that happens to deserialize as a transaction. Either way the pivot is a 64-byte blob, which is why BIP54 only outlaws that one size.
With regards to the inelegance of only outlawing 64 and not smaller, what's the smallest possible size of a (ephemeral dust spending) transaction with a 1Fee (?) output?
If you mean pay-to-anchor (the address is bc1pfeessrawgf, so "fees" rather than "1Fee"): exactly 64 bytes. One input with an empty scriptSig and one P2A output is the unlucky size. - version: 4 - input count: 1 - outpoint: 36 - scriptSig length (empty): 1 - sequence: 4 - output count: 1 - amount: 8 - scriptPubKey length: 1 - P2A script (OP_1 PUSH2 4e73): 4 - locktime: 4 An empty scriptSig requires a segwit input. If that input is itself a P2A anchor, the witness is empty too, so the whole transaction is 64 bytes. With a keyed anchor the witness comes on top, but BIP54 counts the witness-stripped size, so it is still hit. The fixed part is 60 bytes plus the output script. That gives 60 for an empty scriptPubKey, the smallest possible non-coinbase transaction, and 61 for a bare OP_RETURN that burns the dust to fees. So 60 to 63 stay consensus-valid under BIP54, with a hole at 64. None of these relay today. Bitcoin Core rejects anything under 65 non-witness bytes as "tx-size-small", so in practice an anchor sweep already has to be padded to 65, for example with a 5-byte OP_RETURN script. Jeremy Rubin raised this P2A case on the list in May, as a counterexample to the idea that 64-byte transactions are useless: gnusha.org/pi/bitcoindev/123e5545-2eda-4eca-9532-4f4cea2b83…

← More from Sjors Provoost