當前位置: 首頁>>代碼示例>>Java>>正文


Java ECPoint.POINT_INFINITY屬性代碼示例

本文整理匯總了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) {
    }
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:23,代碼來源:ECPublicKeySpec_ImplTest.java

示例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;
}
 
開發者ID:NoYouShutup,項目名稱:CryptMeme,代碼行數:19,代碼來源:ECUtil.java

示例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
  }
}
 
開發者ID:google,項目名稱:wycheproof,代碼行數:16,代碼來源:EcKeyTest.java


注:本文中的java.security.spec.ECPoint.POINT_INFINITY屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。