/** * Returns public key from the given private key. * * @param privKey the private key to derive the public key from * @return BigInteger encoded public key */ public static BigInteger publicKeyFromPrivate(BigInteger privKey) { ECPoint point = publicPointFromPrivate(privKey); byte[] encoded = point.getEncoded(false); return new BigInteger(1, Arrays.copyOfRange(encoded, 1, encoded.length)); // remove prefix }
public ECPoint getPublicKeyPoint() { if (publicKeyPoint == null) { publicKeyPoint = Sign.publicPointFromPrivate(getPrivateKey()); } return publicKeyPoint; }
BigInteger ilInt = new BigInteger(1, il); Arrays.fill(il, (byte) 0); ECPoint ki = Sign.publicPointFromPrivate(ilInt).add(getPublicKeyPoint());
@Test public void testPublicKeyFromPrivatePoint() { ECPoint point = Sign.publicPointFromPrivate(SampleKeys.PRIVATE_KEY); assertThat(Sign.publicFromPoint(point.getEncoded(false)), equalTo(SampleKeys.PUBLIC_KEY)); } }
public ECPoint getPublicKeyPoint() { if (publicKeyPoint == null) { publicKeyPoint = Sign.publicPointFromPrivate(getPrivateKey()); } return publicKeyPoint; }
/** * Returns public key from the given private key. * * @param privKey the private key to derive the public key from * @return BigInteger encoded public key */ public static BigInteger publicKeyFromPrivate(BigInteger privKey) { ECPoint point = publicPointFromPrivate(privKey); byte[] encoded = point.getEncoded(false); return new BigInteger(1, Arrays.copyOfRange(encoded, 1, encoded.length)); // remove prefix }
/** * Returns public key from the given private key. * * @param privKey the private key to derive the public key from * @return BigInteger encoded public key */ public static BigInteger publicKeyFromPrivate(BigInteger privKey) { ECPoint point = publicPointFromPrivate(privKey); byte[] encoded = point.getEncoded(false); return new BigInteger(1, Arrays.copyOfRange(encoded, 1, encoded.length)); // remove prefix }
BigInteger ilInt = new BigInteger(1, il); Arrays.fill(il, (byte) 0); ECPoint ki = Sign.publicPointFromPrivate(ilInt).add(getPublicKeyPoint());