usnistgov / SP800-90B_EntropyAssessment

The SP800-90B_EntropyAssessment C++package implements the min-entropy assessment methods included in Special Publication 800-90B.
201 stars 87 forks source link

Calculation of alpha in the restart test isn't correct, or as specified in 90B #95

Closed joshuaehill closed 5 years ago

joshuaehill commented 6 years ago

The restart code sets alpha = 0.01/(double)(r+c), but this is not a valid way of calculating this value, even if the underlying distribution was the binomial distribution (which it is not).

90B directs that this value is to be alpha = 0.000005, which is an approximation of the statement alpha = 1 - exp(log(0.99)/2000). The underlying idea here is that we want the overall chance of failure to be 0.01 under the the assumption that there are 2000 independent tests, each of which must have the stated probability of false reject.

I'm basically replacing this functionality in my branch, but in the event that this doesn't happen, someone should fix this test so that it implements what is described in the final 90B document.

joshuaehill commented 6 years ago

I fixed this in my reference branch: https://github.com/joshuaehill/SP800-90B_EntropyAssessment/tree/2018UL

The approach in my branch is to discard the underlying binomial distribution assumption (as this appears to not be true; see our 90B comments: https://bit.ly/UL90BCOM) and instead establishes bounds specific to the provided entropy level via simulation.

As a technical aside, this code also uses OpenMP functionality (similar to my approach to the permutation tests). This is all bound up in the RNG work that hasn't yet been merged, so I haven't prepared a separate pull request for this functionality yet.

joshuaehill commented 6 years ago

I modified this slightly so that it was more clear where the constants came from.