net.i2p.crypto

## Class YKGenerator

- java.lang.Object
- - net.i2p.crypto.YKGenerator

-     final class YKGenerator
      extends Object

  Precalculate the Y and K for ElGamal encryption operations. This class precalcs a set of values on its own thread, using those transparently when a new instance is created. By default, the minimum threshold for creating new values for the pool is 20, and the max pool size is 50. Whenever the pool has less than the minimum, it fills it up again to the max. There is a delay after each precalculation so that the CPU isn't hosed during startup. These three parameters are controlled by java environmental variables and can be adjusted via: -Dcrypto.yk.precalc.min=40 -Dcrypto.yk.precalc.max=100 -Dcrypto.yk.precalc.delay=60000 (delay is milliseconds) To disable precalculation, set min to 0

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `DEFAULT_YK_PRECALC_DELAY`
    `static int` | `DEFAULT_YK_PRECALC_MAX`
    `static int` | `DEFAULT_YK_PRECALC_MIN`
    `static String` | `PROP_YK_PRECALC_DELAY`
    `static String` | `PROP_YK_PRECALC_MAX`
    `static String` | `PROP_YK_PRECALC_MIN`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `YKGenerator(I2PAppContext context)` Caller must also call start() to start the background precalc thread.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `BigInteger[]` | `getNextYK()` Gets the next YK value.
    `void` | `shutdown()` Stop the background precalc thread.
    `void` | `start()` Start the background precalc thread.

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

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

- - ### Field Detail

    - #### DEFAULT_YK_PRECALC_DELAY

          public static final int DEFAULT_YK_PRECALC_DELAY

    - #### DEFAULT_YK_PRECALC_MAX

          public static final int DEFAULT_YK_PRECALC_MAX

    - #### DEFAULT_YK_PRECALC_MIN

          public static final int DEFAULT_YK_PRECALC_MIN

    - #### PROP_YK_PRECALC_DELAY

          public static final String PROP_YK_PRECALC_DELAY

      See Also:
        Constant Field Values

    - #### PROP_YK_PRECALC_MAX

          public static final String PROP_YK_PRECALC_MAX

      See Also:
        Constant Field Values

    - #### PROP_YK_PRECALC_MIN

          public static final String PROP_YK_PRECALC_MIN

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### YKGenerator

          public YKGenerator(I2PAppContext context)

      Caller must also call start() to start the background precalc thread. Unit tests will still work without calling start().

  - ### Method Detail

    - #### getNextYK

          public BigInteger[] getNextYK()

      Gets the next YK value.
      Returns:
        rv[0] = Y; rv[1] = K

    - #### shutdown

          public void shutdown()

      Stop the background precalc thread. Can be restarted. Not required for unit tests.

    - #### start

          public void start()

      Start the background precalc thread. Must be called for normal operation. If not called, all generation happens in the foreground. Not required for unit tests.