net.i2p.router.transport.crypto

## Class X25519KeyFactory

- java.lang.Object
- - java.lang.Thread
  - - net.i2p.util.I2PThread
    - - net.i2p.router.transport.crypto.X25519KeyFactory

- All Implemented Interfaces:
    Runnable, KeyFactory

      public class X25519KeyFactory
      extends I2PThread
      implements KeyFactory

  Try to keep DH pairs at the ready. It's important to do this in a separate thread, because if we run out, the pairs are generated in the NTCP Pumper thread, and it can fall behind.

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class net.i2p.util.I2PThread

      `I2PThread.OOMEventListener`

    - ### Nested classes/interfaces inherited from class java.lang.Thread

      `Thread.State, Thread.UncaughtExceptionHandler`

  - ### Field Summary

    - ### Fields inherited from class java.lang.Thread

      `MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `X25519KeyFactory(I2PAppContext ctx)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `KeyPair` | `getKeys()` Pulls a prebuilt keypair from the queue, or if not available, construct a new one.
    `void` | `returnUnused(KeyPair kp)` Return an unused DH key builder to be put back onto the queue for reuse.
    `void` | `run()`
    `void` | `shutdown()` Note that this stops the singleton precalc thread.

    - ### Methods inherited from class net.i2p.util.I2PThread

      `addOOMEventListener, fireOOM, removeOOMEventListener, start`

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

      `activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, stop, stop, suspend, toString, yield`

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

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

- - ### Constructor Detail

    - #### X25519KeyFactory

          public X25519KeyFactory(I2PAppContext ctx)

  - ### Method Detail

    - #### getKeys

          public KeyPair getKeys()

      Pulls a prebuilt keypair from the queue, or if not available, construct a new one.
      Specified by:
        `getKeys` in interface `KeyFactory`

    - #### returnUnused

          public void returnUnused(KeyPair kp)

      Return an unused DH key builder to be put back onto the queue for reuse.

    - #### run

          public void run()

      Specified by:
        `run` in interface `Runnable`
      Overrides:
        `run` in class `I2PThread`

    - #### shutdown

          public void shutdown()

      Note that this stops the singleton precalc thread. You don't want to do this if there are multiple routers in the JVM. Fix this if you care. See Router.shutdown().