public static PointEdwardsProjective Tripple(PointEdwardsProjective P)//9M + 3S + 1*a + 7add + 2*2
        {
            BigInteger YY  = P.y * P.y;
            BigInteger aXX = P.E.a * P.x * P.x;
            BigInteger Ap  = YY + aXX;
            BigInteger B   = 2 * (2 * P.z * P.z - Ap);
            BigInteger xB  = aXX * B;
            BigInteger yB  = YY * B;
            BigInteger AA  = Ap * (YY - aXX);
            BigInteger F   = AA - yB;
            BigInteger G   = AA + xB;
            BigInteger x   = (P.x * (yB + AA) * F) % P.E.n;
            BigInteger y   = (P.y * (xB - AA) * G) % P.E.n;
            BigInteger z   = (P.z * F * G) % P.E.n;

            return(new PointEdwardsProjective(x, y, z, P.E));
        }
        public static PointEdwardsProjective Double(PointEdwardsProjective P)//3M + 4S + 1*a + 6add + 1*2
        {
            BigInteger n = P.E.n;
            BigInteger A = (P.x + P.y);
            BigInteger B = A * A;
            BigInteger C = P.x * P.x;
            BigInteger D = P.y * P.y;
            BigInteger E = P.E.a * C;
            BigInteger F = E + D;
            BigInteger H = P.z * P.z;
            BigInteger J = F - 2 * H;
            BigInteger x = ((B - C - D) * J) % P.E.n;
            BigInteger y = (F * (E - D)) % P.E.n;
            BigInteger z = (F * J) % P.E.n;

            return(new PointEdwardsProjective(x, y, z, P.E));
        }
Exemple #3
0
        public static BigInteger GetFactorProjective(BigInteger n, int B1, int B2, TorsionType type)
        {
            BigInteger x, y;
            var        E = GenerateCurve(n, out x, out y, type);
            var        P = new PointEdwardsProjective(x, y, E);

            //STEP 1
            var P1     = P as IPoint;
            var result = StageOneEdwardsProjective(ref P1, n, B1);

            if (result > 1 || result == 0)
            {
                return(result);
            }

            //STEP 2
            result = StageTwoEdwardsProjective(ref P1, n, B1, B2);

            return(result);
        }//projective
        public static PointEdwardsProjective operator *(BigInteger k, PointEdwardsProjective P)
        {
            bool isFirst = true;
            var  R       = new PointEdwardsProjective(0, 1, 1, P.E);

            while (k > 0)
            {
                if (k % 2 == 1 && isFirst)
                {
                    R       = new PointEdwardsProjective(P.x, P.y, P.z, P.E);
                    isFirst = false;
                }
                else if (k % 2 == 1)
                {
                    R += P;
                }
                k /= 2;
                P  = Double(P);
            }
            return(R);
        }