Example usage for org.bouncycastle.jce.provider JCEECPrivateKey getParameters

List of usage examples for org.bouncycastle.jce.provider JCEECPrivateKey getParameters

Introduction

In this page you can find the example usage for org.bouncycastle.jce.provider JCEECPrivateKey getParameters.

Prototype

public org.bouncycastle.jce.spec.ECParameterSpec getParameters() 

Source Link

Usage

From source file:org.jmrtd.app.DocumentEditFrame.java

License:Open Source License

private static PublicKey getECPublicKeyFromPrivateKey(PrivateKey privateKey) throws GeneralSecurityException {
    KeyFactory keyFactory = KeyFactory.getInstance("EC", BC_PROVIDER);
    org.bouncycastle.jce.provider.JCEECPrivateKey priv = (org.bouncycastle.jce.provider.JCEECPrivateKey) privateKey;
    org.bouncycastle.jce.spec.ECParameterSpec params = priv.getParameters();
    org.bouncycastle.jce.spec.ECPublicKeySpec pubKS = new org.bouncycastle.jce.spec.ECPublicKeySpec(
            params.getG().multiply(priv.getD()), params);
    PublicKey publicKey = keyFactory.generatePublic(pubKS);
    return publicKey;
}