Beispiel #1
0
 public static void Invert(ulong[] x, ulong[] z)
 {
     //IL_0008: Unknown result type (might be due to invalid IL or missing references)
     if (Nat320.IsZero64(x))
     {
         throw new InvalidOperationException();
     }
     ulong[] array  = Nat320.Create64();
     ulong[] array2 = Nat320.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);
     Square(array2, array2);
     Multiply(array2, x, array2);
     SquareN(array2, 17, array);
     Multiply(array, array2, array);
     Square(array, array);
     Multiply(array, x, array);
     SquareN(array, 35, array2);
     Multiply(array2, array, array2);
     SquareN(array2, 70, array);
     Multiply(array, array2, array);
     Square(array, array);
     Multiply(array, x, array);
     SquareN(array, 141, array2);
     Multiply(array2, array, array2);
     Square(array2, z);
 }
        public static void Invert(ulong[] x, ulong[] z)
        {
            if (Nat320.IsZero64(x))
            {
                throw new InvalidOperationException();
            }

            // Itoh-Tsujii inversion

            ulong[] t0 = Nat320.Create64();
            ulong[] t1 = Nat320.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);
            Square(t1, t1);
            Multiply(t1, x, t1);
            SquareN(t1, 17, t0);
            Multiply(t0, t1, t0);
            Square(t0, t0);
            Multiply(t0, x, t0);
            SquareN(t0, 35, t1);
            Multiply(t1, t0, t1);
            SquareN(t1, 70, t0);
            Multiply(t0, t1, t0);
            Square(t0, t0);
            Multiply(t0, x, t0);
            SquareN(t0, 141, t1);
            Multiply(t1, t0, t1);
            Square(t1, z);
        }