<p>scriptSig contians a signature of the concantenation* of the previous transaction's script and the new transaction.  It has to be both because if it were a signature of just the previous transaction, someone could swap the output address in the new transaction and relay the transaction sending the coins to himself!</p>

<p>scriptSig also contains the public key to verify the signature because the previous transaction only has the hash of the public key.  The hash of a public key is an address.</p>

<p>Source: <a href="https://en.bitcoin.it/w/images/en/7/70/Bitcoin_OpCheckSig_InDetail.png">https://en.bitcoin.it/w/images/en/7/70/Bitcoin_OpCheckSig_InDetail.png</a></p>

<p>* Not really concatenated, it's inserted in the middle.</p>

CC BY-SA 3.0
2013-04-07T18:15:38.580Z
2013-04-07T18:15:38.580Z
Eyal
<p>I'm a bit confused about the signature contained in the scriptSig of a transaction. My question is: what do we really sign? Is it the hash of the previous transaction? </p>

<transactions><script>
How is the hash that is signed calculated?
anapaso
# How is the hash that is signed calculated?

(Asked by: username_0 on 2013-04-07)

I'm a bit confused about the signature contained in the scriptSig of a transaction. My question is: what do we really sign? Is it the hash of the previous transaction?

**Tags:** transactions, script


---

## 1 answers

### Answer by username_1 on 2013-04-07. Score: 6 | Accepted answer

scriptSig contians a signature of the concantenation\* of the previous transaction's script and the new transaction. It has to be both because if it were a signature of just the previous transaction, someone could swap the output address in the new transaction and relay the transaction sending the coins to himself!

scriptSig also contains the public key to verify the signature because the previous transaction only has the hash of the public key. The hash of a public key is an address.

Source: <https://en.bitcoin.it/w/images/en/7/70/Bitcoin_OpCheckSig_InDetail.png>

\* Not really concatenated, it's inserted in the middle.


---

