Пример #1
0
 public static void Reduce32(uint x, uint[] z)
 {
     if ((x != 0 && Nat224.Mul33WordAdd(PInv33, x, z, 0) != 0) ||
         (z[6] == P6 && Nat224.Gte(z, P)))
     {
         Nat.Add33To(7, PInv33, z);
     }
 }
Пример #2
0
        public static void Add(uint[] x, uint[] y, uint[] z)
        {
            uint c = Nat224.Add(x, y, z);

            if (c != 0 || (z[6] == P6 && Nat224.Gte(z, P)))
            {
                Nat224.AddDWord(PInv, z, 0);
            }
        }
Пример #3
0
 public static uint[] FromBigInteger(BigInteger x)
 {
     uint[] z = Nat224.FromBigInteger(x);
     if (z[6] == P6 && Nat224.Gte(z, P))
     {
         Nat224.SubFrom(P, z);
     }
     return(z);
 }
Пример #4
0
 public static uint[] FromBigInteger(BigInteger x)
 {
     uint[] z = Nat224.FromBigInteger(x);
     if (z[6] == P6 && Nat224.Gte(z, P))
     {
         Nat224.AddDWord(PInv, z, 0);
     }
     return(z);
 }
Пример #5
0
        public static void Reduce32(uint x, uint[] z)
        {
            int c = Nat224.SubWord(x, z, 0) + (int)Nat224.AddWord(x, z, 3);

            if (c != 0 || (z[6] == P6 && Nat224.Gte(z, P)))
            {
                Nat224.Sub(z, P, z);
            }
        }
Пример #6
0
        public static void Add(uint[] x, uint[] y, uint[] z)
        {
            uint c = Nat224.Add(x, y, z);

            if (c != 0 || (z[6] == P6 && Nat224.Gte(z, P)))
            {
                AddPInvTo(z);
            }
        }
Пример #7
0
        public static void Twice(uint[] x, uint[] z)
        {
            uint c = Nat224.ShiftUpBit(x, 0, z);

            if (c != 0 || (z[6] == P6 && Nat224.Gte(z, P)))
            {
                Nat224.AddDWord(PInv, z, 0);
            }
        }
Пример #8
0
        public static void Twice(uint[] x, uint[] z)
        {
            uint c = Nat224.ShiftUpBit(x, 0, z);

            if (c != 0 || (z[6] == P6 && Nat224.Gte(z, P)))
            {
                Nat224.Sub(z, P, z);
            }
        }
Пример #9
0
        public static void Reduce(uint[] xx, uint[] z)
        {
            ulong y = Nat224.Mul33Add(6803u, xx, 7, xx, 0, z, 0);

            if (Nat224.Mul33DWordAdd(6803u, y, z, 0) != 0 || (z[6] == 4294967295u && Nat224.Gte(z, P)))
            {
                Nat.Add33To(7, 6803u, z);
            }
        }
Пример #10
0
 public static uint[] FromBigInteger(BigInteger x)
 {
     uint[] numArray = Nat224.FromBigInteger(x);
     if ((numArray[6] == uint.MaxValue) && Nat224.Gte(numArray, P))
     {
         Nat224.SubFrom(P, numArray);
     }
     return(numArray);
 }
Пример #11
0
 public static uint[] FromBigInteger(BigInteger x)
 {
     uint[] array = Nat224.FromBigInteger(x);
     if (array[6] == uint.MaxValue && Nat224.Gte(array, P))
     {
         Nat224.SubFrom(P, array);
     }
     return(array);
 }
        public static void Add(uint[] x, uint[] y, uint[] z)
        {
            uint c = Nat224.Add(x, y, z);

            if (c != 0 || (z[6] == P6 && Nat224.Gte(z, P)))
            {
                Nat.Add33To(7, PInv33, z);
            }
        }
Пример #13
0
 public static uint[] FromBigInteger(BigInteger x)
 {
     uint[] array = Nat224.FromBigInteger(x);
     if (array[6] == 4294967295u && Nat224.Gte(array, SecP224R1Field.P))
     {
         Nat224.SubFrom(SecP224R1Field.P, array);
     }
     return(array);
 }
Пример #14
0
        public static void AddOne(uint[] x, uint[] z)
        {
            uint c = Nat.Inc(7, x, z);

            if (c != 0 || (z[6] == P6 && Nat224.Gte(z, P)))
            {
                AddPInvTo(z);
            }
        }
Пример #15
0
        public static void Twice(uint[] x, uint[] z)
        {
            uint c = Nat.ShiftUpBit(7, x, 0, z);

            if (c != 0 || (z[6] == P6 && Nat224.Gte(z, P)))
            {
                AddPInvTo(z);
            }
        }
Пример #16
0
        public static void AddOne(uint[] x, uint[] z)
        {
            Nat224.Copy(x, z);
            uint c = Nat224.Inc(z, 0);

            if (c != 0 || (z[6] == P6 && Nat224.Gte(z, P)))
            {
                Nat224.AddDWord(PInv, z, 0);
            }
        }
Пример #17
0
        public static void Reduce(uint[] xx, uint[] z)
        {
            long num  = (long)((ulong)xx[10]);
            long num2 = (long)((ulong)xx[11]);
            long num3 = (long)((ulong)xx[12]);
            long num4 = (long)((ulong)xx[13]);
            long num5 = (long)((ulong)xx[7] + (ulong)num2 - 1uL);
            long num6 = (long)((ulong)xx[8] + (ulong)num3);
            long num7 = (long)((ulong)xx[9] + (ulong)num4);
            long num8 = 0L;

            num8 += (long)((ulong)xx[0] - (ulong)num5);
            long num9 = (long)((ulong)((uint)num8));

            num8 >>= 32;
            num8  += (long)((ulong)xx[1] - (ulong)num6);
            z[1]   = (uint)num8;
            num8 >>= 32;
            num8  += (long)((ulong)xx[2] - (ulong)num7);
            z[2]   = (uint)num8;
            num8 >>= 32;
            num8  += (long)((ulong)xx[3] + (ulong)num5 - (ulong)num);
            long num10 = (long)((ulong)((uint)num8));

            num8 >>= 32;
            num8  += (long)((ulong)xx[4] + (ulong)num6 - (ulong)num2);
            z[4]   = (uint)num8;
            num8 >>= 32;
            num8  += (long)((ulong)xx[5] + (ulong)num7 - (ulong)num3);
            z[5]   = (uint)num8;
            num8 >>= 32;
            num8  += (long)((ulong)xx[6] + (ulong)num - (ulong)num4);
            z[6]   = (uint)num8;
            num8 >>= 32;
            num8  += 1L;
            num10 += num8;
            num9  -= num8;
            z[0]   = (uint)num9;
            num8   = num9 >> 32;
            if (num8 != 0L)
            {
                num8  += (long)((ulong)z[1]);
                z[1]   = (uint)num8;
                num8 >>= 32;
                num8  += (long)((ulong)z[2]);
                z[2]   = (uint)num8;
                num10 += num8 >> 32;
            }
            z[3] = (uint)num10;
            num8 = num10 >> 32;
            if ((num8 != 0L && Nat.IncAt(7, z, 4) != 0u) || (z[6] == 4294967295u && Nat224.Gte(z, SecP224R1Field.P)))
            {
                SecP224R1Field.AddPInvTo(z);
            }
        }
Пример #18
0
        public static void Reduce(uint[] xx, uint[] z)
        {
            long num  = xx[10];
            long num2 = xx[11];
            long num3 = xx[12];
            long num4 = xx[13];
            long num5 = xx[7] + num2 - 1;
            long num6 = xx[8] + num3;
            long num7 = xx[9] + num4;
            long num8 = 0L;

            num8 += xx[0] - num5;
            long num9 = (uint)num8;

            num8 >>= 32;
            num8  += xx[1] - num6;
            z[1]   = (uint)num8;
            num8 >>= 32;
            num8  += xx[2] - num7;
            z[2]   = (uint)num8;
            num8 >>= 32;
            num8  += xx[3] + num5 - num;
            long num10 = (uint)num8;

            num8 >>= 32;
            num8  += xx[4] + num6 - num2;
            z[4]   = (uint)num8;
            num8 >>= 32;
            num8  += xx[5] + num7 - num3;
            z[5]   = (uint)num8;
            num8 >>= 32;
            num8  += xx[6] + num - num4;
            z[6]   = (uint)num8;
            num8 >>= 32;
            num8++;
            num10 += num8;
            num9  -= num8;
            z[0]   = (uint)num9;
            num8   = num9 >> 32;
            if (num8 != 0)
            {
                num8  += z[1];
                z[1]   = (uint)num8;
                num8 >>= 32;
                num8  += z[2];
                z[2]   = (uint)num8;
                num10 += num8 >> 32;
            }
            z[3] = (uint)num10;
            num8 = num10 >> 32;
            if ((num8 != 0 && Nat.IncAt(7, z, 4) != 0) || (z[6] == 4294967295u && Nat224.Gte(z, P)))
            {
                AddPInvTo(z);
            }
        }
Пример #19
0
        public static void Reduce32(uint x, uint[] z)
        {
            uint c = Nat224.Mul33WordAdd(PInv33, x, z, 0);

            Debug.Assert(c == 0 || c == 1);

            if (c != 0 || (z[6] == P6 && Nat224.Gte(z, P)))
            {
                Nat224.AddDWord(PInv, z, 0);
            }
        }
        public static void Reduce(uint[] xx, uint[] z)
        {
            ulong cc = Nat224.Mul33Add(PInv33, xx, 7, xx, 0, z, 0);
            uint  c  = Nat224.Mul33DWordAdd(PInv33, cc, z, 0);

            Debug.Assert(c == 0 || c == 1);

            if (c != 0 || (z[6] == P6 && Nat224.Gte(z, P)))
            {
                Nat.Add33To(7, PInv33, z);
            }
        }
Пример #21
0
        public static void Reduce(uint[] xx, uint[] z)
        {
            long xx10 = xx[10], xx11 = xx[11], xx12 = xx[12], xx13 = xx[13];

            const long n = 1;

            long t0 = (long)xx[7] + xx11 - n;
            long t1 = (long)xx[8] + xx12;
            long t2 = (long)xx[9] + xx13;

            long cc = 0;

            cc += (long)xx[0] - t0;
            long z0 = (uint)cc;

            cc >>= 32;
            cc  += (long)xx[1] - t1;
            z[1] = (uint)cc;
            cc >>= 32;
            cc  += (long)xx[2] - t2;
            z[2] = (uint)cc;
            cc >>= 32;
            cc  += (long)xx[3] + t0 - xx10;
            long z3 = (uint)cc;

            cc >>= 32;
            cc  += (long)xx[4] + t1 - xx11;
            z[4] = (uint)cc;
            cc >>= 32;
            cc  += (long)xx[5] + t2 - xx12;
            z[5] = (uint)cc;
            cc >>= 32;
            cc  += (long)xx[6] + xx10 - xx13;
            z[6] = (uint)cc;
            cc >>= 32;
            cc  += n;

            Debug.Assert(cc >= 0);

            z3 += cc;

            z0  -= cc;
            z[0] = (uint)z0;
            cc   = z0 >> 32;
            if (cc != 0)
            {
                cc  += (long)z[1];
                z[1] = (uint)cc;
                cc >>= 32;
                cc  += (long)z[2];
                z[2] = (uint)cc;
                z3  += cc >> 32;
            }
            z[3] = (uint)z3;
            cc   = z3 >> 32;

            Debug.Assert(cc == 0 || cc == 1);

            if ((cc != 0 && Nat.IncAt(7, z, 4) != 0) ||
                (z[6] == P6 && Nat224.Gte(z, P)))
            {
                AddPInvTo(z);
            }
        }
Пример #22
0
        public static void Reduce(uint[] xx, uint[] z)
        {
            ulong y = Nat224.Mul33Add(0x1a93, xx, 7, xx, 0, z, 0);

            if ((Nat224.Mul33DWordAdd(0x1a93, y, z, 0) != 0) || ((z[6] == uint.MaxValue) && Nat224.Gte(z, P)))
            {
                Nat.Add33To(7, 0x1a93, z);
            }
        }
Пример #23
0
 public static void Reduce32(uint x, uint[] z)
 {
     if (((x != 0) && (Nat224.Mul33WordAdd(0x1a93, x, z, 0) != 0)) || ((z[6] == uint.MaxValue) && Nat224.Gte(z, P)))
     {
         Nat.Add33To(7, 0x1a93, z);
     }
 }
Пример #24
0
 public static void Reduce32(uint x, uint[] z)
 {
     if ((x != 0u && Nat224.Mul33WordAdd(6803u, x, z, 0) != 0u) || (z[6] == 4294967295u && Nat224.Gte(z, SecP224K1Field.P)))
     {
         Nat.Add33To(7, 6803u, z);
     }
 }
Пример #25
0
 public static void Reduce32(uint x, uint[] z)
 {
     if ((x != 0 && Nat224.Mul33WordAdd(6803u, x, z, 0) != 0) || (z[6] == uint.MaxValue && Nat224.Gte(z, P)))
     {
         Nat.Add33To(7, 6803u, z);
     }
 }
Пример #26
0
        public static void Reduce32(uint x, uint[] z)
        {
            long num = 0L;

            if (x != 0)
            {
                long num2 = x;
                num  = ((long)((ulong)num)) + (z[0] - num2);
                z[0] = (uint)num;
                num  = num >> 0x20;
                if (num != 0L)
                {
                    num += z[1];
                    z[1] = (uint)num;
                    num  = num >> 0x20;
                    num += z[2];
                    z[2] = (uint)num;
                    num  = num >> 0x20;
                }
                num  = ((long)((ulong)num)) + (z[3] + num2);
                z[3] = (uint)num;
                num  = num >> 0x20;
            }
            if (((num != 0L) && (Nat.IncAt(7, z, 4) != 0)) || ((z[6] == uint.MaxValue) && Nat224.Gte(z, P)))
            {
                AddPInvTo(z);
            }
        }
Пример #27
0
        public static void Reduce(uint[] xx, uint[] z)
        {
            long num  = xx[10];
            long num2 = xx[11];
            long num3 = xx[12];
            long num4 = xx[13];
            long num5 = (xx[7] + num2) - 1L;
            long num6 = xx[8] + num3;
            long num7 = xx[9] + num4;
            long num8 = 0L;

            num8 = ((long)((ulong)num8)) + (xx[0] - num5);
            long num9 = (uint)num8;

            num8 = num8 >> 0x20;
            num8 = ((long)((ulong)num8)) + (xx[1] - num6);
            z[1] = (uint)num8;
            num8 = num8 >> 0x20;
            num8 = ((long)((ulong)num8)) + (xx[2] - num7);
            z[2] = (uint)num8;
            num8 = num8 >> 0x20;
            num8 = ((long)((ulong)num8)) + ((xx[3] + num5) - ((ulong)num));
            long num10 = (uint)num8;

            num8   = num8 >> 0x20;
            num8   = ((long)((ulong)num8)) + ((xx[4] + num6) - ((ulong)num2));
            z[4]   = (uint)num8;
            num8   = num8 >> 0x20;
            num8   = ((long)((ulong)num8)) + ((xx[5] + num7) - ((ulong)num3));
            z[5]   = (uint)num8;
            num8   = num8 >> 0x20;
            num8   = ((long)((ulong)num8)) + ((xx[6] + num) - ((ulong)num4));
            z[6]   = (uint)num8;
            num8   = num8 >> 0x20;
            num8  += 1L;
            num10 += num8;
            num9  -= num8;
            z[0]   = (uint)num9;
            num8   = num9 >> 0x20;
            if (num8 != 0L)
            {
                num8  += z[1];
                z[1]   = (uint)num8;
                num8   = num8 >> 0x20;
                num8  += z[2];
                z[2]   = (uint)num8;
                num10 += num8 >> 0x20;
            }
            z[3] = (uint)num10;
            num8 = num10 >> 0x20;
            if (((num8 != 0L) && (Nat.IncAt(7, z, 4) != 0)) || ((z[6] == uint.MaxValue) && Nat224.Gte(z, P)))
            {
                AddPInvTo(z);
            }
        }