java流程控制both_Java Nat.addBothTo方法代码示例

import org.bouncycastle.math.raw.Nat; //导入方法依赖的package包/类

public ECPoint twice()

{

if (this.isInfinity())

{

return this;

}

ECCurve curve = this.getCurve();

SecP384R1FieldElement Y1 = (SecP384R1FieldElement)this.y;

if (Y1.isZero())

{

return curve.getInfinity();

}

SecP384R1FieldElement X1 = (SecP384R1FieldElement)this.x, Z1 = (SecP384R1FieldElement)this.zs[0];

int c;

int[] t1 = Nat.create(12);

int[] t2 = Nat.create(12);

int[] Y1Squared = Nat.create(12);

SecP384R1Field.square(Y1.x, Y1Squared);

int[] T = Nat.create(12);

SecP384R1Field.square(Y1Squared, T);

boolean Z1IsOne = Z1.isOne();

int[] Z1Squared = Z1.x;

if (!Z1IsOne)

{

Z1Squared = t2;

SecP384R1Field.square(Z1.x, Z1Squared);

}

SecP384R1Field.subtract(X1.x, Z1Squared, t1);

int[] M = t2;

SecP384R1Field.add(X1.x, Z1Squared, M);

SecP384R1Field.multiply(M, t1, M);

c = Nat.addBothTo(12, M, M, M);

SecP384R1Field.reduce32(c, M);

int[] S = Y1Squared;

SecP384R1Field.multiply(Y1Squared, X1.x, S);

c = Nat.shiftUpBits(12, S, 2, 0);

SecP384R1Field.reduce32(c, S);

c = Nat.shiftUpBits(12, T, 3, 0, t1);

SecP384R1Field.reduce32(c, t1);

SecP384R1FieldElement X3 = new SecP384R1FieldElement(T);

SecP384R1Field.square(M, X3.x);

SecP384R1Field.subtract(X3.x, S, X3.x);

SecP384R1Field.subtract(X3.x, S, X3.x);

SecP384R1FieldElement Y3 = new SecP384R1FieldElement(S);

SecP384R1Field.subtract(S, X3.x, Y3.x);

SecP384R1Field.multiply(Y3.x, M, Y3.x);

SecP384R1Field.subtract(Y3.x, t1, Y3.x);

SecP384R1FieldElement Z3 = new SecP384R1FieldElement(M);

SecP384R1Field.twice(Y1.x, Z3.x);

if (!Z1IsOne)

{

SecP384R1Field.multiply(Z3.x, Z1.x, Z3.x);

}

return new SecP384R1Point(curve, X3, Y3, new ECFieldElement[]{ Z3 }, this.withCompression);

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值