public static void Invert(ulong[] x, ulong[] z)
        {
            if (Nat192.IsZero64(x))
            {
                throw new InvalidOperationException();
            }

            // Itoh-Tsujii inversion

            ulong[] t0 = Nat192.Create64();
            ulong[] t1 = Nat192.Create64();

            Square(x, t0);
            Multiply(t0, x, t0);
            SquareN(t0, 2, t1);
            Multiply(t1, t0, t1);
            SquareN(t1, 4, t0);
            Multiply(t0, t1, t0);
            SquareN(t0, 8, t1);
            Multiply(t1, t0, t1);
            SquareN(t1, 16, t0);
            Multiply(t0, t1, t0);
            SquareN(t0, 32, t1);
            Multiply(t1, t0, t1);
            Square(t1, t1);
            Multiply(t1, x, t1);
            SquareN(t1, 65, t0);
            Multiply(t0, t1, t0);
            Square(t0, z);
        }
Exemple #2
0
 public static void Invert(ulong[] x, ulong[] z)
 {
     //IL_0008: Unknown result type (might be due to invalid IL or missing references)
     if (Nat192.IsZero64(x))
     {
         throw new InvalidOperationException();
     }
     ulong[] array  = Nat192.Create64();
     ulong[] array2 = Nat192.Create64();
     Square(x, array);
     Multiply(array, x, array);
     SquareN(array, 2, array2);
     Multiply(array2, array, array2);
     SquareN(array2, 4, array);
     Multiply(array, array2, array);
     SquareN(array, 8, array2);
     Multiply(array2, array, array2);
     SquareN(array2, 16, array);
     Multiply(array, array2, array);
     SquareN(array, 32, array2);
     Multiply(array2, array, array2);
     Square(array2, array2);
     Multiply(array2, x, array2);
     SquareN(array2, 65, array);
     Multiply(array, array2, array);
     Square(array, z);
 }
 public static void Invert(ulong[] x, ulong[] z)
 {
     if (Nat192.IsZero64(x))
     {
         throw new InvalidOperationException();
     }
     ulong[] numArray  = Nat192.Create64();
     ulong[] numArray2 = Nat192.Create64();
     Square(x, numArray);
     Multiply(numArray, x, numArray);
     SquareN(numArray, 2, numArray2);
     Multiply(numArray2, numArray, numArray2);
     SquareN(numArray2, 4, numArray);
     Multiply(numArray, numArray2, numArray);
     SquareN(numArray, 8, numArray2);
     Multiply(numArray2, numArray, numArray2);
     SquareN(numArray2, 0x10, numArray);
     Multiply(numArray, numArray2, numArray);
     SquareN(numArray, 0x20, numArray2);
     Multiply(numArray2, numArray, numArray2);
     Square(numArray2, numArray2);
     Multiply(numArray2, x, numArray2);
     SquareN(numArray2, 0x41, numArray);
     Multiply(numArray, numArray2, numArray);
     Square(numArray, z);
 }
        public static void Invert(ulong[] x, ulong[] z)
        {
            if (Nat192.IsZero64(x))
            {
                throw new InvalidOperationException();
            }

            // Itoh-Tsujii inversion with bases { 2, 3 }

            ulong[] t0 = Nat192.Create64();
            ulong[] t1 = Nat192.Create64();

            Square(x, t0);

            // 3 | 162
            SquareN(t0, 1, t1);
            Multiply(t0, t1, t0);
            SquareN(t1, 1, t1);
            Multiply(t0, t1, t0);

            // 3 | 54
            SquareN(t0, 3, t1);
            Multiply(t0, t1, t0);
            SquareN(t1, 3, t1);
            Multiply(t0, t1, t0);

            // 3 | 18
            SquareN(t0, 9, t1);
            Multiply(t0, t1, t0);
            SquareN(t1, 9, t1);
            Multiply(t0, t1, t0);

            // 3 | 6
            SquareN(t0, 27, t1);
            Multiply(t0, t1, t0);
            SquareN(t1, 27, t1);
            Multiply(t0, t1, t0);

            // 2 | 2
            SquareN(t0, 81, t1);
            Multiply(t0, t1, z);
        }