Sort:  

It’s not exactly simple; there’s a lot of logic involved in generating a shared secret between the private and public keys using Elliptic Curve Diffie-Hellman (ECDH) key exchange. But there are existing codes to handle that, so it all works out. Therefore, it’s actually pretty simple now .

Yes you are right, it was tricky. it took me days and night to get a solid solution to prevent spamming at first stage!