net.i2p.crypto.eddsa

## Class KeyPairGenerator

- java.lang.Object
- - java.security.KeyPairGeneratorSpi
  - - net.i2p.crypto.eddsa.KeyPairGenerator

- Direct Known Subclasses:
    RedKeyPairGenerator

      public class KeyPairGenerator
      extends KeyPairGeneratorSpi

  Key pair generator for EdDSA (Edwards-curve Digital Signature Algorithm) keys. This implementation generates EdDSA key pairs with a default key size of 256 bits using the Ed25519 curve, which provides strong security with excellent performance characteristics. EdDSA is the recommended signature algorithm for new I2P applications.

  Generated keys are suitable for:

  - Digital signatures and verification
  - I2P destination keys
  - Router identity and communication
  See Also:
    RFC 8032 - EdDSA

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected static int` | `DEFAULT_KEYSIZE`
    `protected EdDSAParameterSpec` | `edParams`
    `protected boolean` | `initialized`
    `protected SecureRandom` | `random`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `KeyPairGenerator()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected EdDSANamedCurveSpec` | `createNamedCurveSpec(String curveName)` Create an EdDSANamedCurveSpec from the provided curve name.
    `KeyPair` | `generateKeyPair()`
    `void` | `initialize(AlgorithmParameterSpec params, SecureRandom random)`
    `void` | `initialize(int keysize, SecureRandom random)`

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

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

- - ### Field Detail

    - #### DEFAULT_KEYSIZE

          protected static final int DEFAULT_KEYSIZE

      See Also:
        Constant Field Values

    - #### edParams

          protected EdDSAParameterSpec edParams

    - #### initialized

          protected boolean initialized

    - #### random

          protected SecureRandom random

  - ### Constructor Detail

    - #### KeyPairGenerator

          public KeyPairGenerator()

  - ### Method Detail

    - #### createNamedCurveSpec

          protected EdDSANamedCurveSpec createNamedCurveSpec(String curveName)
                                                      throws InvalidAlgorithmParameterException

      Create an EdDSANamedCurveSpec from the provided curve name. The current implementation fetches the pre-created curve spec from a table.
      Parameters:
        `curveName` - the EdDSA named curve.
      Returns:
        the specification for the named curve.
      Throws:
        `InvalidAlgorithmParameterException` - if the named curve is unknown.

    - #### generateKeyPair

          public KeyPair generateKeyPair()

      Specified by:
        `generateKeyPair` in class `KeyPairGeneratorSpi`

    - #### initialize

          public void initialize(AlgorithmParameterSpec params,
                                 SecureRandom random)
                          throws InvalidAlgorithmParameterException

      Overrides:
        `initialize` in class `KeyPairGeneratorSpi`
      Throws:
        `InvalidAlgorithmParameterException`

    - #### initialize

          public void initialize(int keysize,
                                 SecureRandom random)

      Specified by:
        `initialize` in class `KeyPairGeneratorSpi`