Wisniewska Comparing Quality SwBiR V9 1-2 2018
Wisniewska Comparing Quality SwBiR V9 1-2 2018
Joanna WIŚNIEWSKA
Wojskowa Akademia Techniczna
ul. gen. W. Urbanowicza 2, 00-908 Warszawa
E-mail: joanna.wisniewska@wat.edu.pl
73
Joanna WIŚNIEWSKA
numbers, e.g. MT19937 (period 4,3 x 106001), MRG32K3A (period 3,1 x 1057),
LFSR113 (period 1034), GM61 (period 5,3 x 1036).
TRNGs are physical generators which use a quantum physics phenomenon to obtain
truly random values. We can imagine the whole procedure as a measurement of a single
photon’s state. Two basic states of one photon may be expressed as a vertical or
horizontal polarization – just like a single bit which may hold a value 0 or 1. Quantum
states have this advantage that except of being equal to one of the basic states, they may
be a mixture of basic states. Using Dirac notation, a single photon state we can express
as |uv〉:
|uv〉 = 6 |u0〉 + 6 |u1〉 . (1)
u u
Let us assume that |0〉 corresponds to the vertical polarization and |1〉 to the horizontal
polarization. Complex numbers 6 and 6 , called amplitudes, describe the probability if
the state after the measurement is, respectively, |u0〉 or |u1〉, therefore: |6 | + |6 | = 1.
The generator produces quantum state:
74
Comparing quality of pseudo- and true-random numbers
obtained from different sources
In next section of this work results of tests for some pseudo- and true-random numbers
will be presented. A battery chosen for this task is Dieharder, because the software is
still developed and updated. It is very easy to install and use on Linux-like operating
systems.
The Dieharder battery contains the following tests from Marsaglia’s Diehard:
• Birthday spacing – { days from O-day year are generated (O ≥ 2 | ).
The spacings between drawed days should be asymptotically exponentially
distributed.
• Overlapping permutations – permutations of five consecutive numbers are
generated. This 120 series should occur in an analyzed set with an equal
probability.
• Binary rank matrices – 40000 binary matrices sized 32 × 32 are generated.
The rank of every matrix is calculated. Matrices with the rank greater than 28
are counted. Numbers of these matrices should be consistent with chi-squared
test.
• Monkey tests – four tests (Bitstream, Overlapping Pairs Sparse Occupancy,
Overlapping Quadruples Sparse Occupancy, DNA Test) based on the infinite
monkey theorem saying that if there is enough time and monkeys equipped
with typewriters they are able write all Shakespeare’s plays.
• Count the 1s – the generated series are divided to O-element sequences.
In every sequence the number of 1s is counted. The sequences are converted
to letters, e.g. if there is zero 1s letter A is producted, for two 1s letter B, etc.
The distribution of letters in the series is analyzed.
• Parking lot test – in 2-dimentional array 100 × 100. There are 12000 numbers
generated (from range 1 to 10000). The number of values generated only once
should follow the normal distribution.
• Random spheres tests – in 2- or 3-dimentional array (1000 × 1000 or 1000 ×
1000 × 1000) 8000 or 4000, respectively, cells are randomly chosen. These
cells become centers of the spheres with maximum radiuses not overlapping
their neighbors. The distribution for the number of smallest spheres should be
exponential.
• Squeeze test – the number 231 is multiplied by random floats from range (0,1)
until the result is equal 1. The test is performed 100000 times. The number
of generated floats should follow a certain distribution.
• Overlapping sums – long sequences of floats from range (0,1) are generated.
Every 100 consecutive floats are added. The sums should be normally
distributed.
• Runs tests – long sequences of floats from range (0,1) are generated.
The length of subseries of ascending and descending values are counted.
The obtained sums should follow a certain distribution.
• Craps tests – 200000 games of craps are simulated. The numbers of wins
and throws per game should follow a certain distribution.
The tests added by Robert G. Brown are:
75
Joanna WIŚNIEWSKA
• Marsaglia-Tsang GCD – 107 32-bit unsigned integers are generated. For every
pair of the numbers their greatest common divisor (GCD) is calculated with
use of the Euclid’s Method. The GCDs and number of algorithm’s steps should
follow a certain distribution.
• STS Monobit test – counts the 1s in a long sequence of 32-bit unsigned
integers. The sum is compared to the expected value.
• STS Runs – the binary series are generated. Counted are “0 run” and “1 run”
which should follow a certain distribution. “0 run” begins with 10 and ends
with 01. “1 run” begins with 01 and ends with 10.
• STS Serial tests – for the parameter O = €€€€€€ 1,16, 2• O-bit sequences are
generated. The number of the same sequences should occur with the same
probability.
• STS Serial tests with overlapping – tests similar to above, but additionally
a cyclic wrap is realized on the analyzed series.
• RGB Bit Distribution tests – O-element tuples of 0s and 1s are generated where
O = €€€€€€
1,12. The numbers of the same elements on the same positions should be
consistent with the chi-squared test.
• RGB Minimum Distance Tests – four hybrid tests, made as the generalizations
of Random Spheres and Minimum Distance tests (Minimum Distance test is
originally Diehard test in which distances between 8000 points in 2-dimen-
sional array (10000 × 10000) should follow exponential distribution).
• RGB Permutations tests – O! permutations of O numbers are generated
(O = €€€€
2,5). In the tested series all permutations should occur the same number
of times.
• RGB Lagged Sum tests – the generated numbers are added with skipping of O
elements (O = €€€€€€
0,32). The average value of the summed numbers should fit
to the average values of numbers from the generator’s range.
• RGB Kolmogorov-Smirnov test – the generated values should follow the
Anderson-Darling or Kuiper Kolmogorov-Smirnov test.
• DAB Byte Distribution test – there are 256 × O counters, O independent bytes
are extracted from each of consecutive words. The counters are increased if
the bytes repeat in the words. Values of counters should be consistent with
the chi-squared test.
• DAB DCT Frequency Analysis test – the Discrete Cosine Transform (DCT)
is performed on the output of the number generator. The finite sequences
of the data points, in terms of a sum of cosine functions oscillating at different
frequencies, should be consistent with the chi-squared test.
• DAB Fill Tree test – a binary tree of the fixed depth is filled with the words
from the generator. When a word cannot be inserted into the tree, the counter
of words in tree is saved – these values should be consistent with the chi-
squared test.
• DAB Fill Tree 2 test – similar to previous test, but instead of the words
the trees are filled with the bits.
76
Comparing quality of pseudo- and true-random numbers
obtained from different sources
77
Joanna WIŚNIEWSKA
78
Comparing quality of pseudo-
pseudo and true-random numbers
obtained from different sources
79
Joanna WIŚNIEWSKA
5 Summary
In this section the obtained results for five generators, with use of Dieharder battery
of tests, will be commented. Additionally, it sounds reasonable to take into
consideration also a correlation between the results of the tests for every generator.
Comparing results for the PRNGs: MT19937 and RAND; we can see that RAND failed
in a greater number of the tests. In contrast to RAND, MT19937 did not obtain any
“failed” mark. For both aforementioned generators the correlation between tests is very
high. This means there are no significant differences between results of the tests, e.g.
most of all tests for MT19937 were passed, RAND failed all monkey tests.
The results for the TRNG are not prefect what may be surprising. It obtained “weak”
and “failed” marks in more tests than simple RAND generator. What can be observed
for this generator is that there are some tests results which are not correlated:
overlapping permutations were passed 4 times, failed twice and the mark “weak” was
reached 4 times; squeeze test was passed 4 times, failed 3 times and the mark “weak”
was obtained 3 times; in two craps tests there were 7 marks “passed”, 8 marks “weak”
and 5 marks “failed”.
Taking into account the results for DRNGs, we can observe that the function RdRand
differs a lot according to its implementation for the operating system. RdRand for
Fedora behaves similarly to MT19937 and RdRand for Windows like the TRNG.
RdRand on Fedora did not obtain any mark “failed” and the correlation between tests
results is very high. RdRand on Windows has more varied marks and the correlation
between tests results is lower, especially for: two binary rank matrices tests (6 times
“passed”, 11 times “weak”, 3 times “failed”), four monkey tests (24 times “passed”, 8
times “weak”, 8 times “failed”), two craps tests (3 times “passed”, 6 times “weak”, 11
times “failed”), 32 STS serial tests (221 times “passed”, 84 times “weak”, 15 times
“failed”), four RGB minimum distance tests (7 times “passed”, 15 times “weak”, 18
times “failed”), four RGB permutations tests (12 times “passed”, 16 times “weak”, 12
times “failed”) and RGB Kolmogorov-Smirnov test (5 times “passed”, 4 times “weak”,
1 time “failed”).
80
Comparing quality of pseudo-
pseudo and true-random numbers
obtained from different sources
81
Joanna WIŚNIEWSKA
7. Rukhin A., Soto J., Nechvatal J., Smid M., Barker E., Leigh S., Levenson M.,
Vangel M., Banks D., Heckert A., Dray J., Vo S.: A Statistical Test Suite for
Random and Pseudorandom Number Generators for Cryptographic Applications.
Raport NIST, 2010
Summary
The manuscript refers to the problem of the pseudorandom numbers generation.
Numbers needed during a simulation may be generated by pseudorandom numbers
generators but also by true random numbers generators or digital random number
generators. In this work some tests were described which help to evaluate quality
of random values. For five generators, the batteries of tests were run and the manuscript
contains results of these tests in a form of graphs.
Keywords: (pseudo)random numbers generators, quality of random values, simulation
82
Symulacja w Badaniach i Rozwoju
Vol. 9, No. 1-2/2018
83