This repository implements a cryptographically secure Random Number Generator (RNG) built on **HMAC-DRBG** (Deterministic Random Bit Generator).
npm install @1fun-oss/rngThis 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``shell`
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.
`shell`
npx ts-node ./cli/generate-dieharder-ascii.ts \
--server-seed abcdefghijklmnopqrstuvwxyz \
--client-seed abcdefghijklmnopqrstuvwxyz \
--count 2684354560 \
--destination data/hmac-dbrng.txt
This 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:
`shell`
dieharder -g 202 -f data/hmac-dbrng.txt -a
`shell`
npx ts-node ./cli/generate-dieharder-bin.ts \
--server-seed abcdefghijklmnopqrstuvwxyz \
--client-seed abcdefghijklmnopqrstuvwxyz \
--count 2684354560 \
--destination data/hmac-dbrng.bin
This 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:
`shell`
dieharder -g 201 -f data/hmac-dbrng.bin -a
`shell`
npx 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.txt
The additional parameter --with-replacements` allows for numbers to be repeated within selections.
> range-start and range-end are inclusive
- Mintablo/mintablo-rng
- bcoin-org/bcrypto
- indutny/hmac-drbg