A powerful .NET library for generating and testing high-quality truly random data using consumer hardware (generation is available only for Windows). Includes easy-to-use implementation of the NIST SP 800-22 test library. No external dependencies.
The library allows developers to retrieve low-entropy data from microphones, cameras and user input (mouse and keyboard), process this low-entropy data into high-entropy using different randomness extractors, test it using a library of tests defined in NIST SP 800-22, store and retrieve it and finally use it to get random data of various types:
//Using camera as an entropy source
VideoSource source = new VideoSource();
//Creating extractors
DeflateExtractor deflateExtractor = new DeflateExtractor();
ShuffleExtractor shuffleExtractor = new ShuffleExtractor();
HashExtractor hashExtractor = new HashExtractor();
//Creating tester
Tester tester = new Tester();
//Creating buffer
Buffer buffer = new Buffer();
//Linking all the modules together
deflateExtractor.AddSource(source);
shuffleExtractor.AddSource(deflateExtractor);
hashExtractor.AddSource(shuffleExtractor);
tester.AddSource(hashExtractor);
buffer.AddSource(tester);
//Starting the chain
source.Start();
deflateExtractor.Start();
shuffleExtractor.Start();
hashExtractor.Start();
tester.Start();
buffer.Start();
//Waiting for data to collect
while (buffer.BytesInBuffer < 1000)
{
Thread.Sleep(100);
}
//Using the data
int result = buffer.DataSource.GetInt();
Library can be simply used to test user data with test functions defined in NIST SP 800-22:
if (TrulyRandom.NistTests.Frequency(userData).PValues[0] > 0.01)
{
System.Console.WriteLine("Success!");
}
And finally it provides a number of additional features:
- Sample application to ease the startup;
- Creation of the detailed test reports;
- Long-term evaluation of the generator quality;
- Automatic dumping of the exccess random data to the disk and retrieval from it when required;
- Automatic test parameter selection in accordance to NIST SP 800-22;
- Extractor seeding;
- Dynamic compression adjustment depending on the output buffer state;
- Module statistics: throughput in bytes per second, enthropy level, success rate, etc.;
- Device autoselection for video and audio sources;
- Still image detection;
- Generation of different types of random data from the collected entropy;
- Additional utilites like random array shuffle.
Please, if you find this library useful (or useless) or you have any other suggestions or comments - don't hesitate to contact me.