当前位置: 首页>>代码示例>>Java>>正文


Java ECFieldElement.square方法代码示例

本文整理汇总了Java中org.bouncycastle.math.ec.ECFieldElement.square方法的典型用法代码示例。如果您正苦于以下问题:Java ECFieldElement.square方法的具体用法?Java ECFieldElement.square怎么用?Java ECFieldElement.square使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bouncycastle.math.ec.ECFieldElement的用法示例。


在下文中一共展示了ECFieldElement.square方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: findBetaValues

import org.bouncycastle.math.ec.ECFieldElement; //导入方法依赖的package包/类
private static ECFieldElement[] findBetaValues(ECCurve c)
{
    BigInteger q = c.getField().getCharacteristic();
    BigInteger e = q.divide(ECConstants.THREE);

    // Search for a random value that generates a non-trival cube root of 1
    SecureRandom random = new SecureRandom();
    BigInteger b;
    do
    {
        BigInteger r = BigIntegers.createRandomInRange(ECConstants.TWO, q.subtract(ECConstants.TWO), random);
        b = r.modPow(e, q);
    }
    while (b.equals(ECConstants.ONE));

    ECFieldElement beta = c.fromBigInteger(b);

    return new ECFieldElement[]{ beta, beta.square() }; 
}
 
开发者ID:thedrummeraki,项目名称:Aki-SSL,代码行数:20,代码来源:DiscoverEndomorphisms.java

示例2: solveQuadradicEquation

import org.bouncycastle.math.ec.ECFieldElement; //导入方法依赖的package包/类
/**
 * Solves a quadratic equation <code>z<sup>2</sup> + z = beta</code>(X9.62
 * D.1.6) The other solution is <code>z + 1</code>.
 *
 * @param beta The value to solve the qradratic equation for.
 * @return the solution for <code>z<sup>2</sup> + z = beta</code> or
 *         <code>null</code> if no solution exists.
 */
private static ECFieldElement solveQuadradicEquation(ECFieldElement beta)
{
    ECFieldElement.F2m b = (ECFieldElement.F2m)beta;
    ECFieldElement zeroElement = new ECFieldElement.F2m(
        b.getM(), b.getK1(), b.getK2(), b.getK3(), ECConstants.ZERO);

    if (beta.toBigInteger().equals(ECConstants.ZERO))
    {
        return zeroElement;
    }

    ECFieldElement z = null;
    ECFieldElement gamma = zeroElement;

    Random rand = new Random();
    int m = b.getM();
    do
    {
        ECFieldElement t = new ECFieldElement.F2m(b.getM(), b.getK1(),
            b.getK2(), b.getK3(), new BigInteger(m, rand));
        z = zeroElement;
        ECFieldElement w = beta;
        for (int i = 1; i <= m - 1; i++)
        {
            ECFieldElement w2 = w.square();
            z = z.square().add(w2.multiply(t));
            w = w2.add(beta);
        }
        if (!w.toBigInteger().equals(ECConstants.ZERO))
        {
            return null;
        }
        gamma = z.square().add(z);
    }
    while (gamma.toBigInteger().equals(ECConstants.ZERO));

    return z;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:47,代码来源:DSTU4145PointEncoder.java

示例3: twice

import org.bouncycastle.math.ec.ECFieldElement; //导入方法依赖的package包/类
public ECPoint twice()
{
    if (this.isInfinity())
    {
        return this;
    }

    ECCurve curve = this.getCurve();

    ECFieldElement X1 = this.x;
    if (X1.isZero())
    {
        // A point with X == 0 is it's own additive inverse
        return curve.getInfinity();
    }

    ECFieldElement L1 = this.y, Z1 = this.zs[0];

    boolean Z1IsOne = Z1.isOne();
    ECFieldElement L1Z1 = Z1IsOne ? L1 : L1.multiply(Z1);
    ECFieldElement Z1Sq = Z1IsOne ? Z1 : Z1.square();
    ECFieldElement a = curve.getA();
    ECFieldElement aZ1Sq = Z1IsOne ? a : a.multiply(Z1Sq);
    ECFieldElement T = L1.square().add(L1Z1).add(aZ1Sq);
    if (T.isZero())
    {
        return new SecT113R1Point(curve, T, curve.getB().sqrt(), withCompression);
    }

    ECFieldElement X3 = T.square();
    ECFieldElement Z3 = Z1IsOne ? T : T.multiply(Z1Sq);

    ECFieldElement X1Z1 = Z1IsOne ? X1 : X1.multiply(Z1);
    ECFieldElement L3 = X1Z1.squarePlusProduct(T, L1Z1).add(X3).add(Z3);

    return new SecT113R1Point(curve, X3, L3, new ECFieldElement[]{ Z3 }, this.withCompression);
}
 
开发者ID:thedrummeraki,项目名称:Aki-SSL,代码行数:38,代码来源:SecT113R1Point.java

示例4: twice

import org.bouncycastle.math.ec.ECFieldElement; //导入方法依赖的package包/类
public ECPoint twice()
{
    if (this.isInfinity())
    {
        return this;
    }

    ECCurve curve = this.getCurve();

    ECFieldElement X1 = this.x;
    if (X1.isZero())
    {
        // A point with X == 0 is it's own additive inverse
        return curve.getInfinity();
    }

    ECFieldElement L1 = this.y, Z1 = this.zs[0];

    boolean Z1IsOne = Z1.isOne();
    ECFieldElement L1Z1 = Z1IsOne ? L1 : L1.multiply(Z1);
    ECFieldElement Z1Sq = Z1IsOne ? Z1 : Z1.square();
    ECFieldElement a = curve.getA();
    ECFieldElement aZ1Sq = Z1IsOne ? a : a.multiply(Z1Sq);
    ECFieldElement T = L1.square().add(L1Z1).add(aZ1Sq);
    if (T.isZero())
    {
        return new SecT193R1Point(curve, T, curve.getB().sqrt(), withCompression);
    }

    ECFieldElement X3 = T.square();
    ECFieldElement Z3 = Z1IsOne ? T : T.multiply(Z1Sq);

    ECFieldElement X1Z1 = Z1IsOne ? X1 : X1.multiply(Z1);
    ECFieldElement L3 = X1Z1.squarePlusProduct(T, L1Z1).add(X3).add(Z3);

    return new SecT193R1Point(curve, X3, L3, new ECFieldElement[]{ Z3 }, this.withCompression);
}
 
开发者ID:thedrummeraki,项目名称:Aki-SSL,代码行数:38,代码来源:SecT193R1Point.java

示例5: twice

import org.bouncycastle.math.ec.ECFieldElement; //导入方法依赖的package包/类
public ECPoint twice()
{
    if (this.isInfinity())
    {
        return this;
    }

    ECCurve curve = this.getCurve();

    ECFieldElement X1 = this.x;
    if (X1.isZero())
    {
        // A point with X == 0 is it's own additive inverse
        return curve.getInfinity();
    }

    ECFieldElement L1 = this.y, Z1 = this.zs[0];

    boolean Z1IsOne = Z1.isOne();
    ECFieldElement L1Z1 = Z1IsOne ? L1 : L1.multiply(Z1);
    ECFieldElement Z1Sq = Z1IsOne ? Z1 : Z1.square();
    ECFieldElement a = curve.getA();
    ECFieldElement aZ1Sq = Z1IsOne ? a : a.multiply(Z1Sq);
    ECFieldElement T = L1.square().add(L1Z1).add(aZ1Sq);
    if (T.isZero())
    {
        return new SecT131R1Point(curve, T, curve.getB().sqrt(), withCompression);
    }

    ECFieldElement X3 = T.square();
    ECFieldElement Z3 = Z1IsOne ? T : T.multiply(Z1Sq);

    ECFieldElement X1Z1 = Z1IsOne ? X1 : X1.multiply(Z1);
    ECFieldElement L3 = X1Z1.squarePlusProduct(T, L1Z1).add(X3).add(Z3);

    return new SecT131R1Point(curve, X3, L3, new ECFieldElement[]{ Z3 }, this.withCompression);
}
 
开发者ID:thedrummeraki,项目名称:Aki-SSL,代码行数:38,代码来源:SecT131R1Point.java

示例6: twice

import org.bouncycastle.math.ec.ECFieldElement; //导入方法依赖的package包/类
public ECPoint twice()
{
    if (this.isInfinity())
    {
        return this;
    }

    ECCurve curve = this.getCurve();

    ECFieldElement X1 = this.x;
    if (X1.isZero())
    {
        // A point with X == 0 is it's own additive inverse
        return curve.getInfinity();
    }

    ECFieldElement L1 = this.y, Z1 = this.zs[0];

    boolean Z1IsOne = Z1.isOne();
    ECFieldElement L1Z1 = Z1IsOne ? L1 : L1.multiply(Z1);
    ECFieldElement Z1Sq = Z1IsOne ? Z1 : Z1.square();
    ECFieldElement a = curve.getA();
    ECFieldElement aZ1Sq = Z1IsOne ? a : a.multiply(Z1Sq);
    ECFieldElement T = L1.square().add(L1Z1).add(aZ1Sq);
    if (T.isZero())
    {
        return new SecT113R2Point(curve, T, curve.getB().sqrt(), withCompression);
    }

    ECFieldElement X3 = T.square();
    ECFieldElement Z3 = Z1IsOne ? T : T.multiply(Z1Sq);

    ECFieldElement X1Z1 = Z1IsOne ? X1 : X1.multiply(Z1);
    ECFieldElement L3 = X1Z1.squarePlusProduct(T, L1Z1).add(X3).add(Z3);

    return new SecT113R2Point(curve, X3, L3, new ECFieldElement[]{ Z3 }, this.withCompression);
}
 
开发者ID:thedrummeraki,项目名称:Aki-SSL,代码行数:38,代码来源:SecT113R2Point.java

示例7: twice

import org.bouncycastle.math.ec.ECFieldElement; //导入方法依赖的package包/类
public ECPoint twice()
{
    if (this.isInfinity())
    {
        return this;
    }

    ECCurve curve = this.getCurve();

    ECFieldElement X1 = this.x;
    if (X1.isZero())
    {
        // A point with X == 0 is it's own additive inverse
        return curve.getInfinity();
    }

    ECFieldElement L1 = this.y, Z1 = this.zs[0];

    boolean Z1IsOne = Z1.isOne();
    ECFieldElement L1Z1 = Z1IsOne ? L1 : L1.multiply(Z1);
    ECFieldElement Z1Sq = Z1IsOne ? Z1 : Z1.square();
    ECFieldElement a = curve.getA();
    ECFieldElement aZ1Sq = Z1IsOne ? a : a.multiply(Z1Sq);
    ECFieldElement T = L1.square().add(L1Z1).add(aZ1Sq);
    if (T.isZero())
    {
        return new SecT193R2Point(curve, T, curve.getB().sqrt(), withCompression);
    }

    ECFieldElement X3 = T.square();
    ECFieldElement Z3 = Z1IsOne ? T : T.multiply(Z1Sq);

    ECFieldElement X1Z1 = Z1IsOne ? X1 : X1.multiply(Z1);
    ECFieldElement L3 = X1Z1.squarePlusProduct(T, L1Z1).add(X3).add(Z3);

    return new SecT193R2Point(curve, X3, L3, new ECFieldElement[]{ Z3 }, this.withCompression);
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:38,代码来源:SecT193R2Point.java

示例8: twice

import org.bouncycastle.math.ec.ECFieldElement; //导入方法依赖的package包/类
public ECPoint twice()
{
    if (this.isInfinity())
    {
        return this;
    }

    ECCurve curve = this.getCurve();

    ECFieldElement X1 = this.x;
    if (X1.isZero())
    {
        // A point with X == 0 is it's own additive inverse
        return curve.getInfinity();
    }

    ECFieldElement L1 = this.y, Z1 = this.zs[0];

    boolean Z1IsOne = Z1.isOne();
    ECFieldElement L1Z1 = Z1IsOne ? L1 : L1.multiply(Z1);
    ECFieldElement Z1Sq = Z1IsOne ? Z1 : Z1.square();
    ECFieldElement T = L1.square().add(L1Z1).add(Z1Sq);
    if (T.isZero())
    {
        return new SecT233R1Point(curve, T, curve.getB().sqrt(), withCompression);
    }

    ECFieldElement X3 = T.square();
    ECFieldElement Z3 = Z1IsOne ? T : T.multiply(Z1Sq);

    ECFieldElement X1Z1 = Z1IsOne ? X1 : X1.multiply(Z1);
    ECFieldElement L3 = X1Z1.squarePlusProduct(T, L1Z1).add(X3).add(Z3);

    return new SecT233R1Point(curve, X3, L3, new ECFieldElement[]{ Z3 }, this.withCompression);
}
 
开发者ID:thedrummeraki,项目名称:Aki-SSL,代码行数:36,代码来源:SecT233R1Point.java

示例9: twice

import org.bouncycastle.math.ec.ECFieldElement; //导入方法依赖的package包/类
public ECPoint twice()
    {
        if (this.isInfinity())
        {
            return this;
        }

        ECCurve curve = this.getCurve();

        ECFieldElement X1 = this.x;
        if (X1.isZero())
        {
            // A point with X == 0 is it's own additive inverse
            return curve.getInfinity();
        }

        ECFieldElement L1 = this.y, Z1 = this.zs[0];

        boolean Z1IsOne = Z1.isOne();
        ECFieldElement L1Z1 = Z1IsOne ? L1 : L1.multiply(Z1);
        ECFieldElement Z1Sq = Z1IsOne ? Z1 : Z1.square();
        ECFieldElement T = L1.square().add(L1Z1).add(Z1Sq);
        if (T.isZero())
        {
//            return new SecT571R1Point(curve, T, curve.getB().sqrt(), withCompression);
            return new SecT571R1Point(curve, T, SecT571R1Curve.SecT571R1_B_SQRT, withCompression);
        }

        ECFieldElement X3 = T.square();
        ECFieldElement Z3 = Z1IsOne ? T : T.multiply(Z1Sq);

        ECFieldElement X1Z1 = Z1IsOne ? X1 : X1.multiply(Z1);
        ECFieldElement L3 = X1Z1.squarePlusProduct(T, L1Z1).add(X3).add(Z3);

        return new SecT571R1Point(curve, X3, L3, new ECFieldElement[]{ Z3 }, this.withCompression);
    }
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:37,代码来源:SecT571R1Point.java

示例10: decodePoint

import org.bouncycastle.math.ec.ECFieldElement; //导入方法依赖的package包/类
public static ECPoint decodePoint(ECCurve curve, byte[] bytes)
{
    /*byte[] bp_enc=new byte[bytes.length+1];
      if (0==(bytes[bytes.length-1]&0x1))
          bp_enc[0]=0x02;
      else
          bp_enc[0]=0x03;
      System.arraycopy(bytes, 0, bp_enc, 1, bytes.length);
      if (!trace(curve.fromBigInteger(new BigInteger(1, bytes))).equals(curve.getA().toBigInteger()))
          bp_enc[bp_enc.length-1]^=0x01;

      return curve.decodePoint(bp_enc);*/

    BigInteger k = BigInteger.valueOf(bytes[bytes.length - 1] & 0x1);
    if (!trace(curve.fromBigInteger(new BigInteger(1, bytes))).equals(curve.getA().toBigInteger()))
    {
        bytes = Arrays.clone(bytes);
        bytes[bytes.length - 1] ^= 0x01;
    }
    ECCurve.F2m c = (ECCurve.F2m)curve;
    ECFieldElement xp = curve.fromBigInteger(new BigInteger(1, bytes));
    ECFieldElement yp = null;
    if (xp.toBigInteger().equals(ECConstants.ZERO))
    {
        yp = (ECFieldElement.F2m)curve.getB();
        for (int i = 0; i < c.getM() - 1; i++)
        {
            yp = yp.square();
        }
    }
    else
    {
        ECFieldElement beta = xp.add(curve.getA()).add(
            curve.getB().multiply(xp.square().invert()));
        ECFieldElement z = solveQuadradicEquation(beta);
        if (z == null)
        {
            throw new RuntimeException("Invalid point compression");
        }
        if (!trace(z).equals(k))
        {
            z = z.add(curve.fromBigInteger(ECConstants.ONE));
        }
        yp = xp.multiply(z);
    }

    return new ECPoint.F2m(curve, xp, yp);
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:49,代码来源:DSTU4145PointEncoder.java

示例11: twicePlus

import org.bouncycastle.math.ec.ECFieldElement; //导入方法依赖的package包/类
public ECPoint twicePlus(ECPoint b)
    {
        if (this.isInfinity())
        {
            return b;
        }
        if (b.isInfinity())
        {
            return twice();
        }

        ECCurve curve = this.getCurve();

        ECFieldElement X1 = this.x;
        if (X1.isZero())
        {
            // A point with X == 0 is it's own additive inverse
            return b;
        }

        ECFieldElement X2 = b.getRawXCoord(), Z2 = b.getZCoord(0);
        if (X2.isZero() || !Z2.isOne())
        {
            return twice().add(b);
        }

        ECFieldElement L1 = this.y, Z1 = this.zs[0];
        ECFieldElement L2 = b.getRawYCoord();

        ECFieldElement X1Sq = X1.square();
        ECFieldElement L1Sq = L1.square();
        ECFieldElement Z1Sq = Z1.square();
        ECFieldElement L1Z1 = L1.multiply(Z1);

//        ECFieldElement T = curve.getA().multiply(Z1Sq).add(L1Sq).add(L1Z1);
        ECFieldElement T = Z1Sq.add(L1Sq).add(L1Z1);
        ECFieldElement L2plus1 = L2.addOne();
//        ECFieldElement A = curve.getA().add(L2plus1).multiply(Z1Sq).add(L1Sq).multiplyPlusProduct(T, X1Sq, Z1Sq);
        ECFieldElement A = L2.multiply(Z1Sq).add(L1Sq).multiplyPlusProduct(T, X1Sq, Z1Sq);
        ECFieldElement X2Z1Sq = X2.multiply(Z1Sq);
        ECFieldElement B = X2Z1Sq.add(T).square();

        if (B.isZero())
        {
            if (A.isZero())
            {
                return b.twice();
            }

            return curve.getInfinity();
        }

        if (A.isZero())
        {
            return new SecT283R1Point(curve, A, curve.getB().sqrt(), withCompression);
        }

        ECFieldElement X3 = A.square().multiply(X2Z1Sq);
        ECFieldElement Z3 = A.multiply(B).multiply(Z1Sq);
        ECFieldElement L3 = A.add(B).square().multiplyPlusProduct(T, L2plus1, Z3);

        return new SecT283R1Point(curve, X3, L3, new ECFieldElement[]{ Z3 }, this.withCompression);
    }
 
开发者ID:thedrummeraki,项目名称:Aki-SSL,代码行数:64,代码来源:SecT283R1Point.java

示例12: twicePlus

import org.bouncycastle.math.ec.ECFieldElement; //导入方法依赖的package包/类
public ECPoint twicePlus(ECPoint b)
{
    if (this.isInfinity())
    {
        return b;
    }
    if (b.isInfinity())
    {
        return twice();
    }

    ECCurve curve = this.getCurve();

    ECFieldElement X1 = this.x;
    if (X1.isZero())
    {
        // A point with X == 0 is it's own additive inverse
        return b;
    }

    ECFieldElement X2 = b.getRawXCoord(), Z2 = b.getZCoord(0);
    if (X2.isZero() || !Z2.isOne())
    {
        return twice().add(b);
    }

    ECFieldElement L1 = this.y, Z1 = this.zs[0];
    ECFieldElement L2 = b.getRawYCoord();

    ECFieldElement X1Sq = X1.square();
    ECFieldElement L1Sq = L1.square();
    ECFieldElement Z1Sq = Z1.square();
    ECFieldElement L1Z1 = L1.multiply(Z1);

    ECFieldElement T = curve.getA().multiply(Z1Sq).add(L1Sq).add(L1Z1);
    ECFieldElement L2plus1 = L2.addOne();
    ECFieldElement A = curve.getA().add(L2plus1).multiply(Z1Sq).add(L1Sq).multiplyPlusProduct(T, X1Sq, Z1Sq);
    ECFieldElement X2Z1Sq = X2.multiply(Z1Sq);
    ECFieldElement B = X2Z1Sq.add(T).square();

    if (B.isZero())
    {
        if (A.isZero())
        {
            return b.twice();
        }

        return curve.getInfinity();
    }

    if (A.isZero())
    {
        return new SecT131R2Point(curve, A, curve.getB().sqrt(), withCompression);
    }

    ECFieldElement X3 = A.square().multiply(X2Z1Sq);
    ECFieldElement Z3 = A.multiply(B).multiply(Z1Sq);
    ECFieldElement L3 = A.add(B).square().multiplyPlusProduct(T, L2plus1, Z3);

    return new SecT131R2Point(curve, X3, L3, new ECFieldElement[]{ Z3 }, this.withCompression);
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:62,代码来源:SecT131R2Point.java

示例13: twicePlus

import org.bouncycastle.math.ec.ECFieldElement; //导入方法依赖的package包/类
public ECPoint twicePlus(ECPoint b)
{
    if (this.isInfinity())
    {
        return b;
    }
    if (b.isInfinity())
    {
        return twice();
    }

    ECCurve curve = this.getCurve();

    ECFieldElement X1 = this.x;
    if (X1.isZero())
    {
        // A point with X == 0 is it's own additive inverse
        return b;
    }

    ECFieldElement X2 = b.getRawXCoord(), Z2 = b.getZCoord(0);
    if (X2.isZero() || !Z2.isOne())
    {
        return twice().add(b);
    }

    ECFieldElement L1 = this.y, Z1 = this.zs[0];
    ECFieldElement L2 = b.getRawYCoord();

    ECFieldElement X1Sq = X1.square();
    ECFieldElement L1Sq = L1.square();
    ECFieldElement Z1Sq = Z1.square();
    ECFieldElement L1Z1 = L1.multiply(Z1);

    ECFieldElement T = curve.getA().multiply(Z1Sq).add(L1Sq).add(L1Z1);
    ECFieldElement L2plus1 = L2.addOne();
    ECFieldElement A = curve.getA().add(L2plus1).multiply(Z1Sq).add(L1Sq).multiplyPlusProduct(T, X1Sq, Z1Sq);
    ECFieldElement X2Z1Sq = X2.multiply(Z1Sq);
    ECFieldElement B = X2Z1Sq.add(T).square();

    if (B.isZero())
    {
        if (A.isZero())
        {
            return b.twice();
        }

        return curve.getInfinity();
    }

    if (A.isZero())
    {
        return new SecT193R1Point(curve, A, curve.getB().sqrt(), withCompression);
    }

    ECFieldElement X3 = A.square().multiply(X2Z1Sq);
    ECFieldElement Z3 = A.multiply(B).multiply(Z1Sq);
    ECFieldElement L3 = A.add(B).square().multiplyPlusProduct(T, L2plus1, Z3);

    return new SecT193R1Point(curve, X3, L3, new ECFieldElement[]{ Z3 }, this.withCompression);
}
 
开发者ID:thedrummeraki,项目名称:Aki-SSL,代码行数:62,代码来源:SecT193R1Point.java

示例14: twicePlus

import org.bouncycastle.math.ec.ECFieldElement; //导入方法依赖的package包/类
public ECPoint twicePlus(ECPoint b)
    {
        if (this.isInfinity())
        {
            return b;
        }
        if (b.isInfinity())
        {
            return twice();
        }

        ECCurve curve = this.getCurve();

        ECFieldElement X1 = this.x;
        if (X1.isZero())
        {
            // A point with X == 0 is it's own additive inverse
            return b;
        }

        // NOTE: twicePlus() only optimized for lambda-affine argument
        ECFieldElement X2 = b.getRawXCoord(), Z2 = b.getZCoord(0);
        if (X2.isZero() || !Z2.isOne())
        {
            return twice().add(b);
        }

        ECFieldElement L1 = this.y, Z1 = this.zs[0];
        ECFieldElement L2 = b.getRawYCoord();

        ECFieldElement X1Sq = X1.square();
        ECFieldElement L1Sq = L1.square();
        ECFieldElement Z1Sq = Z1.square();
        ECFieldElement L1Z1 = L1.multiply(Z1);

//        ECFieldElement T = curve.getA().multiply(Z1Sq).add(L1Sq).add(L1Z1);
        ECFieldElement T = L1Sq.add(L1Z1);
        ECFieldElement L2plus1 = L2.addOne();
//        ECFieldElement A = curve.getA().add(L2plus1).multiply(Z1Sq).add(L1Sq).multiplyPlusProduct(T, X1Sq, Z1Sq);
        ECFieldElement A = L2plus1.multiply(Z1Sq).add(L1Sq).multiplyPlusProduct(T, X1Sq, Z1Sq);
        ECFieldElement X2Z1Sq = X2.multiply(Z1Sq);
        ECFieldElement B = X2Z1Sq.add(T).square();

        if (B.isZero())
        {
            if (A.isZero())
            {
                return b.twice();
            }

            return curve.getInfinity();
        }

        if (A.isZero())
        {
//            return new SecT571K1Point(curve, A, curve.getB().sqrt(), withCompression);
            return new SecT571K1Point(curve, A, curve.getB(), withCompression);
        }

        ECFieldElement X3 = A.square().multiply(X2Z1Sq);
        ECFieldElement Z3 = A.multiply(B).multiply(Z1Sq);
        ECFieldElement L3 = A.add(B).square().multiplyPlusProduct(T, L2plus1, Z3);

        return new SecT571K1Point(curve, X3, L3, new ECFieldElement[]{ Z3 }, this.withCompression);
    }
 
开发者ID:thedrummeraki,项目名称:Aki-SSL,代码行数:66,代码来源:SecT571K1Point.java

示例15: twicePlus

import org.bouncycastle.math.ec.ECFieldElement; //导入方法依赖的package包/类
public ECPoint twicePlus(ECPoint b)
{
    if (this.isInfinity())
    {
        return b;
    }
    if (b.isInfinity())
    {
        return twice();
    }

    ECCurve curve = this.getCurve();

    ECFieldElement X1 = this.x;
    if (X1.isZero())
    {
        // A point with X == 0 is it's own additive inverse
        return b;
    }

    ECFieldElement X2 = b.getRawXCoord(), Z2 = b.getZCoord(0);
    if (X2.isZero() || !Z2.isOne())
    {
        return twice().add(b);
    }

    ECFieldElement L1 = this.y, Z1 = this.zs[0];
    ECFieldElement L2 = b.getRawYCoord();

    ECFieldElement X1Sq = X1.square();
    ECFieldElement L1Sq = L1.square();
    ECFieldElement Z1Sq = Z1.square();
    ECFieldElement L1Z1 = L1.multiply(Z1);

    ECFieldElement T = curve.getA().multiply(Z1Sq).add(L1Sq).add(L1Z1);
    ECFieldElement L2plus1 = L2.addOne();
    ECFieldElement A = curve.getA().add(L2plus1).multiply(Z1Sq).add(L1Sq).multiplyPlusProduct(T, X1Sq, Z1Sq);
    ECFieldElement X2Z1Sq = X2.multiply(Z1Sq);
    ECFieldElement B = X2Z1Sq.add(T).square();

    if (B.isZero())
    {
        if (A.isZero())
        {
            return b.twice();
        }

        return curve.getInfinity();
    }

    if (A.isZero())
    {
        return new SecT113R2Point(curve, A, curve.getB().sqrt(), withCompression);
    }

    ECFieldElement X3 = A.square().multiply(X2Z1Sq);
    ECFieldElement Z3 = A.multiply(B).multiply(Z1Sq);
    ECFieldElement L3 = A.add(B).square().multiplyPlusProduct(T, L2plus1, Z3);

    return new SecT113R2Point(curve, X3, L3, new ECFieldElement[]{ Z3 }, this.withCompression);
}
 
开发者ID:thedrummeraki,项目名称:Aki-SSL,代码行数:62,代码来源:SecT113R2Point.java


注:本文中的org.bouncycastle.math.ec.ECFieldElement.square方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。