I am currently using ejabberd. My app is working fine but I have a question. How can I encrypt the stanzas sent to ejabberd from the client (Presence, Message, IQ). I am currently using TLS transport protocol for client to server communication and server to server communications. What I want to do is encrypt the data sent to ejabberd from the clients to server using a public key.
I believe you are talking about End-To-End encryption
If we are talking about XMPP in general, the following things are available and can be used:
Regarding Ejabberd - as stated here https://www.process-one.net/en/ejabberd/protocols/ - they support OpenPGP out of the box.
Other things (at least OTR) also can be used in any messaging apps.
Anyway, it's a very broad topic and you need to invest some good amount of time to implement End-To-End encryption, it's not a quick task