blob: e5f1d8fbc0a9fa8a386ae25b27feb6e347180724 [file] [log] [blame]
/* GENERATED SOURCE. DO NOT MODIFY. */
package com.android.org.bouncycastle.math.ec;
import java.math.BigInteger;
/**
* @hide This class is not part of the Android public SDK API
*/
public abstract class AbstractECMultiplier implements ECMultiplier
{
public ECPoint multiply(ECPoint p, BigInteger k)
{
int sign = k.signum();
if (sign == 0 || p.isInfinity())
{
return p.getCurve().getInfinity();
}
ECPoint positive = multiplyPositive(p, k.abs());
ECPoint result = sign > 0 ? positive : positive.negate();
/*
* Although the various multipliers ought not to produce invalid output under normal
* circumstances, a final check here is advised to guard against fault attacks.
*/
return checkResult(result);
}
protected abstract ECPoint multiplyPositive(ECPoint p, BigInteger k);
protected ECPoint checkResult(ECPoint p)
{
return ECAlgorithms.implCheckResult(p);
}
}