nxt.addons

## Class ReproducibleRandomness

- java.lang.Object
- - nxt.addons.ReproducibleRandomness

- All Implemented Interfaces:
    RandomnessSource

      public class ReproducibleRandomness
      extends java.lang.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.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ReproducibleRandomness()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.util.stream.DoubleStream` | `doubles()`
    `java.util.stream.DoubleStream` | `doubles(double randomNumberOrigin, double randomNumberBound)`
    `java.util.stream.DoubleStream` | `doubles(long streamSize)`
    `java.util.stream.DoubleStream` | `doubles(long streamSize, double randomNumberOrigin, double randomNumberBound)`
    `long` | `getSeed()`
    `java.util.stream.IntStream` | `ints()`
    `java.util.stream.IntStream` | `ints(int randomNumberOrigin, int randomNumberBound)`
    `java.util.stream.IntStream` | `ints(long streamSize)`
    `java.util.stream.IntStream` | `ints(long streamSize, int randomNumberOrigin, int randomNumberBound)`
    `java.util.stream.LongStream` | `longs()`
    `java.util.stream.LongStream` | `longs(long streamSize)`
    `java.util.stream.LongStream` | `longs(long randomNumberOrigin, long randomNumberBound)`
    `java.util.stream.LongStream` | `longs(long streamSize, long randomNumberOrigin, long randomNumberBound)`
    `boolean` | `nextBoolean()`
    `void` | `nextBytes(byte[] bytes)`
    `double` | `nextDouble()`
    `float` | `nextFloat()`
    `int` | `nextInt()`
    `int` | `nextInt(int bound)`
    `long` | `nextLong()`
    `void` | `setSeed(long seed)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### ReproducibleRandomness

          public ReproducibleRandomness()

  - ### Method Detail

    - #### setSeed

          public void setSeed(long seed)

      Specified by:
        `setSeed` in interface `RandomnessSource`

    - #### getSeed

          public long getSeed()

      Specified by:
        `getSeed` in interface `RandomnessSource`

    - #### nextBytes

          public void nextBytes(byte[] bytes)

      Specified by:
        `nextBytes` in interface `RandomnessSource`

    - #### nextInt

          public int nextInt()

      Specified by:
        `nextInt` in interface `RandomnessSource`

    - #### nextInt

          public int nextInt(int bound)

      Specified by:
        `nextInt` in interface `RandomnessSource`

    - #### nextLong

          public long nextLong()

      Specified by:
        `nextLong` in interface `RandomnessSource`

    - #### nextBoolean

          public boolean nextBoolean()

      Specified by:
        `nextBoolean` in interface `RandomnessSource`

    - #### nextFloat

          public float nextFloat()

      Specified by:
        `nextFloat` in interface `RandomnessSource`

    - #### nextDouble

          public double nextDouble()

      Specified by:
        `nextDouble` in interface `RandomnessSource`

    - #### ints

          public java.util.stream.IntStream ints(long streamSize)

      Specified by:
        `ints` in interface `RandomnessSource`

    - #### ints

          public java.util.stream.IntStream ints()

      Specified by:
        `ints` in interface `RandomnessSource`

    - #### ints

          public java.util.stream.IntStream ints(long streamSize,
                                                 int randomNumberOrigin,
                                                 int randomNumberBound)

      Specified by:
        `ints` in interface `RandomnessSource`

    - #### ints

          public java.util.stream.IntStream ints(int randomNumberOrigin,
                                                 int randomNumberBound)

      Specified by:
        `ints` in interface `RandomnessSource`

    - #### longs

          public java.util.stream.LongStream longs(long streamSize)

      Specified by:
        `longs` in interface `RandomnessSource`

    - #### longs

          public java.util.stream.LongStream longs()

      Specified by:
        `longs` in interface `RandomnessSource`

    - #### longs

          public java.util.stream.LongStream longs(long streamSize,
                                                   long randomNumberOrigin,
                                                   long randomNumberBound)

      Specified by:
        `longs` in interface `RandomnessSource`

    - #### longs

          public java.util.stream.LongStream longs(long randomNumberOrigin,
                                                   long randomNumberBound)

      Specified by:
        `longs` in interface `RandomnessSource`

    - #### doubles

          public java.util.stream.DoubleStream doubles(long streamSize)

      Specified by:
        `doubles` in interface `RandomnessSource`

    - #### doubles

          public java.util.stream.DoubleStream doubles()

      Specified by:
        `doubles` in interface `RandomnessSource`

    - #### doubles

          public java.util.stream.DoubleStream doubles(long streamSize,
                                                       double randomNumberOrigin,
                                                       double randomNumberBound)

      Specified by:
        `doubles` in interface `RandomnessSource`

    - #### doubles

          public java.util.stream.DoubleStream doubles(double randomNumberOrigin,
                                                       double randomNumberBound)

      Specified by:
        `doubles` in interface `RandomnessSource`