Package nxt.addons

Class ReproducibleRandomness

java.lang.Object
nxt.addons.ReproducibleRandomness
All Implemented Interfaces:
RandomnessSource

public class ReproducibleRandomness extends Object implements RandomnessSource
The purpose of this class is to make sure all contract runners will generate the same random numbers given the same random seed. Unfortunately, the default SecureRandom implementation in Java 9+ does not respect this property i.e. given the same random seed even two different secure random objects in the same process will generate different numbers. The java.util.Random implementation is reproducible, but is trivial to predict. We therefore rely on the "SHA1PRNG" algorithm (Java 8 default) which is reproducible and provides reasonable level of security and interoperability between Java versions. This class delegates all random number requests to the actual secure random.