I'm a developers interested in bitcoin, one question: every transaction should be verified by all peers, it means every peer should have the transaction owner's public key, but how and where they get the owner's public key? it's stored somewhere?
-
You do know that there is a specialized bitcoin sister site, right?– Maarten BodewesCommented May 3, 2017 at 7:17
-
not until saw your comment.thanks– Jason.shenCommented May 3, 2017 at 9:19
-
1Stack Overflow is a site for programming and development questions. This question appears to be off-topic because it is not about programming or development. See What topics can I ask about here in the Help Center. Perhaps Bitcoin Stack Exchange would be a better place to ask.– jwwCommented May 3, 2017 at 16:18
2 Answers
They don't. Bitcoin uses a block chain to keep track of transactions. Say a person A transferred Bitcoin to person B. Then the transaction is validated and stored by a set of servers called blockchain.
From Wikipedia
The blockchain is a public ledger that records bitcoin transactions. A novel solution accomplishes this without any trusted central authority: maintenance of the blockchain is performed by a network of communicating nodes running bitcoin software.Transactions of the form payer X sends Y bitcoins to payee Z are broadcast to this network using readily available software applications.Network nodes can validate transactions, add them to their copy of the ledger, and then broadcast these ledger additions to other nodes. The blockchain is a distributed database – to achieve independent verification of the chain of ownership of any and every bitcoin (amount), each network node stores its own copy of the blockchain.
-
“Network nodes can validate transactions” so how nodes validate transactions ? they should validate by using public key, right ? or how ? Commented May 3, 2017 at 2:47
-
Read about RSA keys. When A transfers set a number of bitcoins to B. A signs the transaction with his private key. The transaction signed by A can only be deciphered by using his public key. That way everyone knows that it's A who really created the transaction. As long as A keeps his private key private, no one can imitate A. Commented May 3, 2017 at 3:58
-
ok, let me make myself clear. B received this transaction, then he has to validate the transaction, right? so how to validate ? B should use A's public key to validate, right? then where to get A's public key Commented May 3, 2017 at 4:00
-
Why would you need to validate A's public key? As I understand and I might be wrong , A as a part of the transaction sends you his public key which is then reported to the blockchain and you can wait for various degree of confirmation. Commented May 3, 2017 at 6:26
-
oh, I see. my question is where to get A's public key, not validate A's public key. sorry for not making myself clear. So the transaction will contain A's public key Commented May 3, 2017 at 6:50
AA will send its Public Key as part of the signed transaction. BB will use that public key to decrypt the transaction hash sent by AA and verify that public key actual belongs to AA's private key.
Now important part is how will BB knows that this public key belongs to AA's address and AA has not signed transaction on UTXOs belonging to other random addresses.
Well this verification is easy as addresses are created using public keys.
ADDRESS = base58(ripemd-160(sha256(public key)))
So BB will use above formula to check if the public key belongs to same address which is used by AA to spend the transaction.