net.i2p.crypto.elgamal.impl

## Class ElGamalPublicKeyImpl

- java.lang.Object
- - net.i2p.crypto.elgamal.impl.ElGamalPublicKeyImpl

- All Implemented Interfaces:
    Serializable, Key, PublicKey, DHKey, DHPublicKey, ElGamalKey, ElGamalPublicKey

      public class ElGamalPublicKeyImpl
      extends Object
      implements ElGamalPublicKey, DHPublicKey

  Implementation of ElGamal public keys. This class provides a concrete implementation of the ElGamalPublicKey interface, representing the public component of an ElGamal key pair. It stores the public value y = g^x mod p and the ElGamal parameters (prime p and generator g), and supports X.509 encoding for standardized key storage and transmission.
  See Also:
    Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ElGamalPublicKeyImpl(BigInteger y, ElGamalParameterSpec elSpec)`
    `ElGamalPublicKeyImpl(DHPublicKey key)`
    `ElGamalPublicKeyImpl(DHPublicKeySpec spec)`
    `ElGamalPublicKeyImpl(ElGamalPublicKey key)`
    `ElGamalPublicKeyImpl(ElGamalPublicKeySpec spec)`
    `ElGamalPublicKeyImpl(X509EncodedKeySpec spec)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `String` | `getAlgorithm()`
    `byte[]` | `getEncoded()`
    `String` | `getFormat()`
    `ElGamalParameterSpec` | `getParameters()`
    `DHParameterSpec` | `getParams()`
    `BigInteger` | `getY()`
    `(package private) static int` | `spaceFor(int val)`

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

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

- - ### Constructor Detail

    - #### ElGamalPublicKeyImpl

          public ElGamalPublicKeyImpl(BigInteger y,
                                      ElGamalParameterSpec elSpec)

    - #### ElGamalPublicKeyImpl

          public ElGamalPublicKeyImpl(DHPublicKey key)

    - #### ElGamalPublicKeyImpl

          public ElGamalPublicKeyImpl(DHPublicKeySpec spec)

    - #### ElGamalPublicKeyImpl

          public ElGamalPublicKeyImpl(ElGamalPublicKey key)

    - #### ElGamalPublicKeyImpl

          public ElGamalPublicKeyImpl(ElGamalPublicKeySpec spec)

    - #### ElGamalPublicKeyImpl

          public ElGamalPublicKeyImpl(X509EncodedKeySpec spec)
                               throws InvalidKeySpecException

      Throws:
        `InvalidKeySpecException`

  - ### Method Detail

    - #### getAlgorithm

          public String getAlgorithm()

      Specified by:
        `getAlgorithm` in interface `Key`

    - #### getEncoded

          public byte[] getEncoded()

      Specified by:
        `getEncoded` in interface `Key`

    - #### getFormat

          public String getFormat()

      Specified by:
        `getFormat` in interface `Key`

    - #### getParameters

          public ElGamalParameterSpec getParameters()

      Specified by:
        `getParameters` in interface `ElGamalKey`

    - #### getParams

          public DHParameterSpec getParams()

      Specified by:
        `getParams` in interface `DHKey`

    - #### getY

          public BigInteger getY()

      Specified by:
        `getY` in interface `DHPublicKey`
      Specified by:
        `getY` in interface `ElGamalPublicKey`

    - #### spaceFor

          static int spaceFor(int val)

      Parameters:
        `val` - the length of the value, 65535 max
      Returns:
        the length of the TLV