diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2014-06-21 10:33:53 +0400 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2014-06-21 10:33:53 +0400 |
commit | 75f736199814889cce3e2023ce988c367cbaacc7 (patch) | |
tree | f61da48811279367902729a93c7eacc0abb8cf03 | |
parent | c5ee3b316092d9dab7525dc5e47fcafea9c25d82 (diff) |
Add inverse32 method
-rw-r--r-- | core/src/main/java/org/bouncycastle/math/raw/Mod.java | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/core/src/main/java/org/bouncycastle/math/raw/Mod.java b/core/src/main/java/org/bouncycastle/math/raw/Mod.java index e8128ec4..1bc7d3f7 100644 --- a/core/src/main/java/org/bouncycastle/math/raw/Mod.java +++ b/core/src/main/java/org/bouncycastle/math/raw/Mod.java @@ -6,6 +6,18 @@ import org.bouncycastle.util.Pack; public abstract class Mod { + public static int inverse32(int d) + { +// int x = d + (((d + 1) & 4) << 1); // d.x == 1 mod 2**4 + int x = d; // d.x == 1 mod 2**3 + x *= 2 - d * x; // d.x == 1 mod 2**6 + x *= 2 - d * x; // d.x == 1 mod 2**12 + x *= 2 - d * x; // d.x == 1 mod 2**24 + x *= 2 - d * x; // d.x == 1 mod 2**48 +// assert d * x == 1; + return x; + } + public static void invert(int[] p, int[] x, int[] z) { int len = p.length; |