public override ECFieldElement MultiplyPlusProduct(ECFieldElement b, ECFieldElement x, ECFieldElement y) { ulong[] ax = this.x, bx = ((SecT233FieldElement)b).x; ulong[] xx = ((SecT233FieldElement)x).x, yx = ((SecT233FieldElement)y).x; ulong[] tt = Nat256.CreateExt64(); SecT233Field.MultiplyAddToExt(ax, bx, tt); SecT233Field.MultiplyAddToExt(xx, yx, tt); ulong[] z = Nat256.Create64(); SecT233Field.Reduce(tt, z); return(new SecT233FieldElement(z)); }
public override ECFieldElement MultiplyPlusProduct(ECFieldElement b, ECFieldElement x, ECFieldElement y) { ulong[] array = this.x; ulong[] y2 = ((SecT233FieldElement)b).x; ulong[] array2 = ((SecT233FieldElement)x).x; ulong[] y3 = ((SecT233FieldElement)y).x; ulong[] array3 = Nat256.CreateExt64(); SecT233Field.MultiplyAddToExt(array, y2, array3); SecT233Field.MultiplyAddToExt(array2, y3, array3); ulong[] z = Nat256.Create64(); SecT233Field.Reduce(array3, z); return(new SecT233FieldElement(z)); }
public static void Sqrt(ulong[] x, ulong[] z) { ulong num = Interleave.Unshuffle(x[0]); ulong num2 = Interleave.Unshuffle(x[1]); ulong num3 = (num & uint.MaxValue) | (num2 << 32); ulong num4 = (ulong)((long)(num >> 32) | ((long)num2 & -4294967296L)); num = Interleave.Unshuffle(x[2]); num2 = Interleave.Unshuffle(x[3]); ulong num5 = (num & uint.MaxValue) | (num2 << 32); ulong num6 = (ulong)((long)(num >> 32) | ((long)num2 & -4294967296L)); ulong num7 = num6 >> 49; ulong num8 = (num4 >> 49) | (num6 << 15); num6 ^= num4 << 15; ulong[] array = Nat256.CreateExt64(); int[] array2 = new int[2] { 39, 120 }; ulong[] array3; for (int i = 0; i < array2.Length; i++) { int num9 = array2[i] >> 6; int num10 = array2[i] & 0x3F; ulong[] array4 = array3 = array; int num11 = num9; IntPtr intPtr = (IntPtr)num11; array4[num11] = (array3[(long)intPtr] ^ (num4 << num10)); ulong[] array5 = array3 = array; int num12 = num9 + 1; intPtr = (IntPtr)num12; array5[num12] = (array3[(long)intPtr] ^ ((num6 << num10) | (num4 >> -num10))); ulong[] array6 = array3 = array; int num13 = num9 + 2; intPtr = (IntPtr)num13; array6[num13] = (array3[(long)intPtr] ^ ((num8 << num10) | (num6 >> -num10))); ulong[] array7 = array3 = array; int num14 = num9 + 3; intPtr = (IntPtr)num14; array7[num14] = (array3[(long)intPtr] ^ ((num7 << num10) | (num8 >> -num10))); ulong[] array8 = array3 = array; int num15 = num9 + 4; intPtr = (IntPtr)num15; array8[num15] = (array3[(long)intPtr] ^ (num7 >> -num10)); } Reduce(array, z); (array3 = z)[0] = (array3[0] ^ num3); (array3 = z)[1] = (array3[1] ^ num5); }
public static void SquareN(ulong[] x, int n, ulong[] z) { Debug.Assert(n > 0); ulong[] tt = Nat256.CreateExt64(); ImplSquare(x, tt); Reduce(tt, z); while (--n > 0) { ImplSquare(z, tt); Reduce(tt, z); } }
public static void HalfTrace(ulong[] x, ulong[] z) { ulong[] tt = Nat256.CreateExt64(); Nat256.Copy64(x, z); for (int i = 1; i < 239; i += 2) { ImplSquare(z, tt); Reduce(tt, z); ImplSquare(z, tt); Reduce(tt, z); AddTo(x, z); } }
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; }
public static void MultiplyAddToExt(ulong[] x, ulong[] y, ulong[] zz) { ulong[] tt = Nat256.CreateExt64(); ImplMultiply(x, y, tt); AddExt(zz, tt, zz); }
public static void Multiply(ulong[] x, ulong[] y, ulong[] z) { ulong[] tt = Nat256.CreateExt64(); ImplMultiply(x, y, tt); Reduce(tt, z); }
public static void SquareAddToExt(ulong[] x, ulong[] zz) { ulong[] tt = Nat256.CreateExt64(); ImplSquare(x, tt); AddExt(zz, tt, zz); }
public static void Square(ulong[] x, ulong[] z) { ulong[] tt = Nat256.CreateExt64(); ImplSquare(x, tt); Reduce(tt, z); }
public static void MultiplyAddToExt(ulong[] x, ulong[] y, ulong[] zz) { ulong[] array = Nat256.CreateExt64(); ImplMultiply(x, y, array); AddExt(zz, array, zz); }
public static void Multiply(ulong[] x, ulong[] y, ulong[] z) { ulong[] array = Nat256.CreateExt64(); ImplMultiply(x, y, array); Reduce(array, z); }
public static void SquareAddToExt(ulong[] x, ulong[] zz) { ulong[] array = Nat256.CreateExt64(); ImplSquare(x, array); AddExt(zz, array, zz); }
public static void Square(ulong[] x, ulong[] z) { ulong[] array = Nat256.CreateExt64(); ImplSquare(x, array); Reduce(array, z); }