<p>Assume you understand how <a href="https://en.wikipedia.org/wiki/Public-key_cryptography" rel="nofollow noreferrer">public-key cryptography</a> works. In short, one can verify the ownership of an address by checking the signature. A valid signature can only be generated by the private key owner.</p>

<p>The detail of signature verification in Bitcoin is described <a href="https://en.bitcoin.it/wiki/Transaction#Pay-to-PubkeyHash" rel="nofollow noreferrer">here</a></p>

<p>Without digging into the details, <code>OP_xxx</code> are stack operations. For example, <code>OP_DUP</code> is to duplicate top of the stack. Basically it </p>

<ul>
<li>first hashes the public key by operation <code>OP_HASH160</code> and check if the result is identical to <code>pubKeyHash</code> by operation <code>OP_EQUALVERIFY</code></li>
<li>then verifies <code>sig</code> and <code>pubKey</code> by operation <code>OP_CHECKSIG</code></li>
</ul>

<p>You can read more about <code>OP_CHECKSIG</code> <a href="https://en.bitcoin.it/wiki/OP_CHECKSIG" rel="nofollow noreferrer">here</a></p>

CC BY-SA 3.0
2018-04-27T07:01:44.887Z
Please elaborate on what the links explain in the answer as well. As it stands, this answer is not helpful if the links stop working.
Raghav Sood
CC BY-SA 3.0
2018-04-27T03:34:09.387Z
2018-04-27T07:58:59.767Z
2018-04-27T07:58:59.767Z
Will Gu
<p>The ownership is proven for each input by providing a valid signature in the <code>scriptSig</code> field. If one of the signatures is missing, the whole transaction is invalid. </p>

<p>The <code>scriptPubKey</code> for each output in the example you provided is locked to a Bitcoin address. A Bitcoin address is, in a nutshell, a hash of a public key. So, in order to provide a valid signature, the secret key belonging to the same key pair of the public key referred in each input is required. </p>

CC BY-SA 3.0
2018-04-27T07:26:14.590Z
2018-04-27T07:26:14.590Z
sr_gi
<p>I read the following from the book &lt;&lt; Mastering Bitcoin >></p>

<blockquote>
  <p>"As you may notice, the transaction contains an empty scriptSig because we haven’t signed it yet. Without a signature, this transaction is meaningless, we haven’t yet proven that we own the address from which the unspent output is sourced."</p>
</blockquote>

<p>I am wondering how a signature can prove that this transaction owns the address from which the unspent output is sourced?  </p>

<transactions><signature>
How a transaction proves its ownership of the its source, which can be one or multiple unspent output?
Qi Zhang
# How a transaction proves its ownership of the its source, which can be one or multiple unspent output?

(Asked by: username_0 on 2018-04-27)

I read the following from the book << Mastering Bitcoin >>

> "As you may notice, the transaction contains an empty scriptSig because we haven’t signed it yet. Without a signature, this transaction is meaningless, we haven’t yet proven that we own the address from which the unspent output is sourced."

I am wondering how a signature can prove that this transaction owns the address from which the unspent output is sourced?

**Tags:** transactions, signature


---

## 2 answers

### Answer by username_1 on 2018-04-27. Score: 3

Assume you understand how [public-key cryptography](https://en.wikipedia.org/wiki/Public-key_cryptography) works. In short, one can verify the ownership of an address by checking the signature. A valid signature can only be generated by the private key owner.

The detail of signature verification in Bitcoin is described [here](https://en.bitcoin.it/wiki/Transaction#Pay-to-PubkeyHash)

Without digging into the details, `OP_xxx` are stack operations. For example, `OP_DUP` is to duplicate top of the stack. Basically it

* first hashes the public key by operation `OP_HASH160` and check if the result is identical to `pubKeyHash` by operation `OP_EQUALVERIFY`
* then verifies `sig` and `pubKey` by operation `OP_CHECKSIG`

You can read more about `OP_CHECKSIG` [here](https://en.bitcoin.it/wiki/OP_CHECKSIG)

> **Comments:**
> **username_2**: Please elaborate on what the links explain in the answer as well. As it stands, this answer is not helpful if the links stop working.  

---

### Answer by username_3 on 2018-04-27. Score: 2

The ownership is proven for each input by providing a valid signature in the `scriptSig` field. If one of the signatures is missing, the whole transaction is invalid.

The `scriptPubKey` for each output in the example you provided is locked to a Bitcoin address. A Bitcoin address is, in a nutshell, a hash of a public key. So, in order to provide a valid signature, the secret key belonging to the same key pair of the public key referred in each input is required.


---

