asmcrypto / asmcrypto.js

JavaScript Cryptographic Library with performance in mind.
MIT License
659 stars 182 forks source link

Refactor code #94

Closed mobilekosmos closed 8 years ago

mobilekosmos commented 8 years ago

I tried to cut out the pieces that there are needed if you only need the PBKDF2 functionality and it was not possible for me to make it work. I know this is the fastest lib, but it is also soooo much more code comparing to e.g. sjcl. It would be nice if you could refactor the code, maybe do a fork for each functionality.

vibornoff commented 8 years ago

Hi, and sorry for late response. Regarding your question, it's trivial to build PBKDF2-only asmcrypto. You should decide what sort of PBKDF2 you need. E.g. you wish to build only SHA-256 based one. Just use the next snippet from the project root:

$ npm install && ./node_modules/.bin/grunt --with pbkdf2-hmac-sha256

It results in 40KB of minified js file or 16KB gzipped one.

mobilekosmos commented 8 years ago

Thank you Sir, that helps, but sjcl is still smaller (~30KB) without cutting out anything!

vibornoff commented 8 years ago

OFC, take a look to https://github.com/vibornoff/asmcrypto.js/blob/master/src/hash/sha256/sha256.asm.js and you'll see that the most of code comes from the loop unrolling.

You should chose what to focus on: compact size (use sjcl) or best speed (use asmcrypto).

mobilekosmos commented 8 years ago

Ok, that make sense, thanks for the explanation!