summary refs log tree commit diff
path: root/crypto/test
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2014-01-22 12:47:20 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2014-01-22 12:47:20 +0700
commita1f04c18f436a7206c990e1c1625250f5dee93b3 (patch)
treec94f8bff3b38f7c2d7d2f3322ef6c32ac3ff0fa9 /crypto/test
parentMake public (diff)
downloadBouncyCastle.NET-ed25519-a1f04c18f436a7206c990e1c1625250f5dee93b3.tar.xz
Add foundations for supporting other coordinate systems
Add curve configuration
Multipliers now live on the curve instead of points
Diffstat (limited to 'crypto/test')
-rw-r--r--crypto/test/src/math/ec/test/ECPointPerformanceTest.cs44
-rw-r--r--crypto/test/src/math/ec/test/ECPointTest.cs2
2 files changed, 34 insertions, 12 deletions
diff --git a/crypto/test/src/math/ec/test/ECPointPerformanceTest.cs b/crypto/test/src/math/ec/test/ECPointPerformanceTest.cs
index 380004d96..6b9e2efce 100644
--- a/crypto/test/src/math/ec/test/ECPointPerformanceTest.cs
+++ b/crypto/test/src/math/ec/test/ECPointPerformanceTest.cs
@@ -27,6 +27,9 @@ namespace Org.BouncyCastle.Math.EC.Tests
         public const int PRE_ROUNDS = 10;
         public const int NUM_ROUNDS = 100;
 
+        private static string[] COORD_NAMES = new string[]{ "AFFINE", "HOMOGENEOUS", "JACOBIAN", "JACOBIAN-CHUDNOVSKY",
+            "JACOBIAN-MODIFIED", "LAMBDA-AFFINE", "LAMBDA-PROJECTIVE", "SKEWED" };
+
         private void RandMult(string curveName)
         {
             X9ECParameters spec = ECNamedCurveTable.GetByName(curveName);
@@ -44,26 +47,45 @@ namespace Org.BouncyCastle.Math.EC.Tests
 
         private void RandMult(string label, X9ECParameters spec)
         {
+            ECCurve C = spec.Curve;
             ECPoint G = (ECPoint)spec.G;
             BigInteger n = spec.N;
+
             SecureRandom random = new SecureRandom();
             random.SetSeed(DateTimeUtilities.CurrentUnixMs());
 
             Console.WriteLine(label);
 
-            double avgDuration = RandMult(random, G, n);
-            string coordName = "AFFINE";
-            StringBuilder sb = new StringBuilder();
-            sb.Append("  ");
-            sb.Append(coordName);
-            for (int j = coordName.Length; j < 30; ++j)
+            int[] coords = ECCurve.GetAllCoordinateSystems();
+            for (int i = 0; i < coords.Length; ++i)
             {
-                sb.Append(' ');
+                int coord = coords[i];
+                if (C.SupportsCoordinateSystem(coord))
+                {
+                    ECCurve c = C;
+                    ECPoint g = G;
+
+                    if (c.CoordinateSystem != coord)
+                    {
+                        c = C.Configure().SetCoordinateSystem(coord).Create();
+                        g = c.ImportPoint(G);
+                    }
+
+                    double avgDuration = RandMult(random, g, n);
+                    string coordName = COORD_NAMES[coord];
+                    StringBuilder sb = new StringBuilder();
+                    sb.Append("  ");
+                    sb.Append(coordName);
+                    for (int j = coordName.Length; j < 30; ++j)
+                    {
+                        sb.Append(' ');
+                    }
+                    sb.Append(": ");
+                    sb.Append(avgDuration);
+                    sb.Append("ms");
+                    Console.WriteLine(sb.ToString());
+                }
             }
-            sb.Append(": ");
-            sb.Append(avgDuration);
-            sb.Append("ms");
-            Console.WriteLine(sb.ToString());
         }
 
         private double RandMult(SecureRandom random, ECPoint g, BigInteger n)
diff --git a/crypto/test/src/math/ec/test/ECPointTest.cs b/crypto/test/src/math/ec/test/ECPointTest.cs
index 696448544..6c628c29c 100644
--- a/crypto/test/src/math/ec/test/ECPointTest.cs
+++ b/crypto/test/src/math/ec/test/ECPointTest.cs
@@ -56,7 +56,7 @@ namespace Org.BouncyCastle.Math.EC.Tests
                 {
                     p[i] = curve.CreatePoint(
                         new BigInteger(pointSource[2 * i].ToString()),
-                        new BigInteger(pointSource[2 * i + 1].ToString()), false);
+                        new BigInteger(pointSource[2 * i + 1].ToString()));
                 }
             }
         }