pedrorrivero / qrand

A multiprotocol and multiplatform quantum random number generation framework
https://pypi.org/project/qrand/
Apache License 2.0
24 stars 14 forks source link

Entropy validation suite #3

Open pedrorrivero opened 3 years ago

pedrorrivero commented 3 years ago

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:

roha913 commented 3 years ago

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)

pedrorrivero commented 3 years ago

Hi @roha913! Thanks so much for sharing. Can you elaborate on what you are trying to accomplish here with a bit more detail?

roha913 commented 3 years ago

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.

pedrorrivero commented 3 years ago

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!

charmerDark commented 3 years ago

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.

pedrorrivero commented 3 years ago

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 😉

pedrorrivero commented 3 years ago

Good start @charmerDark! Looking forward to seeing the rest of the tests! 😄