public static ECKeyPair create(BigInteger privateKey) { return new ECKeyPair(privateKey, Sign.publicKeyFromPrivate(privateKey)); }
public static ECKeyPair deserialize(byte[] input) { if (input.length != PRIVATE_KEY_SIZE + PUBLIC_KEY_SIZE) { throw new RuntimeException("Invalid input key size"); } BigInteger privateKey = Numeric.toBigInt(input, 0, PRIVATE_KEY_SIZE); BigInteger publicKey = Numeric.toBigInt(input, PRIVATE_KEY_SIZE, PUBLIC_KEY_SIZE); return new ECKeyPair(privateKey, publicKey); } }
public static ECKeyPair create(KeyPair keyPair) { BCECPrivateKey privateKey = (BCECPrivateKey) keyPair.getPrivate(); BCECPublicKey publicKey = (BCECPublicKey) keyPair.getPublic(); BigInteger privateKeyValue = privateKey.getD(); // Ethereum does not use encoded public keys like bitcoin - see // https://en.bitcoin.it/wiki/Elliptic_Curve_Digital_Signature_Algorithm for details // Additionally, as the first bit is a constant prefix (0x04) we ignore this value byte[] publicKeyBytes = publicKey.getQ().getEncoded(false); BigInteger publicKeyValue = new BigInteger(1, Arrays.copyOfRange(publicKeyBytes, 1, publicKeyBytes.length)); return new ECKeyPair(privateKeyValue, publicKeyValue); }
public static Credentials create(String privateKey, String publicKey) { return create(new ECKeyPair(Numeric.toBigInt(privateKey), Numeric.toBigInt(publicKey))); }
public static ECKeyPair create(BigInteger privateKey) { return new ECKeyPair(privateKey, Sign.publicKeyFromPrivate(privateKey)); }
public static ECKeyPair deserialize(byte[] input) { if (input.length != PRIVATE_KEY_SIZE + PUBLIC_KEY_SIZE) { throw new RuntimeException("Invalid input key size"); } BigInteger privateKey = Numeric.toBigInt(input, 0, PRIVATE_KEY_SIZE); BigInteger publicKey = Numeric.toBigInt(input, PRIVATE_KEY_SIZE, PUBLIC_KEY_SIZE); return new ECKeyPair(privateKey, publicKey); } }
public static ECKeyPair create(KeyPair keyPair) { BCECPrivateKey privateKey = (BCECPrivateKey) keyPair.getPrivate(); BCECPublicKey publicKey = (BCECPublicKey) keyPair.getPublic(); BigInteger privateKeyValue = privateKey.getD(); // Ethereum does not use encoded public keys like bitcoin - see // https://en.bitcoin.it/wiki/Elliptic_Curve_Digital_Signature_Algorithm for details // Additionally, as the first bit is a constant prefix (0x04) we ignore this value byte[] publicKeyBytes = publicKey.getQ().getEncoded(false); BigInteger publicKeyValue = new BigInteger(1, Arrays.copyOfRange(publicKeyBytes, 1, publicKeyBytes.length)); return new ECKeyPair(privateKeyValue, publicKeyValue); }
public static Credentials create(String privateKey, String publicKey) { return create(new ECKeyPair(Numeric.toBigInt(privateKey), Numeric.toBigInt(publicKey))); }