0
2
Trying to learn the basics of the bitcoin's standard transaction script here. For a transaction where Alice has sent coins to Bob, who is now trying to redeem them, we have the concatenated scriptSig and scriptPubKey as below
<Sig> <PubKey> OP_DUP OP_HASH160 <PubkeyHash> OP_EQUALVERIFY OP_CHECKSIG
When we say that the recipient must specify the PubKey and Sig in scriptSig, what exactly is in Sig? My understanding is that Bob is signing the entire transaction with his private key and then this is what OP_CHECKSIG verifies. In this case, the inputs to OP_CHECKSIG are the transaction data and the public key. Please let me know if this is correct and if not, then what exactly are the inputs that OP_CHECKSIG requires?
Secondly, what is the point of the first part of the script that checks the match between scriptSig's PubKey and scriptPubKey? Could we not instead get a simpler script where the outputs of a transaction specify the public key itself instead of the hash of the public key? In this case, we would simply have
<Sig> <PubKey> OP_CHECKSIG,
where Sig comes from the Bob and PubKey from Alice.
So just to clarify, the message you speak of is something that has transaction information in it, yes? I had this slight misunderstanding that the message was Bob's public key hash itself (which would be dangerous, since anyone can replicate it after he signs it one time). Therefore the <sig> is different for each transaction, Please let me know if my understanding is correct - Thank you! – user1936752 – 2017-08-05T04:58:34.600
1Yes in this case the message is the transaction data itself, I'll update my answer – MeshCollider – 2017-08-05T06:44:08.730
1
I think MeshCollider has answered already, just wanted to point out to Ken Shirriff's document. He gives a good step by step overview how a transaction is constructed, and then signed: http://www.righto.com/2014/02/bitcoins-hard-way-using-raw-bitcoin.html
– pebwindkraft – 2017-08-05T07:07:34.710Isn't in P2PK the address public key itself? And in P2PKH the address the hash of the public key? – croraf – 2017-11-26T22:07:24.933
@croraf yes that's what the second paragraph of the answer says :) – MeshCollider – 2017-11-27T00:37:31.683