Source:
How to solve this problem programmatically
try {
KeyPairGenerator keyGen = KeyPairGenerator.getInstance("ECDSA", "BC");
SecureRandom random = SecureRandom.getInstance("SHA1PRNG");
ECGenParameterSpec ecSpec = new ECGenParameterSpec("prime192v1");
// Initialize the key generator and generate a KeyPair
keyGen.initialize(ecSpec, random); // 256 bytes provides an
// acceptable security level
KeyPair keyPair = keyGen.generateKeyPair();
// Set the public and private keys from the keyPair
privateKey = keyPair.getPrivate();
publicKey = keyPair.getPublic();
System.out.println("Private and public keys:");
System.out.println("PRIVATE: " + StringUtil.getStringFromKey(this.privateKey));
System.out.println("PUBLIC: " + StringUtil.getStringFromKey(this.publicKey));
} catch (Exception e) {
throw new RuntimeException(e);
}