Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/quite/humla-spongycastle.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2013-09-26 15:06:10 +0400
committerPeter Dettman <peter.dettman@bouncycastle.org>2013-09-26 15:06:10 +0400
commit88f64cd9cf988ca0f3744a06d6db7fc2e835682c (patch)
tree0214aa52e21e314799658ac12948a3e31cc4b6ce /core/src/main/java/org/bouncycastle/math
parent92fab742effdf667ba1c9a02d19adf7e544e7fc7 (diff)
Use normalizeAll to speed up WNaf precomputation
Diffstat (limited to 'core/src/main/java/org/bouncycastle/math')
-rw-r--r--core/src/main/java/org/bouncycastle/math/ec/WNafUtil.java13
1 files changed, 9 insertions, 4 deletions
diff --git a/core/src/main/java/org/bouncycastle/math/ec/WNafUtil.java b/core/src/main/java/org/bouncycastle/math/ec/WNafUtil.java
index 0c7b2175..f5d25b5e 100644
--- a/core/src/main/java/org/bouncycastle/math/ec/WNafUtil.java
+++ b/core/src/main/java/org/bouncycastle/math/ec/WNafUtil.java
@@ -234,7 +234,7 @@ public abstract class WNafUtil
ECPoint[] preComp = wnafPreCompInfo.getPreComp();
if (preComp == null)
{
- preComp = new ECPoint[]{ p.normalize() };
+ preComp = new ECPoint[]{ p };
}
int preCompLen = preComp.length;
@@ -245,7 +245,7 @@ public abstract class WNafUtil
ECPoint twiceP = wnafPreCompInfo.getTwiceP();
if (twiceP == null)
{
- twiceP = preComp[0].twice().normalize();
+ twiceP = preComp[0].twice();
wnafPreCompInfo.setTwiceP(twiceP);
}
@@ -261,8 +261,13 @@ public abstract class WNafUtil
* Compute the new ECPoints for the precomputation array. The values 1, 3, 5, ...,
* 2^(width-1)-1 times p are computed
*/
- preComp[i] = twiceP.add(preComp[i - 1]).normalize();
- }
+ preComp[i] = twiceP.add(preComp[i - 1]);
+ }
+
+ /*
+ * Having oft-used operands in affine form makes operations faster.
+ */
+ c.normalizeAll(preComp);
}
wnafPreCompInfo.setPreComp(preComp);