pinenacl 0.6.0

SDKdartflutter
Platformandroidioswindowslinuxmacosweb

The Dart implementation of the PyNaCl APIs with the TweetNaCl cryptographic library

Benchmark

There are 3 type of executables in dart:

  • JiT: runs the program in the Dart VM by dart or pub run
  • AoT: compiled native binary for the target OS (iOS, Android, Linux macOS Windows),
  • JavaScript: runs with node or in browser.

Note: Keep in mind that there are 32 and 64 bit architectures, and it seems that the armv7 compiled dart-sdk does not run under QEMU emulation.

All benchmarks used a 1MB large message for hashing, en/decrypt and sign/verify.

JiT (Dart VM) Benhcmark

Just simply run the benchmarks in Dart VM.

$ pub get
$ pub run benchmark/all_benchmark.dart
| Digest | BLAKE2B | 22.67 MB/s | 114 iterations | 5029 ms | 114.00 MB |
| Digest | SHA-256 | 14.21 MB/s | 72 iterations | 5066 ms | 72.00 MB |
...

Results

Converted to table MacBook Pro (2016), macOS Big Sur, with 2.7GHz i7 /w 16GB

20/01/2021

Alg typeAlgrateiterationstimedata throughput
DigestBLAKE2B22.67 MB/s114 iterations5029 ms114.00 MB
DigestSHA-25614.21 MB/s72 iterations5066 ms72.00 MB
DigestSHA-5127.27 MB/s37 iterations5089 ms37.00 MB
SignaturesEd25519 - sign3.58 MB/s18 iterations5023 ms18.00 MB
SignaturesEd25519 - verify5.76 MB/s29 iterations5033 ms29.00 MB
Authenticated EncryptionSecretBox - encrypt9.56 MB/s48 iterations5022 ms48.00 MB
Authenticated EncryptionSecretBox - decrypt10.78 MB/s54 iterations5007 ms54.00 MB
Authenticated EncryptionBox - encrypt8.77 MB/s44 iterations5014 ms44.00 MB
Authenticated EncryptionBox - decrypt9.88 MB/s50 iterations5058 ms50.00 MB
TweetNaClcrypto_hash_sha25613.35 MB/s67 iterations5018 ms67.00 MB
TweetNaClcrypto_hash_sha5127.60 MB/s38 iterations5002 ms38.00 MB
TweetNaClcrypto_auth_hmacsha25611.47 MB/s58 iterations5057 ms58.00 MB
TweetNaClcrypto_auth_hmacsha5126.50 MB/s33 iterations5079 ms33.00 MB
TweetNaClcrypto_box_keypair623.14 MB/s3116 iterations5000 ms3.04 GB
TweetNaClcrypto_box_curve25519xsalsa20poly130518.21 MB/s92 iterations5052 ms92.00 MB
TweetNaClcrypto_box_beforenm954.37 MB/s4772 iterations5000 ms4.66 GB
TweetNaClcrypto_box_afternm16.44 MB/s83 iterations5048 ms83.00 MB
TweetNaClcrypto_box_open_afternm17.77 MB/s89 iterations5007 ms89.00 MB
TweetNaClcrypto_stream340.49 GB/s1743291 iterations5000 ms1702.43 GB
TweetNaClcrypto_stream_xor20.88 MB/s105 iterations5029 ms105.00 MB
TweetNaClcrypto_core_salsa20740.98 GB/s3793818 iterations5000 ms3704.90 GB
TweetNaClcrypto_core_hsalsa20754.57 GB/s3863415 iterations5000 ms3772.87 GB
TweetNaClcrypto_point_add2.01 GB/s10294 iterations5000 ms10.05 GB
TweetNaClcrypto_scalar_base527.46 MB/s2638 iterations5001 ms2.58 GB
TweetNaClcrypto_scalarmult_base940.88 MB/s4705 iterations5000 ms4.59 GB
TweetNaClcrypto_scalarmult911.16 MB/s4556 iterations5000 ms4.45 GB
TweetNaClcrypto_sign_ed25519_pk_to_x25519_pk3.04 GB/s15552 iterations5000 ms15.19 GB
TweetNaClcrypto_sign_ed25519_sk_to_x25519_sk99.41 GB/s508972 iterations5000 ms497.04 GB
TweetNaClcrypto_sign_keypair520.30 MB/s2602 iterations5001 ms2.54 GB
TweetNaClcrypto_sign3.78 MB/s19 iterations5029 ms19.00 MB
TweetNaClcrypto_sign_open7.64 MB/s39 iterations5107 ms39.00 MB
TweetNaClcrypto_verify_164515.12 GB/s23117428 iterations5000 ms22575.61 GB
TweetNaClcrypto_verify_323963.50 GB/s20293152 iterations5000 ms19817.53 GB
TweetNaClcrypto_verify_644048.47 GB/s20728189 iterations5000 ms20242.37 GB

AoT (native binary)

$ pub get
$ dart2native benchmark/all_benchmark.dart -o all_benchmark
$ ./all_benchmark
| Digest | BLAKE2B | 21.99 MB/s | 110 iterations | 5001 ms | 110.00 MB |
| Digest | SHA-256 | 7.44 MB/s | 38 iterations | 5108 ms | 38.00 MB |
...

Results

Alg typeAlgrateiterationstimedata throughput
DigestBLAKE2B21.99 MB/s110 iterations5001 ms110.00 MB
DigestSHA-2567.44 MB/s38 iterations5108 ms38.00 MB
DigestSHA-5124.89 MB/s25 iterations5108 ms25.00 MB
SignaturesEd25519 - sign2.46 MB/s13 iterations5290 ms13.00 MB
SignaturesEd25519 - verify3.60 MB/s18 iterations5004 ms18.00 MB
Authenticated EncryptionSecretBox - encrypt7.14 MB/s36 iterations5040 ms36.00 MB
Authenticated EncryptionSecretBox - decrypt6.60 MB/s34 iterations5154 ms34.00 MB
Authenticated EncryptionBox - encrypt7.01 MB/s36 iterations5133 ms36.00 MB
Authenticated EncryptionBox - decrypt6.58 MB/s33 iterations5013 ms33.00 MB
TweetNaClcrypto_hash_sha2568.48 MB/s43 iterations5070 ms43.00 MB
TweetNaClcrypto_hash_sha5125.25 MB/s27 iterations5140 ms27.00 MB
TweetNaClcrypto_auth_hmacsha2567.07 MB/s36 iterations5093 ms36.00 MB
TweetNaClcrypto_auth_hmacsha5124.68 MB/s24 iterations5126 ms24.00 MB
TweetNaClcrypto_box_keypair183.84 MB/s920 iterations5004 ms920.00 MB
TweetNaClcrypto_box_curve25519xsalsa20poly130512.66 MB/s64 iterations5055 ms64.00 MB
TweetNaClcrypto_box_beforenm219.73 MB/s1099 iterations5001 ms1.07 GB
TweetNaClcrypto_box_afternm13.51 MB/s68 iterations5031 ms68.00 MB
TweetNaClcrypto_box_open_afternm13.53 MB/s68 iterations5026 ms68.00 MB
TweetNaClcrypto_stream253.90 GB/s1299990 iterations5000 ms1269.52 GB
TweetNaClcrypto_stream_xor15.38 MB/s77 iterations5007 ms77.00 MB
TweetNaClcrypto_core_salsa20501.70 GB/s2568713 iterations5000 ms2508.51 GB
TweetNaClcrypto_core_hsalsa20542.12 GB/s2775633 iterations5000 ms2710.58 GB
TweetNaClcrypto_point_add1.40 GB/s7151 iterations5000 ms6.98 GB
TweetNaClcrypto_scalar_base119.08 MB/s596 iterations5005 ms596.00 MB
TweetNaClcrypto_scalarmult_base222.95 MB/s1115 iterations5001 ms1.09 GB
TweetNaClcrypto_scalarmult213.73 MB/s1069 iterations5001 ms1.04 GB
TweetNaClcrypto_sign_ed25519_pk_to_x25519_pk1.26 GB/s6467 iterations5000 ms6.32 GB
TweetNaClcrypto_sign_ed25519_sk_to_x25519_sk54.29 GB/s277969 iterations5000 ms271.45 GB
TweetNaClcrypto_sign_keypair137.13 MB/s686 iterations5002 ms686.00 MB
TweetNaClcrypto_sign2.67 MB/s14 iterations5235 ms14.00 MB
TweetNaClcrypto_sign_open4.60 MB/s23 iterations5004 ms23.00 MB
TweetNaClcrypto_verify_163872.89 GB/s19829184 iterations5000 ms19364.44 GB
TweetNaClcrypto_verify_323581.01 GB/s18334757 iterations5000 ms17905.04 GB
TweetNaClcrypto_verify_643682.11 GB/s18852390 iterations5000 ms18410.54 GB

Javascript

In javascript converted code, the bitwise operations are handled as 32-bit operations.

$ pub get
$ dart2js benchmark/all_benchmark.dart -o all_benchmark.js
$ node all_benchmark.js
| Digest | BLAKE2B | 14.67 MB/s | 74 iterations | 5044 ms | 74.00 MB |
| Digest | SHA-256 | 14.75 MB/s | 74 iterations | 5018 ms | 74.00 MB |
...

Resultss

Alg typeAlgrateiterationstimedata throughput
DigestBLAKE2B14.67 MB/s74 iterations5044 ms74.00 MB
DigestSHA-25614.75 MB/s74 iterations5018 ms74.00 MB
DigestSHA-5121.69 MB/s9 iterations5324 ms9.00 MB
SignaturesEd25519 - sign877.01 KB/s5 iterations5838 ms5.00 MB
SignaturesEd25519 - verify1.52 MB/s8 iterations5267 ms8.00 MB
Authenticated EncryptionSecretBox - encrypt2.65 MB/s14 iterations5276 ms14.00 MB
Authenticated EncryptionSecretBox - decrypt3.67 MB/s19 iterations5175 ms19.00 MB
Authenticated EncryptionBox - encrypt2.75 MB/s14 iterations5099 ms14.00 MB
Authenticated EncryptionBox - decrypt3.69 MB/s19 iterations5144 ms19.00 MB
TweetNaClcrypto_hash_sha25611.24 MB/s57 iterations5072 ms57.00 MB
TweetNaClcrypto_hash_sha5121.91 MB/s10 iterations5237 ms10.00 MB
TweetNaClcrypto_auth_hmacsha2564.53 MB/s23 iterations5074 ms23.00 MB
TweetNaClcrypto_auth_hmacsha5121.53 MB/s8 iterations5235 ms8.00 MB
TweetNaClcrypto_box_keypair499.60 MB/s2498 iterations5000 ms2.44 GB
TweetNaClcrypto_box_curve25519xsalsa20poly13056.75 MB/s34 iterations5039 ms34.00 MB
TweetNaClcrypto_box_beforenm544.29 MB/s2722 iterations5001 ms2.66 GB
TweetNaClcrypto_box_afternm6.38 MB/s32 iterations5013 ms32.00 MB
TweetNaClcrypto_box_open_afternm6.63 MB/s34 iterations5129 ms34.00 MB
TweetNaClcrypto_stream92.58 GB/s473999 iterations5000 ms462.89 GB
TweetNaClcrypto_stream_xor7.57 MB/s38 iterations5017 ms38.00 MB
TweetNaClcrypto_core_salsa20195.29 GB/s999893 iterations5000 ms976.46 GB
TweetNaClcrypto_core_hsalsa20196.11 GB/s1004089 iterations5000 ms980.56 GB
TweetNaClcrypto_point_add3.55 GB/s18177 iterations5000 ms17.75 GB
TweetNaClcrypto_scalar_base295.16 MB/s1477 iterations5004 ms1.44 GB
TweetNaClcrypto_scalarmult_base529.09 MB/s2646 iterations5001 ms2.58 GB
TweetNaClcrypto_scalarmult556.69 MB/s2784 iterations5001 ms2.72 GB
TweetNaClcrypto_sign_ed25519_pk_to_x25519_pk3.62 GB/s18515 iterations5000 ms18.08 GB
TweetNaClcrypto_sign_ed25519_sk_to_x25519_sk13.41 GB/s68635 iterations5000 ms67.03 GB
TweetNaClcrypto_sign_keypair287.09 MB/s1436 iterations5002 ms1.40 GB
TweetNaClcrypto_sign932.10 KB/s5 iterations5493 ms5.00 MB
TweetNaClcrypto_sign_open1.78 MB/s9 iterations5066 ms9.00 MB
TweetNaClcrypto_verify_163523.37 GB/s18039674 iterations5000 ms17616.87 GB
TweetNaClcrypto_verify_322585.52 GB/s13237885 iterations5000 ms12927.62 GB
TweetNaClcrypto_verify_642594.30 GB/s13282803 iterations5000 ms12971.49 GB

Conclusion

TBD