ECDSAKeyGenerator implements KeyGenerator<ECDSAKey> { public PublicKey createPublicKey(final byte[] compressed) throws Exception { return createPublicKey(ecParams.getCurve().decodePoint(compressed)); }  @Override ECDSAKey create(); ECDSAKey create(final String seed); ECDSAKey create(final byte[] encodedPrivateKey); ECDSAKey create(final BigInteger d); ECDSAKey create(final PrivateKey privateKey); PrivateKey createPrivateKey(final BigInteger d); PublicKey createPublicKey(final byte[] compressed); PublicKey createPublicKey(final BigInteger x, final BigInteger y); static final ECDomainParameters ecParams; }
@Test public void testCreatePublicKey() throws Exception { final ECDSAKeyGenerator generator = new ECDSAKeyGenerator(); final ECDSAKey key = generator.create(); final org.bouncycastle.jce.interfaces.ECPublicKey ecPublicKey = (org.bouncycastle.jce.interfaces.ECPublicKey) key.getPublicKey(); final PublicKey recovered = generator.createPublicKey(ecPublicKey.getQ().getXCoord().toBigInteger(), ecPublicKey.getQ().getYCoord().toBigInteger()); assertEquals(ecPublicKey.getQ(), ((org.bouncycastle.jce.interfaces.ECPublicKey) recovered).getQ()); }