public static void Sqrt(ulong[] x, ulong[] z) { ulong[] odd = Nat192.Create64(); ulong u0, u1; u0 = Interleave.Unshuffle(x[0]); u1 = Interleave.Unshuffle(x[1]); ulong e0 = (u0 & 0x00000000FFFFFFFFUL) | (u1 << 32); odd[0] = (u0 >> 32) | (u1 & 0xFFFFFFFF00000000UL); u0 = Interleave.Unshuffle(x[2]); ulong e1 = (u0 & 0x00000000FFFFFFFFUL); odd[1] = (u0 >> 32); Multiply(odd, ROOT_Z, z); z[0] ^= e0; z[1] ^= e1; }
public static void Sqrt(ulong[] x, ulong[] z) { ulong[] evn = Nat576.Create64(), odd = Nat576.Create64(); int pos = 0; for (int i = 0; i < 4; ++i) { ulong u0 = Interleave.Unshuffle(x[pos++]); ulong u1 = Interleave.Unshuffle(x[pos++]); evn[i] = (u0 & 0x00000000FFFFFFFFUL) | (u1 << 32); odd[i] = (u0 >> 32) | (u1 & 0xFFFFFFFF00000000UL); } { ulong u0 = Interleave.Unshuffle(x[pos]); evn[4] = (u0 & 0x00000000FFFFFFFFUL); odd[4] = (u0 >> 32); } Multiply(odd, ROOT_Z, z); Add(z, evn, z); }
public static void Sqrt(ulong[] x, ulong[] z) { ulong[] array = Nat320.Create64(); ulong num = Interleave.Unshuffle(x[0]); ulong num2 = Interleave.Unshuffle(x[1]); ulong num3 = (num & 0xFFFFFFFFu) | (num2 << 32); array[0] = (num >> 32) | (num2 & 0xFFFFFFFF00000000uL); num = Interleave.Unshuffle(x[2]); num2 = Interleave.Unshuffle(x[3]); ulong num4 = (num & 0xFFFFFFFFu) | (num2 << 32); array[1] = (num >> 32) | (num2 & 0xFFFFFFFF00000000uL); num = Interleave.Unshuffle(x[4]); ulong num5 = num & 0xFFFFFFFFu; array[2] = num >> 32; Multiply(array, ROOT_Z, z); ulong[] array2; (array2 = z)[0] = array2[0] ^ num3; (array2 = z)[1] = array2[1] ^ num4; (array2 = z)[2] = array2[2] ^ num5; }
public static void Sqrt(ulong[] x, ulong[] z) { ulong u0, u1; u0 = Interleave.Unshuffle(x[0]); u1 = Interleave.Unshuffle(x[1]); ulong e0 = (u0 & 0x00000000FFFFFFFFUL) | (u1 << 32); ulong c0 = (u0 >> 32) | (u1 & 0xFFFFFFFF00000000UL); u0 = Interleave.Unshuffle(x[2]); u1 = Interleave.Unshuffle(x[3]); ulong e1 = (u0 & 0x00000000FFFFFFFFUL) | (u1 << 32); ulong c1 = (u0 >> 32) | (u1 & 0xFFFFFFFF00000000UL); ulong c2, c3; c3 = (c1 >> 49); c2 = (c0 >> 49) | (c1 << 15); c1 ^= (c0 << 15); ulong[] tt = Nat256.CreateExt64(); int[] shifts = { 39, 120 }; for (int i = 0; i < shifts.Length; ++i) { int w = shifts[i] >> 6, s = shifts[i] & 63; Debug.Assert(s != 0); tt[w] ^= (c0 << s); tt[w + 1] ^= (c1 << s) | (c0 >> -s); tt[w + 2] ^= (c2 << s) | (c1 >> -s); tt[w + 3] ^= (c3 << s) | (c2 >> -s); tt[w + 4] ^= (c3 >> -s); } Reduce(tt, z); z[0] ^= e0; z[1] ^= e1; }