Why do I need a private key to send someone my bitcoins?
5 Answers
A private key is the only way to assure everybody else you and only signed a specific transaction saying 'give X of my coins to Y'.
If you publish your private key, anybody can sign transactions like that and your money can be stolen. You should keep your private key private.
Standard Bitcoin addresses encode a user's public key. When someone sends bitcoins to such a "pay-to-public-key-hash" address, they sign them over to the owner of the specific public key. The public key hereby is part of a unique key pair. The public key (as in public knowledge) can be shared freely, while the private key should be kept secret.
When the new owner of the funds wants to spend them, they have to prove their ownership. To that end, they provide a signature that corresponds to the public key that the funds were assigned to. This signature can only be produced with the knowledge of the corresponding private key, but can then be checked by everyone that knows the public key.
You therefore need the private key to prove your ownership in order to spend funds.
technically speaking, the private key is used to sign a hash of a transaction. This signature process proves, that only the person with a private key belonging to its public key (from which the address could be derived) could sign this hash. As this is somewhat of a very generic question, I think it is a good idea to look up the principles of transaction processing in bitcoin in Andreas' book "Mastering Bitcoin". It is an amazing book that'll definitely get you started. It's freely available online here ...
At the time when the new owner of the assets needs to spend them, they need to demonstrate their possession. That time they give a signature that belongs to the public key that the assets were assigned to. This signature can only be invented with the instruction of the corresponding private key, but can then be checked by everyone that knows the public key. You always need the private key for showing ownership of this assets in order to spend funds.
Each transaction is paid to someone who owns the public key.
Every wallet will be notifying all transactions, then it will find out the key is matching transaction pay output, so the wallet show the message "there is a transaction that your public key own it", usually being listed on your wallet with time and amount.
Even you off-line that doesn't matter, when you go online, the wallet will update all the block to the newest.
The total amount on your software wallet is a summary of the transaction that pay to your public key, but haven't spent yet.
Everyone can claim they own the money, if they have your public key , but they don't have your private key to spend it.
there is a sample: (ignore the transaction fee)
Transaction A
output: pay 2Btc to PK-B
Transaction B
output: pay 1Btc to PK-B
Your wallet
you have 2btc income on 2018/3/21 13:22:11
you have 1btc income on 2018/3/25 16:21:10
Transaction C (you gonna spend the money)
input : Signature(Transaction A,Transaction B) PK-B
output: pay to 3Btc to PK-X
Whatever who received the transaction, they can take the PK-B to verify that the signature is correct, the signature also indicates the transaction was created by someone who own the private and public key. Then go to transaction A, B check the output is matched PK-B or not.
The public key is used to prove that someone pays you the money.
A private key (Signature) is used to prove that you create the transaction.
Someone has both keys, the money is yours.