Reputation: 1
I have been tried to use the EdDSA algorithm in order to generate keys using jar eddsa 0.3.0. However, I get java.security.NoSuchAlgorithmException: Ed25519 KeyPairGenerator not available
when I try to do KeyPairGenerator.getInstance("Ed25519");
Also, I have the following exception java.security.NoSuchAlgorithmException: Ed25519 Signature not available
when I try to generate signatures.
Are there any examples of how to make it work?
I've done the research but I am new to the encryption phase and I don't really get how I should make it work.
I known that the eddsaparam constructor is wrong. The code below:
KeyPairGenerator keyPairGenerator=KeyPairGenerator.getInstance("EdDSA");//getInstance("ECDSA","BC");//EDDSA
SecureRandom secureRandom=SecureRandom.getInstance("SHA1PRNG");
EdDSANamedCurveSpec ed25519 = EdDSANamedCurveTable.getByName("Ed25519");
EdDSAParameterSpec edDSAParameterSpec = new EdDSAParameterSpec(ed25519, "Ed25519");
keyPairGenerator.initialize(edDSAParameterSpec,secureRandom);
Upvotes: 0
Views: 3899
Reputation: 4162
I'm affraid that "Ed25519" is a typo and it should be "EdDSA".
Assuming your pom file contains this:
<dependency>
<groupId>net.i2p.crypto</groupId>
<artifactId>eddsa</artifactId>
<version>0.3.0</version>
</dependency>
And your code resembles this:
import net.i2p.crypto.eddsa.EdDSASecurityProvider;
import java.security.KeyPairGenerator;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.Security;
public class App {
public static void main(String[] args) throws NoSuchAlgorithmException, NoSuchProviderException {
// throws NoSuchAlgorithmException: EdDSA KeyPairGenerator not available
//KeyPairGenerator.getInstance("EdDSA");
// add eddsa to the security providers
Security.addProvider(new EdDSASecurityProvider());
// throws: NoSuchAlgorithmException: Ed25519 KeyPairGenerator not available
//KeyPairGenerator.getInstance("Ed25519");
// throws: NoSuchAlgorithmException: no such algorithm: Ed25519 for provider EdDSA
//KeyPairGenerator.getInstance("Ed25519", "EdDSA");
// works
KeyPairGenerator.getInstance("EdDSA", "EdDSA");
// also works
KeyPairGenerator.getInstance("EdDSA");
}
}
Upvotes: 2