/** * Multiplies a {@link org.spongycastle.math.ec.ECPoint.F2m ECPoint.F2m} * by <code>k</code> using the reduced <code>τ</code>-adic NAF (RTNAF) * method. * @param p The ECPoint.F2m to multiply. * @param k The integer by which to multiply <code>k</code>. * @return <code>p</code> multiplied by <code>k</code>. */ public ECPoint multiply(ECPoint point, BigInteger k, PreCompInfo preCompInfo) { if (!(point instanceof ECPoint.F2m)) { throw new IllegalArgumentException("Only ECPoint.F2m can be " + "used in WTauNafMultiplier"); } ECPoint.F2m p = (ECPoint.F2m)point; ECCurve.F2m curve = (ECCurve.F2m) p.getCurve(); int m = curve.getM(); byte a = curve.getA().toBigInteger().byteValue(); byte mu = curve.getMu(); BigInteger[] s = curve.getSi(); ZTauElement rho = Tnaf.partModReduction(k, m, a, s, mu, (byte)10); return multiplyWTnaf(p, rho, preCompInfo, a, mu); }
/** * Multiplies a {@link org.spongycastle.math.ec.ECPoint.AbstractF2m ECPoint.AbstractF2m} * by <code>k</code> using the reduced <code>τ</code>-adic NAF (RTNAF) * method. * @param point The ECPoint.AbstractF2m to multiply. * @param k The integer by which to multiply <code>k</code>. * @return <code>p</code> multiplied by <code>k</code>. */ protected ECPoint multiplyPositive(ECPoint point, BigInteger k) { if (!(point instanceof ECPoint.AbstractF2m)) { throw new IllegalArgumentException("Only ECPoint.AbstractF2m can be " + "used in WTauNafMultiplier"); } ECPoint.AbstractF2m p = (ECPoint.AbstractF2m)point; ECCurve.AbstractF2m curve = (ECCurve.AbstractF2m)p.getCurve(); int m = curve.getFieldSize(); byte a = curve.getA().toBigInteger().byteValue(); byte mu = Tnaf.getMu(a); BigInteger[] s = curve.getSi(); ZTauElement rho = Tnaf.partModReduction(k, m, a, s, mu, (byte)10); return multiplyWTnaf(p, rho, curve.getPreCompInfo(p, PRECOMP_NAME), a, mu); }