public ECPoint Multiply(BigInteger b) { if (b.Sign == -1) { throw new FormatException("The multiplicator cannot be negative"); } b = b % Secp256k1.N; BigInteger exp = (b * 3) ^ b; ECPoint result = ECPoint.Infinity; ECPoint affine = this.Normalize(); ECPoint negative = affine.Negate(); int high = exp <= 0 ? 0 : (int)Math.Floor(BigInteger.Log(exp, 2)); BigInteger bit = BigInteger.One << high; for (int i = high; --i >= 0; bit >>= 1) { result = result.Twice(); if (!(exp & bit).IsZero) { result = result.Add(!(b & bit).IsZero ? negative : affine); } } result = result.Normalize(); return(result); }
public ECPoint Subtract(ECPoint b) { return(Add(b.Negate())); }
public ECPoint Subtract(ECPoint b) { return Add(b.Negate()); }