0

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?

3 Answers 3

2

The usage is a 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.

8
  • 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
    Commented Oct 21, 2021 at 12:31
  • I don't understand what you mean by "role". Its role is signing the transaction to authorize the spending. Commented Oct 21, 2021 at 12:39
  • 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
    Commented Oct 21, 2021 at 12:43
  • 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. Commented Oct 21, 2021 at 12:45
  • FWIW, I'm just trying to find out where the hole in your understanding is, so I can write an actual answer addressing that. Commented Oct 21, 2021 at 13:49
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 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.

1
  • 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
    Commented Oct 23, 2021 at 19:44
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.