public SecP192K1FieldElement(BigInteger x) { if (x == null || x.signum() < 0 || x.compareTo(Q) >= 0) { throw new IllegalArgumentException("x value invalid for SecP192K1FieldElement"); } this.x = SecP192K1Field.fromBigInteger(x); }
SecP192K1Field.square(x1, x2); SecP192K1Field.multiply(x2, x1, x2); int[] x3 = Nat192.create(); SecP192K1Field.square(x2, x3); SecP192K1Field.multiply(x3, x1, x3); int[] x6 = Nat192.create(); SecP192K1Field.squareN(x3, 3, x6); SecP192K1Field.multiply(x6, x3, x6); int[] x8 = x6; SecP192K1Field.squareN(x6, 2, x8); SecP192K1Field.multiply(x8, x2, x8); int[] x16 = x2; SecP192K1Field.squareN(x8, 8, x16); SecP192K1Field.multiply(x16, x8, x16); int[] x19 = x8; SecP192K1Field.squareN(x16, 3, x19); SecP192K1Field.multiply(x19, x3, x19); int[] x35 = Nat192.create(); SecP192K1Field.squareN(x19, 16, x35); SecP192K1Field.multiply(x35, x16, x35); int[] x70 = x16; SecP192K1Field.squareN(x35, 35, x70); SecP192K1Field.multiply(x70, x35, x70); int[] x140 = x35; SecP192K1Field.squareN(x70, 70, x140); SecP192K1Field.multiply(x140, x70, x140); int[] x159 = x70; SecP192K1Field.squareN(x140, 19, x159); SecP192K1Field.multiply(x159, x19, x159);
SecP192K1Field.square(Z1.x, S2); SecP192K1Field.multiply(S2, X2.x, U2); SecP192K1Field.multiply(S2, Z1.x, S2); SecP192K1Field.multiply(S2, Y2.x, S2); SecP192K1Field.square(Z2.x, S1); SecP192K1Field.multiply(S1, X1.x, U1); SecP192K1Field.multiply(S1, Z2.x, S1); SecP192K1Field.multiply(S1, Y1.x, S1); SecP192K1Field.subtract(U1, U2, H); SecP192K1Field.subtract(S1, S2, R); SecP192K1Field.square(H, HSquared); SecP192K1Field.multiply(HSquared, H, G); SecP192K1Field.multiply(HSquared, U1, V); SecP192K1Field.negate(G, G); Nat192.mul(S1, G, tt1); SecP192K1Field.reduce32(c, G);
SecP192K1Field.square(Y1.x, Y1Squared); SecP192K1Field.square(Y1Squared, T); SecP192K1Field.square(X1.x, M); c = Nat192.addBothTo(M, M, M); SecP192K1Field.reduce32(c, M); SecP192K1Field.multiply(Y1Squared, X1.x, S); c = Nat.shiftUpBits(6, S, 2, 0); SecP192K1Field.reduce32(c, S); SecP192K1Field.reduce32(c, t1); SecP192K1Field.square(M, X3.x); SecP192K1Field.subtract(X3.x, S, X3.x); SecP192K1Field.subtract(X3.x, S, X3.x); SecP192K1Field.subtract(S, X3.x, Y3.x); SecP192K1Field.multiply(Y3.x, M, Y3.x); SecP192K1Field.subtract(Y3.x, t1, Y3.x); SecP192K1Field.twice(Y1.x, Z3.x); if (!Z1.isOne()) SecP192K1Field.multiply(Z3.x, Z1.x, Z3.x);
public ECFieldElement multiply(ECFieldElement b) { int[] z = Nat192.create(); SecP192K1Field.multiply(x, ((SecP192K1FieldElement)b).x, z); return new SecP192K1FieldElement(z); }
public ECFieldElement addOne() { int[] z = Nat192.create(); SecP192K1Field.addOne(x, z); return new SecP192K1FieldElement(z); }
public ECFieldElement add(ECFieldElement b) { int[] z = Nat192.create(); SecP192K1Field.add(x, ((SecP192K1FieldElement)b).x, z); return new SecP192K1FieldElement(z); }
public ECFieldElement negate() { int[] z = Nat192.create(); SecP192K1Field.negate(x, z); return new SecP192K1FieldElement(z); }
public ECFieldElement square() { int[] z = Nat192.create(); SecP192K1Field.square(x, z); return new SecP192K1FieldElement(z); }
SecP192K1Field.square(Z1.x, S2); SecP192K1Field.multiply(S2, X2.x, U2); SecP192K1Field.multiply(S2, Z1.x, S2); SecP192K1Field.multiply(S2, Y2.x, S2); SecP192K1Field.square(Z2.x, S1); SecP192K1Field.multiply(S1, X1.x, U1); SecP192K1Field.multiply(S1, Z2.x, S1); SecP192K1Field.multiply(S1, Y1.x, S1); SecP192K1Field.subtract(U1, U2, H); SecP192K1Field.subtract(S1, S2, R); SecP192K1Field.square(H, HSquared); SecP192K1Field.multiply(HSquared, H, G); SecP192K1Field.multiply(HSquared, U1, V); SecP192K1Field.negate(G, G); Nat192.mul(S1, G, tt1); SecP192K1Field.reduce32(c, G);
SecP192K1Field.square(Y1.x, Y1Squared); SecP192K1Field.square(Y1Squared, T); SecP192K1Field.square(X1.x, M); c = Nat192.addBothTo(M, M, M); SecP192K1Field.reduce32(c, M); SecP192K1Field.multiply(Y1Squared, X1.x, S); c = Nat.shiftUpBits(6, S, 2, 0); SecP192K1Field.reduce32(c, S); SecP192K1Field.reduce32(c, t1); SecP192K1Field.square(M, X3.x); SecP192K1Field.subtract(X3.x, S, X3.x); SecP192K1Field.subtract(X3.x, S, X3.x); SecP192K1Field.subtract(S, X3.x, Y3.x); SecP192K1Field.multiply(Y3.x, M, Y3.x); SecP192K1Field.subtract(Y3.x, t1, Y3.x); SecP192K1Field.twice(Y1.x, Z3.x); if (!Z1.isOne()) SecP192K1Field.multiply(Z3.x, Z1.x, Z3.x);
public ECFieldElement multiply(ECFieldElement b) { int[] z = Nat192.create(); SecP192K1Field.multiply(x, ((SecP192K1FieldElement)b).x, z); return new SecP192K1FieldElement(z); }
public ECFieldElement addOne() { int[] z = Nat192.create(); SecP192K1Field.addOne(x, z); return new SecP192K1FieldElement(z); }
public ECFieldElement add(ECFieldElement b) { int[] z = Nat192.create(); SecP192K1Field.add(x, ((SecP192K1FieldElement)b).x, z); return new SecP192K1FieldElement(z); }
public ECFieldElement negate() { int[] z = Nat192.create(); SecP192K1Field.negate(x, z); return new SecP192K1FieldElement(z); }
public ECFieldElement square() { int[] z = Nat192.create(); SecP192K1Field.square(x, z); return new SecP192K1FieldElement(z); }
SecP192K1Field.square(x1, x2); SecP192K1Field.multiply(x2, x1, x2); int[] x3 = Nat192.create(); SecP192K1Field.square(x2, x3); SecP192K1Field.multiply(x3, x1, x3); int[] x6 = Nat192.create(); SecP192K1Field.squareN(x3, 3, x6); SecP192K1Field.multiply(x6, x3, x6); int[] x8 = x6; SecP192K1Field.squareN(x6, 2, x8); SecP192K1Field.multiply(x8, x2, x8); int[] x16 = x2; SecP192K1Field.squareN(x8, 8, x16); SecP192K1Field.multiply(x16, x8, x16); int[] x19 = x8; SecP192K1Field.squareN(x16, 3, x19); SecP192K1Field.multiply(x19, x3, x19); int[] x35 = Nat192.create(); SecP192K1Field.squareN(x19, 16, x35); SecP192K1Field.multiply(x35, x16, x35); int[] x70 = x16; SecP192K1Field.squareN(x35, 35, x70); SecP192K1Field.multiply(x70, x35, x70); int[] x140 = x35; SecP192K1Field.squareN(x70, 70, x140); SecP192K1Field.multiply(x140, x70, x140); int[] x159 = x70; SecP192K1Field.squareN(x140, 19, x159); SecP192K1Field.multiply(x159, x19, x159);
public ECFieldElement divide(ECFieldElement b) { // return multiply(b.invert()); int[] z = Nat192.create(); Mod.invert(SecP192K1Field.P, ((SecP192K1FieldElement)b).x, z); SecP192K1Field.multiply(z, x, z); return new SecP192K1FieldElement(z); }