Class MLKEMKeyFactory

java.lang.Object
java.lang.Thread
net.i2p.util.I2PThread
net.i2p.router.crypto.pqc.MLKEMKeyFactory
All Implemented Interfaces:
Runnable, KeyFactory

public class MLKEMKeyFactory extends I2PThread implements KeyFactory
Try to keep key pairs at the ready. It's important to do this in a separate thread, because if we run out, the pairs are generated other threads, and it can fall behind. Started by ECIESAEADEngine. One type per-thread. Only used for 768, for now.
Since:
0.9.68 adapted from X25519KeyFactory
  • Constructor Details

    • MLKEMKeyFactory

      public MLKEMKeyFactory(I2PAppContext ctx, EncType type)
      Alice side only
      Parameters:
      type - must be one of the internal types MLKEM*_INT
  • Method Details

    • 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().
    • run

      public void run()
      Specified by:
      run in interface Runnable
      Overrides:
      run in class I2PThread
    • 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 key pair to be put back onto the queue for reuse.