diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2020-07-04 16:42:57 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2020-07-04 16:42:57 +0700 |
commit | b27bcfb49d403d9c0d4f4924de5f869db1c041cc (patch) | |
tree | 72c3a1bae971caa7575c1bb54fb9baa30d51ca36 /crypto/src/math/raw/Nat.cs | |
parent | Blind the inversion when normalizing (diff) | |
download | BouncyCastle.NET-ed25519-b27bcfb49d403d9c0d4f4924de5f869db1c041cc.tar.xz |
EC updates from bc-java
Diffstat (limited to '')
-rw-r--r-- | crypto/src/math/raw/Nat.cs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/crypto/src/math/raw/Nat.cs b/crypto/src/math/raw/Nat.cs index 9786d3ecf..8ec328d11 100644 --- a/crypto/src/math/raw/Nat.cs +++ b/crypto/src/math/raw/Nat.cs @@ -570,6 +570,30 @@ namespace Org.BouncyCastle.Math.Raw return true; } + public static int LessThan(int len, uint[] x, uint[] y) + { + long c = 0; + for (int i = 0; i < len; ++i) + { + c += (long)x[i] - y[i]; + c >>= 32; + } + Debug.Assert(c == 0L || c == -1L); + return (int)c; + } + + public static int LessThan(int len, uint[] x, int xOff, uint[] y, int yOff) + { + long c = 0; + for (int i = 0; i < len; ++i) + { + c += (long)x[xOff + i] - y[yOff + i]; + c >>= 32; + } + Debug.Assert(c == 0L || c == -1L); + return (int)c; + } + public static void Mul(int len, uint[] x, uint[] y, uint[] zz) { zz[len] = MulWord(len, x[0], y, zz); |