public ECFieldElement add(ECFieldElement b) { long[] z = Nat576.create64(); SecT571Field.add(x, ((SecT571FieldElement)b).x, z); return new SecT571FieldElement(z); }
public static long[] precompMultiplicand(long[] x) { /* * Precompute table of all 4-bit products of x (first section) */ int len = 9 << 4; long[] t = new long[len << 1]; System.arraycopy(x, 0, t, 9, 9); // reduce5(T0, 9); int tOff = 0; for (int i = 7; i > 0; --i) { tOff += 18; Nat.shiftUpBit64(9, t, tOff >>> 1, 0L, t, tOff); reduce5(t, tOff); add(t, 9, t, tOff, t, tOff + 9); } /* * Second section with all 4-bit products of B shifted 4 bits */ Nat.shiftUpBits64(len, t, 0, 4, 0L, t, len); return t; }
public static void sqrt(long[] x, long[] z) { long[] evn = Nat576.create64(), odd = Nat576.create64(); int pos = 0; for (int i = 0; i < 4; ++i) { long u0 = Interleave.unshuffle(x[pos++]); long u1 = Interleave.unshuffle(x[pos++]); evn[i] = (u0 & 0x00000000FFFFFFFFL) | (u1 << 32); odd[i] = (u0 >>> 32) | (u1 & 0xFFFFFFFF00000000L); } { long u0 = Interleave.unshuffle(x[pos]); evn[4] = (u0 & 0x00000000FFFFFFFFL); odd[4] = (u0 >>> 32); } multiply(odd, ROOT_Z, z); add(z, evn, z); }