I am trying to determine how much entropy is going into a specific CSPRNG in JavaScript, but I can't seem to find a pure-JS client-side implementation of an entropy estimator.

So, I need to find a way to estimate entropy locally with pure JavaScript.

If it helps, the entropy is in an array which should be easy to manipulate.

  • $\begingroup$ Estimate the entropy of what? $\endgroup$
    – Natanael
    Commented Aug 29, 2019 at 17:56
  • 1
    $\begingroup$ To grasp why that's not doable from a theoretical standpoint, see this obligatory Dilbert strip. More seriously, consider an hypothetical such entropy estimator fed with pieces taken from a CSPRNG (or, if that estimator is a pure function, just repeatedly fed with the same input taken from a perfect entropy source). $\endgroup$
    – fgrieu
    Commented Aug 29, 2019 at 21:02

1 Answer 1


If someone chooses to run your program with a seed that you can't predict but an adversary can, you won't be able to tell. There is no way around this: nothing about the software can tell you what an adversary does or doesn't know; you can only use cryptography to ensure that if an adversary doesn't know a key and the message, then they can't decrypt the message.

In general, to estimate the entropy of a system, you need to have a model for how the system behaves. This is how all entropy estimation tools work: they posit some parametric model for how the input data might have been generated; then use the data to fit parameters for that model; and finally spit out the entropy of the model with the fitted parameters.

  • 2
    $\begingroup$ Would the downvoter care to explain what you disagree with in this answer, Paul? $\endgroup$ Commented Aug 30, 2019 at 0:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.