public override ECFieldElement SquarePlusProduct(ECFieldElement x, ECFieldElement y)
 {
     ulong[] numArray  = this.x;
     ulong[] numArray2 = ((SecT283FieldElement)x).x;
     ulong[] numArray3 = ((SecT283FieldElement)y).x;
     ulong[] zz        = Nat.Create64(9);
     SecT283Field.SquareAddToExt(numArray, zz);
     SecT283Field.MultiplyAddToExt(numArray2, numArray3, zz);
     ulong[] z = Nat320.Create64();
     SecT283Field.Reduce(zz, z);
     return(new SecT283FieldElement(z));
 }
        public override ECFieldElement MultiplyPlusProduct(ECFieldElement b, ECFieldElement x, ECFieldElement y)
        {
            ulong[] ax = this.x, bx = ((SecT283FieldElement)b).x;
            ulong[] xx = ((SecT283FieldElement)x).x, yx = ((SecT283FieldElement)y).x;

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

            ulong[] z = Nat320.Create64();
            SecT283Field.Reduce(tt, z);
            return(new SecT283FieldElement(z));
        }
Esempio n. 3
0
 public override ECFieldElement MultiplyPlusProduct(ECFieldElement b, ECFieldElement x, ECFieldElement y)
 {
     ulong[] array  = this.x;
     ulong[] y2     = ((SecT283FieldElement)b).x;
     ulong[] array2 = ((SecT283FieldElement)x).x;
     ulong[] y3     = ((SecT283FieldElement)y).x;
     ulong[] array3 = Nat.Create64(9);
     SecT283Field.MultiplyAddToExt(array, y2, array3);
     SecT283Field.MultiplyAddToExt(array2, y3, array3);
     ulong[] z = Nat320.Create64();
     SecT283Field.Reduce(array3, z);
     return(new SecT283FieldElement(z));
 }
Esempio n. 4
0
            public override ECPoint LookupVar(int index)
            {
                ulong[] x   = Nat320.Create64(), y = Nat320.Create64();
                int     pos = index * SECT283R1_FE_LONGS * 2;

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

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

                    pos += (SECT283R1_FE_LONGS * 2);
                }

                return(m_outer.CreateRawPoint(new SecT283FieldElement(x), new SecT283FieldElement(y), false));
            }
Esempio n. 6
0
            public override ECPoint Lookup(int index)
            {
                ulong[] x   = Nat320.Create64(), y = Nat320.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 < SECT283R1_FE_LONGS; ++j)
                    {
                        x[j] ^= m_table[pos + j] & MASK;
                        y[j] ^= m_table[pos + SECT283R1_FE_LONGS + j] & MASK;
                    }

                    pos += (SECT283R1_FE_LONGS * 2);
                }

                return(CreatePoint(x, y));
            }
Esempio n. 7
0
        public static void Sqrt(ulong[] x, ulong[] z)
        {
            ulong[] array = Nat320.Create64();
            ulong   num   = Interleave.Unshuffle(x[0]);
            ulong   num2  = Interleave.Unshuffle(x[1]);
            ulong   num3  = (num & 0xFFFFFFFFu) | (num2 << 32);

            array[0] = (num >> 32) | (num2 & 0xFFFFFFFF00000000uL);
            num      = Interleave.Unshuffle(x[2]);
            num2     = Interleave.Unshuffle(x[3]);
            ulong num4 = (num & 0xFFFFFFFFu) | (num2 << 32);

            array[1] = (num >> 32) | (num2 & 0xFFFFFFFF00000000uL);
            num      = Interleave.Unshuffle(x[4]);
            ulong num5 = num & 0xFFFFFFFFu;

            array[2] = num >> 32;
            Multiply(array, ROOT_Z, z);
            ulong[] array2;
            (array2 = z)[0] = array2[0] ^ num3;
            (array2 = z)[1] = array2[1] ^ num4;
            (array2 = z)[2] = array2[2] ^ num5;
        }
Esempio n. 8
0
        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);
        }
 public override ECFieldElement Multiply(ECFieldElement b)
 {
     ulong[] z = Nat320.Create64();
     SecT283Field.Multiply(x, ((SecT283FieldElement)b).x, z);
     return(new SecT283FieldElement(z));
 }
Esempio n. 10
0
 public override ECFieldElement AddOne()
 {
     ulong[] z = Nat320.Create64();
     SecT283Field.AddOne(x, z);
     return(new SecT283FieldElement(z));
 }
Esempio n. 11
0
 public SecT283FieldElement()
 {
     this.x = Nat320.Create64();
 }
Esempio n. 12
0
 public override ECFieldElement Square()
 {
     ulong[] z = Nat320.Create64();
     SecT283Field.Square(this.x, z);
     return(new SecT283FieldElement(z));
 }
Esempio n. 13
0
 public override ECFieldElement Add(ECFieldElement b)
 {
     ulong[] z = Nat320.Create64();
     SecT283Field.Add(this.x, ((SecT283FieldElement)b).x, z);
     return(new SecT283FieldElement(z));
 }