Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create unit test to confirm non-biased random numbers (uniform distribution) #6

Open
sa6mwa opened this issue May 27, 2021 · 0 comments
Labels
enhancement New feature or request

Comments

@sa6mwa
Copy link
Owner

sa6mwa commented May 27, 2021

I don't know enough about RNG tests, but think it would be cool to have the RNG in Krypto431 pass all of the dieharder(1) tests. This is an example how to test the Linux /dev/urandom PRNG (well, /dev/random is also a PRNG, it just blocks when the entropy is out). We can do a similar test with the PRNGs in Krypto431, but the numbers need to be 0 to 25 (you probably need to set the range in dieharder somehow). For example, look at the two WEAK assessments below...

From the dieharder man page...

   Alternatively, dieharder can be used to test files of numbers  produced
   by a candidate random number generators:

     dieharder -a -g 201 -f random.org_bin

   for raw binary input or

     dieharder -a -g 202 -f random.org.txt
$ cat /dev/urandom | dieharder -a -g 200
#=============================================================================#
#            dieharder version 3.31.1 Copyright 2003 Robert G. Brown          #
#=============================================================================#
   rng_name    |rands/second|   Seed   |
stdin_input_raw|  1.13e+07  |1428260778|
#=============================================================================#
        test_name   |ntup| tsamples |psamples|  p-value |Assessment
#=============================================================================#
   diehard_birthdays|   0|       100|     100|0.28151290|  PASSED  
      diehard_operm5|   0|   1000000|     100|0.62816230|  PASSED  
  diehard_rank_32x32|   0|     40000|     100|0.22641794|  PASSED  
    diehard_rank_6x8|   0|    100000|     100|0.07648248|  PASSED  
   diehard_bitstream|   0|   2097152|     100|0.90620443|  PASSED  
        diehard_opso|   0|   2097152|     100|0.19382105|  PASSED  
        diehard_oqso|   0|   2097152|     100|0.16862596|  PASSED  
         diehard_dna|   0|   2097152|     100|0.80774230|  PASSED  
diehard_count_1s_str|   0|    256000|     100|0.81936551|  PASSED  
diehard_count_1s_byt|   0|    256000|     100|0.17920809|  PASSED  
 diehard_parking_lot|   0|     12000|     100|0.96831462|  PASSED  
    diehard_2dsphere|   2|      8000|     100|0.96217378|  PASSED  
    diehard_3dsphere|   3|      4000|     100|0.55956984|  PASSED  
     diehard_squeeze|   0|    100000|     100|0.44334894|  PASSED  
        diehard_sums|   0|       100|     100|0.70990252|  PASSED  
        diehard_runs|   0|    100000|     100|0.75815013|  PASSED  
        diehard_runs|   0|    100000|     100|0.04289927|  PASSED  
       diehard_craps|   0|    200000|     100|0.94163220|  PASSED  
       diehard_craps|   0|    200000|     100|0.97273682|  PASSED  
 marsaglia_tsang_gcd|   0|  10000000|     100|0.91438421|  PASSED  
 marsaglia_tsang_gcd|   0|  10000000|     100|0.97598335|  PASSED  
         sts_monobit|   1|    100000|     100|0.60896355|  PASSED  
            sts_runs|   2|    100000|     100|0.74353520|  PASSED  
          sts_serial|   1|    100000|     100|0.19787900|  PASSED  
          sts_serial|   2|    100000|     100|0.70397015|  PASSED  
          sts_serial|   3|    100000|     100|0.08278372|  PASSED  
          sts_serial|   3|    100000|     100|0.93438930|  PASSED  
          sts_serial|   4|    100000|     100|0.07266823|  PASSED  
          sts_serial|   4|    100000|     100|0.20766267|  PASSED  
          sts_serial|   5|    100000|     100|0.23227633|  PASSED  
          sts_serial|   5|    100000|     100|0.99087787|  PASSED  
          sts_serial|   6|    100000|     100|0.02708506|  PASSED  
          sts_serial|   6|    100000|     100|0.23152481|  PASSED  
          sts_serial|   7|    100000|     100|0.00124029|   WEAK   
          sts_serial|   7|    100000|     100|0.00175634|   WEAK   
          sts_serial|   8|    100000|     100|0.15996183|  PASSED  
          sts_serial|   8|    100000|     100|0.63733538|  PASSED  
          sts_serial|   9|    100000|     100|0.58882223|  PASSED  
          sts_serial|   9|    100000|     100|0.09394493|  PASSED  
          sts_serial|  10|    100000|     100|0.35573017|  PASSED  
          sts_serial|  10|    100000|     100|0.59022963|  PASSED  
          sts_serial|  11|    100000|     100|0.52742847|  PASSED  
          sts_serial|  11|    100000|     100|0.89610194|  PASSED  
          sts_serial|  12|    100000|     100|0.14909867|  PASSED  
          sts_serial|  12|    100000|     100|0.92046940|  PASSED  
          sts_serial|  13|    100000|     100|0.88926749|  PASSED  
          sts_serial|  13|    100000|     100|0.30840791|  PASSED  
          sts_serial|  14|    100000|     100|0.46455530|  PASSED  
          sts_serial|  14|    100000|     100|0.70294453|  PASSED  
          sts_serial|  15|    100000|     100|0.20870357|  PASSED  
          sts_serial|  15|    100000|     100|0.01099756|  PASSED  
          sts_serial|  16|    100000|     100|0.22245261|  PASSED  
          sts_serial|  16|    100000|     100|0.55027247|  PASSED  
         rgb_bitdist|   1|    100000|     100|0.93378073|  PASSED  
         rgb_bitdist|   2|    100000|     100|0.81954461|  PASSED  
         rgb_bitdist|   3|    100000|     100|0.64799316|  PASSED  
         rgb_bitdist|   4|    100000|     100|0.35560131|  PASSED  
         rgb_bitdist|   5|    100000|     100|0.37430215|  PASSED  
         rgb_bitdist|   6|    100000|     100|0.42392682|  PASSED  
         rgb_bitdist|   7|    100000|     100|0.89174165|  PASSED  
         rgb_bitdist|   8|    100000|     100|0.65737678|  PASSED  
         rgb_bitdist|   9|    100000|     100|0.98717990|  PASSED  
         rgb_bitdist|  10|    100000|     100|0.33063485|  PASSED  
         rgb_bitdist|  11|    100000|     100|0.64609554|  PASSED  

...

@sa6mwa sa6mwa added this to the Cryptographically secure milestone May 27, 2021
@sa6mwa sa6mwa added the enhancement New feature or request label May 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Todo
Development

No branches or pull requests

1 participant