summary refs log tree commit diff
path: root/crypto/src/math/ec/custom/sec/Nat256.cs
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2014-02-24 19:44:57 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2014-02-24 19:44:57 +0700
commit9beb3a6ea61b10349e348c1216f52b187d172d2c (patch)
tree2331137e3b37cd3f48f5ec3a3d6fe0fa20ab66cb /crypto/src/math/ec/custom/sec/Nat256.cs
parentTabs -> spaces (diff)
downloadBouncyCastle.NET-ed25519-9beb3a6ea61b10349e348c1216f52b187d172d2c.tar.xz
Refactoring in Nat* classes
Diffstat (limited to 'crypto/src/math/ec/custom/sec/Nat256.cs')
-rw-r--r--crypto/src/math/ec/custom/sec/Nat256.cs76
1 files changed, 29 insertions, 47 deletions
diff --git a/crypto/src/math/ec/custom/sec/Nat256.cs b/crypto/src/math/ec/custom/sec/Nat256.cs
index 4e3741886..c846f56fb 100644
--- a/crypto/src/math/ec/custom/sec/Nat256.cs
+++ b/crypto/src/math/ec/custom/sec/Nat256.cs
@@ -628,46 +628,44 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
             return (uint)zc;
         }
 
-        public static ulong Mul33AddExt(uint w, uint[] xx, int xxOff, uint[] yy, int yyOff, uint[] zz, int zzOff)
+        public static ulong Mul33Add(uint w, uint[] x, int xOff, uint[] y, int yOff, uint[] z, int zOff)
         {
             Debug.Assert(w >> 31 == 0);
-            Debug.Assert(xxOff <= 8);
-            Debug.Assert(yyOff <= 8);
-            Debug.Assert(zzOff <= 8);
+
             ulong c = 0, wVal = w;
-            ulong xx00 = xx[xxOff + 0];
-            c += wVal * xx00 + yy[yyOff + 0];
-            zz[zzOff + 0] = (uint)c;
+            ulong x0 = x[xOff + 0];
+            c += wVal * x0 + y[yOff + 0];
+            z[zOff + 0] = (uint)c;
             c >>= 32;
-            ulong xx01 = xx[xxOff + 1];
-            c += wVal * xx01 + xx00 + yy[yyOff + 1];
-            zz[zzOff + 1] = (uint)c;
+            ulong x1 = x[xOff + 1];
+            c += wVal * x1 + x0 + y[yOff + 1];
+            z[zOff + 1] = (uint)c;
             c >>= 32;
-            ulong xx02 = xx[xxOff + 2];
-            c += wVal * xx02 + xx01 + yy[yyOff + 2];
-            zz[zzOff + 2] = (uint)c;
+            ulong x2 = x[xOff + 2];
+            c += wVal * x2 + x1 + y[yOff + 2];
+            z[zOff + 2] = (uint)c;
             c >>= 32;
-            ulong xx03 = xx[xxOff + 3];
-            c += wVal * xx03 + xx02 + yy[yyOff + 3];
-            zz[zzOff + 3] = (uint)c;
+            ulong x3 = x[xOff + 3];
+            c += wVal * x3 + x2 + y[yOff + 3];
+            z[zOff + 3] = (uint)c;
             c >>= 32;
-            ulong xx04 = xx[xxOff + 4];
-            c += wVal * xx04 + xx03 + yy[yyOff + 4];
-            zz[zzOff + 4] = (uint)c;
+            ulong x4 = x[xOff + 4];
+            c += wVal * x4 + x3 + y[yOff + 4];
+            z[zOff + 4] = (uint)c;
             c >>= 32;
-            ulong xx05 = xx[xxOff + 5];
-            c += wVal * xx05 + xx04 + yy[yyOff + 5];
-            zz[zzOff + 5] = (uint)c;
+            ulong x5 = x[xOff + 5];
+            c += wVal * x5 + x4 + y[yOff + 5];
+            z[zOff + 5] = (uint)c;
             c >>= 32;
-            ulong xx06 = xx[xxOff + 6];
-            c += wVal * xx06 + xx05 + yy[yyOff + 6];
-            zz[zzOff + 6] = (uint)c;
+            ulong x6 = x[xOff + 6];
+            c += wVal * x6 + x5 + y[yOff + 6];
+            z[zOff + 6] = (uint)c;
             c >>= 32;
-            ulong xx07 = xx[xxOff + 7];
-            c += wVal * xx07 + xx06 + yy[yyOff + 7];
-            zz[zzOff + 7] = (uint)c;
+            ulong x7 = x[xOff + 7];
+            c += wVal * x7 + x6 + y[yOff + 7];
+            z[zOff + 7] = (uint)c;
             c >>= 32;
-            c += xx07;
+            c += x7;
             return c;
         }
 
@@ -799,15 +797,14 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
             return c == 0 ? 0 : Inc(z, zOff + 3);
         }
 
-        public static uint MulWordExt(uint x, uint[] y, uint[] zz, int zzOff)
+        public static uint MulWord(uint x, uint[] y, uint[] z, int zOff)
         {
-            Debug.Assert(zzOff <= 8);
             ulong c = 0, xVal = x;
             int i = 0;
             do
             {
                 c += xVal * y[i];
-                zz[zzOff + i] = (uint)c;
+                z[zOff + i] = (uint)c;
                 c >>= 32;
             }
             while (++i < 8);
@@ -1168,21 +1165,6 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
             ShiftUpBit(zz, zzOff, 16, (uint)x_0 << 31);
         }
 
-        public static uint SquareWordAddExt(uint[] x, int xPos, uint[] zz)
-        {
-            Debug.Assert(xPos > 0 && xPos < 8);
-            ulong c = 0, xVal = x[xPos];
-            int i = 0;
-            do
-            {
-                c += xVal * x[i] + zz[xPos + i];
-                zz[xPos + i] = (uint)c;
-                c >>= 32;
-            }
-            while (++i < xPos);
-            return (uint)c;
-        }
-
         public static int Sub(uint[] x, uint[] y, uint[] z)
         {
             long c = 0;