use of java.security.spec.ECPoint in project j2objc by google.
the class ECPointTest method testGetAffineY01.
/**
* Test #1 for <code>getAffineY()</code> method<br>
* Assertion: returns affine <code>y</code> coordinate<br>
* Test preconditions: <code>ECPoint</code> instance
* created using valid parameters<br>
* Expected: must return affine <code>y</code> coordinate
* which is equal to the one passed to the constructor;
* (both must refer the same object)
*/
public final void testGetAffineY01() {
BigInteger y = BigInteger.valueOf(23456L);
ECPoint p = new ECPoint(BigInteger.valueOf(-23456L), y);
BigInteger yRet = p.getAffineY();
assertEquals(y, yRet);
assertSame(y, yRet);
}
use of java.security.spec.ECPoint in project j2objc by google.
the class ECPointTest method testGetAffineX01.
/**
* Test #1 for <code>getAffineX()</code> method<br>
* Assertion: returns affine <code>x</code> coordinate<br>
* Test preconditions: <code>ECPoint</code> instance
* created using valid parameters<br>
* Expected: must return affine <code>x</code> coordinate
* which is equal to the one passed to the constructor;
* (both must refer the same object)
*/
public final void testGetAffineX01() {
BigInteger x = BigInteger.valueOf(-23456L);
ECPoint p = new ECPoint(x, BigInteger.valueOf(23456L));
BigInteger xRet = p.getAffineX();
assertEquals(x, xRet);
assertSame(x, xRet);
}
use of java.security.spec.ECPoint in project j2objc by google.
the class ECPublicKeySpecTest method setUp.
protected void setUp() throws Exception {
super.setUp();
ECPoint ecpoint = new ECPoint(BigInteger.valueOf(1), BigInteger.valueOf(1));
EllipticCurve curve = new EllipticCurve(new ECFieldF2m(2), BigInteger.valueOf(1), BigInteger.valueOf(1));
w = new ECPoint(BigInteger.valueOf(1), BigInteger.valueOf(1));
params = new ECParameterSpec(curve, ecpoint, BigInteger.valueOf(1), 1);
ecpks = new ECPublicKeySpec(w, params);
}
use of java.security.spec.ECPoint in project cxf by apache.
the class CryptoUtils method getECPublicKey.
public static ECPublicKey getECPublicKey(String curve, byte[] xPoint, byte[] yPoint) {
try {
ECParameterSpec params = getECParameterSpec(curve, false);
ECPoint ecPoint = new ECPoint(toBigInteger(xPoint), toBigInteger(yPoint));
ECPublicKeySpec keySpec = new ECPublicKeySpec(ecPoint, params);
KeyFactory kf = KeyFactory.getInstance("EC");
return (ECPublicKey) kf.generatePublic(keySpec);
} catch (Exception ex) {
throw new SecurityException(ex);
}
}
use of java.security.spec.ECPoint in project hutool by looly.
the class BCUtil method decodeECPoint.
/**
* 解码恢复EC压缩公钥,支持Base64和Hex编码,(基于BouncyCastle)
*
* @param encodeByte 压缩公钥
* @param curveName EC曲线名,例如{@link SmUtil#SM2_DOMAIN_PARAMS}
* @return 公钥
* @since 4.4.4
*/
public static PublicKey decodeECPoint(byte[] encodeByte, String curveName) {
final X9ECParameters x9ECParameters = ECUtil.getNamedCurveByName(curveName);
final ECCurve curve = x9ECParameters.getCurve();
final ECPoint point = EC5Util.convertPoint(curve.decodePoint(encodeByte));
// 根据曲线恢复公钥格式
final ECNamedCurveSpec ecSpec = new ECNamedCurveSpec(curveName, curve, x9ECParameters.getG(), x9ECParameters.getN());
return KeyUtil.generatePublicKey("EC", new ECPublicKeySpec(point, ecSpec));
}
Aggregations