Beispiel #1
0
        public EllipticCurve_Point GenerateRandomPoint()
        {
            EllipticCurve_Point ret = new EllipticCurve_Point();
            BigInteger          x   = new BigInteger();
            BigInteger          sqr = new BigInteger();
            BigInteger          pp  = BigInteger.Parse(P.ToString());

            do
            {
                x = Maths.RandInRange(0, P);
                BigInteger alpha = ((x * x * x) + A * x + B) % P;
                if (alpha == 0)
                {
                    ret.X = x;
                    ret.Y = 0;
                    return(ret);
                }
                BigInteger bi = BigInteger.Parse(alpha.ToString());
                sqr = Maths.ModSqrt(bi, pp);
                if ((sqr * sqr) % pp != bi)
                {
                    sqr = 0;
                }
            }while (sqr == 0);
            ret.X = x;
            ret.Y = sqr;
            return(ret);
        }