dchest / tweetnacl-js

Port of TweetNaCl cryptographic library to JavaScript
https://tweetnacl.js.org
The Unlicense
1.75k stars 292 forks source link

Integrate your ed2curve-js and add generating shared secret from two X25519 keys #174

Closed catbref closed 4 years ago

catbref commented 4 years ago

Hello,

We're hoping to migrate from tonyg/js-nacl, which is Emscripten port of libsodium to JS. However, we're missing a few key nacl calls in your version.

I see you have a separate repository "edcurve-js" for converting Ed25519 keys to X25519 form. Would it be possible to integrate these calls into this main repository for completeness?

More importantly, we need the function to generate the shared secret using two X25519 keys (one private, one public). I guess you'd actually have to write this, albeit you can refer to existing code from elsewhere as a guide.

Hopefully not too much work and please let me know if I can help.

Thanks

dchest commented 4 years ago

I see you have a separate repository "edcurve-js" for converting Ed25519 keys to X25519 form. Would it be possible to integrate these calls into this main repository for completeness?

No, TweetNaCl.js API mirrors features available in TweetNaCl without introducing additional cryptography written by me. There is some overhead with using a separate package, since it copies some functions, but it's tiny enough not to matter (~1.2K gzipped).

More importantly, we need the function to generate the shared secret using two X25519 keys (one private, one public). I guess you'd actually have to write this, albeit you can refer to existing code from elsewhere as a guide.

If I understood you correctly, nacl.box.before is what you want https://github.com/dchest/tweetnacl-js#naclboxbeforetheirpublickey-mysecretkey

catbref commented 4 years ago

Thanks for the prompt reply.

Yes, nacl.box.before does look like exactly what we need. I've no idea how I didn't spot that before!