本文整理汇总了Java中java.security.spec.ECPoint.POINT_INFINITY属性的典型用法代码示例。如果您正苦于以下问题:Java ECPoint.POINT_INFINITY属性的具体用法?Java ECPoint.POINT_INFINITY怎么用?Java ECPoint.POINT_INFINITY使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类java.security.spec.ECPoint
的用法示例。
在下文中一共展示了ECPoint.POINT_INFINITY属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testECPublicKeySpec03
/**
* Test #3 for <code>ECPublicKeySpec(ECPoint, ECParameterSpec)</code> constructor<br>
* Assertion: throws <code>IllegalArgumentException</code> if
* <code>w</code> is point at infinity<br>
* Test preconditions: pass <code>ECPoint.POINT_INFINITY</code>
* as mentioned parameter value<br>
* Expected: must throw <code>IllegalArgumentException</code>
*/
public final void testECPublicKeySpec03() {
// Valid (see note below) parameters set
EllipticCurve c =
new EllipticCurve(new ECFieldFp(BigInteger.valueOf(5L)),
BigInteger.ZERO,
BigInteger.valueOf(4L));
ECPoint g = new ECPoint(BigInteger.ZERO, BigInteger.valueOf(2L));
try {
new ECPublicKeySpec(ECPoint.POINT_INFINITY,
new ECParameterSpec(c, g, BigInteger.valueOf(5L), 10));
fail("Expected IAE not thrown");
} catch (IllegalArgumentException ok) {
}
}
示例2: scalarMult
public static ECPoint scalarMult(ECPoint p, BigInteger kin, EllipticCurve curve) {
ECPoint r = ECPoint.POINT_INFINITY;
BigInteger prime = ((ECFieldFp) curve.getField()).getP();
BigInteger k = kin.mod(prime);
int length = k.bitLength();
byte[] binarray = new byte[length];
for (int i = 0; i <= length-1; i++) {
binarray[i] = k.mod(TWO).byteValue();
k = k.divide(TWO);
}
for (int i = length-1; i >= 0; i--) {
// i should start at length-1 not -2 because the MSB of binarry may not be 1
r = doublePoint(r, curve);
if (binarray[i] == 1)
r = addPoint(r, p, curve);
}
return r;
}
示例3: testPublicKeyAtInfinity
/**
* Tries to generate a public key with a point at infinity. Public keys with a point at infinity
* should be rejected to prevent subgroup confinement attacks.
*/
@Test
public void testPublicKeyAtInfinity() throws Exception {
ECParameterSpec ecSpec = EcUtil.getNistP256Params();
try {
ECPublicKeySpec pubSpec = new ECPublicKeySpec(ECPoint.POINT_INFINITY, ecSpec);
fail(
"Point at infinity is not a valid public key. "
+ pubSpec.getW().equals(ECPoint.POINT_INFINITY));
} catch (java.lang.IllegalArgumentException ex) {
// This is expected
}
}