diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2013-10-04 05:20:07 +0400 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2013-10-04 05:20:07 +0400 |
commit | cd09a6578985280d42e4507412d73dd56957e89c (patch) | |
tree | ba4896819be299490ab8e29178863a2d121acb19 /core/src/main/java/org/bouncycastle/math/ec/LongArray.java | |
parent | 9c5522f0947608f8d5d83cbb075179a0594315c4 (diff) |
Move F2m reduction inside the multiplication and square methods (renamed
to modMultiply and modSquare)
Diffstat (limited to 'core/src/main/java/org/bouncycastle/math/ec/LongArray.java')
-rw-r--r-- | core/src/main/java/org/bouncycastle/math/ec/LongArray.java | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/core/src/main/java/org/bouncycastle/math/ec/LongArray.java b/core/src/main/java/org/bouncycastle/math/ec/LongArray.java index 3b9cd801..cd1790ca 100644 --- a/core/src/main/java/org/bouncycastle/math/ec/LongArray.java +++ b/core/src/main/java/org/bouncycastle/math/ec/LongArray.java @@ -529,7 +529,7 @@ class LongArray m_ints[theInt] &= ~setter; } - public LongArray multiply(LongArray other, int m) + public LongArray modMultiply(LongArray other, int m, int[] ks) { int aLen = getUsedLength(); if (aLen == 0) @@ -568,7 +568,9 @@ class LongArray } ++k; } - return new LongArray(c); + LongArray p = new LongArray(c); + p.reduce(m, ks); + return p; } int width, shifts, top; @@ -659,6 +661,7 @@ class LongArray // TODO reduce in place to avoid extra copying LongArray p = new LongArray(cLen); System.arraycopy(c, ci[1], p.m_ints, 0, cLen); + p.reduce(m, ks); return p; } @@ -689,7 +692,7 @@ class LongArray // return x; // } - public void reduce(int m, int[] ks) + private void reduce(int m, int[] ks) { int len = getUsedLength(); int mLen = (m + 63) >>> 6; @@ -762,7 +765,7 @@ class LongArray } } - public LongArray square(int m) + public LongArray modSquare(int m, int[] ks) { int len = getUsedLength(); if (len == 0) @@ -781,7 +784,9 @@ class LongArray r[pos++] = expand32((int)(mi >>> 32)); } - return new LongArray(r); + LongArray p = new LongArray(r); + p.reduce(m, ks); + return p; } private static void interleave3(long[] x, int xOff, long[] z, int zOff, int count) |