<p>A bitcoin transaction will create outputs, which can later be used as input to a new transaction. Each output will be locked to what is called a <code>scriptpubkey</code>, which basically sets up the cryptographic puzzle that must be satisfied (ie, return <code>true</code> when run) in order for those coins to be spent. Any transaction spending those coins will need to provide a <code>scriptsig</code> (unlocking script) that satisfies this puzzle.</p>
<p>So for example, when creating a transaction that pays to a 'pay-to-public-key-hash' (P2PKH) bitcoin address, the pubkey related to the address will not be known to the network. But when this output is later used as an input to a new transaction, the scriptsig that unlocks those coins would include the pubkey, alongside a valid signature, and thus network nodes will be able to verify that the rightful owner of those coins is making the spend (by hashing the provided pubkey, and verifying that the hash output matches the bitcoin address the coins are locked to).</p>
<hr />
<p>As for the ordering of signatures, here are a few questions/answers with some good details:</p>
<p><a href="https://bitcoin.stackexchange.com/questions/78235/what-exactly-is-hashed-and-signed-in-a-segwit-transaction">What exactly is hashed and signed in a segwit transaction</a></p>
<p><a href="https://bitcoin.stackexchange.com/questions/32628/redeeming-a-raw-transaction-step-by-step-example-required/32695#32695">Redeeming a raw transaction step by step example required</a></p>
<p><a href="https://bitcoin.stackexchange.com/questions/3374/how-to-redeem-a-basic-tx">How to redeem a basic Tx?</a></p>
<p><a href="https://bitcoin.stackexchange.com/questions/59231/how-to-sign-a-segwit-transaction-via-nbitcoin">How to sign a SegWit transaction via NBitcoin?</a></p>
<p><a href="https://bitcoin.stackexchange.com/questions/92558/what-is-the-signature-digest-for-segwit-outputs">What is the signature digest for Segwit outputs</a></p>
<hr />
<p>Other relevant Qs I found:</p>
<p><a href="https://bitcoin.stackexchange.com/questions/553/how-do-scripts-work/554#554">How do Scripts work?</a></p>
<p><a href="https://bitcoin.stackexchange.com/questions/8250/what-is-relation-between-scriptsig-and-scriptpubkey">What is relation between scriptSig and scriptPubKey?</a></p>

CC BY-SA 4.0
2021-02-16T01:01:59.673Z
2021-02-16T01:01:59.673Z
chytrik
<p>When you spend from a Bitcoin address, your transaction includes both the public key corresponding to the hashed address you're trying to spend from, as well as a signature that can be verified with that public key.</p>
<p>Your link is to a block, which is not signed itself. However, let's look at a transaction from your block: <a href="https://www.blockchain.com/btc/tx/b8f925d09c647904e428d902c8404fc91e5dbe53773b82d717cf13374785ca20" rel="noreferrer">https://www.blockchain.com/btc/tx/b8f925d09c647904e428d902c8404fc91e5dbe53773b82d717cf13374785ca20</a></p>
<p>Scroll down to 'inputs', and under Sigscript, <code>3045022100c89735ddbb5e231044610590c086d41f1e871067987087ed48e041f8999314830220011deba08ad9a67ddafe51dc530f3f60c8974373bf2f25953a89c139d238216201</code> is the ECDSA signature, and <code>023aa5b3f24a2b8fc8f64b69ba383b148892deef94cf060288cc99e81be0f9722e</code> is the public key corresponding to the address.</p>

CC BY-SA 4.0
2021-02-16T00:54:21.800Z
2021-02-16T00:54:21.800Z
ieatpizza
<p>I understand how asymmetric cryptosystems and digital signatures work:</p>
<blockquote>
<p>You generate a (private key, public key) pair. You never share the private key, you make the public key ... well, public.</p>
<p>You have a set of functions:</p>
<ul>
<li>encrypt(public key, plain text) = cipher text</li>
<li>decrypt(private key, cipher text) = plain text</li>
<li>sign(private key, plain text) = signed text</li>
<li>verify_signature(public key, signed text) = is_signature_valid_bool</li>
</ul>
</blockquote>
<p>However, in Bitcoin, the addresses are hashed versions of the public key. There is no way to &quot;undo&quot; the hashing. Hence I'm uncertain how transactions are verified.</p>
<p>I guess the question then is what is actually transferred to whom / stored, when I want to make a transaction. I assumed:</p>
<ul>
<li>Input Bitcoin addresses</li>
<li>Output Bitcoin addresses</li>
<li>Signature of the transaction with all input address private keys (I guess in order of the inputs)</li>
</ul>
<p>... but then I don't see how the validation is done. So I assume you sent your public key(s) when you create a transaction. This would explain why you shouldn't use any address again after you spent money from it. The point that confuses me is that <a href="https://www.blockchain.com/btc/block/0000000000000000000c7232393945dd8fd1b85a7cf91355cc084b284b53c5c0" rel="nofollow noreferrer">I don't see any public keys here</a></p>
<p>The next unclear thing is the order. Is there an implicit order in which the signatures have to be applied? I assumed this would be done with <a href="https://en.bitcoin.it/wiki/Script" rel="nofollow noreferrer">Script</a>, but I don't see this in the block explorer.</p>
<p>Can somebody shed some light on it?</p>
<h2>Non-Answers</h2>
<ul>
<li><a href="https://bitcoin.stackexchange.com/a/64483/6721">How Blockchain transaction verification takes place?</a>: The accepted answer just says &quot;when a node hears about a new transaction, it checks to make sure that the signature is valid&quot;. My question is about how this is done without the public key.</li>
</ul>

<transactions><transaction-verification><validation>
How are transactions verified with only the Bitcoin address, not the public key?
Martin Thoma
# How are transactions verified with only the Bitcoin address, not the public key?

(Asked by: username_0 on 2021-02-15)

I understand how asymmetric cryptosystems and digital signatures work:

> You generate a (private key, public key) pair. You never share the private key, you make the public key ... well, public.
>
> You have a set of functions:
>
> * encrypt(public key, plain text) = cipher text
> * decrypt(private key, cipher text) = plain text
> * sign(private key, plain text) = signed text
> * verify\_signature(public key, signed text) = is\_signature\_valid\_bool

However, in Bitcoin, the addresses are hashed versions of the public key. There is no way to "undo" the hashing. Hence I'm uncertain how transactions are verified.

I guess the question then is what is actually transferred to whom / stored, when I want to make a transaction. I assumed:

* Input Bitcoin addresses
* Output Bitcoin addresses
* Signature of the transaction with all input address private keys (I guess in order of the inputs)

... but then I don't see how the validation is done. So I assume you sent your public key(s) when you create a transaction. This would explain why you shouldn't use any address again after you spent money from it. The point that confuses me is that [I don't see any public keys here](https://www.blockchain.com/btc/block/0000000000000000000c7232393945dd8fd1b85a7cf91355cc084b284b53c5c0)

The next unclear thing is the order. Is there an implicit order in which the signatures have to be applied? I assumed this would be done with [Script](https://en.bitcoin.it/wiki/Script), but I don't see this in the block explorer.

Can somebody shed some light on it?

## Non-Answers

* [How Blockchain transaction verification takes place?](https://bitcoin.stackexchange.com/a/64483/6721): The accepted answer just says "when a node hears about a new transaction, it checks to make sure that the signature is valid". My question is about how this is done without the public key.

**Tags:** transactions, transaction-verification, validation


---

## 2 answers

### Answer by username_2 on 2021-02-16. Score: 7 | Accepted answer

When you spend from a Bitcoin address, your transaction includes both the public key corresponding to the hashed address you're trying to spend from, as well as a signature that can be verified with that public key.

Your link is to a block, which is not signed itself. However, let's look at a transaction from your block: <https://www.blockchain.com/btc/tx/b8f925d09c647904e428d902c8404fc91e5dbe53773b82d717cf13374785ca20>

Scroll down to 'inputs', and under Sigscript, `3045022100c89735ddbb5e231044610590c086d41f1e871067987087ed48e041f8999314830220011deba08ad9a67ddafe51dc530f3f60c8974373bf2f25953a89c139d238216201` is the ECDSA signature, and `023aa5b3f24a2b8fc8f64b69ba383b148892deef94cf060288cc99e81be0f9722e` is the public key corresponding to the address.


---

### Answer by username_1 on 2021-02-16. Score: 4

A bitcoin transaction will create outputs, which can later be used as input to a new transaction. Each output will be locked to what is called a `scriptpubkey`, which basically sets up the cryptographic puzzle that must be satisfied (ie, return `true` when run) in order for those coins to be spent. Any transaction spending those coins will need to provide a `scriptsig` (unlocking script) that satisfies this puzzle.

So for example, when creating a transaction that pays to a 'pay-to-public-key-hash' (P2PKH) bitcoin address, the pubkey related to the address will not be known to the network. But when this output is later used as an input to a new transaction, the scriptsig that unlocks those coins would include the pubkey, alongside a valid signature, and thus network nodes will be able to verify that the rightful owner of those coins is making the spend (by hashing the provided pubkey, and verifying that the hash output matches the bitcoin address the coins are locked to).

---

As for the ordering of signatures, here are a few questions/answers with some good details:

[What exactly is hashed and signed in a segwit transaction](https://bitcoin.stackexchange.com/questions/78235/what-exactly-is-hashed-and-signed-in-a-segwit-transaction)

[Redeeming a raw transaction step by step example required](https://bitcoin.stackexchange.com/questions/32628/redeeming-a-raw-transaction-step-by-step-example-required/32695#32695)

[How to redeem a basic Tx?](https://bitcoin.stackexchange.com/questions/3374/how-to-redeem-a-basic-tx)

[How to sign a SegWit transaction via NBitcoin?](https://bitcoin.stackexchange.com/questions/59231/how-to-sign-a-segwit-transaction-via-nbitcoin)

[What is the signature digest for Segwit outputs](https://bitcoin.stackexchange.com/questions/92558/what-is-the-signature-digest-for-segwit-outputs)

---

Other relevant Qs I found:

[How do Scripts work?](https://bitcoin.stackexchange.com/questions/553/how-do-scripts-work/554#554)

[What is relation between scriptSig and scriptPubKey?](https://bitcoin.stackexchange.com/questions/8250/what-is-relation-between-scriptsig-and-scriptpubkey)


---

