Esempio n. 1
0
 public static void Invert(ulong[] x, ulong[] z)
 {
     if (Nat128.IsZero64(x))
     {
         throw new InvalidOperationException();
     }
     ulong[] numArray  = Nat128.Create64();
     ulong[] numArray2 = Nat128.Create64();
     Square(x, numArray);
     Multiply(numArray, x, numArray);
     Square(numArray, numArray);
     Multiply(numArray, x, numArray);
     SquareN(numArray, 3, numArray2);
     Multiply(numArray2, numArray, numArray2);
     Square(numArray2, numArray2);
     Multiply(numArray2, x, numArray2);
     SquareN(numArray2, 7, numArray);
     Multiply(numArray, numArray2, numArray);
     SquareN(numArray, 14, numArray2);
     Multiply(numArray2, numArray, numArray2);
     SquareN(numArray2, 0x1c, numArray);
     Multiply(numArray, numArray2, numArray);
     SquareN(numArray, 0x38, numArray2);
     Multiply(numArray2, numArray, numArray2);
     Square(numArray2, z);
 }
Esempio n. 2
0
        public static void Invert(ulong[] x, ulong[] z)
        {
            if (Nat128.IsZero64(x))
            {
                throw new InvalidOperationException();
            }

            // Itoh-Tsujii inversion

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

            Square(x, t0);
            Multiply(t0, x, t0);
            Square(t0, t0);
            Multiply(t0, x, t0);
            SquareN(t0, 3, t1);
            Multiply(t1, t0, t1);
            Square(t1, t1);
            Multiply(t1, x, t1);
            SquareN(t1, 7, t0);
            Multiply(t0, t1, t0);
            SquareN(t0, 14, t1);
            Multiply(t1, t0, t1);
            SquareN(t1, 28, t0);
            Multiply(t0, t1, t0);
            SquareN(t0, 56, t1);
            Multiply(t1, t0, t1);
            Square(t1, z);
        }
Esempio n. 3
0
 public static void Invert(ulong[] x, ulong[] z)
 {
     //IL_0008: Unknown result type (might be due to invalid IL or missing references)
     if (Nat128.IsZero64(x))
     {
         throw new InvalidOperationException();
     }
     ulong[] array  = Nat128.Create64();
     ulong[] array2 = Nat128.Create64();
     Square(x, array);
     Multiply(array, x, array);
     Square(array, array);
     Multiply(array, x, array);
     SquareN(array, 3, array2);
     Multiply(array2, array, array2);
     Square(array2, array2);
     Multiply(array2, x, array2);
     SquareN(array2, 7, array);
     Multiply(array, array2, array);
     SquareN(array, 14, array2);
     Multiply(array2, array, array2);
     SquareN(array2, 28, array);
     Multiply(array, array2, array);
     SquareN(array, 56, array2);
     Multiply(array2, array, array2);
     Square(array2, z);
 }
        public override ECFieldElement SquarePow(int pow)
        {
            if (pow < 1)
                return this;

            ulong[] z = Nat128.Create64();
            SecT113Field.SquareN(x, pow, z);
            return new SecT113FieldElement(z);
        }
 public override ECFieldElement SquarePow(int pow)
 {
     if (pow < 1)
     {
         return(this);
     }
     ulong[] z = Nat128.Create64();
     SecT113Field.SquareN(this.x, pow, z);
     return(new SecT113FieldElement(z));
 }
Esempio n. 6
0
 public override ECFieldElement SquarePlusProduct(ECFieldElement x, ECFieldElement y)
 {
     ulong[] array  = this.x;
     ulong[] array2 = ((SecT113FieldElement)x).x;
     ulong[] y2     = ((SecT113FieldElement)y).x;
     ulong[] array3 = Nat128.CreateExt64();
     SecT113Field.SquareAddToExt(array, array3);
     SecT113Field.MultiplyAddToExt(array2, y2, array3);
     ulong[] z = Nat128.Create64();
     SecT113Field.Reduce(array3, z);
     return(new SecT113FieldElement(z));
 }
        public override ECFieldElement MultiplyPlusProduct(ECFieldElement b, ECFieldElement x, ECFieldElement y)
        {
            ulong[] ax = this.x, bx = ((SecT113FieldElement)b).x;
            ulong[] xx = ((SecT113FieldElement)x).x, yx = ((SecT113FieldElement)y).x;

            ulong[] tt = Nat128.CreateExt64();
            SecT113Field.MultiplyAddToExt(ax, bx, tt);
            SecT113Field.MultiplyAddToExt(xx, yx, tt);

            ulong[] z = Nat128.Create64();
            SecT113Field.Reduce(tt, z);
            return(new SecT113FieldElement(z));
        }
Esempio n. 8
0
            public override ECPoint LookupVar(int index)
            {
                ulong[] x   = Nat128.Create64(), y = Nat128.Create64();
                int     pos = index * SECT113R2_FE_LONGS * 2;

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

                return(CreatePoint(x, y));
            }
Esempio n. 9
0
 public override ECFieldElement MultiplyPlusProduct(ECFieldElement b, ECFieldElement x, ECFieldElement y)
 {
     ulong[] numArray  = this.x;
     ulong[] numArray2 = ((SecT113FieldElement)b).x;
     ulong[] numArray3 = ((SecT113FieldElement)x).x;
     ulong[] numArray4 = ((SecT113FieldElement)y).x;
     ulong[] zz        = Nat128.CreateExt64();
     SecT113Field.MultiplyAddToExt(numArray, numArray2, zz);
     SecT113Field.MultiplyAddToExt(numArray3, numArray4, zz);
     ulong[] z = Nat128.Create64();
     SecT113Field.Reduce(zz, z);
     return(new SecT113FieldElement(z));
 }
Esempio n. 10
0
            public override ECPoint Lookup(int index)
            {
                ulong[] x   = Nat128.Create64(), y = Nat128.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 < SECT113R2_FE_LONGS; ++j)
                    {
                        x[j] ^= m_table[pos + j] & MASK;
                        y[j] ^= m_table[pos + SECT113R2_FE_LONGS + j] & MASK;
                    }

                    pos += (SECT113R2_FE_LONGS * 2);
                }

                return(CreatePoint(x, y));
            }
            public virtual ECPoint Lookup(int index)
            {
                ulong[] x   = Nat128.Create64(), y = Nat128.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 < SECT113R1_FE_LONGS; ++j)
                    {
                        x[j] ^= m_table[pos + j] & MASK;
                        y[j] ^= m_table[pos + SECT113R1_FE_LONGS + j] & MASK;
                    }

                    pos += (SECT113R1_FE_LONGS * 2);
                }

                return(m_outer.CreateRawPoint(new SecT113FieldElement(x), new SecT113FieldElement(y), false));
            }
Esempio n. 12
0
 public override ECFieldElement Multiply(ECFieldElement b)
 {
     ulong[] z = Nat128.Create64();
     SecT113Field.Multiply(x, ((SecT113FieldElement)b).x, z);
     return(new SecT113FieldElement(z));
 }
Esempio n. 13
0
 public override ECFieldElement AddOne()
 {
     ulong[] z = Nat128.Create64();
     SecT113Field.AddOne(x, z);
     return(new SecT113FieldElement(z));
 }
Esempio n. 14
0
 public SecT113FieldElement()
 {
     this.x = Nat128.Create64();
 }
 public override ECFieldElement Square()
 {
     ulong[] z = Nat128.Create64();
     SecT113Field.Square(this.x, z);
     return(new SecT113FieldElement(z));
 }
 public override ECFieldElement Add(ECFieldElement b)
 {
     ulong[] z = Nat128.Create64();
     SecT113Field.Add(this.x, ((SecT113FieldElement)b).x, z);
     return(new SecT113FieldElement(z));
 }