bcgit / bc-java

Bouncy Castle Java Distribution (Mirror)
https://www.bouncycastle.org/java.html
MIT License
2.29k stars 1.13k forks source link

How to perform X25519 after deriving montgomery keypair? #320

Closed vikram919 closed 6 years ago

vikram919 commented 6 years ago

Below is the code, how I have derived montgomery keypair:

ECParameterSpec ecsp = ECNamedCurveTable.getParameterSpec("curve25519"); KeyPairGenerator kpg = KeyPairGenerator.getInstance("ECDH", "BC"); kpg.initialize(ecsp, new SecureRandom()); return kpg.genKeyPair();

How to perform ECDH using X25519 to derive shared secret?

peterdettman commented 6 years ago

X25519 is not yet available through the provider ("curve25519" is not the same thing), however you can use the org.bouncycastle.math.ec.rfc7748.X25519 class directly. Refer to the org.bouncycastle.math.ec.rfc7748.test.X25519Test class to see how to perform ECDH.