bbs 0.0.1
bbs: ^0.0.1 copied to clipboard
Implementation of the BlumBlumShub CSPRNG (Cryptographically Secure Pseudo Random Number Generator)
bbs #
Implementation of the BlumBlumShub algorithm adapted from VSpikes python implementation. This provides an easy to use interface of the BBS CSPRNG (Cryptographically Secure Pseudo Random Number Generator).
Warning: This implementation has not been tested in production nor has it been examined by a security audit. All uses are your own responsibility.
Caveats #
This CSPRNG is just as secure as the primes which are used to generate random numbers. By
default, this implementation uses two 128 bit primes (which you can change by passing
a custom bit amount to the BlumBlumShub constructor).
Usage #
As this CSPRNG implements the dart:math.Random interface, all familiar methods like
nextInt and nextBool. Currently, nextDouble is not implemented and will raise an
UnimplementedError. To instantiate a BlumBlumShub generator, proceed as follows:
var bbs = new BlumBlumShub();
If you want to change the amount of bits used by a generator, instantiate it passing the desired number of bits to use (CAUTION: The number of bits is divided by two because two primes have to be created).
var bbs = new BlumBlumShub(1024);
After you've instantiated a generator, use it as you wish.
bbs.nextInt(100);
bbs.next(100); // Generates a 100 bit BigInteger value
bbs.nextBool();
Features and bugs #
If you want a feature: Pull requests are always welcome. For bugs, open an issue or also: Pull request.