qrand
qrand copied to clipboard
Entropy validation suite
Develop an initial set of classes implementing the ValidationStrategy
interface.
These classes will need to expose a validate method which takes in a bitstring (i.e. a string of only zeros and ones) and returns either True
or False
depending on whether it passes a particular entropy/randomness validation test or not.
Please, develop each test class on a separate file/module inside the validation subpackage, and use descriptive names. Also, remember to include a precise reference to the test documentation in the docstring (e.g. document, website, pages...).
References:
- https://csrc.nist.gov/projects/random-bit-generation
- https://csrc.nist.gov/publications/detail/sp/800-22/rev-1a/final
- https://csrc.nist.gov/Projects/Random-Bit-Generation/publications
So hi! I'm not sure where to put this, so I'm putting it here from scipy.stats import chi2 def function(qrand, range, times,significance_level): #qrand is function, range is range of function c=0 for N in range(0,times): c = c + ((qrand() - times/range)**2)/ (times/range) p = chi2.cdf(c,range - 1) if(p<significance_level): return(false) else: return(true)
Hi @roha913! Thanks so much for sharing. Can you elaborate on what you are trying to accomplish here with a bit more detail?
So I looked at issues and I found this one. So from what I understand its trying to find a measure of how random the qrand is, so I used chi-sq. Sorry if I messed up.
I just wanted to make sure I understood what you were aiming at @roha913. Thanks for the clarification!
You can find the latest version of the source code in the master
branch now. Take a look at the validation
package. For this feature we need to write down classes that implement the ValidationStrategy
interface, and correspond to different entropy validation tests (as mentioned in the description).
Notice that significance levels should not be passed as an argument in the validate method, but can be used as object attributes passed in during instantiation.
Let me know if you have any other questions. You can follow the references above for ideas on what tests are available!
Hello! I would like to try this issue. 'A Statistical Test Suite for Random and Pseudorandom Number Generators for Cryptographic Applications' Page 23 recommends the frequency test as the most basic test for entropy. I would like to implement that test first.
Go for it @charmerDark! That is probably a good place to start. From there you can keep adding more tests as you become more and more familiar 😉
Good start @charmerDark! Looking forward to seeing the rest of the tests! 😄