private static void Test3Inner(int multipleCount) { const int d = 8; const int fieldOrder = 13; var projectiveEdwardsCurve = new ProjectiveEdwardsCurve(d, fieldOrder); var pointsFactory = new PointsFactory(projectiveEdwardsCurve); var initialPoint = pointsFactory.CreatePoint(6, 12, 2); var point1 = pointsFactory.CreatePoint(6, 12, 2); var calculator = new ProjectiveEdwardsCurvePointCalculator(); for (var i = 0; i < multipleCount - 1; i++) { point1 = calculator.Sum(point1, initialPoint); } var point2 = calculator.Mult(multipleCount, initialPoint); if (point1.Equals(point2)) { Console.Write("."); return; } throw new ArithmeticException("Точки, полученные сложением и умножение, отличаются при multipleCount = " + multipleCount); }
private static void Test4() { BigInteger fieldOrder = BigInteger.Parse("73928303") * BigInteger.Parse("73928293"); BigInteger x = 3; BigInteger y = 2; BigInteger z = 1; var d = ((x * x * z * z + y * y * z * z - z * z * z * z) * (x * x * y * y).Inverse(fieldOrder)).Mod(fieldOrder); const int multipleCount = 73928303; var projectiveEdwardsCurve = new ProjectiveEdwardsCurve(d, fieldOrder); var pointsFactory = new PointsFactory(projectiveEdwardsCurve); var calculator = new ProjectiveEdwardsCurvePointCalculator(); var initialPoint = pointsFactory.CreatePoint(x, y, z); var point1 = pointsFactory.CreatePoint(x, y, z); for (var i = 0; i < multipleCount - 1; i++) { point1 = calculator.Sum(point1, initialPoint); var gcd = BigInteger.GreatestCommonDivisor(point1.ParameterZ, fieldOrder); if (gcd != BigInteger.One) { Console.WriteLine("divider = " + gcd); return; } // Console.WriteLine(point1); // Console.WriteLine(point1.ToEdwardsCurvePoint()); } }
private static void Test2() { const int d = 8; const int fieldOrder = 13; var projectiveEdwardsCurve = new ProjectiveEdwardsCurve(d, fieldOrder); var pointsFactory = new PointsFactory(projectiveEdwardsCurve); var point1 = pointsFactory.CreatePoint(6, 12, 2); var point2 = projectiveEdwardsCurve.NeitralPoint; var calculator = new ProjectiveEdwardsCurvePointCalculator(); var sum = calculator.Sum(point1, point2); Console.WriteLine(sum); Console.WriteLine(sum.ToEdwardsCurvePoint()); }
/// <summary> Тест на корректность суммирования </summary> private static void Test1() { var d = 8; var fieldOrder = 13; var projectiveEdwardsCurve = new ProjectiveEdwardsCurve(d, fieldOrder); var pointsFactory = new PointsFactory(projectiveEdwardsCurve); var point1 = pointsFactory.CreatePoint(3, 6, 1); var point2 = pointsFactory.CreatePoint(6, 3, 1); var calculator = new ProjectiveEdwardsCurvePointCalculator(); var sum = calculator.Sum(point1, point2); Console.WriteLine(sum); Console.WriteLine(sum.ToEdwardsCurvePoint()); }