Bitcoin Forum

Bitcoin => Bitcoin Technical Support => Topic started by: SOKO-DEKE on June 24, 2022, 12:14:24 AM



Title: How can I use private key to create signature
Post by: SOKO-DEKE on June 24, 2022, 12:14:24 AM
I am newbie who is very glad to be here. This farum was introduced to me by one of my friend some few month back that I can learn much about cryptocurrency here.
I 'm currently reading a topic about key private key, so i got confused.

I saw a sentence like private key is used to create a signature that are required to be spend Bitcoin by proving ownership of found used in a transaction.

My question is now how can I create signature from my private key?


Title: Re: How can I use private key to create signature
Post by: Charles-Tim on June 24, 2022, 12:55:56 AM
Your wallet automatically handles that, when you generate the wallet, keys and addresses are generated, the master private key generates the child keys. The child private key generate a signature while spending, to prove you are the owner of a public key while not revealing the private key. Without the signature, you can not be able to spend. So, without private key, you can not spend your coins. To understand better, if you import the master public keys (not private key), only child public keys and addresses are generated which are used for watch-only wallet, in watch-only wallet, you can not spend because it has no private key, it is used for just making an unsigned transactions and for tracking transactions.

Learn more from here: https://learnmeabitcoin.com/beginners/digital_signatures#:~:text=A%20digital%20signature%20is%20something,digital%20signature%20to%20prove%20it.


Title: Re: How can I use private key to create signature
Post by: nc50lc on June 24, 2022, 03:36:13 AM
-snip-
My question is now how can I create signature from my private key?
Bitcoin is using ECDSA for its signature using secp256k1 curve, more info about ECDSA here: /wiki/Elliptic_Curve_Digital_Signature_Algorithm (https://en.wikipedia.org/wiki/Elliptic_Curve_Digital_Signature_Algorithm#Signature_generation_algorithm)

In Bitcoin transactions, the "message" to be signed is the transaction itself.
This article explained it better: learnmeabitcoin.com/technical/ecdsa#signing-a-transaction (https://learnmeabitcoin.com/technical/ecdsa#signing-a-transaction) (I'd recommend to read the whole article)
Here's the beginner version: learnmeabitcoin.com/beginners/digital_signatures_signing_verifying (https://learnmeabitcoin.com/beginners/digital_signatures_signing_verifying)


Title: Re: How can I use private key to create signature
Post by: NotATether on June 25, 2022, 01:56:06 PM
When your wallet creates a transaction, for example Bitcoin Core, the transaction is considered raw and cannot be broadcasted without a signature for security reasons. So to create that signature, your private key and the raw transaction are inserted inside an ECDSA signing operation to create the message signature, which is then placed inside the raw transaction to create a signed transaction.

Nodes will also verify transactions, to make sure that the signature is correct, using the ECDSA verification algorithm by passing parts of the signed transaction and signature as inputs. Generally, there is only one valid signature for each transaction, to prevent forgery.