KeyPairUtils { public static KeyPair createECKeyPair(String name) { try { ECParameterSpec ecSpec = ECNamedCurveTable.getParameterSpec(name); KeyPairGenerator g = KeyPairGenerator.getInstance("ECDSA", "BC"); g.initialize(ecSpec, new SecureRandom()); return g.generateKeyPair(); } catch (NoSuchAlgorithmException | InvalidAlgorithmParameterException ex) { throw new IllegalArgumentException("Invalid curve name " + name, ex); } catch (NoSuchProviderException ex) { throw new IllegalStateException(ex); } } private  KeyPairUtils(); static KeyPair createKeyPair(); static KeyPair createKeyPair(int keysize); static KeyPair createECKeyPair(String name); static KeyPair readKeyPair(Reader r); static void writeKeyPair(KeyPair keypair, Writer w);  }
@Test public void testCreateECCKeyPair() { KeyPair pair = KeyPairUtils.createECKeyPair(EC_CURVE); assertThat(pair, is(notNullValue())); assertThat(pair.getPublic(), is(instanceOf(ECPublicKey.class))); }