diff --git a/results/dieharder/README.md b/results/dieharder/README.md new file mode 100644 index 0000000..f1395a6 --- /dev/null +++ b/results/dieharder/README.md @@ -0,0 +1,20 @@ +# Guide to Dieharder Results + +Test suite: dieharder version 3.31.2 Copyright 2003 Robert G. Brown + +More information on dieharder test suite can be seen here: https://webhome.phy.duke.edu/~rgb/General/dieharder.php + +Notes are provided below on how the various files were generated: + +## Files + +A discussion of how files were created and a summary of results therein are provided below. + +- `rainstorm-256.txt`: The source file was generated with `rainsum -a storm -s 256 -l 4000000 -o storm-256-4M.bin` which produces 4 million 256-bit output values. These are then read by dieharder as a stream of bits and shaped into whatever input format (ints, 32-bit ints, whatever) that a test requires. The file is "rewound" when it is exhausted. The total files size is 1 gigabyte. Dieharder was then run on the file with `dieharder -a -g 201 bow-256-4M.bin` to produce the included results file `rainbow-256.txt`. You can see that while most tests pass, some are weak and some fail. I think this is because the file is "too short" for some tests and is rewound. The reason I think this is because when I run it in "open format" (that is, streamed infinitely from rainsum and piped directly to dieharder, rather than through a fixed length file) all occasions for regret disappear. + +- `rainbow-256.txt`: The source file was generated with `rainsum -a bow -s 256 -l 4000000 -o bow-256-4M.bin` which produces 4 million 256-bit output values. These are then read by dieharder as a stream of bits and shaped into whatever input format (ints, 32-bit ints, whatever) that a test requires. The file is "rewound" when it is exhausted. The total files size is 1 gigabyte. Dieharder was then run on the file with `dieharder -a -g 201 bow-256-4M.bin` to produce the included results file `rainbow-256.txt`. You can see that while most tests pass, some are weak and some fail. I think this is because the file is "too short" for some tests and is rewound. The reason I think this is because when I run it in "open format" (that is, streamed infinitely from rainsum and piped directly to dieharder, rather than through a fixed length file) all occasions for regret disappear. + +- `rainbow-64-infinite.txt`: The source stream was generated with `rainsum -a bow -s 64 -l 4000000000` (which would generate more than enough for a full run of dieharder). The stream was consumed by dieharder using the command: `rainsum dieharder -m stream -a bow -s 64 -l 4000000000 | ./dieharder -a -g 200` (in effect keying the stream generation off of hashing the dieharder binary itself!). This produces the included results file, which, as you can see, evidently passes all tests with 1 weak and NO fail. + +- `rainstorm-64-infinite.txt`: The source stream was generated with `rainsum -a storm -s 64 -l 4000000000` (which would generate more than enough for a full run of dieharder). The stream was consumed by dieharder using the command: `rainsum dieharder -m stream -a storm -s 64 -l 4000000000 | ./dieharder -a -g 200` (in effect keying the stream generation off of hashing the dieharder binary itself!). This produces the included results file, which, as you can see, evidently passes all tests with 2 weak and NO fail. + diff --git a/results/dieharder/rainbow-64-infinite.txt b/results/dieharder/rainbow-64-infinite.txt new file mode 100644 index 0000000..3cae8e0 --- /dev/null +++ b/results/dieharder/rainbow-64-infinite.txt @@ -0,0 +1,118 @@ +#=============================================================================# +# dieharder version 3.31.2 Copyright 2003 Robert G. Brown # +#=============================================================================# + rng_name |rands/second| Seed | +stdin_input_raw| 3.72e+07 |1650568772| +#=============================================================================# + test_name |ntup| tsamples |psamples| p-value |Assessment +#=============================================================================# + diehard_birthdays| 0| 100| 100|0.97620874| PASSED + diehard_operm5| 0| 1000000| 100|0.87873560| PASSED + diehard_rank_32x32| 0| 40000| 100|0.14448625| PASSED + diehard_rank_6x8| 0| 100000| 100|0.62530876| PASSED + diehard_bitstream| 0| 2097152| 100|0.24952078| PASSED + diehard_opso| 0| 2097152| 100|0.55730109| PASSED + diehard_oqso| 0| 2097152| 100|0.21102166| PASSED + diehard_dna| 0| 2097152| 100|0.15110870| PASSED +diehard_count_1s_str| 0| 256000| 100|0.35610311| PASSED +diehard_count_1s_byt| 0| 256000| 100|0.77679896| PASSED + diehard_parking_lot| 0| 12000| 100|0.08460368| PASSED + diehard_2dsphere| 2| 8000| 100|0.85007183| PASSED + diehard_3dsphere| 3| 4000| 100|0.01743816| PASSED + diehard_squeeze| 0| 100000| 100|0.12547237| PASSED + diehard_sums| 0| 100| 100|0.08855109| PASSED + diehard_runs| 0| 100000| 100|0.08051884| PASSED + diehard_runs| 0| 100000| 100|0.40950717| PASSED + diehard_craps| 0| 200000| 100|0.36943614| PASSED + diehard_craps| 0| 200000| 100|0.78011361| PASSED + marsaglia_tsang_gcd| 0| 10000000| 100|0.94508197| PASSED + marsaglia_tsang_gcd| 0| 10000000| 100|0.18177180| PASSED + sts_monobit| 1| 100000| 100|0.33093204| PASSED + sts_runs| 2| 100000| 100|0.36332786| PASSED + sts_serial| 1| 100000| 100|0.98562669| PASSED + sts_serial| 2| 100000| 100|0.35962966| PASSED + sts_serial| 3| 100000| 100|0.42374822| PASSED + sts_serial| 3| 100000| 100|0.97159250| PASSED + sts_serial| 4| 100000| 100|0.15284886| PASSED + sts_serial| 4| 100000| 100|0.91212379| PASSED + sts_serial| 5| 100000| 100|0.20847892| PASSED + sts_serial| 5| 100000| 100|0.65272799| PASSED + sts_serial| 6| 100000| 100|0.58495391| PASSED + sts_serial| 6| 100000| 100|0.31534988| PASSED + sts_serial| 7| 100000| 100|0.26478981| PASSED + sts_serial| 7| 100000| 100|0.78532625| PASSED + sts_serial| 8| 100000| 100|0.87132459| PASSED + sts_serial| 8| 100000| 100|0.96367403| PASSED + sts_serial| 9| 100000| 100|0.22798102| PASSED + sts_serial| 9| 100000| 100|0.41398155| PASSED + sts_serial| 10| 100000| 100|0.31406992| PASSED + sts_serial| 10| 100000| 100|0.58740553| PASSED + sts_serial| 11| 100000| 100|0.04652123| PASSED + sts_serial| 11| 100000| 100|0.24269179| PASSED + sts_serial| 12| 100000| 100|0.10806450| PASSED + sts_serial| 12| 100000| 100|0.43513453| PASSED + sts_serial| 13| 100000| 100|0.19593585| PASSED + sts_serial| 13| 100000| 100|0.14176875| PASSED + sts_serial| 14| 100000| 100|0.35386390| PASSED + sts_serial| 14| 100000| 100|0.72152274| PASSED + sts_serial| 15| 100000| 100|0.55460201| PASSED + sts_serial| 15| 100000| 100|0.56612314| PASSED + sts_serial| 16| 100000| 100|0.91734962| PASSED + sts_serial| 16| 100000| 100|0.87905532| PASSED + rgb_bitdist| 1| 100000| 100|0.23389621| PASSED + rgb_bitdist| 2| 100000| 100|0.34904630| PASSED + rgb_bitdist| 3| 100000| 100|0.10891006| PASSED + rgb_bitdist| 4| 100000| 100|0.57593753| PASSED + rgb_bitdist| 5| 100000| 100|0.93546439| PASSED + rgb_bitdist| 6| 100000| 100|0.56909583| PASSED + rgb_bitdist| 7| 100000| 100|0.63706155| PASSED + rgb_bitdist| 8| 100000| 100|0.78720354| PASSED + rgb_bitdist| 9| 100000| 100|0.46654419| PASSED + rgb_bitdist| 10| 100000| 100|0.59302007| PASSED + rgb_bitdist| 11| 100000| 100|0.36861761| PASSED + rgb_bitdist| 12| 100000| 100|0.31745077| PASSED +rgb_minimum_distance| 2| 10000| 1000|0.54622896| PASSED +rgb_minimum_distance| 3| 10000| 1000|0.29125187| PASSED +rgb_minimum_distance| 4| 10000| 1000|0.23210571| PASSED +rgb_minimum_distance| 5| 10000| 1000|0.02743919| PASSED + rgb_permutations| 2| 100000| 100|0.53865960| PASSED + rgb_permutations| 3| 100000| 100|0.10033653| PASSED + rgb_permutations| 4| 100000| 100|0.11184889| PASSED + rgb_permutations| 5| 100000| 100|0.79859250| PASSED + rgb_lagged_sum| 0| 1000000| 100|0.69225913| PASSED + rgb_lagged_sum| 1| 1000000| 100|0.74135606| PASSED + rgb_lagged_sum| 2| 1000000| 100|0.23229680| PASSED + rgb_lagged_sum| 3| 1000000| 100|0.99478715| PASSED + rgb_lagged_sum| 4| 1000000| 100|0.45133633| PASSED + rgb_lagged_sum| 5| 1000000| 100|0.68619018| PASSED + rgb_lagged_sum| 6| 1000000| 100|0.87943401| PASSED + rgb_lagged_sum| 7| 1000000| 100|0.70647842| PASSED + rgb_lagged_sum| 8| 1000000| 100|0.08420323| PASSED + rgb_lagged_sum| 9| 1000000| 100|0.80586279| PASSED + rgb_lagged_sum| 10| 1000000| 100|0.99117863| PASSED + rgb_lagged_sum| 11| 1000000| 100|0.44821676| PASSED + rgb_lagged_sum| 12| 1000000| 100|0.45967132| PASSED + rgb_lagged_sum| 13| 1000000| 100|0.67364481| PASSED + rgb_lagged_sum| 14| 1000000| 100|0.79992808| PASSED + rgb_lagged_sum| 15| 1000000| 100|0.96239638| PASSED + rgb_lagged_sum| 16| 1000000| 100|0.81617319| PASSED + rgb_lagged_sum| 17| 1000000| 100|0.62173146| PASSED + rgb_lagged_sum| 18| 1000000| 100|0.63405946| PASSED + rgb_lagged_sum| 19| 1000000| 100|0.52790775| PASSED + rgb_lagged_sum| 20| 1000000| 100|0.77707672| PASSED + rgb_lagged_sum| 21| 1000000| 100|0.62107020| PASSED + rgb_lagged_sum| 22| 1000000| 100|0.26253105| PASSED + rgb_lagged_sum| 23| 1000000| 100|0.43538242| PASSED + rgb_lagged_sum| 24| 1000000| 100|0.20333417| PASSED + rgb_lagged_sum| 25| 1000000| 100|0.91403647| PASSED + rgb_lagged_sum| 26| 1000000| 100|0.03074014| PASSED + rgb_lagged_sum| 27| 1000000| 100|0.99735934| WEAK + rgb_lagged_sum| 28| 1000000| 100|0.80150994| PASSED + rgb_lagged_sum| 29| 1000000| 100|0.42959136| PASSED + rgb_lagged_sum| 30| 1000000| 100|0.92416976| PASSED + rgb_lagged_sum| 31| 1000000| 100|0.34520536| PASSED + rgb_lagged_sum| 32| 1000000| 100|0.96519660| PASSED + rgb_kstest_test| 0| 10000| 1000|0.18983936| PASSED + dab_bytedistrib| 0| 51200000| 1|0.82570446| PASSED + dab_dct| 256| 50000| 1|0.53551438| PASSED + diff --git a/results/dieharder/rainstorm-64-infinite.txt b/results/dieharder/rainstorm-64-infinite.txt new file mode 100644 index 0000000..c6c124a --- /dev/null +++ b/results/dieharder/rainstorm-64-infinite.txt @@ -0,0 +1,118 @@ +#=============================================================================# +# dieharder version 3.31.2 Copyright 2003 Robert G. Brown # +#=============================================================================# + rng_name |rands/second| Seed | +stdin_input_raw| 2.25e+07 |1839658955| +#=============================================================================# + test_name |ntup| tsamples |psamples| p-value |Assessment +#=============================================================================# + diehard_birthdays| 0| 100| 100|0.02407438| PASSED + diehard_operm5| 0| 1000000| 100|0.30807741| PASSED + diehard_rank_32x32| 0| 40000| 100|0.79129707| PASSED + diehard_rank_6x8| 0| 100000| 100|0.57666722| PASSED + diehard_bitstream| 0| 2097152| 100|0.97431411| PASSED + diehard_opso| 0| 2097152| 100|0.96877577| PASSED + diehard_oqso| 0| 2097152| 100|0.63415543| PASSED + diehard_dna| 0| 2097152| 100|0.08686733| PASSED +diehard_count_1s_str| 0| 256000| 100|0.21189011| PASSED +diehard_count_1s_byt| 0| 256000| 100|0.12580921| PASSED + diehard_parking_lot| 0| 12000| 100|0.40756286| PASSED + diehard_2dsphere| 2| 8000| 100|0.12807352| PASSED + diehard_3dsphere| 3| 4000| 100|0.23233362| PASSED + diehard_squeeze| 0| 100000| 100|0.14801581| PASSED + diehard_sums| 0| 100| 100|0.18007782| PASSED + diehard_runs| 0| 100000| 100|0.90671851| PASSED + diehard_runs| 0| 100000| 100|0.10071335| PASSED + diehard_craps| 0| 200000| 100|0.43383791| PASSED + diehard_craps| 0| 200000| 100|0.71452827| PASSED + marsaglia_tsang_gcd| 0| 10000000| 100|0.98219683| PASSED + marsaglia_tsang_gcd| 0| 10000000| 100|0.32577364| PASSED + sts_monobit| 1| 100000| 100|0.58120308| PASSED + sts_runs| 2| 100000| 100|0.70673693| PASSED + sts_serial| 1| 100000| 100|0.68145655| PASSED + sts_serial| 2| 100000| 100|0.97812198| PASSED + sts_serial| 3| 100000| 100|0.86766859| PASSED + sts_serial| 3| 100000| 100|0.67469397| PASSED + sts_serial| 4| 100000| 100|0.20257142| PASSED + sts_serial| 4| 100000| 100|0.36443725| PASSED + sts_serial| 5| 100000| 100|0.84252787| PASSED + sts_serial| 5| 100000| 100|0.27926599| PASSED + sts_serial| 6| 100000| 100|0.37510775| PASSED + sts_serial| 6| 100000| 100|0.65433107| PASSED + sts_serial| 7| 100000| 100|0.25779069| PASSED + sts_serial| 7| 100000| 100|0.32259214| PASSED + sts_serial| 8| 100000| 100|0.00507906| PASSED + sts_serial| 8| 100000| 100|0.01597711| PASSED + sts_serial| 9| 100000| 100|0.40149534| PASSED + sts_serial| 9| 100000| 100|0.61609562| PASSED + sts_serial| 10| 100000| 100|0.80949613| PASSED + sts_serial| 10| 100000| 100|0.46224839| PASSED + sts_serial| 11| 100000| 100|0.76618608| PASSED + sts_serial| 11| 100000| 100|0.44094776| PASSED + sts_serial| 12| 100000| 100|0.58629000| PASSED + sts_serial| 12| 100000| 100|0.81242455| PASSED + sts_serial| 13| 100000| 100|0.92690456| PASSED + sts_serial| 13| 100000| 100|0.12271120| PASSED + sts_serial| 14| 100000| 100|0.16176432| PASSED + sts_serial| 14| 100000| 100|0.74941176| PASSED + sts_serial| 15| 100000| 100|0.16948284| PASSED + sts_serial| 15| 100000| 100|0.73627926| PASSED + sts_serial| 16| 100000| 100|0.87353684| PASSED + sts_serial| 16| 100000| 100|0.97880214| PASSED + rgb_bitdist| 1| 100000| 100|0.56228722| PASSED + rgb_bitdist| 2| 100000| 100|0.74644851| PASSED + rgb_bitdist| 3| 100000| 100|0.61395633| PASSED + rgb_bitdist| 4| 100000| 100|0.01131176| PASSED + rgb_bitdist| 5| 100000| 100|0.39296846| PASSED + rgb_bitdist| 6| 100000| 100|0.23725040| PASSED + rgb_bitdist| 7| 100000| 100|0.00916509| PASSED + rgb_bitdist| 8| 100000| 100|0.17725599| PASSED + rgb_bitdist| 9| 100000| 100|0.41642261| PASSED + rgb_bitdist| 10| 100000| 100|0.57519512| PASSED + rgb_bitdist| 11| 100000| 100|0.07583075| PASSED + rgb_bitdist| 12| 100000| 100|0.11602769| PASSED +rgb_minimum_distance| 2| 10000| 1000|0.29050660| PASSED +rgb_minimum_distance| 3| 10000| 1000|0.02238752| PASSED +rgb_minimum_distance| 4| 10000| 1000|0.35790653| PASSED +rgb_minimum_distance| 5| 10000| 1000|0.65438550| PASSED + rgb_permutations| 2| 100000| 100|0.94403562| PASSED + rgb_permutations| 3| 100000| 100|0.33032397| PASSED + rgb_permutations| 4| 100000| 100|0.99701756| WEAK + rgb_permutations| 5| 100000| 100|0.78499227| PASSED + rgb_lagged_sum| 0| 1000000| 100|0.34878668| PASSED + rgb_lagged_sum| 1| 1000000| 100|0.38787094| PASSED + rgb_lagged_sum| 2| 1000000| 100|0.07752410| PASSED + rgb_lagged_sum| 3| 1000000| 100|0.37931312| PASSED + rgb_lagged_sum| 4| 1000000| 100|0.42391076| PASSED + rgb_lagged_sum| 5| 1000000| 100|0.52886911| PASSED + rgb_lagged_sum| 6| 1000000| 100|0.24733170| PASSED + rgb_lagged_sum| 7| 1000000| 100|0.50089053| PASSED + rgb_lagged_sum| 8| 1000000| 100|0.79265691| PASSED + rgb_lagged_sum| 9| 1000000| 100|0.99851052| WEAK + rgb_lagged_sum| 10| 1000000| 100|0.47362070| PASSED + rgb_lagged_sum| 11| 1000000| 100|0.15064045| PASSED + rgb_lagged_sum| 12| 1000000| 100|0.07579120| PASSED + rgb_lagged_sum| 13| 1000000| 100|0.88455216| PASSED + rgb_lagged_sum| 14| 1000000| 100|0.94952468| PASSED + rgb_lagged_sum| 15| 1000000| 100|0.48593370| PASSED + rgb_lagged_sum| 16| 1000000| 100|0.80321155| PASSED + rgb_lagged_sum| 17| 1000000| 100|0.20458056| PASSED + rgb_lagged_sum| 18| 1000000| 100|0.99154847| PASSED + rgb_lagged_sum| 19| 1000000| 100|0.83686195| PASSED + rgb_lagged_sum| 20| 1000000| 100|0.42768902| PASSED + rgb_lagged_sum| 21| 1000000| 100|0.66267760| PASSED + rgb_lagged_sum| 22| 1000000| 100|0.90146841| PASSED + rgb_lagged_sum| 23| 1000000| 100|0.48599929| PASSED + rgb_lagged_sum| 24| 1000000| 100|0.04989900| PASSED + rgb_lagged_sum| 25| 1000000| 100|0.45638869| PASSED + rgb_lagged_sum| 26| 1000000| 100|0.01341698| PASSED + rgb_lagged_sum| 27| 1000000| 100|0.58866782| PASSED + rgb_lagged_sum| 28| 1000000| 100|0.12506567| PASSED + rgb_lagged_sum| 29| 1000000| 100|0.93729379| PASSED + rgb_lagged_sum| 30| 1000000| 100|0.14790577| PASSED + rgb_lagged_sum| 31| 1000000| 100|0.94046585| PASSED + rgb_lagged_sum| 32| 1000000| 100|0.32009907| PASSED + rgb_kstest_test| 0| 10000| 1000|0.03427524| PASSED + dab_bytedistrib| 0| 51200000| 1|0.13431819| PASSED + dab_dct| 256| 50000| 1|0.18071617| PASSED + diff --git a/src/rainsum.cpp b/src/rainsum.cpp index e295f84..92a74bc 100644 --- a/src/rainsum.cpp +++ b/src/rainsum.cpp @@ -42,9 +42,9 @@ std::vector test_vectors = {"", // Prototype of functions void usage(); -void performHash(Mode mode, const std::string& algorithm, const std::string& inpath, const std::string& outpath, uint32_t size, bool use_test_vectors, uint64_t seed, int output_length); +void performHash(Mode mode, const std::string& algorithm, const std::string& inpath, const std::string& outpath, uint32_t size, bool use_test_vectors, uint64_t seed, uint64_t output_length); std::string generate_filename(const std::string& filename); -void generate_hash(Mode mode, const std::string& algorithm, std::vector& buffer, uint64_t seed, int output_length, std::ostream& outstream, uint32_t hash_size); +void generate_hash(Mode mode, const std::string& algorithm, std::vector& buffer, uint64_t seed, uint64_t output_length, std::ostream& outstream, uint32_t hash_size); uint64_t hash_string_to_64_bit(const std::string& seed_str); int main(int argc, char** argv) { @@ -58,7 +58,7 @@ int main(int argc, char** argv) { ("s,size", "Specify the size of the hash", cxxopts::value()->default_value("256")) ("o,output-file", "Output file for the hash", cxxopts::value()->default_value("/dev/stdout")) ("t,test-vectors", "Calculate the hash of the standard test vectors", cxxopts::value()->default_value("false")) - ("l,output-length", "Output length in hashes", cxxopts::value()->default_value("1000000")) + ("l,output-length", "Output length in hashes", cxxopts::value()->default_value("1000000")) ("seed", "Seed value", seed_option) ("h,help", "Print usage"); @@ -103,7 +103,7 @@ int main(int argc, char** argv) { uint32_t size = result["size"].as(); std::string outpath = result["output-file"].as(); bool use_test_vectors = result["test-vectors"].as(); - int output_length = result["output-length"].as(); + uint64_t output_length = result["output-length"].as(); if ( mode == Mode::Digest ) { output_length = size / 8; @@ -179,7 +179,7 @@ uint64_t hash_string_to_64_bit(const std::string& seed_str) { return seed; } -void performHash(Mode mode, const std::string& algorithm, const std::string& inpath, const std::string& outpath, uint32_t size, bool use_test_vectors, uint64_t seed, int output_length) { +void performHash(Mode mode, const std::string& algorithm, const std::string& inpath, const std::string& outpath, uint32_t size, bool use_test_vectors, uint64_t seed, uint64_t output_length) { std::vector buffer; std::ofstream outfile(outpath, std::ios::binary); @@ -223,7 +223,7 @@ std::string generate_filename(const std::string& filename) { return new_filename; } -void generate_hash(Mode mode, const std::string& algorithm, std::vector& buffer, uint64_t seed, int output_length, std::ostream& outstream, uint32_t hash_size) { +void generate_hash(Mode mode, const std::string& algorithm, std::vector& buffer, uint64_t seed, uint64_t output_length, std::ostream& outstream, uint32_t hash_size) { int byte_size = hash_size / 8; std::vector temp_out(byte_size); @@ -238,7 +238,7 @@ void generate_hash(Mode mode, const std::string& algorithm, std::vector& b while(output_length > 0) { invokeHash(algorithm, seed, buffer, temp_out, hash_size); - int chunk_size = std::min(output_length, byte_size); + uint64_t chunk_size = std::min(output_length, (uint64_t)byte_size); outstream.write(reinterpret_cast(temp_out.data()), chunk_size); output_length -= chunk_size;