I have heard that hashing the message M prevents an existential forgery attack. I was wondering how.
Existential forgery attacks allow the attacker to choose (or calculate) a signature, and then the message is derived from this signature (and the public key) using the existential forgery attack algorithm.
The signature is valid for the derived message, but the problem is that the attacker cannot control the message. It could be anything.
Hashing the message before verification requires the attacker, Oscar, to additionally find some data that hashes to his derived message, which is practically impossible.
Hashing allows the recipient to know that the message comes from an intended person. By using the SHA-1 algorithm, if the hashed message does not match up, then the recipient knows that the message has been forged/is fraudulent. Check out digital signatures for more information.