0
This is my understanding of what a transaction looks like:
inputs:
input0:
txid: <funding tx0 TXID>
outputID: <output ID of UTXO in the funding tx0>
scriptSig: <pkhash_redeemer> <sig0_redeemer>
input1:
txid: <funding tx1 TXID>
outputID: <output ID of UTXO in the funding tx1>
scriptSig: <pkhash_redeemer> <sig1_redeemer>
...
outputs:
output0:
scriptPK: <scriptPK for new UTXO>
amount: <amount for new UTXO>
Where the signature <sig_redeemer0> is over:
<funding tx0 TXID><output ID of UTXO in the funding tx0>- funding transaction's Pub Key Script
<scriptPK for new UTXO><amount for new UTXO>
I've read much that states things along the lines of: "the signature is over the entire transaction" or "the signature signs all the inputs and outputs". However, there are a few points of confusion I have:
Do multiple inputs necessitate multiple signatures? Or is my example wrong?
Why do we need to sign the inputs of the transaction?
If the inputs aren't signed, that means the following are left unsigned:
txidof funding transaction<output ID of UTXO in the funding tx>- sequence number (?)
If all outputs are signed, the amounts and scriptPubKeys of all UTXOs from funding transactions are fixed. An attacker might be able to change the inputs to the redeeming tx, but they are only unlockable if the inputs remain the same, so an attacker can't use an arbitrary input.
Any help would be appreciated! Thanks
There may be multiple utxos that the same script would unlock. The most common example is two transactions that both pay the same address. If inputs weren't signed, an attacker could replace one input utxo by a different utxo that pays the same address, and this would be bad. – Nate Eldredge – 2018-12-08T00:31:29.650
So if I understand correctly, if A creates a tx that pays B 1BTC (UTXO 1) and returns 1BTC of change back to A (UTXO 2), B could: (1) Redeem the 1BTC locked by UTXO1, (2) Redeem the 1BTC locked by UTXO1 again, since there's no explicit mapping between inputs and outputs in the tx. If A attempts to redeem UTXO2, they won't be able to, since all the inputs are already redeemed. – acnalb – 2018-12-08T02:33:00.307
That particular example won't work; since the transaction in question has outputs totaling 2BTC, if B edits it to use UTXO 2 as the input (whose value is 1BTC), it won't be valid. I'll add an answer explaining what I have in mind. – Nate Eldredge – 2018-12-08T02:47:46.347