Exemplo n.º 1
0
        public static Point CalculateMultiplication(this EllypticCurve curve, Point g, BigInteger scalar)
        {
            var binary = scalar.ToBinaryString();

            binary = binary.TrimStart('0');

            var p = new Point(g.XCoordinate, g.YCoordinate);

            for (var i = 1; i < binary.Length; i++)
            {
                bool add = binary[i] == '1';

                p = curve.CalculateDoubling(p);

                if (add)
                {
                    p = curve.CalculateAddition(p, g);
                }
            }

            return(p);
        }
Exemplo n.º 2
0
 public static Point CalculateDoubling(this EllypticCurve curve, Point p)
 {
     return(curve.CalculateAddition(p, p));
 }