1

https://en.bitcoin.it/wiki/Script#Standard_Transaction_to_Bitcoin_address_.28pay-to-pubkey-hash.29

The last step of pay to pubkey hash transaction is to check the signature of the previous transaction tx hash and pubkey .

But how the script interpreter knows the sig is the signature of the previous transition hash, what if the sig is the signature of some other content?

2

But how the script interpreter knows the sig the signature of the previous transition hash, what if the sig is the signature of some other content?

It also compares the signed data with the transaction hash itself. In general, this is how digital signatures work. If the data isn't signed by the right key, and data hash doesn't match, then the signature is invalid. See src/script/interpreter.cpp L#1264.

This verification process ensures two things:
1. The person has the private key which corresponds with the public key provided.
2. The data has not been tampered with.

  • The code in SignatureHash() looks reconstruct (l1217~1235) part of the transaction and hash again. Then use pubKey to verify the hash and sig. Is the "data" you mentioned above is that the reconstructed byte list? – Carpemer Aug 31 '18 at 15:22
  • It's actually not simple, but there is a good explanation of what is hashed and signed here: bitcoin.stackexchange.com/a/5241/60443 – JBaczuk Aug 31 '18 at 17:15
  • One more question, in step 9, why the sender will decide the fee (0.001) in the process of generation input. If it is true, how the verifier could know what is the fee from the hash code? Actually, from the code in GitHub, it looks like it uses the original amount directly, and in the gitbub, it output the amount and then sequence (FFFFFFFF), but in that post, the order like amount first, then output script in step 9 and step 10. – Carpemer Sep 1 '18 at 2:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.