public SecP224K1FieldElement(BigInteger x) { if (x == null || x.signum() < 0 || x.compareTo(Q) >= 0) { throw new IllegalArgumentException("x value invalid for SecP224K1FieldElement"); } this.x = SecP224K1Field.fromBigInteger(x); }
SecP224K1Field.square(x1, x2); SecP224K1Field.multiply(x2, x1, x2); int[] x3 = x2; SecP224K1Field.square(x2, x3); SecP224K1Field.multiply(x3, x1, x3); int[] x4 = Nat224.create(); SecP224K1Field.square(x3, x4); SecP224K1Field.multiply(x4, x1, x4); int[] x8 = Nat224.create(); SecP224K1Field.squareN(x4, 4, x8); SecP224K1Field.multiply(x8, x4, x8); int[] x11 = Nat224.create(); SecP224K1Field.squareN(x8, 3, x11); SecP224K1Field.multiply(x11, x3, x11); int[] x19 = x11; SecP224K1Field.squareN(x11, 8, x19); SecP224K1Field.multiply(x19, x8, x19); int[] x23 = x8; SecP224K1Field.squareN(x19, 4, x23); SecP224K1Field.multiply(x23, x4, x23); int[] x42 = x4; SecP224K1Field.squareN(x23, 19, x42); SecP224K1Field.multiply(x42, x19, x42); int[] x84 = Nat224.create(); SecP224K1Field.squareN(x42, 42, x84); SecP224K1Field.multiply(x84, x42, x84); int[] x107 = x42; SecP224K1Field.squareN(x84, 23, x107); SecP224K1Field.multiply(x107, x23, x107);
SecP224K1Field.square(Z1.x, S2); SecP224K1Field.multiply(S2, X2.x, U2); SecP224K1Field.multiply(S2, Z1.x, S2); SecP224K1Field.multiply(S2, Y2.x, S2); SecP224K1Field.square(Z2.x, S1); SecP224K1Field.multiply(S1, X1.x, U1); SecP224K1Field.multiply(S1, Z2.x, S1); SecP224K1Field.multiply(S1, Y1.x, S1); SecP224K1Field.subtract(U1, U2, H); SecP224K1Field.subtract(S1, S2, R); SecP224K1Field.square(H, HSquared); SecP224K1Field.multiply(HSquared, H, G); SecP224K1Field.multiply(HSquared, U1, V); SecP224K1Field.negate(G, G); Nat224.mul(S1, G, tt1); SecP224K1Field.reduce32(c, G);
SecP224K1Field.square(Y1.x, Y1Squared); SecP224K1Field.square(Y1Squared, T); SecP224K1Field.square(X1.x, M); c = Nat224.addBothTo(M, M, M); SecP224K1Field.reduce32(c, M); SecP224K1Field.multiply(Y1Squared, X1.x, S); c = Nat.shiftUpBits(7, S, 2, 0); SecP224K1Field.reduce32(c, S); SecP224K1Field.reduce32(c, t1); SecP224K1Field.square(M, X3.x); SecP224K1Field.subtract(X3.x, S, X3.x); SecP224K1Field.subtract(X3.x, S, X3.x); SecP224K1Field.subtract(S, X3.x, Y3.x); SecP224K1Field.multiply(Y3.x, M, Y3.x); SecP224K1Field.subtract(Y3.x, t1, Y3.x); SecP224K1Field.twice(Y1.x, Z3.x); if (!Z1.isOne()) SecP224K1Field.multiply(Z3.x, Z1.x, Z3.x);
public ECFieldElement multiply(ECFieldElement b) { int[] z = Nat224.create(); SecP224K1Field.multiply(x, ((SecP224K1FieldElement)b).x, z); return new SecP224K1FieldElement(z); }
public ECFieldElement negate() { int[] z = Nat224.create(); SecP224K1Field.negate(x, z); return new SecP224K1FieldElement(z); }
public ECFieldElement addOne() { int[] z = Nat224.create(); SecP224K1Field.addOne(x, z); return new SecP224K1FieldElement(z); }
public ECFieldElement add(ECFieldElement b) { int[] z = Nat224.create(); SecP224K1Field.add(x, ((SecP224K1FieldElement)b).x, z); return new SecP224K1FieldElement(z); }
public ECFieldElement square() { int[] z = Nat224.create(); SecP224K1Field.square(x, z); return new SecP224K1FieldElement(z); }
SecP224K1Field.square(Z1.x, S2); SecP224K1Field.multiply(S2, X2.x, U2); SecP224K1Field.multiply(S2, Z1.x, S2); SecP224K1Field.multiply(S2, Y2.x, S2); SecP224K1Field.square(Z2.x, S1); SecP224K1Field.multiply(S1, X1.x, U1); SecP224K1Field.multiply(S1, Z2.x, S1); SecP224K1Field.multiply(S1, Y1.x, S1); SecP224K1Field.subtract(U1, U2, H); SecP224K1Field.subtract(S1, S2, R); SecP224K1Field.square(H, HSquared); SecP224K1Field.multiply(HSquared, H, G); SecP224K1Field.multiply(HSquared, U1, V); SecP224K1Field.negate(G, G); Nat224.mul(S1, G, tt1); SecP224K1Field.reduce32(c, G);
SecP224K1Field.square(Y1.x, Y1Squared); SecP224K1Field.square(Y1Squared, T); SecP224K1Field.square(X1.x, M); c = Nat224.addBothTo(M, M, M); SecP224K1Field.reduce32(c, M); SecP224K1Field.multiply(Y1Squared, X1.x, S); c = Nat.shiftUpBits(7, S, 2, 0); SecP224K1Field.reduce32(c, S); SecP224K1Field.reduce32(c, t1); SecP224K1Field.square(M, X3.x); SecP224K1Field.subtract(X3.x, S, X3.x); SecP224K1Field.subtract(X3.x, S, X3.x); SecP224K1Field.subtract(S, X3.x, Y3.x); SecP224K1Field.multiply(Y3.x, M, Y3.x); SecP224K1Field.subtract(Y3.x, t1, Y3.x); SecP224K1Field.twice(Y1.x, Z3.x); if (!Z1.isOne()) SecP224K1Field.multiply(Z3.x, Z1.x, Z3.x);
public ECFieldElement multiply(ECFieldElement b) { int[] z = Nat224.create(); SecP224K1Field.multiply(x, ((SecP224K1FieldElement)b).x, z); return new SecP224K1FieldElement(z); }
public ECFieldElement negate() { int[] z = Nat224.create(); SecP224K1Field.negate(x, z); return new SecP224K1FieldElement(z); }
public ECFieldElement addOne() { int[] z = Nat224.create(); SecP224K1Field.addOne(x, z); return new SecP224K1FieldElement(z); }
public ECFieldElement add(ECFieldElement b) { int[] z = Nat224.create(); SecP224K1Field.add(x, ((SecP224K1FieldElement)b).x, z); return new SecP224K1FieldElement(z); }
public ECFieldElement square() { int[] z = Nat224.create(); SecP224K1Field.square(x, z); return new SecP224K1FieldElement(z); }
SecP224K1Field.square(x1, x2); SecP224K1Field.multiply(x2, x1, x2); int[] x3 = x2; SecP224K1Field.square(x2, x3); SecP224K1Field.multiply(x3, x1, x3); int[] x4 = Nat224.create(); SecP224K1Field.square(x3, x4); SecP224K1Field.multiply(x4, x1, x4); int[] x8 = Nat224.create(); SecP224K1Field.squareN(x4, 4, x8); SecP224K1Field.multiply(x8, x4, x8); int[] x11 = Nat224.create(); SecP224K1Field.squareN(x8, 3, x11); SecP224K1Field.multiply(x11, x3, x11); int[] x19 = x11; SecP224K1Field.squareN(x11, 8, x19); SecP224K1Field.multiply(x19, x8, x19); int[] x23 = x8; SecP224K1Field.squareN(x19, 4, x23); SecP224K1Field.multiply(x23, x4, x23); int[] x42 = x4; SecP224K1Field.squareN(x23, 19, x42); SecP224K1Field.multiply(x42, x19, x42); int[] x84 = Nat224.create(); SecP224K1Field.squareN(x42, 42, x84); SecP224K1Field.multiply(x84, x42, x84); int[] x107 = x42; SecP224K1Field.squareN(x84, 23, x107); SecP224K1Field.multiply(x107, x23, x107);
public ECFieldElement divide(ECFieldElement b) { // return multiply(b.invert()); int[] z = Nat224.create(); Mod.invert(SecP224K1Field.P, ((SecP224K1FieldElement)b).x, z); SecP224K1Field.multiply(z, x, z); return new SecP224K1FieldElement(z); }