# Security definition for IND-CPA of public key encryption

In the security game between the challenger and the adversary for the security definition of public key encryption, the challenger creates and gives the public key pk to the adversary. The adversary chooses two messages of equal length $$m_0$$ and $$m_1$$ and asks the challenger to encode these. Finally, the adversary has to guess which message was encoded.

Isn't it always possible for the adversary to do this, since she knows the public key and can simply use the encryption algorithm to create the ciphertexts for both the messages and output the one which matches the challenger's reply?

I was using Dan Boneh's course to study crypto:

In public-key cryptography, the adversary is indeed able to create encryptions of their chosen messages $$m_1$$ and $$m_2$$ on their own.