Java EdDSA (Ed25519 / Ed448) Example

EdDSA (Edwards-Curve Digital Signature Algorithm) [RFC 8032] is another additional digital signature scheme added in Java 15 thorough JEP 339.

It does not replace the existing Elliptic Curve Digital Signature Algorithm (ECDSA) in JDK.

EdDSA provides following parameter choices :

Algorithm Name
Edwards-Curve signature algorithm as defined in RFC 8032
Edwards-Curve signature algorithm with Ed25519 as defined in RFC 8032
Edwards-Curve signature algorithm with Ed448 as defined in RFC 8032

1. Advantages of EdDSA (using Ed25519)

  • Provides platform-independent implementation of EdDSA with better performance than the existing ECDSA implementation.
  • Does not change the execution time based on the length of secret key.
  • Provides standardized parameter sets such as Ed25519 and Ed448 which can be specified using identifiers.
  • It is scheduled to be integrated with JSSE for TLS 1.3. It is one of only three signature schemes that are allowed in TLS 1.3.

2. Java EdDSA Example

Given below is a code example of how to use the EdDSA algorithm in a Java program to encrypt a String.

import java.nio.charset.StandardCharsets;
import java.util.Base64;

public class EdwardAlgoExample {
  public static void main(String[] args)
      throws NoSuchAlgorithmException, InvalidKeyException, SignatureException {

    KeyPairGenerator kpg = KeyPairGenerator.getInstance("Ed25519");
    KeyPair kp = kpg.generateKeyPair();

    byte[] msg = "test_string".getBytes(StandardCharsets.UTF_8);

    Signature sig = Signature.getInstance("Ed25519");
    byte[] s = sig.sign();

    String encodedString = Base64.getEncoder().encodeToString(s);

Program output.


Happy Learning !!

Was this post helpful?

Join 7000+ Awesome Developers

Get the latest updates from industry, awesome resources, blog updates and much more.

* We do not spam !!

2 thoughts on “Java EdDSA (Ed25519 / Ed448) Example”

  1. Getting an exception Ed25519 KeyPairGenerator not available

    What java version is used and is there a specific maven dependency required?


Leave a Comment


A blog about Java and related technologies, the best practices, algorithms, and interview questions.