Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dropping TweetNaCl #18

Open
christianbundy opened this issue Aug 25, 2020 · 7 comments
Open

Dropping TweetNaCl #18

christianbundy opened this issue Aug 25, 2020 · 7 comments

Comments

@christianbundy
Copy link
Contributor

Issues like #3 make me wonder whether this module would be better as a wrapper around sodium-chloride and sodium-universal, dropping support for TweetNaCl entirely. Trying to bridge two disparate APIs into a consistent interface is hard work, and unless we feel very strongly about TweetNaCl vs Sodium-JavaScript I think this might be the right move.

@christianbundy
Copy link
Contributor Author

christianbundy commented Aug 26, 2020

I didn't realize that we actually have at least three providers:

  • Browser:
    • Big: libsodium-wrappers (emscripten)
    • Small: TweetNaCl
  • Node.js: Sodium-Native

I took the various chloride-* modules and pulled their histories together to create one (much smaller) repository that uses Sodium-Universal, but unfortunately there are a few functions missing. More info here: sodium-friends/sodium-javascript#19


Here's my branch: https://github.com/christianbundy/chloride/tree/sodium-universal


Compatibility:

  • crypto_sign_PUBLICKEYBYTES
  • crypto_sign_SECRETKEYBYTES
  • crypto_sign_seed_keypair
  • crypto_sign_keypair
  • crypto_sign_BYTES
  • crypto_sign
  • crypto_sign_open
  • crypto_sign_detached
  • crypto_sign_verify_detached
  • crypto_box_PUBLICKEYBYTES
  • crypto_box_SECRETKEYBYTES
  • crypto_box_seed_keypair
  • crypto_box_keypair
  • crypto_box_MACBYTES
  • crypto_box_easy
  • crypto_box_open_easy
  • crypto_secretbox_easy
  • crypto_secretbox_open_easy
  • crypto_auth_BYTES
  • crypto_auth
  • crypto_auth_verify
  • crypto_hash_BYTES
  • crypto_hash
  • crypto_hash_sha256_BYTES
  • crypto_hash_sha256
  • crypto_scalarmult_BYTES
  • crypto_box_PUBLICKEYBYTES
  • crypto_sign_ed25519_pk_to_curve25519
  • crypto_box_SECRETKEYBYTES
  • randombytes_buf

@staltz
Copy link
Member

staltz commented Sep 3, 2020

@arj03 What are you relying on in the SSB browser demo?

@arj03
Copy link
Member

arj03 commented Sep 3, 2020

Browser core is very dependant on sodium-browserify to have web assembly working. JS is insanely slow compared to web assembly. So I don't really care about tweetnacl. I would actually like to get rid of tweetnacl as that makes the bundle smaller. So big +1 from me :-) Great work @christianbundy.

And thanks for the ping @staltz I didn't have notifications turned on for this repo until now.

@christianbundy
Copy link
Contributor Author

Sweet. I'm curious to benchmark libsodium-wrappers (emscripten) vs sodium-javascript (handwritten) once all of the methods are ported. If we can just depend on sodium-universal that'd remove lots of complexity from this module and consolidate our libsodium dependencies to the sodium-friends org.

@christianbundy
Copy link
Contributor Author

I ran sodiumperf against libsodium-wrappers and sodium-javascript and it looks like this might actually give us a nice performance boost:

(This assumes that my PRs into sodium-javascript are merged, and currently leaves out crypto_sign_ed25519_pk_to_curve25519 because I've only written tests, not the implementation.)

@mixmix
Copy link
Member

mixmix commented Sep 4, 2020

Have read this, but haven't got super familiar with details. Please tag me if you need my attention on this.

FWIW I'm mainly using graphql to connect from browser to back end, so don't use eg ssb-client which needs this much.
Happy to trust your expertise

@christianbundy
Copy link
Contributor Author

🎉

All of our required functionality has been released in Sodium-Javascript!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants