From 125e93ac90fab535316f55695f14dde8e9c76c97 Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Mon, 28 Dec 2015 14:59:52 +0700 Subject: Optimized Sqrt and Trace for custom binary curves --- crypto/test/src/math/ec/test/ECPointTest.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'crypto/test/src/math') diff --git a/crypto/test/src/math/ec/test/ECPointTest.cs b/crypto/test/src/math/ec/test/ECPointTest.cs index 3c10170f7..57f838f9f 100644 --- a/crypto/test/src/math/ec/test/ECPointTest.cs +++ b/crypto/test/src/math/ec/test/ECPointTest.cs @@ -437,6 +437,19 @@ namespace Org.BouncyCastle.Math.EC.Tests } } } + else if (ECAlgorithms.IsF2mCurve(c)) + { + int m = c.FieldSize; + BigInteger x = new BigInteger(m, secRand); + ECFieldElement fe = c.FromBigInteger(x); + for (int i = 0; i < 100; ++i) + { + ECFieldElement sq = fe.Square(); + ECFieldElement check = sq.Sqrt(); + Assert.AreEqual(fe, check); + fe = sq; + } + } } private void ImplAddSubtractMultiplyTwiceEncodingTestAllCoords(X9ECParameters x9ECParameters) -- cgit 1.4.1