当前位置: 首页>>代码示例>>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;未经允许,请勿转载。