# Can I use NaCl's scalar multiplication functions for Diffie Hellman Key Agreement?

I want to create some software that performs diffie hellman group key agreement but I don't want to reinvent the wheel even if I know how it's done. So I came accross the NaCl library, especially the scalar_mult functions.

As far I know you can perform Diffie Hellman key agreement on elliptic curves therefore, my thought is if I combine it with crypto_box ones for key generation, I can do a Diffie Hellman Key agreement.

My Idea is (described in some sort of pseudocode) shown in the following image:

Would you recommend it as shown above?

• Well, the function specifies that it can be used for the (Computational) Diffie-Hellman problem, which is the underlying problem that allows DH key agreement calculations. So I presume it is yes. I'm however not a NaCl expert so I'll allow somebody else to answer (I think the function is mainly used in NaCl for ECIES, which would make for an easy answer, but I'm not 100% sure about that particular bit). – Maarten Bodewes Nov 12 '18 at 15:42