/// <summary> /// Multiplies the this value at IntBig value /// </summary> /// <param name="value">IntBig multiplier</param> /// <returns>Result of operation</returns> public IEllipticCurvePoint Multiply(IntBig value2) { EllipticCurvePointC tempPoint = null; EllipticCurvePointC[] points = new EllipticCurvePointC[16]; points[0] = GetInfinity() as EllipticCurvePointC; points[1] = this; points[2] = points[1].Doubling() as EllipticCurvePointC; points[3] = points[1].Addition(points[2]) as EllipticCurvePointC; points[4] = points[2].Doubling() as EllipticCurvePointC; points[5] = points[1].Addition(points[4]) as EllipticCurvePointC; points[6] = points[3].Doubling() as EllipticCurvePointC; points[7] = points[1].Addition(points[6]) as EllipticCurvePointC; points[8] = points[4].Doubling() as EllipticCurvePointC; points[9] = points[1].Addition(points[8]) as EllipticCurvePointC; points[10] = points[5].Doubling() as EllipticCurvePointC; points[11] = points[1].Addition(points[10]) as EllipticCurvePointC; points[12] = points[6].Doubling() as EllipticCurvePointC; points[13] = points[1].Addition(points[12]) as EllipticCurvePointC; points[14] = points[7].Doubling() as EllipticCurvePointC; points[15] = points[1].Addition(points[14]) as EllipticCurvePointC; // First index int index = BigHelper.MaxNonZeroBitIndex(value2.m_Value); int howManyDouble = 0; int howMuchAdd = 0; //if (index < 0) // break; index = GetWindow(value2, index, out howManyDouble, out howMuchAdd); tempPoint = points[howMuchAdd]; while (true) { if (index < 0) { break; } index = GetWindow(value2, index, out howManyDouble, out howMuchAdd); if (howManyDouble > 0) { for (int t = 0; t < howManyDouble; ++t) { tempPoint = tempPoint.Doubling() as EllipticCurvePointC; } } if (howMuchAdd > 0) { tempPoint = tempPoint.Addition(points[howMuchAdd]) as EllipticCurvePointC; } } return(tempPoint); }
/// <summary> /// Adds the value with another value in elliptic curve /// </summary> /// <param name="value1"></param> /// <param name="value2"></param> /// <returns></returns> public static EllipticCurvePointC Addition(EllipticCurvePointC value1, EllipticCurvePointC value2) { return(value1.Addition(value2) as EllipticCurvePointC); }