示例#1
0
        }//projective

        public static BigInteger GetFactorJacobian(BigInteger n, int B1, int B2)
        {
            BigInteger x, y, g;
            var        E = EllipticCurveWeierstrass.GenerateCurveRandom(n, out x, out y, out g, false);
            var        P = new PointJacobian(x, y, E);

            if (g > 1 && g < n)
            {
                return(g);
            }

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

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

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

            return(result);
        }//jacobian
示例#2
0
        public static PointJacobian Double(PointJacobian P)//3M + 6S + 1*a + 4add + 2*2 + 1*3 + 1*4 + 1*8
        {
            if (P.IsInfinite())
            {
                return(new PointJacobian(0, 1, 0, P.E));
            }
            BigInteger XX = P.x * P.x;
            BigInteger YY = P.y * P.y;
            BigInteger ZZ = P.z * P.z;
            BigInteger S  = 4 * P.x * YY;
            BigInteger M  = 3 * XX + P.E.a * ZZ * ZZ;
            BigInteger T  = M * M - 2 * S;
            BigInteger x  = T % P.E.n;
            BigInteger y  = (M * (S - T) - 8 * YY * YY) % P.E.n;
            BigInteger z  = (2 * P.y * P.z) % P.E.n;

            return(new PointJacobian(x, y, z, P.E));
        }
示例#3
0
        public static PointJacobian operator *(BigInteger k, PointJacobian P)
        {
            PointJacobian R = new PointJacobian(0, 1, 0, P.E);

            if (P.IsInfinite())
            {
                return(R);
            }
            while (k > 0)
            {
                if (k % 2 == 1)
                {
                    R += P;
                }
                k /= 2;
                P  = Double(P);
            }
            return(R);
        }