java.lang.Object
net.i2p.crypto.eddsa.EdDSAPublicKey
All Implemented Interfaces:
Serializable, AsymmetricKey, BinaryEncodablePREVIEW, Key, PublicKey, EdDSAKey

public class EdDSAPublicKeyextends 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:
  • Constructor Details

  • Method Details

    • getAlgorithm

      public String getAlgorithm()
      The reported algorithm name for all EdDSA keys.
      Specified by:
      getAlgorithm in interface Key
      Returns:
      the JCA algorithm name shared by all EdDSA keys, "EdDSA"
    • getFormat

      public String getFormat()
      The encoding format of the key.
      Specified by:
      getFormat in interface Key
      Returns:
      the JCA key encoding format, always "X.509"
    • getEncoded

      public byte[] getEncoded()
      Returns the public key in its canonical encoding.

      This implements the following specs:

      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
    • getParams

      public EdDSAParameterSpec getParams()
      The EdDSA domain parameters for the key.
      Specified by:
      getParams in interface AsymmetricKey
      Specified by:
      getParams in interface EdDSAKey
      Returns:
      the EdDSAParameterSpec naming the curve and hash algorithm
    • getA

      public GroupElement getA()
      The public key point A.
      Returns:
      The public key point A.
    • getNegativeA

      public GroupElement getNegativeA()
      The negated public key point.
      Returns:
      The negated public key point.
    • getAbyte

      public byte[] getAbyte()
      The encoded public key.
      Returns:
      The public key bytes.
    • hashCode

      public int hashCode()
      Hash code of the public key bytes, for use in hash tables.
      Overrides:
      hashCode in class Object
      Returns:
      whether h code is present
    • equals

      public boolean equals(Object o)
      Whether this key is equal to the given key.
      Overrides:
      equals in class Object
      Returns:
      true if equal