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.