Hello devs,

In the process of moving BIP54 forward and converging (or not converging)
on the proposed fixes brought by BIP54, it has arised from the consensus
design conversation that the most controversial rule is the introduction of
the outlaw of 64 byte transactions. With an aim of actively resolving the
different viewpoints on the topic, this post briefly reminds the problem
space underlying and justifying the new rule and present the solutions that
are proposed, that have been proposed and their trade-offs [0].

Currently, BIP54 proposes the following modification to the Bitcoin network
consensus rules: "transactions whose witness-stripped serialized size is
exactly 64 bytes are invalid". Translated formally in code [1], in the
contextual check block, if any transaction included a block is stripped
of its witnesses and stripped of the BIP144 marker / flags, the whole
block is marked as invalid for containing a 64 bytes transaction.

Let's remind the initial problem solved [2]. The Merkle tree construction
used by Bitcoin consensus rules presents few security weaknesses due to
the lack of domain separation for the hashing of the internal nodes versus
the tree leaves. In informal terms, an inner Merkle node is the hash of the
concatenation of two 32-byte children hash while the leaf node is the hash
of a serialized transaction.

This weakness enables a malicious peer to announce to another target peer a
valid block and that its Merkle root is a single canonical transaction, when
in reality the serialization of the transaction is equal to the concatenation
of two transactions [3]. If the single transaction is invalid the whole block
is marked as invalid, as such it can be leveraged to trigger a netsplit.

It is known that a (valid) node-to-transaction collision finding can be
generalized to an arbitrary-size row of 64-byte (invalid) transactions, i.e
beyond a 2-transaction block layout. However, due to the constraints on the
structure of the coinbase it is informally deemed as not computationally feasible.

To avoid exploitation of the first special case, bitcoin core node doesn't
mark as permanently invalid any block validation, enabling as such a malleable
block being rejected for a 2-txn-block-hashing-as-a-inner-node-deserializing
to-an-invalid-64-byte-tx to be processed again with the valid transactions
(learnt from an honest peer e.g).

There is a transaction-to-node collision finding variant, where the idea
is to find a valid transaction and make it appears as if it was a Merkle
tree inner node, a valid 64-byte transaction being forced to be interpreted
as the concatenation of two 32 byte (fake) transactions. This can be used
to convince a SPV verifier, who is not aware about the depth of three to
accept the fake transaction, as it was included in a block. The collision
cost here is less expensive than for a block malleability.

By outlawing any witness-stripped 64-byte transaction, BIP 54 design goal
is to prevent any collision due to the lack of domain separation. Indeed,
if any 64-byte transaction is made invalid the serialization of it cannot
be used to collide with the (valid) inner node of a block, the transaction
can be immediately rejected.

While this does not remove all the cases of fake acceptance for a SPV
verifier, the rule outlaws the attack scenario where a malicious peer
would feed a fake transaction of which the hash would correspond to the
last 32 bytes of a valid 64 byte transaction. Whatever the chain depth
of the header, such a situation would be considered invalid.

It has been argued that such generic outlawing rule would create a
seam in bitcoin transaction processing, as now any contract protocol
designer would not be able to create a construction leveraging 64-byte
transaction, or that any wallet flow building collaborative transaction
(e.g Lightning cooperative closure) have to mirror the changes and outlaw
the new check.

In my view a more restricted transaction seam as it has been proposed [4],
comes with the fundamental disadvantage that it doesn't fully prevent
transaction-to-node or node-to-transaction collision-finding, it only adds
more constraints to increase the computational unfeasibility (however one
has to note the proposal doesn't emphasize any collision-finding hardness
analysis...).

However, it sounds to me, intuitively, that a complete outlaw of the 64 byte
structure makes the security analysis simpler, as one doesn't have to think
about the trick to reduce the collision-space (as e.g any fields in the
transaction structure of which the sum of the pair size are equally valid
collisions).

After reading again the whole design background on the 64 byte rule and
the block or SPV proof malleability issues, in my humble opinion, outlawing
as a whole 64-byte transactions sounds a simpler change. That's the change,
of which the only measurable advantages sounds to be for SPV verifier is
worthy of its own, is not further raised in the current post (of course
one's view will be tainted in function of one usage of SPV proof for any
protocol usage...).

Overall, to present a digest of my viewpoint, of all the 4 consensus
changes proposed by BIP54, it sounds that outlawing 64 byte transaction
is the change for which the attack surface reduction fitness has been
the less analyzed and the measurable concrete benefits for the ecosystem
the more uncertain. My humble opinion only.
 
Cheers,
Antoine

OTS hash: c8138d973f2403936ae6c3daa501e83342cd0cab04ce5d6d07485385c337842a

PS: While synthetizing and writing this post, I realize it doesn't cover
the arguments raised by evoskuil that only checking the structure correctness
of the coinbase would be sufficient to assume computational infeasibility of
the attacks (https://groups.google.com/g/bitcoindev/c/CAfm7D5ppjo/m/MsOdTqYyCwAJ).
IIRC, the viewpoint is that block invalid for this reason could be cached
safely for invalidity, as it would be computationally feasible to malleate
them. Those are good remarks, I might do a follow-up post on it (maybe).

[0] As far as I know, in matters of bitcoin consensus changes, there is no
social threshold or markers on when the subject of a proposed consensus
change has been hashed out enough, and in fact given that consensus change
is a dynamic process, in my view it's hard for one to exist. Still, sometimes
it sounds necessary to bring back on the table the design rationale of a change
and its trade-offs. If it doesn't enlighten the protocol experts, at least I
see that a summary exposition can be valuable for the other stakeholders.

[1] https://github.com/bitcoin/bitcoin/pull/35793/changes/1837129581b109a8c9f5f9a0f1ed9a882345cdb8

[2] https://gnusha.org/pi/bitcoindev/CAFp6fsGtEm9p-ZQF_XqfqyQGzZK7BS2SNp2z680QBsJiFDraEA@mail.gmail.com/2-BitcoinMerkle.pdf

[3] The full collision-finding algorithm is not given in the 2018's "Weaknesses
in Bitcoin's Merkle Root Construction" paper, yet one has to keep in mind that
the two serialized transactions are _the preimage_ to find a rough 32-bit collision
(less than 32-bit as there are pairs of valid solutions due to the scriptPubkey -
scriptSig lengths reducing the collision space), as only 4 bytes fields must have
a constrained value for a 64-byte transaction to be a valid transaction.

[4] https://groups.google.com/g/bitcoindev/c/ZVDEzxG6Sq8/m/WFamT4oJAQAJ

--
You received this message because you are subscribed to the Google Groups "Bitcoin Development Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bitcoindev+unsubscribe@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/bitcoindev/CALZpt%2BEDAz86ac8iNHG3OsyU0tcpd3oHk8tqMpb354nrTcSKjQ%40mail.gmail.com.