How does this simple script use the OP_CHECKSIG opcode?
Let's run through the program.


The stack starts as &lt;A sig&gt; &lt;A pubkey&gt;.
You run OP_DUP. The stack is now &lt;A sig&gt; &lt;A pubkey&gt; &lt;A pubkey&gt;.
You run OP_HASH160. The stack is now &lt;A sig&gt; &lt;A pubkey&gt; &lt;A pubkeyhash&gt;.
You push (A expected pubkeyhash). The stack is now &lt;A sig&gt; &lt;A pubkey&gt; &lt;A pubkeyhash&gt; &lt;A expected pubkeyhash&gt;.
You run OP_EQUALVERIFY. If the initial public key on the stack does matches the expected one, the execution aborts and the script fails. If it matches, the resulting stack is &lt;A sig&gt; &lt;A pubkey&gt;.
You run OP_CHECKSIG. If the signature matches, the resulting stack is 1, which means success.


Without the OP_DUP, it would be impossible to verify the public key both against the signature and against the expected public key hash.