summary refs log tree commit diff
path: root/crypto/src/math/ec/custom/sec/SecP384R1Field.cs
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2022-02-05 20:13:56 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2022-02-05 20:13:56 +0700
commit0fbb9e698c6193873b87b19e96a6385c33f436fc (patch)
tree8d7e2c7bf737aa82b585fbabab0dfbf699cca222 /crypto/src/math/ec/custom/sec/SecP384R1Field.cs
parentFix case-sensitive file names (diff)
downloadBouncyCastle.NET-ed25519-0fbb9e698c6193873b87b19e96a6385c33f436fc.tar.xz
Small performance optimization for important curves
Diffstat (limited to 'crypto/src/math/ec/custom/sec/SecP384R1Field.cs')
-rw-r--r--crypto/src/math/ec/custom/sec/SecP384R1Field.cs26
1 files changed, 26 insertions, 0 deletions
diff --git a/crypto/src/math/ec/custom/sec/SecP384R1Field.cs b/crypto/src/math/ec/custom/sec/SecP384R1Field.cs
index cddb46895..16b60af55 100644
--- a/crypto/src/math/ec/custom/sec/SecP384R1Field.cs
+++ b/crypto/src/math/ec/custom/sec/SecP384R1Field.cs
@@ -98,6 +98,12 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
             Reduce(tt, z);
         }
 
+        public static void Multiply(uint[] x, uint[] y, uint[] z, uint[] tt)
+        {
+            Nat384.Mul(x, y, tt);
+            Reduce(tt, z);
+        }
+
         public static void Negate(uint[] x, uint[] z)
         {
             if (0 != IsZero(x))
@@ -234,6 +240,12 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
             Reduce(tt, z);
         }
 
+        public static void Square(uint[] x, uint[] z, uint[] tt)
+        {
+            Nat384.Square(x, tt);
+            Reduce(tt, z);
+        }
+
         public static void SquareN(uint[] x, int n, uint[] z)
         {
             Debug.Assert(n > 0);
@@ -249,6 +261,20 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
             }
         }
 
+        public static void SquareN(uint[] x, int n, uint[] z, uint[] tt)
+        {
+            Debug.Assert(n > 0);
+
+            Nat384.Square(x, tt);
+            Reduce(tt, z);
+
+            while (--n > 0)
+            {
+                Nat384.Square(z, tt);
+                Reduce(tt, z);
+            }
+        }
+
         public static void Subtract(uint[] x, uint[] y, uint[] z)
         {
             int c = Nat.Sub(12, x, y, z);