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


Java ECFieldElement.multiply方法代码示例

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


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

示例1: generateSignature

import org.bouncycastle.math.ec.ECFieldElement; //导入方法依赖的package包/类
public BigInteger[] generateSignature(byte[] message)
{
    ECFieldElement h = hash2FieldElement(key.getParameters().getCurve(), message);
    if (h.toBigInteger().signum() == 0)
    {
        h = key.getParameters().getCurve().fromBigInteger(ONE);
    }

    BigInteger e, r, s;
    ECFieldElement Fe, y;

    do
    {
        do
        {
            do
            {
                e = generateRandomInteger(key.getParameters().getN(), random);
                Fe = key.getParameters().getG().multiply(e).getX();
            }
            while (Fe.toBigInteger().signum() == 0);

            y = h.multiply(Fe);
            r = fieldElement2Integer(key.getParameters().getN(), y);
        }
        while (r.signum() == 0);

        s = r.multiply(((ECPrivateKeyParameters)key).getD()).add(e).mod(key.getParameters().getN());
    }
    while (s.signum() == 0);

    return new BigInteger[]{r, s};
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:34,代码来源:DSTU4145Signer.java

示例2: verifySignature

import org.bouncycastle.math.ec.ECFieldElement; //导入方法依赖的package包/类
public boolean verifySignature(byte[] message, BigInteger r, BigInteger s)
{
    if (r.signum() == 0 || s.signum() == 0)
    {
        return false;
    }
    if (r.compareTo(key.getParameters().getN()) >= 0 || s.compareTo(key.getParameters().getN()) >= 0)
    {
        return false;
    }

    ECFieldElement h = hash2FieldElement(key.getParameters().getCurve(), message);
    if (h.toBigInteger().signum() == 0)
    {
        h = key.getParameters().getCurve().fromBigInteger(ONE);
    }

    ECPoint R = ECAlgorithms.sumOfTwoMultiplies(key.getParameters().getG(), s, ((ECPublicKeyParameters)key).getQ(), r);

    // components must be bogus.
    if (R.isInfinity())
    {
        return false;
    }

    ECFieldElement y = h.multiply(R.getX());
    return fieldElement2Integer(key.getParameters().getN(), y).compareTo(r) == 0;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:29,代码来源:DSTU4145Signer.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 SecT131R2Point(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 SecT131R2Point(curve, X3, L3, new ECFieldElement[]{ Z3 }, this.withCompression);
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:38,代码来源:SecT131R2Point.java

示例4: verifySignature

import org.bouncycastle.math.ec.ECFieldElement; //导入方法依赖的package包/类
public boolean verifySignature(byte[] message, BigInteger r, BigInteger s)
{
    if (r.signum() <= 0 || s.signum() <= 0)
    {
        return false;
    }

    ECDomainParameters parameters = key.getParameters();

    BigInteger n = parameters.getN();
    if (r.compareTo(n) >= 0 || s.compareTo(n) >= 0)
    {
        return false;
    }

    ECCurve curve = parameters.getCurve();

    ECFieldElement h = hash2FieldElement(curve, message);
    if (h.isZero())
    {
        h = curve.fromBigInteger(ONE);
    }

    ECPoint R = ECAlgorithms.sumOfTwoMultiplies(parameters.getG(), s, ((ECPublicKeyParameters)key).getQ(), r).normalize();

    // components must be bogus.
    if (R.isInfinity())
    {
        return false;
    }

    ECFieldElement y = h.multiply(R.getAffineXCoord());
    return fieldElement2Integer(n, y).compareTo(r) == 0;
}
 
开发者ID:thedrummeraki,项目名称:Aki-SSL,代码行数:35,代码来源:DSTU4145Signer.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 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:thedrummeraki,项目名称:Aki-SSL,代码行数:38,代码来源:SecT193R2Point.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 T = L1.square().add(L1Z1).add(Z1Sq);
    if (T.isZero())
    {
        return new SecT163R2Point(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 SecT163R2Point(curve, X3, L3, new ECFieldElement[]{ Z3 }, this.withCompression);
}
 
开发者ID:thedrummeraki,项目名称:Aki-SSL,代码行数:36,代码来源:SecT163R2Point.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 T = L1.square().add(L1Z1).add(Z1Sq);
    if (T.isZero())
    {
        return new SecT283R1Point(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 SecT283R1Point(curve, X3, L3, new ECFieldElement[]{ Z3 }, this.withCompression);
}
 
开发者ID:thedrummeraki,项目名称:Aki-SSL,代码行数:36,代码来源:SecT283R1Point.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 SecT163K1Point(curve, T, curve.getB().sqrt(), withCompression);
            return new SecT163K1Point(curve, T, curve.getB(), withCompression);
        }

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

        ECFieldElement t1 = L1.add(X1).square();
        ECFieldElement L3 = t1.add(T).add(Z1Sq).multiply(t1).add(X3);

        return new SecT163K1Point(curve, X3, L3, new ECFieldElement[]{ Z3 }, this.withCompression);
    }
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:37,代码来源:SecT163K1Point.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 a = curve.getA();
    ECFieldElement aZ1Sq = Z1IsOne ? a : a.multiply(Z1Sq);
    ECFieldElement T = L1.square().add(L1Z1).add(aZ1Sq);
    if (T.isZero())
    {
        return new SecT163R1Point(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 SecT163R1Point(curve, X3, L3, new ECFieldElement[]{ Z3 }, this.withCompression);
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:38,代码来源:SecT163R1Point.java

示例10: 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:ttt43ttt,项目名称:gwt-crypto,代码行数:38,代码来源:SecT193R1Point.java

示例11: 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:ttt43ttt,项目名称:gwt-crypto,代码行数:38,代码来源:SecT113R2Point.java

示例12: 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 SecT409R1Point(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 SecT409R1Point(curve, X3, L3, new ECFieldElement[]{ Z3 }, this.withCompression);
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:36,代码来源:SecT409R1Point.java

示例13: 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

示例14: 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

示例15: 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 Z1Sq = Z1IsOne ? Z1 : Z1.square();
        ECFieldElement T;
        if (Z1IsOne)
        {
            T = L1.square().add(L1);
        }
        else
        {
            T = L1.add(Z1).multiply(L1);
        }

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

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

        ECFieldElement t1 = L1.add(X1).square();
        ECFieldElement t2 = Z1IsOne ? Z1 : Z1Sq.square();
        ECFieldElement L3 = t1.add(T).add(Z1Sq).multiply(t1).add(t2).add(X3).add(Z3);

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


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