1 package org.bouncycastle.math.ec; 2 3 import java.math.BigInteger; 4 5 public abstract class AbstractECMultiplier implements ECMultiplier 6 { multiply(ECPoint p, BigInteger k)7 public ECPoint multiply(ECPoint p, BigInteger k) 8 { 9 int sign = k.signum(); 10 if (sign == 0 || p.isInfinity()) 11 { 12 return p.getCurve().getInfinity(); 13 } 14 15 ECPoint positive = multiplyPositive(p, k.abs()); 16 ECPoint result = sign > 0 ? positive : positive.negate(); 17 18 /* 19 * Although the various multipliers ought not to produce invalid output under normal 20 * circumstances, a final check here is advised to guard against fault attacks. 21 */ 22 return ECAlgorithms.validatePoint(result); 23 } 24 multiplyPositive(ECPoint p, BigInteger k)25 protected abstract ECPoint multiplyPositive(ECPoint p, BigInteger k); 26 } 27