Exemple #1
0
        private BigInteger GetSquareRestForPoints()
        {
            bool       isSquareRest = false;
            BigInteger value;
            BigInteger x;

            while (!isSquareRest)
            {
                x            = GetRandomValue();
                value        = GetYSquare(x);
                isSquareRest = SquareRest.IsSquareRest(modulo, value);
            }
            return(x);
        }
Exemple #2
0
        public Point EncryptMessage(string massage, BigInteger ni)
        {
            byte[] bytes = System.Text.Encoding.UTF8.GetBytes(massage);

            BigInteger M = new BigInteger(bytes);

            for (int i = 1; i <= ni; i++)
            {
                BigInteger x       = (M * ni + i) % modulo;
                BigInteger ySquare = (BigInteger.ModPow(x, 3, modulo) + x * A + B) % modulo;

                if (SquareRest.IsSquareRest(modulo, ySquare))
                {
                    BigInteger y = BigIntigerMath.SqrtModEuler(ySquare, modulo);

                    return(new Point(x, y));
                }
            }
            return(new Point(-1));
        }