Constructor
new prng()
This random number generator is a derivative of Ferguson and Schneier's generator Fortuna. It collects entropy from various events into several pools, implemented by streaming SHA-256 instances. It differs from ordinary Fortuna in a few ways, though.
Most importantly, it has an entropy estimator. This is present because there is a strong conflict here between making the generator available as soon as possible, and making sure that it doesn't "run on empty". In Fortuna, there is a saved state file, and the system is likely to have time to warm up.
Second, because users are unlikely to stay on the page for very long, and to speed startup time, the number of pools increases logarithmically: a new pool is created when the previous one is actually used for a reseed. This gives the same asymptotic guarantees as Fortuna, but gives more entropy to early reseeds.
The entire mechanism here feels pretty klunky. Furthermore, there are several improvements that should be made, including support for dedicated cryptographic functions that may be present in some browsers; state files in local storage; cookies containing randomness; etc. So look for improvements in future versions.
Methods
_reseedFromPools(full)
Parameters:
Name | Type | Description |
---|---|---|
full |
If set, use all the entropy pools in the reseed. |
addEntropy(data, estimatedEntropy, source)
Parameters:
Name | Type | Description |
---|---|---|
data |
The entropic value. Should be a 32-bit integer, array of 32-bit integers, or string | |
estimatedEntropy |
Number | The estimated entropy of data, in bits |
source |
String | The source of the entropy, eg "mouse" |
addEventListener()
getProgress()
isReady()
randomWords(nwords)
Parameters:
Name | Type | Description |
---|---|---|
nwords |
Number | The number of words to generate. |