This repository implements a cryptographically secure Random Number Generator (RNG) built on HMAC-DRBG (Deterministic Random Bit Generator).
The project follows the technical requirements from GLI-19 Chapter 3: Random Number Generator (RNG) Requirements.
This implementation is designed as production-ready RNG code and can be submitted for GLI / iTech Labs certification.
cli- CLI tools for generating test dataexamples- Example usage of the RNGsrc/hmac-drbg- HMAC-DRBG implementationsrc/rng- Shuffling, scaling and draw utilitiessrc/utils- Some helpful utilities
This project includes a Dockerfile with dieharder.
docker build -t 1fun-rng .
docker run -it --rm 1fun-rng
⚠️ Note on Dieharder Testing
Some statistical tests in the Dieharder suite are very data-hungry.
To achieve a full "PASSED" status across all tests, a large amount of RNG output data may be required.
This is expected behavior since certain tests need millions or even billions of samples to converge reliably.
npx ts-node ./cli/generate-dieharder-ascii.ts \
--server-seed abcdefghijklmnopqrstuvwxyz \
--client-seed abcdefghijklmnopqrstuvwxyz \
--count 2684354560 \
--destination data/hmac-dbrng.txtThis creates a file hmac-dbrng.txt with 2 684 354 560 uint32 values generated with the HMAC-DRBG algorithm.
It can be used with the dieharder test suite:
dieharder -g 202 -f data/hmac-dbrng.txt -anpx ts-node ./cli/generate-dieharder-bin.ts \
--server-seed abcdefghijklmnopqrstuvwxyz \
--client-seed abcdefghijklmnopqrstuvwxyz \
--count 2684354560 \
--destination data/hmac-dbrng.binThis creates a file hmac-dbrng.bin with 2 684 354 560 uint32 values (10GiB of data) generated with the HMAC-DRBG algorithm.
It can be used with the dieharder test suite:
dieharder -g 201 -f data/hmac-dbrng.bin -anpx ts-node ./cli/generate-gli-output.ts \
--server-seed abcdefghijklmnopqrstuvwxyz \
--client-seed abcdefghijklmnopqrstuvwxyz \
--range-start 1 \
--range-end 52 \
--selections 52 \
--draws 100000 \
--destination data/gli.txtThe additional parameter --with-replacements allows for numbers to be repeated within selections.
range-start and range-end are inclusive
This project draws ideas and inspiration (and in some cases code concepts) from the following open-source projects: