Esempio n. 1
0
 public SecT163FieldElement(BigInteger x)
 {
     if (x == null || x.SignValue < 0)
     {
         throw new ArgumentException("value invalid for SecT163FieldElement", "x");
     }
     this.x = SecT163Field.FromBigInteger(x);
 }
 public SecT163FieldElement(BigInteger x)
 {
     if (((x == null) || (x.SignValue < 0)) || (x.BitLength > 0xa3))
     {
         throw new ArgumentException("value invalid for SecT163FieldElement", "x");
     }
     this.x = SecT163Field.FromBigInteger(x);
 }
Esempio n. 3
0
 public SecT163FieldElement(BigInteger x)
 {
     //IL_0029: Unknown result type (might be due to invalid IL or missing references)
     if (x == null || x.SignValue < 0 || x.BitLength > 163)
     {
         throw new ArgumentException("value invalid for SecT163FieldElement", "x");
     }
     this.x = SecT163Field.FromBigInteger(x);
 }
Esempio n. 4
0
 public override ECFieldElement SquarePow(int pow)
 {
     if (pow < 1)
     {
         return(this);
     }
     ulong[] z = Nat192.Create64();
     SecT163Field.SquareN(x, pow, z);
     return(new SecT163FieldElement(z));
 }
Esempio n. 5
0
 public static void SquareN(ulong[] x, int n, ulong[] z)
 {
     ulong[] array = Nat192.CreateExt64();
     SecT163Field.ImplSquare(x, array);
     SecT163Field.Reduce(array, z);
     while (--n > 0)
     {
         SecT163Field.ImplSquare(z, array);
         SecT163Field.Reduce(array, z);
     }
 }
Esempio n. 6
0
 public override ECFieldElement SquarePlusProduct(ECFieldElement x, ECFieldElement y)
 {
     ulong[] array  = this.x;
     ulong[] array2 = ((SecT163FieldElement)x).x;
     ulong[] y2     = ((SecT163FieldElement)y).x;
     ulong[] array3 = Nat192.CreateExt64();
     SecT163Field.SquareAddToExt(array, array3);
     SecT163Field.MultiplyAddToExt(array2, y2, array3);
     ulong[] z = Nat192.Create64();
     SecT163Field.Reduce(array3, z);
     return(new SecT163FieldElement(z));
 }
Esempio n. 7
0
        public override ECFieldElement MultiplyPlusProduct(ECFieldElement b, ECFieldElement x, ECFieldElement y)
        {
            ulong[] ax = this.x, bx = ((SecT163FieldElement)b).x;
            ulong[] xx = ((SecT163FieldElement)x).x, yx = ((SecT163FieldElement)y).x;

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

            ulong[] z = Nat192.Create64();
            SecT163Field.Reduce(tt, z);
            return(new SecT163FieldElement(z));
        }
 public override ECFieldElement MultiplyPlusProduct(ECFieldElement b, ECFieldElement x, ECFieldElement y)
 {
     ulong[] numArray  = this.x;
     ulong[] numArray2 = ((SecT163FieldElement)b).x;
     ulong[] numArray3 = ((SecT163FieldElement)x).x;
     ulong[] numArray4 = ((SecT163FieldElement)y).x;
     ulong[] zz        = Nat192.CreateExt64();
     SecT163Field.MultiplyAddToExt(numArray, numArray2, zz);
     SecT163Field.MultiplyAddToExt(numArray3, numArray4, zz);
     ulong[] z = Nat192.Create64();
     SecT163Field.Reduce(zz, z);
     return(new SecT163FieldElement(z));
 }
Esempio n. 9
0
 public override ECFieldElement Multiply(ECFieldElement b)
 {
     ulong[] z = Nat192.Create64();
     SecT163Field.Multiply(x, ((SecT163FieldElement)b).x, z);
     return(new SecT163FieldElement(z));
 }
Esempio n. 10
0
 public override ECFieldElement AddOne()
 {
     ulong[] z = Nat192.Create64();
     SecT163Field.AddOne(x, z);
     return(new SecT163FieldElement(z));
 }
Esempio n. 11
0
 public static void SquareAddToExt(ulong[] x, ulong[] zz)
 {
     ulong[] array = Nat192.CreateExt64();
     SecT163Field.ImplSquare(x, array);
     SecT163Field.AddExt(zz, array, zz);
 }
Esempio n. 12
0
 public static void Square(ulong[] x, ulong[] z)
 {
     ulong[] array = Nat192.CreateExt64();
     SecT163Field.ImplSquare(x, array);
     SecT163Field.Reduce(array, z);
 }
Esempio n. 13
0
 public static void MultiplyAddToExt(ulong[] x, ulong[] y, ulong[] zz)
 {
     ulong[] array = Nat192.CreateExt64();
     SecT163Field.ImplMultiply(x, y, array);
     SecT163Field.AddExt(zz, array, zz);
 }
Esempio n. 14
0
 public static void Multiply(ulong[] x, ulong[] y, ulong[] z)
 {
     ulong[] array = Nat192.CreateExt64();
     SecT163Field.ImplMultiply(x, y, array);
     SecT163Field.Reduce(array, z);
 }
Esempio n. 15
0
 public static ulong[] FromBigInteger(BigInteger x)
 {
     ulong[] array = Nat192.FromBigInteger64(x);
     SecT163Field.Reduce29(array, 0);
     return(array);
 }
Esempio n. 16
0
        protected static void ImplMultiply(ulong[] x, ulong[] y, ulong[] zz)
        {
            ulong num  = x[0];
            ulong num2 = x[1];
            ulong num3 = x[2];

            num3 = (num2 >> 46 ^ num3 << 18);
            num2 = ((num >> 55 ^ num2 << 9) & 36028797018963967uL);
            num &= 36028797018963967uL;
            ulong num4 = y[0];
            ulong num5 = y[1];
            ulong num6 = y[2];

            num6  = (num5 >> 46 ^ num6 << 18);
            num5  = ((num4 >> 55 ^ num5 << 9) & 36028797018963967uL);
            num4 &= 36028797018963967uL;
            ulong[] array = new ulong[10];
            SecT163Field.ImplMulw(num, num4, array, 0);
            SecT163Field.ImplMulw(num3, num6, array, 2);
            ulong num7 = num ^ num2 ^ num3;
            ulong num8 = num4 ^ num5 ^ num6;

            SecT163Field.ImplMulw(num7, num8, array, 4);
            ulong num9  = num2 << 1 ^ num3 << 2;
            ulong num10 = num5 << 1 ^ num6 << 2;

            SecT163Field.ImplMulw(num ^ num9, num4 ^ num10, array, 6);
            SecT163Field.ImplMulw(num7 ^ num9, num8 ^ num10, array, 8);
            ulong num11 = array[6] ^ array[8];
            ulong num12 = array[7] ^ array[9];
            ulong num13 = num11 << 1 ^ array[6];
            ulong num14 = num11 ^ num12 << 1 ^ array[7];
            ulong num15 = num12;
            ulong num16 = array[0];
            ulong num17 = array[1] ^ array[0] ^ array[4];
            ulong num18 = array[1] ^ array[5];
            ulong num19 = num16 ^ num13 ^ array[2] << 4 ^ array[2] << 1;
            ulong num20 = num17 ^ num14 ^ array[3] << 4 ^ array[3] << 1;
            ulong num21 = num18 ^ num15;

            num20  ^= num19 >> 55;
            num19  &= 36028797018963967uL;
            num21  ^= num20 >> 55;
            num20  &= 36028797018963967uL;
            num19   = (num19 >> 1 ^ (num20 & 1uL) << 54);
            num20   = (num20 >> 1 ^ (num21 & 1uL) << 54);
            num21 >>= 1;
            num19  ^= num19 << 1;
            num19  ^= num19 << 2;
            num19  ^= num19 << 4;
            num19  ^= num19 << 8;
            num19  ^= num19 << 16;
            num19  ^= num19 << 32;
            num19  &= 36028797018963967uL;
            num20  ^= num19 >> 54;
            num20  ^= num20 << 1;
            num20  ^= num20 << 2;
            num20  ^= num20 << 4;
            num20  ^= num20 << 8;
            num20  ^= num20 << 16;
            num20  ^= num20 << 32;
            num20  &= 36028797018963967uL;
            num21  ^= num20 >> 54;
            num21  ^= num21 << 1;
            num21  ^= num21 << 2;
            num21  ^= num21 << 4;
            num21  ^= num21 << 8;
            num21  ^= num21 << 16;
            num21  ^= num21 << 32;
            zz[0]   = num16;
            zz[1]   = (num17 ^ num19 ^ array[2]);
            zz[2]   = (num18 ^ num20 ^ num19 ^ array[3]);
            zz[3]   = (num21 ^ num20);
            zz[4]   = (num21 ^ array[2]);
            zz[5]   = array[3];
            SecT163Field.ImplCompactExt(zz);
        }
 public override ECFieldElement Add(ECFieldElement b)
 {
     ulong[] z = Nat192.Create64();
     SecT163Field.Add(this.x, ((SecT163FieldElement)b).x, z);
     return(new SecT163FieldElement(z));
 }
Esempio n. 18
0
 public override int Trace()
 {
     return((int)SecT163Field.Trace(x));
 }
 public override ECFieldElement Invert()
 {
     ulong[] z = Nat192.Create64();
     SecT163Field.Invert(this.x, z);
     return(new SecT163FieldElement(z));
 }