Ejemplo n.º 1
0
        public static void Reduce32(uint x, uint[] z)
        {
            long xx12 = x;

            long cc = 0;

            cc  += (long)z[0] + xx12;
            z[0] = (uint)cc;
            cc >>= 32;
            cc  += (long)z[1] - xx12;
            z[1] = (uint)cc;
            cc >>= 32;
            cc  += (long)z[2];
            z[2] = (uint)cc;
            cc >>= 32;
            cc  += (long)z[3] + xx12;
            z[3] = (uint)cc;
            cc >>= 32;
            cc  += (long)z[4] + xx12;
            z[4] = (uint)cc;
            cc >>= 32;

            Debug.Assert(cc >= 0);

            if (cc > 0)
            {
                uint c = Nat.AddWord(12, (uint)cc, z, 5);
                if (c != 0 || (z[11] == P11 && Nat.Gte(12, z, P)))
                {
                    Nat.Sub(12, z, P, z);
                }
            }
        }
Ejemplo n.º 2
0
        public static void Reduce23(uint[] z)
        {
            uint z16 = z[16];
            uint c   = Nat.AddWord(16, z16 >> 9, z, 0) + (z16 & P16);

            if (c > P16 || (c == P16 && Nat.Eq(16, z, P)))
            {
                c += Nat.Inc(16, z, 0);
                c &= P16;
            }
            z[16] = c;
        }