I found these problems with the code:
- Math.random is a bad source of random.
- rawprng() can return NaN.
- random.done() can cause use after free type bugs.
- In random.random(), Number.MAX_VALUE is not what you think it is.
- random(), random.range(), random.intBetween(), and random.random() are not evenly distributed.
- This is clearly not a CSPRNG. You should remove the "UHEPRNG" code and replace it with Node's crypto.randomBytes and if a seed is given just do something like
key = H(seed); counter = 0; for seeding, key = H(key + "-" + entropy) for adding entropy, and key = H(key + counter++); return H(key); for random data. H() being a cryptographic hash function like SHA256 or a KDF like HKDF. This will be vastly superior.
I found these problems with the code:
key = H(seed); counter = 0;for seeding,key = H(key + "-" + entropy)for adding entropy, andkey = H(key + counter++); return H(key);for random data. H() being a cryptographic hash function like SHA256 or a KDF like HKDF. This will be vastly superior.