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

"Faster" xsalsa20 and curve25519. #19

Closed
wants to merge 9 commits into from
Closed

"Faster" xsalsa20 and curve25519. #19

wants to merge 9 commits into from

Conversation

dchest
Copy link
Owner

@dchest dchest commented Jun 25, 2014

This pull request adds nacl-fast.js, a supposedly faster drop-in replacement for nacl.js.

Turns out curve25519 is not much faster. But xsalsa20 is ~5 times faster. Not sure if we need this.

Very rough benchmarks on my super-slow Atom:

Chrome:

BEFORE                                              AFTER

 Benchmarking crypto_stream_xor      Benchmarking crypto_stream_xor
 0.19821605550049554 MB/s            2.3529411764705883 MB/s

 Benchmarking crypto_onetimeauth     Benchmarking crypto_onetimeauth
 1.697792869269949 MB/s              1.876172607879925 MB/s

 Benchmarking crypto_secretbox       Benchmarking crypto_secretbox
 0.2014098690835851 MB/s             1.1947431302270013 MB/s

 Benchmarking crypto_hash            Benchmarking crypto_hash
 395.3488372093023 ops/s             382.3088455772114 ops/s
 0.48053820278712156 MB/s            0.47961630695443647 MB/s

 Benchmarking secretbox              Benchmarking secretbox
 0.19952114924181963 MB/s            1.1587485515643106 MB/s

 Benchmarking secretbox.open         Benchmarking secretbox.open
 0.17806267806267806 MB/s            1.016260162601626 MB/s

 Benchmarking crypto_scalarmult_bas  Benchmarking crypto_scalarmult_bas
 26.515151515151516 ops/s            22.853411687887693 ops/s

 Benchmarking box                    Benchmarking box
 0.023299161230195712 MB/s           0.02221235006663705 MB/s

 Benchmarking box.open (valid)       Benchmarking box.open (valid)
 0.023004370830457786 MB/s           0.021958717610891524 MB/s

 Benchmarking box.open (invalid key  Benchmarking box.open (invalid key
 0.025906735751295335 MB/s           0.02218770800976259 MB/s

(note that getting rid of type arrays in core() in favor of normal arrays speeds up salsa in Chrome to ~1 MB/s).

Firefox:

 Benchmarking crypto_stream_xor      Benchmarking crypto_stream_xor
 1.017293997965412 MB/s              6.0606060606060606 MB/s

 Benchmarking crypto_onetimeauth     Benchmarking crypto_onetimeauth
 1.7241379310344827 MB/s             1.9342359767891684 MB/s

 Benchmarking crypto_secretbox       Benchmarking crypto_secretbox
 0.6269592476489029 MB/s             1.455604075691412 MB/s

 Benchmarking crypto_hash            Benchmarking crypto_hash
 262.88659793814435 ops/s            252.22551928783383 ops/s
 0.3776435045317221 MB/s             0.40404040404040403 MB/s

 Benchmarking secretbox              Benchmarking secretbox
 0.6738544474393531 MB/s             1.4124293785310735 MB/s

 Benchmarking secretbox.open         Benchmarking secretbox.open
 0.5824111822947 MB/s                1.3262599469496021 MB/s

 Benchmarking crypto_scalarmult_bas  Benchmarking crypto_scalarmult_bas
 16.073478760045923 ops/s            21.315468940316688 ops/s

 Benchmarking box                    Benchmarking box
 0.015232292460015232 MB/s           0.020479213598197828 MB/s

 Benchmarking box.open (valid)       Benchmarking box.open (valid)
 0.01525320317266626 MB/s            0.01908761213972132 MB/s

 Benchmarking box.open (invalid key  Benchmarking box.open (invalid key
 0.016116035455278 MB/s              0.02011263073209976 MB/s

@dchest dchest mentioned this pull request Jun 25, 2014
@nadimkobeissi
Copy link
Contributor

I would really like to see this merged. It made nacl.box() ~350% faster for me.

@dchest
Copy link
Owner Author

dchest commented Jun 26, 2014

@KAepora thanks; I'll see if anything else can be improved and will merge.

@dchest
Copy link
Owner Author

dchest commented Jul 3, 2014

This branch is now out of sync with master due to new testing infrastructure there. Need to think how to integrate nacl-fast.js with it in a less painful way.

@dchest
Copy link
Owner Author

dchest commented Jul 4, 2014

See PR #25.

@dchest dchest closed this Jul 4, 2014
@dchest dchest deleted the fast branch July 4, 2014 18:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants