Esempio n. 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);
     }
 }
Esempio n. 2
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);
 }
Esempio n. 3
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)))
            {
                Nat.Add33To(7, PInv33, z);
            }
        }
Esempio n. 4
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)))
            {
                Nat.Add33To(7, PInv33, z);
            }
        }
        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);
            }
        }
Esempio n. 6
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);
 }
Esempio n. 7
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] == uint.MaxValue && Nat224.Gte(z, P)))
        {
            Nat.Add33To(7, 6803u, z);
        }
    }
Esempio n. 8
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);
            }
        }
        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);
            }
        }
Esempio n. 10
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);
     }
 }