From 47d13b5a8d368ffc048e2804cf24ca3b66b8ecae Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Wed, 22 Jan 2014 10:51:57 +0700 Subject: Implement TwicePlus optimization in Fp curves --- crypto/test/src/math/ec/test/ECPointTest.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'crypto/test') 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 implTestThreeTimes() for Fp and + * F2m. + */ + [Test] + public void TestThreeTimes() + { + implTestThreeTimes(Fp.p); + implTestThreeTimes(F2m.p); + } + /** * Goes through all points on an elliptic curve and checks, if adding a * point k-times is the same as multiplying the point by -- cgit 1.5.1