本文整理匯總了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
}
}