Beispiel #1
0
 public static void Subtract(uint[] x, uint[] y, uint[] z)
 {
     if (Nat192.Sub(x, y, z) != 0)
     {
         SubPInvFrom(z);
     }
 }
 public static void Subtract(uint[] x, uint[] y, uint[] z)
 {
     if (Nat192.Sub(x, y, z) != 0)
     {
         Nat.Sub33From(6, 0x11c9, z);
     }
 }
Beispiel #3
0
        public static void Subtract(uint[] x, uint[] y, uint[] z)
        {
            int c = Nat192.Sub(x, y, z);

            if (c != 0)
            {
                Nat.Sub33From(6, PInv33, z);
            }
        }
Beispiel #4
0
 public static uint[] FromBigInteger(BigInteger x)
 {
     uint[] z = Nat192.FromBigInteger(x);
     if (z[5] == P5 && Nat192.Gte(z, P))
     {
         Nat192.Sub(z, P, z);
     }
     return(z);
 }
Beispiel #5
0
        public static void Twice(uint[] x, uint[] z)
        {
            uint c = Nat192.ShiftUpBit(x, 0, z);

            if (c != 0 || (z[5] == P5 && Nat192.Gte(z, P)))
            {
                Nat192.Sub(z, P, z);
            }
        }
Beispiel #6
0
        public static void Subtract(uint[] x, uint[] y, uint[] z)
        {
            int c = Nat192.Sub(x, y, z);

            if (c != 0)
            {
                Nat192.Add(z, P, z);
            }
        }
Beispiel #7
0
        public static void Add(uint[] x, uint[] y, uint[] z)
        {
            uint c = Nat192.Add(x, y, z);

            if (c != 0 || (z[5] == P5 && Nat192.Gte(z, P)))
            {
                Nat192.Sub(z, P, z);
            }
        }
Beispiel #8
0
        public static void Reduce32(uint x, uint[] z)
        {
            uint c = Nat192.AddWord(x, z, 0) + Nat192.AddWord(x, z, 2);

            if (c != 0 || (z[5] == P5 && Nat192.Gte(z, P)))
            {
                Nat192.Sub(z, P, z);
            }
        }
        public static void Subtract(uint[] x, uint[] y, uint[] z)
        {
            int c = Nat192.Sub(x, y, z);

            if (c != 0)
            {
                Nat192.SubDWord(PInv, z);
            }
        }
        public static void Subtract(uint[] x, uint[] y, uint[] z)
        {
            int num = Nat192.Sub(x, y, z);

            if (num != 0)
            {
                Nat.Sub33From(6, 4553u, z);
            }
        }
 public static void Negate(uint[] x, uint[] z)
 {
     if (Nat192.IsZero(x))
     {
         Nat192.Zero(z);
         return;
     }
     Nat192.Sub(SecP192K1Field.P, x, z);
 }
Beispiel #12
0
        public static void Subtract(uint[] x, uint[] y, uint[] z)
        {
            int num = Nat192.Sub(x, y, z);

            if (num != 0)
            {
                SecP192R1Field.SubPInvFrom(z);
            }
        }
Beispiel #13
0
        public static void AddOne(uint[] x, uint[] z)
        {
            Nat192.Copy(x, z);
            uint c = Nat192.Inc(z, 0);

            if (c != 0 || (z[5] == P5 && Nat192.Gte(z, P)))
            {
                Nat192.Sub(z, P, z);
            }
        }
Beispiel #14
0
 public static void Negate(uint[] x, uint[] z)
 {
     if (Nat192.IsZero(x))
     {
         Nat192.Zero(z);
     }
     else
     {
         Nat192.Sub(P, x, z);
     }
 }
Beispiel #15
0
        public static void Reduce(uint[] xx, uint[] z)
        {
            long xx06 = xx[6], xx07 = xx[7], xx08 = xx[8];
            long xx09 = xx[9], xx10 = xx[10], xx11 = xx[11];

            long t0 = xx06 + xx10;
            long t1 = xx07 + xx11;

            long cc = 0;

            cc  += (long)xx[0] + t0;
            z[0] = (uint)cc;
            cc >>= 32;
            cc  += (long)xx[1] + t1;
            z[1] = (uint)cc;
            cc >>= 32;

            t0 += xx08;
            t1 += xx09;

            cc  += (long)xx[2] + t0;
            z[2] = (uint)cc;
            cc >>= 32;
            cc  += (long)xx[3] + t1;
            z[3] = (uint)cc;
            cc >>= 32;

            t0 -= xx06;
            t1 -= xx07;

            cc  += (long)xx[4] + t0;
            z[4] = (uint)cc;
            cc >>= 32;
            cc  += (long)xx[5] + t1;
            z[5] = (uint)cc;
            cc >>= 32;

            int c = (int)cc;

            Debug.Assert(c >= 0);
            while (c > 0)
            {
                c += Nat192.Sub(z, P, z);
            }

            if (z[5] == P5 && Nat192.Gte(z, P))
            {
                Nat192.Sub(z, P, z);
            }
        }