This is a python 3.6 and above implementation of the NIST Test Suite for Random Number Generators (RNGs). The idea behind this work is to make a script oriented object-oriented framework for said tests. This is born from my research since I required to use the tests inside a python research project and I found existing implementation to be not well suited to that task without extensive modifications.
The NIST reference paper can be found at SP800-22r1a.
This work is inspired by the great work of David Johnston (C) 2017, which can be found on github.
Features
All the test in the NIST paper vectorized and optimized the best I could
Class structure for each test allowing for easy debug and use, both in script and inside broader applications
Utility functions to pack the sequence in 8-bits using numpy and to run the tests in multiple ways
Cache system both at function level and at test level to improve performance
Built-in measurement of time required to perform each test
Default Test class and Result class to allow eventual extension to additional tests
License
BSD 3-Clause License
For additional information check the provided license file.
How to install
If you only need to use the framework, just download the pip package nistrng and import the package in your scripts:
pip install nistrng
If you want to improve/modify/extends the framework, or even just try my own simple benchmarks at home, download or clone the git repository. You are welcome to open issues or participate in the project, especially if further optimization is achieved.
How to use
For a simple use case, refer to benchmark provided in the repository. For advanced use, refer to the built-in documentation and to the provided source code in the repository.
Current issues
Currently the slow speed of both the Serial and Approximate Entropy tests is an open issue. Any solution or improvement is welcome.
Can I help?
Yes, of course! This project is very side to me, so any help in reporting issues, fixing bugs, testing functionalities and overall improving it is welcome!
Changelog
v. 1.2.1:
Improved safe-guard against eventual NaN values that may arise inside the score calculations
Added unpack function to return to the original numeric integer value from a 8-bit binary sequence
Some minor fixes and adjustments
v. 1.2.2:
Fixed SP800_22R1A_BATTERY dictionary which was missing the cumulative sums test
Fixed missing parenthesis on test_approximate_entropy.py
Fixed bugs on some tests for very long sequences
Some minor fixes and adjustments
v. 1.2.3:
Fixed binary matrix rank test (credits to @scrambler-crypto)
Fixed a frequencies computation bug (w.r.t. tickets) on the linear complexity test
Metadata
Release files for nistrng 1.2.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| nistrng-1.2.3.tar.gz | 19.8 kB | Without provenance | Details |
Release files / nistrng-1.2.3.tar.gz
| Download URL | nistrng-1.2.3.tar.gz |
|---|---|
| Size | 19.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
83030d7b2a55a09a9bf2e17a160dec0a6ef4bf0f13245bb086b3f116e88333f8
|
|
BLAKE2b-256 checksum How to use checksums |
3441256fb0b266d271cec12ae87c2f833148deb6dbdf40048a3a3aac843b9bd3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/42.0.1.post20191125 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.6.9
|
Security for nistrng 1.2.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.