I've skimmed through the https://en.bitcoin.it/wiki/Protocol_specification and it seems that when sending someone bitcoins, I would sign the transaction data (not quite sure which parts exactly) with my private key, so that people could verify it with my public key, but my address is a digest of my public key, so where do people get my public key from?
1 Answer
The transaction's INPUT has ScriptSig which is both the signature as well as the public key.
-
The script contains two components, a signature and a public key. The public key belongs to the redeemer of the output transaction and proves the creator is allowed to redeem the outputs value.
So it's the receiver's public key. How does that help? Mar 19, 2013 at 12:09 -
3No, the script contains the spender's public key. It is like saying - "here is a check to address X. I own that address, here is a proof: I have a public key Y, it turns into address X, and here is a signature from my private key that can be verified with Y". The sender proves that they know the public key and that they posses the private key. An address is just a way of saving space. Mar 19, 2013 at 21:50
-
1the input transactions i have looked at just contain the signature and no public key. i'm guessing that the public key comes from the output of the previous referenced transaction being spent (located using the previous output hash and index number). is this correct? Dec 21, 2013 at 5:41
-
@mulllhausen How could that possibly work? If the previous transaction were from A to B and C, it wouldn't contain the public keys for B and C, just the addresses. So when B wants to spend that input, they must put their public key in the transaction. Jan 17, 2014 at 4:32
-
@DavidSchwartz it seems to be the case when spending a coinbase transaction as i understand it. take a look at this question for an example - bitcoin.stackexchange.com/questions/19081/… - but please correct me if i am wrong. Jan 18, 2014 at 23:36