diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2014-01-27 08:22:45 +0400 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2014-01-27 08:22:45 +0400 |
commit | d102d38a881e8d9414867d747b3d946aeba53376 (patch) | |
tree | 86ec9013e7eef8fc19c0c25a2a0b53d3fb189644 /core/src/main/java/org/bouncycastle/math | |
parent | 24b8371ce392bc31da920c3c7c8c2f0e31f46844 (diff) |
Refactoring
Diffstat (limited to 'core/src/main/java/org/bouncycastle/math')
-rw-r--r-- | core/src/main/java/org/bouncycastle/math/ec/WTauNafMultiplier.java | 26 |
1 files changed, 8 insertions, 18 deletions
diff --git a/core/src/main/java/org/bouncycastle/math/ec/WTauNafMultiplier.java b/core/src/main/java/org/bouncycastle/math/ec/WTauNafMultiplier.java index cde78a36..2954956a 100644 --- a/core/src/main/java/org/bouncycastle/math/ec/WTauNafMultiplier.java +++ b/core/src/main/java/org/bouncycastle/math/ec/WTauNafMultiplier.java @@ -49,21 +49,12 @@ public class WTauNafMultiplier extends AbstractECMultiplier private ECPoint.F2m multiplyWTnaf(ECPoint.F2m p, ZTauElement lambda, PreCompInfo preCompInfo, byte a, byte mu) { - ZTauElement[] alpha; - if (a == 0) - { - alpha = Tnaf.alpha0; - } - else - { - // a == 1 - alpha = Tnaf.alpha1; - } + ZTauElement[] alpha = (a == 0) ? Tnaf.alpha0 : Tnaf.alpha1; BigInteger tw = Tnaf.getTw(mu, Tnaf.WIDTH); byte[]u = Tnaf.tauAdicWNaf(mu, lambda, Tnaf.WIDTH, - BigInteger.valueOf(Tnaf.POW_2_WIDTH), tw, alpha); + BigInteger.valueOf(Tnaf.POW_2_WIDTH), tw, alpha); return multiplyFromWTnaf(p, u, preCompInfo); } @@ -77,8 +68,7 @@ public class WTauNafMultiplier extends AbstractECMultiplier * @param u The the WTNAF of <code>λ</code>.. * @return <code>λ * p</code> */ - private static ECPoint.F2m multiplyFromWTnaf(ECPoint.F2m p, byte[] u, - PreCompInfo preCompInfo) + private static ECPoint.F2m multiplyFromWTnaf(ECPoint.F2m p, byte[] u, PreCompInfo preCompInfo) { ECCurve.F2m curve = (ECCurve.F2m)p.getCurve(); byte a = curve.getA().toBigInteger().byteValue(); @@ -102,16 +92,16 @@ public class WTauNafMultiplier extends AbstractECMultiplier for (int i = u.length - 1; i >= 0; i--) { q = Tnaf.tau(q); - if (u[i] != 0) + byte ui = u[i]; + if (ui != 0) { - if (u[i] > 0) + if (ui > 0) { - q = q.addSimple(pu[u[i]]); + q = q.addSimple(pu[ui]); } else { - // u[i] < 0 - q = q.subtractSimple(pu[-u[i]]); + q = q.subtractSimple(pu[-ui]); } } } |