Beispiel #1
0
        public string[] Execute(string[] inputData, TextWriter writer, Model.EllipticCurve curve)
        {
            var s = int.Parse(inputData[0]);

            if (inputData.Length < s)
            {
                Console.WriteLine("Error in input data");
                return(new string[] {});
            }
            if (s <= 0)
            {
                Console.WriteLine("S in not Natural Number");
                return(new string[] {});
            }


            for (var i = 0; i < s; i++)
            {
                var tokens = inputData[i + 1].Split(' ');
                if (tokens.Length != 3)
                {
                    writer.WriteLine("Wrong input data in Multiply Task");
                }
                var point = new EllipticCurvePoint(curve);
                point.Read(tokens[0], tokens[1]);

                var d = BigInteger.Parse(tokens[2]);

                var result = point.Multiply(d);
                writer.WriteLine(result);
            }
            return(inputData.Skip(s + 1).ToArray());
        }
Beispiel #2
0
        public string[] Execute(string[] inputData, TextWriter writer, Model.EllipticCurve curve)
        {
            var t = int.Parse(inputData[0]);

            if (inputData.Length < t)
            {
                Console.WriteLine("Error in input data");
            }
            for (int i = 0; i < t; i++)
            {
                var tokens = inputData[i + 1].Split(' ');
                if (tokens.Length != 4)
                {
                    writer.WriteLine("Wrong input data in Sum Task");
                }
                var point1 = new EllipticCurvePoint(curve);
                point1.Read(tokens[0], tokens[1]);
                var point2 = new EllipticCurvePoint(curve);
                point2.Read(tokens[2], tokens[3]);

                var result = point1 + point2;
                writer.WriteLine(result);
            }
            return(inputData.Skip(t + 1).ToArray());
        }
Beispiel #3
0
        public void ExecuteTasks(ref string[] inputData, TextWriter writer)
        {
            var curve = new Model.EllipticCurve();

            curve.Read(ref inputData);

            foreach (var task in tasks)
            {
                inputData = task.Invoke(inputData, writer, curve);
            }
        }
Beispiel #4
0
        public void Run()
        {
            var lines = File.ReadAllLines("curve.txt");

            curve = new Model.EllipticCurve();
            curve.Read(ref lines);

            IEnumerable <EllipticCurvePoint> result = new List <EllipticCurvePoint>();

            try
            {
                result = GeneratePoints();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }

            File.WriteAllLines("points.txt", result.Select(x => x.ToString()));
        }
Beispiel #5
0
 public EllipticCurvePointsGenerator(Model.EllipticCurve curve)
 {
     this.curve = curve;
 }