use of com.radixdlt.crypto.exception.PrivateKeyException in project radixdlt by radixdlt.
the class BouncyCastleKeyHandler method computePublicKey.
@Override
public byte[] computePublicKey(byte[] privateKey) throws PrivateKeyException, PublicKeyException {
ECKeyUtils.validatePrivate(privateKey);
var d = new BigInteger(1, privateKey);
try {
var publicKeySpec = new ECPublicKeySpec(spec.getG().multiply(d), spec);
// and are casting to a bouncy castle ECPublicKey.
return ((ECPublicKey) KeyFactory.getInstance("EC", "BC").generatePublic(publicKeySpec)).getQ().getEncoded(true);
} catch (Exception e) {
throw new PublicKeyException(e);
}
}
Aggregations