@Test public void testCreateSecp256k1KeyPair() throws Exception { KeyPair keyPair = Keys.createSecp256k1KeyPair(); PrivateKey privateKey = keyPair.getPrivate(); PublicKey publicKey = keyPair.getPublic(); assertNotNull(privateKey); assertNotNull(publicKey); assertThat(privateKey.getEncoded().length, is(144)); assertThat(publicKey.getEncoded().length, is(88)); }
static KeyPair createSecp256k1KeyPair() throws NoSuchProviderException, NoSuchAlgorithmException, InvalidAlgorithmParameterException { KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("ECDSA", "BC"); ECGenParameterSpec ecGenParameterSpec = new ECGenParameterSpec("secp256k1"); keyPairGenerator.initialize(ecGenParameterSpec, secureRandom()); return keyPairGenerator.generateKeyPair(); }
Keys { static KeyPair createSecp256k1KeyPair() throws NoSuchProviderException, NoSuchAlgorithmException, InvalidAlgorithmParameterException { KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("ECDSA", "BC"); ECGenParameterSpec ecGenParameterSpec = new ECGenParameterSpec("secp256k1"); keyPairGenerator.initialize(ecGenParameterSpec, secureRandom()); return keyPairGenerator.generateKeyPair(); } }
Keys { static KeyPair createSecp256k1KeyPair() throws NoSuchProviderException, NoSuchAlgorithmException, InvalidAlgorithmParameterException { KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("ECDSA", "BC"); ECGenParameterSpec ecGenParameterSpec = new ECGenParameterSpec("secp256k1"); keyPairGenerator.initialize(ecGenParameterSpec, secureRandom()); return keyPairGenerator.generateKeyPair(); } private  Keys(); }
Keys { static KeyPair createSecp256k1KeyPair() throws NoSuchProviderException, NoSuchAlgorithmException, InvalidAlgorithmParameterException { KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("ECDSA", "BC"); ECGenParameterSpec ecGenParameterSpec = new ECGenParameterSpec("secp256k1"); keyPairGenerator.initialize(ecGenParameterSpec, secureRandom()); return keyPairGenerator.generateKeyPair(); } private  Keys(); static ECKeyPair createEcKeyPair(); static String getAddress(ECKeyPair ecKeyPair); static String getAddress(BigInteger publicKey); static String getAddress(String publicKey); static byte[] getAddress(byte[] publicKey); static byte[] serialize(ECKeyPair ecKeyPair); static ECKeyPair deserialize(byte[] input); static boolean verifyAddress(String address); static boolean verifyPrivateKey(String privateKey); }
Keys { static KeyPair createSecp256k1KeyPair() throws NoSuchProviderException, NoSuchAlgorithmException, InvalidAlgorithmParameterException { KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("ECDSA", "BC"); ECGenParameterSpec ecGenParameterSpec = new ECGenParameterSpec("secp256k1"); keyPairGenerator.initialize(ecGenParameterSpec, secureRandom()); return keyPairGenerator.generateKeyPair(); } private  Keys(); static ECKeyPair createEcKeyPair(); static String getAddress(ECKeyPair ecKeyPair); static String getAddress(BigInteger publicKey); static String getAddress(String publicKey); static byte[] getAddress(byte[] publicKey); static byte[] serialize(ECKeyPair ecKeyPair); static ECKeyPair deserialize(byte[] input); static boolean verifyAddress(String address); static boolean verifyPrivateKey(String privateKey); static final int ADDRESS_SIZE; static final int ADDRESS_LENGTH_IN_HEX; static final int PRIVATE_KEY_LENGTH_IN_HEX; }