net.i2p.crypto.eddsa

## Class EdDSAPublicKey

- java.lang.Object
- - net.i2p.crypto.eddsa.EdDSAPublicKey

- All Implemented Interfaces:
    Serializable, Key, PublicKey, EdDSAKey

      public class EdDSAPublicKey
      extends Object
      implements EdDSAKey, PublicKey

  An EdDSA public key.

  For compatibility with older releases, decoding supports both RFC 8410 and an older draft specification.

  See Also:
    RFC 8410, Older draft specification, Serialized Form

- - ### Field Summary

    - ### Fields inherited from interface net.i2p.crypto.eddsa.EdDSAKey

      `KEY_ALGORITHM`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `EdDSAPublicKey(EdDSAPublicKeySpec spec)`
    `EdDSAPublicKey(X509EncodedKeySpec spec)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `equals(Object o)`
    `GroupElement` | `getA()`
    `byte[]` | `getAbyte()`
    `String` | `getAlgorithm()`
    `byte[]` | `getEncoded()` Returns the public key in its canonical encoding.
    `String` | `getFormat()`
    `GroupElement` | `getNegativeA()`
    `EdDSAParameterSpec` | `getParams()`
    `int` | `hashCode()`

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

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

- - ### Constructor Detail

    - #### EdDSAPublicKey

          public EdDSAPublicKey(EdDSAPublicKeySpec spec)

    - #### EdDSAPublicKey

          public EdDSAPublicKey(X509EncodedKeySpec spec)
                         throws InvalidKeySpecException

      Throws:
        `InvalidKeySpecException`

  - ### Method Detail

    - #### equals

          public boolean equals(Object o)

      Overrides:
        `equals` in class `Object`

    - #### getA

          public GroupElement getA()

    - #### getAbyte

          public byte[] getAbyte()

    - #### getAlgorithm

          public String getAlgorithm()

      Specified by:
        `getAlgorithm` in interface `Key`

    - #### getEncoded

          public byte[] getEncoded()

      Returns the public key in its canonical encoding.

      This implements the following specs:

      - General encoding: https://tools.ietf.org/html/rfc8410
      - Key encoding: https://tools.ietf.org/html/rfc8032

      For keys in older formats, decoding and then re-encoding is sufficient to migrate them to the canonical encoding.

      Relevant spec quotes:

            In the X.509 certificate, the subjectPublicKeyInfo field has the
            SubjectPublicKeyInfo type, which has the following ASN.1 syntax:

            SubjectPublicKeyInfo  ::=  SEQUENCE  {
              algorithm         AlgorithmIdentifier,
              subjectPublicKey  BIT STRING
            }

            AlgorithmIdentifier  ::=  SEQUENCE  {
              algorithm   OBJECT IDENTIFIER,
              parameters  ANY DEFINED BY algorithm OPTIONAL
            }

            For all of the OIDs, the parameters MUST be absent.

            id-Ed25519   OBJECT IDENTIFIER ::= { 1 3 101 112 }

      Specified by:
        `getEncoded` in interface `Key`
      Returns:
        44 bytes for Ed25519, null for other curves

    - #### getFormat

          public String getFormat()

      Specified by:
        `getFormat` in interface `Key`

    - #### getNegativeA

          public GroupElement getNegativeA()

    - #### getParams

          public EdDSAParameterSpec getParams()

      Specified by:
        `getParams` in interface `EdDSAKey`
      Returns:
        a parameter specification representing the EdDSA domain parameters for the key.

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`