summary refs log tree commit diff
path: root/crypto/src/math/ec/custom/sec/Nat224.cs
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2014-02-26 20:13:52 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2014-02-26 20:13:52 +0700
commit57d401f1c1919e507eb42ac0964a8b5d61ee6049 (patch)
tree413d79b8d57700b9270ab4533787474910e44822 /crypto/src/math/ec/custom/sec/Nat224.cs
parentOptimize Sqrt() for custom curve secp224k1 (diff)
downloadBouncyCastle.NET-ed25519-57d401f1c1919e507eb42ac0964a8b5d61ee6049.tar.xz
Optimization for custom curve reduction when only a few bits need reducing; used to delay reduction in point doubling.
Diffstat (limited to 'crypto/src/math/ec/custom/sec/Nat224.cs')
-rw-r--r--crypto/src/math/ec/custom/sec/Nat224.cs17
1 files changed, 17 insertions, 0 deletions
diff --git a/crypto/src/math/ec/custom/sec/Nat224.cs b/crypto/src/math/ec/custom/sec/Nat224.cs
index 72950e8a6..a391fc248 100644
--- a/crypto/src/math/ec/custom/sec/Nat224.cs
+++ b/crypto/src/math/ec/custom/sec/Nat224.cs
@@ -730,6 +730,23 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
             return c == 0 ? 0 : Inc(z, zOff + 4);
         }
 
+        public static uint Mul33WordAdd(uint x, uint y, uint[] z, int zOff)
+        {
+            Debug.Assert(x >> 31 == 0);
+            Debug.Assert(zOff <= 4);
+            ulong c = 0, yVal = y;
+            c += yVal * x + z[zOff + 0];
+            z[zOff + 0] = (uint)c;
+            c >>= 32;
+            c += yVal + z[zOff + 1];
+            z[zOff + 1] = (uint)c;
+            c >>= 32;
+            c += z[zOff + 2];
+            z[zOff + 2] = (uint)c;
+            c >>= 32;
+            return c == 0 ? 0 : Inc(z, zOff + 3);
+        }
+
         public static uint MulWordDwordAdd(uint x, ulong y, uint[] z, int zOff)
         {
             Debug.Assert(zOff <= 4);