dashhive / DashTx.js

Create TX hex for payments and such
MIT License
3 stars 0 forks source link

`SIGHASH_SINGLE` is insecure, due to its conflict with BIP-69 #66

Closed coolaj86 closed 6 months ago

coolaj86 commented 6 months ago

Workaround

If you want the behavior of a "modular transaction", you can simply create multiple transactions and broadcast them simultaneously as to Instant Send Lock at the same time.

Why no SIGHASH_SINGLE?

SIGHASH_SINGLE requires that the index of the signed input matches the index of the signed output.

BIP-69 addresses the security issue of leaking information about the sender and receiver by ordering inputs and outputs.

  1. Transaction output amounts (as 64-bit unsigned integers) are to be sorted in ascending order.
  2. In the event of two matching output amounts, the respective output scriptPubKeys (as a byte-array) will be compared lexicographically, in ascending order.
  3. If the scriptPubKeys match, the outputs are considered equal.

Therefore, in order to use SIGHASH_SINGLE without creating a vulnerable transaction, you would have to create a situation in which the inputs and outputs have the same indexes - which would severely restrict how the transaction is constructed:

  1. All Inputs have the same amount, and all outputs have the same amount
  2. Output addresses are chosen not by their index of next availability, but by the lexicographical order of their hash
  3. Or it just becomes mind-numbing to try different combinations of coins to get some that just happen to work - possibly by creating new coins and transactions to them

Since this is so complex and nuanced and easy to get wrong and hard to get right, it's simply not supported.