summary refs log tree commit diff
path: root/crypto/test
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2014-01-22 10:51:57 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2014-01-22 10:51:57 +0700
commit47d13b5a8d368ffc048e2804cf24ca3b66b8ecae (patch)
tree5a434037701624335a7cb6d7d9b8a509ed90fb40 /crypto/test
parentPort LongArray from Java and use in F2mFieldElement (diff)
downloadBouncyCastle.NET-ed25519-47d13b5a8d368ffc048e2804cf24ca3b66b8ecae.tar.xz
Implement TwicePlus optimization in Fp curves
Diffstat (limited to 'crypto/test')
-rw-r--r--crypto/test/src/math/ec/test/ECPointTest.cs19
1 files changed, 19 insertions, 0 deletions
diff --git a/crypto/test/src/math/ec/test/ECPointTest.cs b/crypto/test/src/math/ec/test/ECPointTest.cs
index 7d26e6fbb..78f0a3ca6 100644
--- a/crypto/test/src/math/ec/test/ECPointTest.cs
+++ b/crypto/test/src/math/ec/test/ECPointTest.cs
@@ -220,6 +220,25 @@ namespace Org.BouncyCastle.Math.EC.Tests
             implTestTwice(F2m.p);
         }
 
+        private void implTestThreeTimes(ECPoint[] p)
+        {
+            ECPoint P = p[0];
+            ECPoint _3P = P.Add(P).Add(P);
+            Assert.AreEqual(_3P, P.ThreeTimes(), "ThreeTimes incorrect");
+            Assert.AreEqual(_3P, P.TwicePlus(P), "TwicePlus incorrect");
+        }
+
+        /**
+         * Calls <code>implTestThreeTimes()</code> for <code>Fp</code> and
+         * <code>F2m</code>.
+         */
+        [Test]
+        public void TestThreeTimes()
+        {
+            implTestThreeTimes(Fp.p);
+            implTestThreeTimes(F2m.p);
+        }
+
         /**
          * Goes through all points on an elliptic curve and checks, if adding a
          * point <code>k</code>-times is the same as multiplying the point by