diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2020-09-11 11:07:11 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2020-09-11 11:07:11 +0700 |
commit | 8614e492c5ca2733d581b37f9d0e7d6714bb0a29 (patch) | |
tree | cf319be5c818a772f0faebfb5b65486b7399b372 | |
parent | 'safegcd' modular inversion (diff) | |
download | BouncyCastle.NET-ed25519-8614e492c5ca2733d581b37f9d0e7d6714bb0a29.tar.xz |
Further Divsteps30 improvement
-rw-r--r-- | crypto/src/math/raw/Mod.cs | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/crypto/src/math/raw/Mod.cs b/crypto/src/math/raw/Mod.cs index 1a1524c11..a1eeaa9b7 100644 --- a/crypto/src/math/raw/Mod.cs +++ b/crypto/src/math/raw/Mod.cs @@ -278,21 +278,19 @@ namespace Org.BouncyCastle.Math.Raw Debug.Assert((u * f0 + v * g0) == f << i); Debug.Assert((q * f0 + r * g0) == g << i); - int p = -(g & 1); - int s = eta >> 31; + int c1 = eta >> 31; + int c2 = -(g & 1); - int c1 = p & s; - int c2 = p & ~s; + int x = (f ^ c1) - c1; + int y = (u ^ c1) - c1; + int z = (v ^ c1) - c1; - eta = (eta ^ c1) - (c1 + 1); - - g += f & c2; - q += u & c2; - r += v & c2; + g += x & c2; + q += y & c2; + r += z & c2; - g -= f & c1; - q -= u & c1; - r -= v & c1; + c1 &= c2; + eta = (eta ^ c1) - (c1 + 1); f += g & c1; u += q & c1; |