I have Edward curve key parameters - x, d and curve. How can I rebuild PublicKey/Private keys using bouncy castle?
Asked
Active
Viewed 321 times
1 Answers
0
If x
is your public key, d
is your private key and curve is Curve25519 or Curve448, then you can simply do the following:
final BigInteger x = ...; // here is your public key as an integer
final BigInteger d = ...; // here is your private key as an integer
final Ed25519PrivateKeyParameters reconstructedPrivateKey = new Ed25519PrivateKeyParameters(d.toByteArray(), 0);
final Ed25519PublicKeyParameters reconstructedPublicKey = new Ed25519PublicKeyParameters(x.toByteArray(), 0);
This is an example of getting Ed25519 public/private keys, for X25519, Ed448, or X448 you just need to use their respective classes instead.

Eduard Semsch
- 59
- 7