<p>The usage is a <a href="https://en.wikipedia.org/wiki/Digital_signature" rel="nofollow noreferrer">digital signature</a>. It is a form a cryptography, but it is distinct from encryption. In fact, nowhere in Bitcoin's protocol does any form of encryption get used.</p>
<p>A digital signature, formally, is a collection of 3 functions:</p>
<ul>
<li><em>key generation</em>: randomly construct a keypair (i.e., a private key and its related public key).</li>
<li><em>signing</em>: given a message and a private key, construct a signature.</li>
<li><em>verifying</em>: given a message, a public key, and a signature, output true (if that signature was created with the private key corresponding to the provided public key, for the provided message), and false otherwise.</li>
</ul>
<p>While certain signature algorithms are based on encryption algorithms (e.g. for RSA it is the case that private and public key are sort of interchangeable, and you can see signing as &quot;encrypting with the private key&quot;), this is not true for all of them. The specific signature algorithm used in Bitcoin (ECDSA) cannot be used for encryption purposes.</p>

CC BY-SA 4.0
2021-10-21T12:31:33.307Z
Yes, that part is clear. My question is what does mean in technically "private key needed to spend coins", since private key is used for  singing only, and public key is needed to verify sign.  If someone sent me 10 coin, what is my private key role to use these 10 coins ?
aze2201
CC BY-SA 4.0
2021-10-21T12:39:45.830Z
I don't understand what you mean by "role". Its role is signing the transaction to authorize the spending.
Pieter Wuille
CC BY-SA 4.0
2021-10-21T12:43:22.833Z
Let's put it this way. 1) Fariz sends money to Pieter.  2) Fariz signs the transaction with Fariz's private key. 3) Pieter or miners verify the transaction by Fariz'z public key.  So the question is what is Pieter's meaning private key of Pieter to use that coins?
aze2201
CC BY-SA 4.0
2021-10-21T12:45:47.667Z
If I want to construct another transaction to move the coins further to someone else, I'd sign *that new transaction* with my private key. Everyone can verify this, because the output (of your transaction) says "can be spend by public key P", and the input of the next transaction spending it contains a signature that can be verified against that same public key P.
Pieter Wuille
CC BY-SA 4.0
2021-10-21T13:49:10.213Z
FWIW, I'm just trying to find out where the hole in your understanding is, so I can write an actual answer addressing that.
Pieter Wuille
CC BY-SA 4.0
2021-10-21T13:56:30.537Z
Looks it is clear. But still, I am not confident until the transaction is not encrypted (I don't mean signed). Yes, other nodes will make strong immune to reject altered block. But I am still wondering the miner node (hacker) can mine a block first and change the transaction signing (decrease coin and sign with own private key). yes, hackers will lose money, but target wallet under risk. Until transaction can be read by anyone means can be changed (before sharing with other nodes). Still, cannot udnerstand security
aze2201
CC BY-SA 4.0
2021-10-21T13:58:24.163Z
If the transaction is changed, the signature is invalidated. The message being signed *is* (a variant of) the spending transaction itself. The signature is not valid for any other message.
Pieter Wuille
CC BY-SA 4.0
2021-10-21T13:59:27.920Z
Let us [continue this discussion in chat](https://chat.stackexchange.com/rooms/130728/discussion-between-fariz-and-pieter-wuille).
aze2201
CC BY-SA 4.0
2021-10-21T12:17:31.347Z
2021-10-21T12:17:31.347Z
Pieter Wuille
<blockquote>
<p><strong>how Private Key needed to spend coins</strong></p>
</blockquote>
<p>A transaction spends some previously unspent transaction outputs (UTXOs) from one or more previous transactions.</p>
<p>Each UTXO has associated with it, in the transaction data, a script.</p>
<p>This script (sometimes called a locking script) is a small computer program written in a very small programming language that is called the Bitcoin scripting language. It is a bit like a very primitive stack-based assembly language.</p>
<p>This language has operators such as OP_CHECKSIG which use ECDSA to check a signature and return TRUE or FALSE.</p>
<p>This script determines who can spend the associated UTXO. prospective spenders do this by providing data which can be prepended to the locking script and then the whole evaluated using a Bitcoin scripting language interpreter (or compiler). The result will be true or false (any non true value). If the provided data and the old locking script evaluate true the spending transaction is regarded as valid.</p>
<p>There are some standard scripts such as pay to public key hash (P2PKH).</p>
<p>Typically the script requires as inputs a number that is calculated using the private key. Others can then use ECDSA etc to verify that the number was produced from a private key that corresponded to the public key used when creating the locking script.</p>
<hr />
<p>As Pieter noted in his answer, no network or blockchain data is encrypted in a normal Bitcoin transaction. All transaction data is completely readable by anyone.</p>

CC BY-SA 4.0
2021-10-23T19:44:00.573Z
in this case, the private key is only for signing. So, verification of message is going to use Public key. So, if you lost your private key technically it is still possible to construct a transaction with pub key verification. Only you cannot make a new transaction, am I right? But still can access to get balance.
aze2201
CC BY-SA 4.0
2021-10-21T14:03:44.690Z
2021-10-21T14:22:02.823Z
2021-10-21T14:22:02.823Z
RedGrittyBrick
<p>Assume a transaction is composed of two parts:</p>
<p>[proof of ownership] [new owner public key]</p>
<p>Bitcoins are born in coinbase transactions, which are special because they don’t have proof of ownership, and they belong to the miner:</p>
<p>[ ] [miner public key]</p>
<p>When the miner wants to spend this coins (send to Alice), he generates a new transaction, where he needs to prove he owns them, so he signs it with his private key:</p>
<p>[ ] [miner public key] =&gt; [signed with miner private key] [Alice public key]</p>
<p>Everyone can check if the signature is valid, without knowing the miner’s private key, thus verifying the proof of ownership. If it is valid, the transaction is accepted and soon will be confirmed in the blockchain.</p>
<p>Alice is now the owner of some coins. When she decides to spend them, she will repeat the process:</p>
<p>… =&gt; [signed with Alice private key] [Bob public key]</p>
<p>And so on.</p>
<p>Note: for simplicity reasons, I only used public keys to identify the new owner, but <a href="https://bitcoin.stackexchange.com/questions/64733/what-is-p2pk-p2pkh-p2sh-p2wpkh-eli5">there are more types of transactions</a>.</p>

CC BY-SA 4.0
2021-10-23T16:35:07.007Z
2021-10-23T16:35:07.007Z
bordalix
<p>My next question is how Private Key needed to spend coins. According to my understanding for transaction needed below steps:</p>
<ol>
<li>A wants to send 10 coin to B</li>
<li>A make transaction example: <strong>from: A, to :B coint:10</strong></li>
<li>A signs with its private Key: <strong>from: A, to :B coint:10,  <em>sign:qwertyasdfzxcv</em></strong></li>
</ol>
<p>So the result is B gets 10 coins on its public key (wallet address) and sender Public Key is enough to verify sign of Sender.</p>
<p>what is the usage of the private key to use this ? is this is transaction also getting encrypted by B public key (in this case only B's private key can be decrypted)
if like that then noone can read transacrion to valite it ?</p>
<p>So, what is the technical usage of the private keys to use coins?</p>

<blockchain><private-key><public-key><cryptography>
bitcoin private key usage
aze2201
# bitcoin private key usage

(Asked by: username_0 on 2021-10-21)

My next question is how Private Key needed to spend coins. According to my understanding for transaction needed below steps:

1. A wants to send 10 coin to B
2. A make transaction example: **from: A, to :B coint:10**
3. A signs with its private Key: **from: A, to :B coint:10, *sign:qwertyasdfzxcv***

So the result is B gets 10 coins on its public key (wallet address) and sender Public Key is enough to verify sign of Sender.

what is the usage of the private key to use this ? is this is transaction also getting encrypted by B public key (in this case only B's private key can be decrypted)
if like that then noone can read transacrion to valite it ?

So, what is the technical usage of the private keys to use coins?

**Tags:** blockchain, private-key, public-key, cryptography


---

## 3 answers

### Answer by username_1 on 2021-10-21. Score: 2

The usage is a [digital signature](https://en.wikipedia.org/wiki/Digital_signature). It is a form a cryptography, but it is distinct from encryption. In fact, nowhere in Bitcoin's protocol does any form of encryption get used.

A digital signature, formally, is a collection of 3 functions:

* *key generation*: randomly construct a keypair (i.e., a private key and its related public key).
* *signing*: given a message and a private key, construct a signature.
* *verifying*: given a message, a public key, and a signature, output true (if that signature was created with the private key corresponding to the provided public key, for the provided message), and false otherwise.

While certain signature algorithms are based on encryption algorithms (e.g. for RSA it is the case that private and public key are sort of interchangeable, and you can see signing as "encrypting with the private key"), this is not true for all of them. The specific signature algorithm used in Bitcoin (ECDSA) cannot be used for encryption purposes.

> **Comments:**
> **username_0**: Yes, that part is clear. My question is what does mean in technically "private key needed to spend coins", since private key is used for  singing only, and public key is needed to verify sign.  If someone sent me 10 coin, what is my private key role to use these 10 coins ?  
> **username_1**: I don't understand what you mean by "role". Its role is signing the transaction to authorize the spending.  
> **username_0**: Let's put it this way. 1) Fariz sends money to username_1.  2) Fariz signs the transaction with Fariz's private key. 3) username_1 or miners verify the transaction by Fariz'z public key.  So the question is what is username_1's meaning private key of username_1 to use that coins?  
> **username_1**: If I want to construct another transaction to move the coins further to someone else, I'd sign *that new transaction* with my private key. Everyone can verify this, because the output (of your transaction) says "can be spend by public key P", and the input of the next transaction spending it contains a signature that can be verified against that same public key P.  
> **username_1**: FWIW, I'm just trying to find out where the hole in your understanding is, so I can write an actual answer addressing that.  
> **username_0**: Looks it is clear. But still, I am not confident until the transaction is not encrypted (I don't mean signed). Yes, other nodes will make strong immune to reject altered block. But I am still wondering the miner node (hacker) can mine a block first and change the transaction signing (decrease coin and sign with own private key). yes, hackers will lose money, but target wallet under risk. Until transaction can be read by anyone means can be changed (before sharing with other nodes). Still, cannot udnerstand security  
> **username_1**: If the transaction is changed, the signature is invalidated. The message being signed *is* (a variant of) the spending transaction itself. The signature is not valid for any other message.  
> **username_0**: Let us [continue this discussion in chat](https://chat.stackexchange.com/rooms/130728/discussion-between-fariz-and-username_1-username_1).  

---

### Answer by username_2 on 2021-10-21. Score: 1

> **how Private Key needed to spend coins**

A transaction spends some previously unspent transaction outputs (UTXOs) from one or more previous transactions.

Each UTXO has associated with it, in the transaction data, a script.

This script (sometimes called a locking script) is a small computer program written in a very small programming language that is called the Bitcoin scripting language. It is a bit like a very primitive stack-based assembly language.

This language has operators such as OP\_CHECKSIG which use ECDSA to check a signature and return TRUE or FALSE.

This script determines who can spend the associated UTXO. prospective spenders do this by providing data which can be prepended to the locking script and then the whole evaluated using a Bitcoin scripting language interpreter (or compiler). The result will be true or false (any non true value). If the provided data and the old locking script evaluate true the spending transaction is regarded as valid.

There are some standard scripts such as pay to public key hash (P2PKH).

Typically the script requires as inputs a number that is calculated using the private key. Others can then use ECDSA etc to verify that the number was produced from a private key that corresponded to the public key used when creating the locking script.

---

As username_1 noted in his answer, no network or blockchain data is encrypted in a normal Bitcoin transaction. All transaction data is completely readable by anyone.

> **Comments:**
> **username_0**: in this case, the private key is only for signing. So, verification of message is going to use Public key. So, if you lost your private key technically it is still possible to construct a transaction with pub key verification. Only you cannot make a new transaction, am I right? But still can access to get balance.  

---

### Answer by username_3 on 2021-10-23. Score: 0

Assume a transaction is composed of two parts:

[proof of ownership] [new owner public key]

Bitcoins are born in coinbase transactions, which are special because they don’t have proof of ownership, and they belong to the miner:

[ ] [miner public key]

When the miner wants to spend this coins (send to Alice), he generates a new transaction, where he needs to prove he owns them, so he signs it with his private key:

[ ] [miner public key] => [signed with miner private key] [Alice public key]

Everyone can check if the signature is valid, without knowing the miner’s private key, thus verifying the proof of ownership. If it is valid, the transaction is accepted and soon will be confirmed in the blockchain.

Alice is now the owner of some coins. When she decides to spend them, she will repeat the process:

… => [signed with Alice private key] [Bob public key]

And so on.

Note: for simplicity reasons, I only used public keys to identify the new owner, but [there are more types of transactions](https://bitcoin.stackexchange.com/questions/64733/what-is-p2pk-p2pkh-p2sh-p2wpkh-eli5).


---

