tonyg/js-nacl

reduce the size?

benoitc opened this issue · 3 comments

The current size of the produced nacl.js is > !Mb. It would be interesting to reduce its size so it can be easily used on the web. Maybe the --compression arg of emscripten could help here?

Please do give it a try. It should build fine with current versions of emscripten: how about you try the --compression flag of emscripten and report back?

May be, it will be better to organize library utility packages, downloadable, when specifc functionality is required:

  1. secret-box, XSalsa+Poly
  2. box, Curve+XSalsa+Poly
    2.1) just Curve, to do "before" function
  3. Hashes, one for 256, one for 512
  4. HMACs, this will include hashes as well
    Then, one uses what is actually required. I'd love to see and use (1), as this place (encryption of MBs) is worth speedup, provided by proper asm.js. Others may want faster hash (again for MBs of data).
tonyg commented

js-nacl is now using libsodium, compiled using emscripten's emsdk v1.36. The output file, lib/nacl_factory.js, is 658569 bytes uncompressed, and 174224 bytes gzipped. Is a 171k transfer small enough to be getting on with? If not, what other possibilities exist?

While your idea of separate packages, @3nsoft, is nice, I don't have the energy for it at the moment. Perhaps you'd like to have a go? I imagine it would involve carving up the underlying libsodium.