script – Why cannot P2PKH’s scriptPubKey be shortened to solely OP_CHECKSIG?
The script achieves two issues:
- Ensures the supplied public key matches the supplied signature
- Ensures the supplied public key results in the identical handle script the utxo was locked with.
A P2PKH script accommodates the hash of the general public key. While you spend the cash, you present a public key, and a signature.
First, the script duplicates the supplied public key, then runs it via hash160, and compares the output to the hash embedded within the locking script.
As soon as that test passes, it validates the supplied signature towards the identical public key. This ensures that the signature comes from the identical key that was used to generate the handle.