Beispiel #1
0
 public static void Add(uint[] x, uint[] y, uint[] z)
 {
     if (Nat128.Add(x, y, z) != 0 || (z[3] == 4294967293u && Nat128.Gte(z, P)))
     {
         AddPInvTo(z);
     }
 }
Beispiel #2
0
        public static void Reduce32(uint x, uint[] z)
        {
            while (x != 0)
            {
                ulong c, x4 = x;

                c    = (ulong)z[0] + x4;
                z[0] = (uint)c; c >>= 32;
                if (c != 0)
                {
                    c   += (ulong)z[1];
                    z[1] = (uint)c; c >>= 32;
                    c   += (ulong)z[2];
                    z[2] = (uint)c; c >>= 32;
                }
                c   += (ulong)z[3] + (x4 << 1);
                z[3] = (uint)c; c >>= 32;

                Debug.Assert(c >= 0 && c <= 2);

                x = (uint)c;
            }

            if (z[3] >= P3 && Nat128.Gte(z, P))
            {
                AddPInvTo(z);
            }
        }
Beispiel #3
0
 public static void AddOne(uint[] x, uint[] z)
 {
     if (Nat.Inc(4, x, z) != 0 || (z[3] == 4294967293u && Nat128.Gte(z, P)))
     {
         AddPInvTo(z);
     }
 }
Beispiel #4
0
 public static void AddOne(uint[] x, uint[] z)
 {
     if ((Nat.Inc(4, x, z) != 0) || ((z[3] == 0xfffffffd) && Nat128.Gte(z, P)))
     {
         AddPInvTo(z);
     }
 }
Beispiel #5
0
 public static void Twice(uint[] x, uint[] z)
 {
     if (Nat.ShiftUpBit(4, x, 0u, z) != 0 || (z[3] == 4294967293u && Nat128.Gte(z, P)))
     {
         AddPInvTo(z);
     }
 }
Beispiel #6
0
 public static void Twice(uint[] x, uint[] z)
 {
     if ((Nat.ShiftUpBit(4, x, 0, z) != 0) || ((z[3] == 0xfffffffd) && Nat128.Gte(z, P)))
     {
         AddPInvTo(z);
     }
 }
Beispiel #7
0
 public static void Add(uint[] x, uint[] y, uint[] z)
 {
     if ((Nat128.Add(x, y, z) != 0) || ((z[3] == 0xfffffffd) && Nat128.Gte(z, P)))
     {
         AddPInvTo(z);
     }
 }
Beispiel #8
0
 public static void AddOne(uint[] x, uint[] z)
 {
     if (Nat.Inc(4, x, z) != 0u || (z[3] == 4294967293u && Nat128.Gte(z, SecP128R1Field.P)))
     {
         SecP128R1Field.AddPInvTo(z);
     }
 }
Beispiel #9
0
 public static void Twice(uint[] x, uint[] z)
 {
     if (Nat.ShiftUpBit(4, x, 0u, z) != 0u || (z[3] == 4294967293u && Nat128.Gte(z, SecP128R1Field.P)))
     {
         SecP128R1Field.AddPInvTo(z);
     }
 }
Beispiel #10
0
 public static uint[] FromBigInteger(BigInteger x)
 {
     uint[] z = Nat128.FromBigInteger(x);
     if (z[3] >= P3 && Nat128.Gte(z, P))
     {
         Nat128.SubFrom(P, z);
     }
     return(z);
 }
Beispiel #11
0
        public static void AddOne(uint[] x, uint[] z)
        {
            uint c = Nat.Inc(4, x, z);

            if (c != 0 || (z[3] >= P3 && Nat128.Gte(z, P)))
            {
                AddPInvTo(z);
            }
        }
Beispiel #12
0
        public static void Add(uint[] x, uint[] y, uint[] z)
        {
            uint c = Nat128.Add(x, y, z);

            if (c != 0 || (z[3] >= P3 && Nat128.Gte(z, P)))
            {
                AddPInvTo(z);
            }
        }
Beispiel #13
0
        public static void Twice(uint[] x, uint[] z)
        {
            uint c = Nat.ShiftUpBit(4, x, 0, z);

            if (c != 0 || (z[3] >= P3 && Nat128.Gte(z, P)))
            {
                AddPInvTo(z);
            }
        }
Beispiel #14
0
 public static uint[] FromBigInteger(BigInteger x)
 {
     uint[] array = Nat128.FromBigInteger(x);
     if (array[3] == 4294967293u && Nat128.Gte(array, P))
     {
         Nat128.SubFrom(P, array);
     }
     return(array);
 }
Beispiel #15
0
 public static uint[] FromBigInteger(BigInteger x)
 {
     uint[] numArray = Nat128.FromBigInteger(x);
     if ((numArray[3] == 0xfffffffd) && Nat128.Gte(numArray, P))
     {
         Nat128.SubFrom(P, numArray);
     }
     return(numArray);
 }