示例#1
0
        public void GenerateCurveAndPointCheck()
        {
            ElipticCurve curve = new ElipticCurve(64);

            curve.GenerateRandomCurve();

            Point p1 = curve.GenerateRandomPointOnCurve();

            Assert.IsTrue(curve.CheckIfPointBelongsToCurve(p1));

            Point p2 = curve.GenerateRandomPointOnCurve();

            Assert.IsTrue(curve.CheckIfPointBelongsToCurve(p1));

            Assert.IsTrue(curve.CheckIfPointBelongsToCurve(p1 + p1));

            Assert.IsTrue(curve.CheckIfPointBelongsToCurve(p1 + p2));
        }
示例#2
0
        public void ScalarMultiplicationTests()
        {
            ElipticCurve curve = new ElipticCurve(64);

            curve.GenerateRandomCurve();
            Point randomPoint = curve.GenerateRandomPointOnCurve();

            Point testPoint = curve.ScalarMultiplication(randomPoint, 1);

            Assert.IsTrue(curve.CheckIfPointBelongsToCurve(testPoint));

            testPoint = curve.ScalarMultiplication(randomPoint, 5);
            Assert.IsTrue(curve.CheckIfPointBelongsToCurve(testPoint));

            testPoint = curve.ScalarMultiplication(randomPoint, 100);
            Assert.IsTrue(curve.CheckIfPointBelongsToCurve(testPoint));

            testPoint = curve.ScalarMultiplication(randomPoint, BigInteger.Parse("999999999999999999999999999999999999999999999999999999999999"));

            Assert.IsTrue(curve.CheckIfPointBelongsToCurve(testPoint));
        }