Description
Each implementing class represented by RandomSource has a defined seed type. The internal package knows the type and can create appropriate seeds. This occurs when a null seed is passed to the factory method create(RandomSource, ...).
Notably the seed generation functionality satisfies any extra requirements of the generator such as avoiding all zero bytes and, for example, low complexity bytes for the MiddleSquareWeylSequence class.
The seed generation functionality can be exposed to allow:
- Generation of a seed that exactly matches that generated in the factory create method
- Generation of a seed using a user defined source of randomness
This requires 2 new methods in RandomSource:
// To use the factory source of randomness public byte[] createSeed(); // To use a user-defined source of randomness public byte[] createSeed(UniformRandomProvider rng);
This would allow separation of seed generation from RNG construction:
RandomSource source = ...; UniformRandomProvider rng = RandomSource.create(source);
Becomes
RandomSource source = ...; byte[] seed = source.createSeed(); // Some later point UniformRandomProvider rng = RandomSource.create(source, seed);
An example of a user-defined source of randomness:
RandomSource source = ...; UniformRandomProvider seedRng = new JDKRandomWrapper(new SecureRandom()); byte[] seed = source.createSeed(seedRng); UniformRandomProvider rng = RandomSource.create(source, seed);
Attachments
Issue Links
- is a child of
-
RNG-116 RandomSource to expose supported functionality and seed size
- Closed
- links to