Module TestU01.Bbattery

Bbattery

This module contains predefined batteries of statistical tests for sources of random bits or sequences of uniform random numbers in the interval [0,1). To test a RNG for general use, one could first apply the small and fast battery SmallCrush. If it passes, one could then apply the more stringent battery Crush, and finally the yet more time-consuming battery BigCrush.The batteries Alphabit and Rabbit can be applied on a binary file considered as a source of random bits. They can also be applied on a programmed generator. Alphabit has been defined primarily to test hardware random bits generators. The battery PseudoDIEHARD applies most of the tests in the well-known DIEHARD suite of Marsaglia. The battery FIPS-140-2 implements the small suite of tests of the FIPS-140-2 standard from NIST.

The batteries described in this module will write the results of each test (on standard output) with a standard level of details (assuming that the boolean switches of module Swrite have their default values), followed by a summary report of the suspect p-values obtained from the specific tests included in the batteries. It is also possible to get only the summary report in the output, with no detailed output from the tests, by setting the boolean switch Swrite.set_basic to false.

Some of the tests compute more than one statistic using the same stream of random numbers and these statistics are thus not independent. That is why the number of statistics in the summary reports is larger than the number of tests in the description of the batteries.

SmallCrush

val small_crush : Unif01.gen -> unit
val small_crush_file : string -> unit
val repeat_small_crush : Unif01.gen -> int array -> unit
val ntests_small_crush : int

Number of tests in SmallCrush: 10.

Crush

val crush : Unif01.gen -> unit
val repeat_crush : Unif01.gen -> int array -> unit

Similar to repeat_small_crush above but applied on Crush.

val ntests_crush : int

Number of tests in Crush: 96.

BigCrush

val big_crush : Unif01.gen -> unit
val repeat_big_crush : Unif01.gen -> int array -> unit

Similar to repeat_small_crush above but applied on BigCrush.

val ntests_big_crush : int

Number of tests in BigCrush: 106.

Rabbit

val rabbit : Unif01.gen -> float -> unit

Applies the Rabbit battery of tests to the generator gen using at most nb bits for each test. See the description of the tests in rabbit_file.

val rabbit_file : string -> float -> unit
val repeat_rabbit : Unif01.gen -> float -> int array -> unit

Similar to repeat_small_crush above but applied on Rabbit.

val ntests_rabbit : int

Number of tests in Rabbit: 26.

Alphabit

val alphabit : Unif01.gen -> float -> int -> int -> unit

alphabit gen nb r s applies the Alphabit battery of tests to the generator gen using at most nb bits for each test. The bits themselves are processed as blocks of 32 bits (unsigned integers). For each block of 32 bits, the r most significant bits are dropped, and the test is applied on the s following bits. If one wants to test all bits of the stream, one should set r = 0 and s = 32. If one wants to test only 1 bit out of 32, one should set s = 1. See the description of the tests in alphabit_file.

val alphabit_file : string -> float -> unit
val repeat_alphabit : Unif01.gen -> float -> int -> int -> int array -> unit

Similar to repeat_small_crush above but applied on Alphabit.

val ntests_alphabit : int

Number of tests in Alphabit: 9.

BlockAlphabit

val block_alphabit : Unif01.gen -> float -> int -> int -> unit
val block_alphabit_file : string -> float -> unit
val repeat_block_alphabit : Unif01.gen -> float -> int -> int -> int array -> int -> unit

Similar to repeat_small_crush above but applied on BlockAlphabit. The parameter w is the one described in block_alphabit. Restrictions: w ∈ {1,2,4,8,16,32} and w≤s.

val ntests_block_alphabit : int

Number of tests in BlockAlphabit: 9.

PseudoDIEHARD

val pseudo_diehard : Unif01.gen -> unit
val ntests_pseudo_diehard : int

Number of tests in PseudoDIEHARD: 15.

NIST

The NIST (National Institute of Standards and Technology) of the U.S. federal government has proposed a statistical test suite for use in the evaluation of the randomness of bitstreams produced by cryptographic random number generators. The test parameters are not predetermined. The NIST tests and the equivalent tests in TestU01 are:

  1. The Monobit test. This corresponds to Sstring.hamming_weight_2 with L = n.
  2. The Frequency test within a Block. Corresponds to Sstring.hamming_weight_2.
  3. The Runs test. Is implemented as Sstring.run.
  4. The test for the Longest Run of Ones in a Block. Is implemented as the test Sstring.longest_head_run.
  5. The Binary Matrix rank test. Is implemented as Smarsa.matrix_rank.
  6. The Discrete Fourier Transform test. Is implemented as Sspectral.fourier_1.
  7. The Non-overlapping Template Matching test. Is implemented as the test Smarsa.cat_bits.
  8. The Overlapping Template Matching test. This test does not exist as such in TestU01, but a similar and more powerful test is Smultin.multinomial_bits_over.
  9. Maurer’s Universal Statistical test. This test is implemented as Svaria.appearance_spacings.
  10. The Lempel-Ziv Compression test. Is implemented as Scomp.lempel_ziv.
  11. The Linear Complexity test. Is implemented as part of Scomp.linear_comp.
  12. The Serial test. Corresponds to Smultin.multinomail_bits_over with Delta = 1.
  13. The Approximate Entropy test. Corresponds to Smultin.multinomial_bits_over with Delta = 0, and to Sentrop.entropy_disc_over or Sentrop.entropy_disc_over_2.
  14. The Cumulative Sums test. This test is closely related to the M statistic in Swalk.random_walk_1.
  15. The Random Excursions test. This test does not exist in TestU01, but closely related tests are in Swalk.random_walk_1.
  16. The Random Excursions Variant test. This test does not exist in TestU01, but a closely related test is based on the R statistic in Swalk.random_walk_1.

FIPS-140-2

val fips_140_2 : Unif01.gen -> unit
val fips_140_2_file : string -> unit
val ntests_fips_140_2 : int

Number of tests in FIPS-140-2: 4.