Ejemplo n.º 1
0
        public static PointEdwardsInverted Double(PointEdwardsInverted P)//3M + 4S + 1*a + 1*d2 + 6add
        {
            BigInteger A = P.x * P.x;
            BigInteger B = P.y * P.y;
            BigInteger U = P.E.a * B;
            BigInteger C = A + U;
            BigInteger D = A - U;
            BigInteger W = P.x + P.y;
            BigInteger E = W * W - A - B;
            BigInteger x = (C * D) % P.E.n;
            BigInteger y = (E * (C - 2 * P.E.b * P.z * P.z)) % P.E.n;
            BigInteger z = (D * E) % P.E.n;

            return(new PointEdwardsInverted(x, y, z, P.E));
        }
Ejemplo n.º 2
0
        }//projective

        public static BigInteger GetFactorInverted(BigInteger n, int B1, int B2, TorsionType type)
        {
            BigInteger x, y;
            var        E = GenerateCurve(n, out x, out y, type);
            var        P = new PointEdwardsInverted(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);
        }//inverted
Ejemplo n.º 3
0
        public static PointEdwardsInverted operator *(BigInteger k, PointEdwardsInverted P)
        {
            bool isFirst           = true;
            PointEdwardsInverted R = new PointEdwardsInverted(0, 1, 1, P.E);

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