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 (Nat448.IsZero64(x))
     {
         throw new InvalidOperationException();
     }
     ulong[] array  = Nat448.Create64();
     ulong[] array2 = Nat448.Create64();
     ulong[] array3 = Nat448.Create64();
     Square(x, array);
     SquareN(array, 1, array2);
     Multiply(array, array2, array);
     SquareN(array2, 1, array2);
     Multiply(array, array2, array);
     SquareN(array, 3, array2);
     Multiply(array, array2, array);
     SquareN(array, 6, array2);
     Multiply(array, array2, array);
     SquareN(array, 12, array2);
     Multiply(array, array2, array3);
     SquareN(array3, 24, array);
     SquareN(array, 24, array2);
     Multiply(array, array2, array);
     SquareN(array, 48, array2);
     Multiply(array, array2, array);
     SquareN(array, 96, array2);
     Multiply(array, array2, array);
     SquareN(array, 192, array2);
     Multiply(array, array2, array);
     Multiply(array, array3, z);
 }
 public static void Invert(ulong[] x, ulong[] z)
 {
     if (Nat448.IsZero64(x))
     {
         throw new InvalidOperationException();
     }
     ulong[] array  = Nat448.Create64();
     ulong[] array2 = Nat448.Create64();
     ulong[] array3 = Nat448.Create64();
     Square(x, array);
     SquareN(array, 1, array2);
     Multiply(array, array2, array);
     SquareN(array2, 1, array2);
     Multiply(array, array2, array);
     SquareN(array, 3, array2);
     Multiply(array, array2, array);
     SquareN(array, 6, array2);
     Multiply(array, array2, array);
     SquareN(array, 12, array2);
     Multiply(array, array2, array3);
     SquareN(array3, 24, array);
     SquareN(array, 24, array2);
     Multiply(array, array2, array);
     SquareN(array, 48, array2);
     Multiply(array, array2, array);
     SquareN(array, 96, array2);
     Multiply(array, array2, array);
     SquareN(array, 192, array2);
     Multiply(array, array2, array);
     Multiply(array, array3, z);
 }
Beispiel #3
0
 public static void Invert(ulong[] x, ulong[] z)
 {
     if (Nat448.IsZero64(x))
     {
         throw new InvalidOperationException();
     }
     ulong[] numArray  = Nat448.Create64();
     ulong[] numArray2 = Nat448.Create64();
     ulong[] numArray3 = Nat448.Create64();
     Square(x, numArray);
     SquareN(numArray, 1, numArray2);
     Multiply(numArray, numArray2, numArray);
     SquareN(numArray2, 1, numArray2);
     Multiply(numArray, numArray2, numArray);
     SquareN(numArray, 3, numArray2);
     Multiply(numArray, numArray2, numArray);
     SquareN(numArray, 6, numArray2);
     Multiply(numArray, numArray2, numArray);
     SquareN(numArray, 12, numArray2);
     Multiply(numArray, numArray2, numArray3);
     SquareN(numArray3, 0x18, numArray);
     SquareN(numArray, 0x18, numArray2);
     Multiply(numArray, numArray2, numArray);
     SquareN(numArray, 0x30, numArray2);
     Multiply(numArray, numArray2, numArray);
     SquareN(numArray, 0x60, numArray2);
     Multiply(numArray, numArray2, numArray);
     SquareN(numArray, 0xc0, numArray2);
     Multiply(numArray, numArray2, numArray);
     Multiply(numArray, numArray3, z);
 }
Beispiel #4
0
 public override ECFieldElement SquarePow(int pow)
 {
     if (pow < 1)
     {
         return(this);
     }
     ulong[] z = Nat448.Create64();
     SecT409Field.SquareN(x, pow, z);
     return(new SecT409FieldElement(z));
 }
Beispiel #5
0
 public override ECFieldElement SquarePlusProduct(ECFieldElement x, ECFieldElement y)
 {
     ulong[] array  = this.x;
     ulong[] array2 = ((SecT409FieldElement)x).x;
     ulong[] y2     = ((SecT409FieldElement)y).x;
     ulong[] array3 = Nat.Create64(13);
     SecT409Field.SquareAddToExt(array, array3);
     SecT409Field.MultiplyAddToExt(array2, y2, array3);
     ulong[] z = Nat448.Create64();
     SecT409Field.Reduce(array3, z);
     return(new SecT409FieldElement(z));
 }
Beispiel #6
0
        public static void Invert(ulong[] x, ulong[] z)
        {
            if (Nat448.IsZero64(x))
            {
                throw new InvalidOperationException();
            }

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

            ulong[] t0 = Nat448.Create64();
            ulong[] t1 = Nat448.Create64();
            ulong[] t2 = Nat448.Create64();

            Square(x, t0);

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

            // 2 | 136
            SquareN(t0, 3, t1);
            Multiply(t0, t1, t0);

            // 2 | 68
            SquareN(t0, 6, t1);
            Multiply(t0, t1, t0);

            // 2 | 34
            SquareN(t0, 12, t1);
            Multiply(t0, t1, t2);

            // ! {2,3} | 17
            SquareN(t2, 24, t0);
            SquareN(t0, 24, t1);
            Multiply(t0, t1, t0);

            // 2 | 8
            SquareN(t0, 48, t1);
            Multiply(t0, t1, t0);

            // 2 | 4
            SquareN(t0, 96, t1);
            Multiply(t0, t1, t0);

            // 2 | 2
            SquareN(t0, 192, t1);
            Multiply(t0, t1, t0);

            Multiply(t0, t2, z);
        }
        public override ECFieldElement MultiplyPlusProduct(ECFieldElement b, ECFieldElement x, ECFieldElement y)
        {
            ulong[] ax = this.x, bx = ((SecT409FieldElement)b).x;
            ulong[] xx = ((SecT409FieldElement)x).x, yx = ((SecT409FieldElement)y).x;

            ulong[] tt = Nat.Create64(13);
            SecT409Field.MultiplyAddToExt(ax, bx, tt);
            SecT409Field.MultiplyAddToExt(xx, yx, tt);

            ulong[] z = Nat448.Create64();
            SecT409Field.Reduce(tt, z);
            return(new SecT409FieldElement(z));
        }
 public override ECFieldElement MultiplyPlusProduct(ECFieldElement b, ECFieldElement x, ECFieldElement y)
 {
     ulong[] numArray  = this.x;
     ulong[] numArray2 = ((SecT409FieldElement)b).x;
     ulong[] numArray3 = ((SecT409FieldElement)x).x;
     ulong[] numArray4 = ((SecT409FieldElement)y).x;
     ulong[] zz        = Nat.Create64(13);
     SecT409Field.MultiplyAddToExt(numArray, numArray2, zz);
     SecT409Field.MultiplyAddToExt(numArray3, numArray4, zz);
     ulong[] z = Nat448.Create64();
     SecT409Field.Reduce(zz, z);
     return(new SecT409FieldElement(z));
 }
Beispiel #9
0
            public override ECPoint LookupVar(int index)
            {
                ulong[] x   = Nat448.Create64(), y = Nat448.Create64();
                int     pos = index * SECT409R1_FE_LONGS * 2;

                for (int j = 0; j < SECT409R1_FE_LONGS; ++j)
                {
                    x[j] = m_table[pos + j];
                    y[j] = m_table[pos + SECT409R1_FE_LONGS + j];
                }

                return(CreatePoint(x, y));
            }
            public virtual ECPoint Lookup(int index)
            {
                ulong[] x   = Nat448.Create64(), y = Nat448.Create64();
                int     pos = 0;

                for (int i = 0; i < m_size; ++i)
                {
                    ulong MASK = (ulong)(long)(((i ^ index) - 1) >> 31);

                    for (int j = 0; j < SECT409R1_FE_LONGS; ++j)
                    {
                        x[j] ^= m_table[pos + j] & MASK;
                        y[j] ^= m_table[pos + SECT409R1_FE_LONGS + j] & MASK;
                    }

                    pos += (SECT409R1_FE_LONGS * 2);
                }

                return(m_outer.CreateRawPoint(new SecT409FieldElement(x), new SecT409FieldElement(y), false));
            }
Beispiel #11
0
            public override ECPoint Lookup(int index)
            {
                ulong[] x   = Nat448.Create64(), y = Nat448.Create64();
                int     pos = 0;

                for (int i = 0; i < m_size; ++i)
                {
                    ulong MASK = (ulong)(long)(((i ^ index) - 1) >> 31);

                    for (int j = 0; j < SECT409R1_FE_LONGS; ++j)
                    {
                        x[j] ^= m_table[pos + j] & MASK;
                        y[j] ^= m_table[pos + SECT409R1_FE_LONGS + j] & MASK;
                    }

                    pos += (SECT409R1_FE_LONGS * 2);
                }

                return(CreatePoint(x, y));
            }
Beispiel #12
0
 public override ECFieldElement Multiply(ECFieldElement b)
 {
     ulong[] z = Nat448.Create64();
     SecT409Field.Multiply(x, ((SecT409FieldElement)b).x, z);
     return(new SecT409FieldElement(z));
 }
Beispiel #13
0
 public override ECFieldElement AddOne()
 {
     ulong[] z = Nat448.Create64();
     SecT409Field.AddOne(x, z);
     return(new SecT409FieldElement(z));
 }
Beispiel #14
0
 public SecT409FieldElement()
 {
     x = Nat448.Create64();
 }
 public override ECFieldElement Invert()
 {
     ulong[] z = Nat448.Create64();
     SecT409Field.Invert(this.x, z);
     return(new SecT409FieldElement(z));
 }
 public override ECFieldElement Add(ECFieldElement b)
 {
     ulong[] z = Nat448.Create64();
     SecT409Field.Add(this.x, ((SecT409FieldElement)b).x, z);
     return(new SecT409FieldElement(z));
 }