/** * Create a keypair using SECP-256k1 curve. * * <p>Private keypairs are encoded using PKCS8 * * <p>Private keys are encoded using X.509 */ static KeyPair createSecp256k1KeyPair() throws NoSuchProviderException, NoSuchAlgorithmException, InvalidAlgorithmParameterException { return createSecp256k1KeyPair(secureRandom()); }
public static ECKeyPair createEcKeyPair(SecureRandom random) throws InvalidAlgorithmParameterException, NoSuchAlgorithmException, NoSuchProviderException { KeyPair keyPair = createSecp256k1KeyPair(random); return ECKeyPair.create(keyPair); }
@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)); }
public static ECKeyPair createEcKeyPair(SecureRandom random) throws InvalidAlgorithmParameterException, NoSuchAlgorithmException, NoSuchProviderException { KeyPair keyPair = createSecp256k1KeyPair(random); return ECKeyPair.create(keyPair); }
/** * Create a keypair using SECP-256k1 curve. * * <p>Private keypairs are encoded using PKCS8 * * <p>Private keys are encoded using X.509 */ static KeyPair createSecp256k1KeyPair() throws NoSuchProviderException, NoSuchAlgorithmException, InvalidAlgorithmParameterException { return createSecp256k1KeyPair(secureRandom()); }