Esempio n. 1
0
        public static void Reduce(uint[] xx, uint[] z)
        {
            uint num = xx[7];

            Nat.ShiftUpBit(8, xx, 8, num, z, 0);
            uint num2 = Nat256.MulByWordAddTo(19u, xx, z) << 1;
            uint num3 = z[7];

            num2 += (num3 >> 31) - (num >> 31);
            num3 &= 0x7FFFFFFFu;
            if ((z[7] = num3 + Nat.AddWordTo(7, num2 * 19, z)) >= 2147483647 && Nat256.Gte(z, P))
            {
                SubPFrom(z);
            }
        }
Esempio n. 2
0
        public static void Reduce(uint[] xx, uint[] z)
        {
            uint c = xx[7];

            Nat.ShiftUpBit(8, xx, 8, c, z, 0);
            uint num2 = Nat256.MulByWordAddTo(0x13, xx, z) << 1;
            uint num3 = z[7];

            num2 += (num3 >> 0x1f) - (c >> 0x1f);
            num3 &= 0x7fffffff;
            num3 += Nat.AddWordTo(7, num2 * 0x13, z);
            z[7]  = num3;
            if ((num3 >= 0x7fffffff) && Nat256.Gte(z, P))
            {
                SubPFrom(z);
            }
        }
Esempio n. 3
0
        public static void Reduce(uint[] xx, uint[] z)
        {
            uint num = xx[7];

            Nat.ShiftUpBit(8, xx, 8, num, z, 0);
            uint num2 = Nat256.MulByWordAddTo(19u, xx, z) << 1;
            uint num3 = z[7];

            num2 += (num3 >> 31) - (num >> 31);
            num3 &= 2147483647u;
            num3 += Nat.AddWordTo(7, num2 * 19u, z);
            z[7]  = num3;
            if (num3 >= 2147483647u && Nat256.Gte(z, Curve25519Field.P))
            {
                Curve25519Field.SubPFrom(z);
            }
        }
Esempio n. 4
0
        public static void Reduce(uint[] xx, uint[] z)
        {
            Debug.Assert(xx[15] >> 30 == 0);

            uint xx07 = xx[7];

            Nat.ShiftUpBit(8, xx, 8, xx07, z, 0);
            uint c   = Nat256.MulByWordAddTo(PInv, xx, z) << 1;
            uint z07 = z[7];

            z[7] = z07 & P7;
            c   += (z07 >> 31) - (xx07 >> 31);
            Nat.AddWordTo(8, c * PInv, z);
            if (Nat256.Gte(z, P))
            {
                AddPInvTo(z);
            }
        }
Esempio n. 5
0
        public static void Reduce(uint[] xx, uint[] z)
        {
            Debug.Assert(xx[15] >> 30 == 0);

            uint xx07 = xx[7];

            Nat.ShiftUpBit(8, xx, 8, xx07, z, 0);
            uint c  = Nat256.MulByWordAddTo(PInv, xx, z) << 1;
            uint z7 = z[7];

            c   += (z7 >> 31) - (xx07 >> 31);
            z7  &= P7;
            z7  += Nat.AddWordTo(7, c * PInv, z);
            z[7] = z7;
            if (z7 >= P7 && Nat256.Gte(z, P))
            {
                SubPFrom(z);
            }
        }