Class Ed25519

    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static byte[] getHashedScalar​(byte[] privateKey)  
      static void init()
      Initializes Ed25519 if not yet initialized.
      static byte[] scalarMultWithBaseToBytes​(byte[] a)
      Computes a*B where a = a[0]+256*a[1]+...+256^31 a[31] and B is the Ed25519 base point (x,4/5) with x positive.
      static byte[] sign​(byte[] message, byte[] publicKey, byte[] hashedPrivateKey)
      Returns the EdDSA signature for the message based on the hashedPrivateKey.
      static boolean verify​(byte[] message, byte[] signature, byte[] publicKey)
      Returns true if the EdDSA signature with message, can be verified with publicKey.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • scalarMultWithBaseToBytes

        public static byte[] scalarMultWithBaseToBytes​(byte[] a)
        Computes a*B where a = a[0]+256*a[1]+...+256^31 a[31] and B is the Ed25519 base point (x,4/5) with x positive. Preconditions: a[31] <= 127
      • getHashedScalar

        public static byte[] getHashedScalar​(byte[] privateKey)
                                      throws java.security.GeneralSecurityException
        Throws:
        java.security.GeneralSecurityException
      • sign

        public static byte[] sign​(byte[] message,
                                  byte[] publicKey,
                                  byte[] hashedPrivateKey)
                           throws java.security.GeneralSecurityException
        Returns the EdDSA signature for the message based on the hashedPrivateKey.
        Parameters:
        message - to sign
        publicKey - scalarMultWithBaseToBytes(byte[]) of hashedPrivateKey
        hashedPrivateKey - getHashedScalar(byte[]) of the private key
        Returns:
        signature for the message.
        Throws:
        java.security.GeneralSecurityException - if there is no SHA-512 algorithm defined in EngineFactory.MESSAGE_DIGEST.
      • verify

        public static boolean verify​(byte[] message,
                                     byte[] signature,
                                     byte[] publicKey)
                              throws java.security.GeneralSecurityException
        Returns true if the EdDSA signature with message, can be verified with publicKey.
        Throws:
        java.security.GeneralSecurityException - if there is no SHA-512 algorithm defined in EngineFactory.MESSAGE_DIGEST.
      • init

        public static void init()
        Initializes Ed25519 if not yet initialized.