crypto: improve random-bytes performance by ~60%
By using the same method of randomInt
, I added to reduce the random byte generation for key size less than 8 * 1024 bytes
Some of the tests are failing due to the async nature of caching. I appreciate any help for resolving those.
confidence improvement accuracy (*) (**) (***)
crypto/randomBytes.js n=1000 size=1024 *** 11.23 % ±1.66% ±2.21% ±2.87%
crypto/randomBytes.js n=1000 size=524288 0.24 % ±2.20% ±2.93% ±3.82%
crypto/randomBytes.js n=1000 size=64 *** 62.44 % ±5.18% ±6.94% ±9.13%
crypto/randomBytes.js n=1000 size=8192 * -1.85 % ±1.43% ±1.90% ±2.47%
Be aware that when doing many comparisons the risk of a false-positive result increases.
In this case, there are 4 comparisons, you can thus expect the following amount of false-positive results:
0.20 false positives, when considering a 5% risk acceptance (*, **, ***),
0.04 false positives, when considering a 1% risk acceptance (**, ***),
0.00 false positives, when considering a 0.1% risk acceptance (***)