How verification works
The signature packet records the hash algorithm the signer used, typically SHA-256. The tool hashes the exact message bytes, then uses the public key to verify the signature against that digest. Equal means a good signature; any difference means the message, signature, or supplied key is wrong. OpenPGP hashes the message together with the signature packet body and a final trailer, which binds the signature to this exact message and to the algorithms recorded in the packet, so it cannot be transplanted from one message to another.