Scrypt is an algorithm designed cause lots of memory allocations by itself, but it seems that the current scrypt-async-js design contains a lot of additional memory allocations inefficiencies that prevent to use it in the real with the suggested LogN=20 that was proposed in 2009 as the right LogN for file encryption.
https://www.tarsnap.com/scrypt/scrypt-slides.pdf
For example running Scrypt with LogN=20 on Chrome seems to allocate more than 2GB for a sigle run;
This is due to the fact of various variable allocations inside loops and mix javascript sintaxes that could be avoided like:
- new Array inside functions when the variable could be allocated one time outside
- return [x, y, z] inside functions reallocating every time a new array for the return