예제 #1
0
        private BigInteger GetValueY(BigInteger x)
        {
            BigInteger value = GetYSquare(x);
            BigInteger y     = BigIntigerMath.SqrtModEuler(value, modulo);

            return(y);
        }
예제 #2
0
        private Point MultipySamePoints()
        {
            BigInteger x1 = pointP.x;
            BigInteger y1 = pointP.y;
            BigInteger x2 = pointQ.x;
            BigInteger y2 = pointQ.y;

            BigInteger lambda = ((3 * BigInteger.ModPow(x1, 2, modulo) + a) * BigIntigerMath.InverseNumberMod(2 * y1, modulo)) % modulo;
            BigInteger x3     = (BigInteger.ModPow(lambda, 2, modulo) - 2 * x1) % modulo;
            BigInteger y3     = (lambda * (x1 - x3) - y1) % modulo;

            return(new Point(x3, y3));
        }
예제 #3
0
        private Point AddDifferentPointsPAndQ()
        {
            BigInteger x1 = pointP.x;
            BigInteger y1 = pointP.y;
            BigInteger x2 = pointQ.x;
            BigInteger y2 = pointQ.y;

            BigInteger lambda = ((y2 - y1) * BigIntigerMath.InverseNumberMod(x2 - x1, modulo)) % modulo;
            BigInteger x3     = (BigInteger.ModPow(lambda, 2, modulo) - x1 - x2) % modulo;
            BigInteger y3     = (lambda * (x1 - x3) - y1) % modulo;

            return(new Point(x3, y3));
        }
예제 #4
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));
        }