'String to PrivateKey Ed25519

I have a private key as a String and I want to convert it to PrivateKey

String privateKey = "Y2E3YjYwYzRjMDRjMjk1ZDQ5ZTQzM2RlMTdjZjVkNGE0NGFjYzJmM2IzOWExNWZhMjViNGE4ZWJiZDBiMDVkYTIwNGU4MWE3ZWZmMTQ0NGE2ZmM2NjExNzRmNTY4M2I0YmYyMTk5YTkyY2UzOWRkZjdmMzhkNTFjYTNmM2Q3ZDU";

byte[] pkcs8EncodedBytes = Base64.getDecoder().decode(privateKey);

PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(pkcs8EncodedBytes);

PrivateKey pkey = KeyFactory.getInstance("Ed25519") //NoSuchAlgorithmException
                            .generatePrivate(keySpec);

But I get this error:

java.security.NoSuchAlgorithmException: Ed25519 KeyFactory not available

at KeyFactory.getInstance("Ed25519")

I'm using Java-10



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source