From 6e306046568f9a4d13639b913f0ff6d5879fa165 Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Wed, 23 Jul 2014 15:17:12 +0700 Subject: Add automatic EC point validation for decoded points and for multiplier outputs --- crypto/test/src/math/ec/test/ECPointTest.cs | 33 ++--------------------------- 1 file changed, 2 insertions(+), 31 deletions(-) (limited to 'crypto/test/src') diff --git a/crypto/test/src/math/ec/test/ECPointTest.cs b/crypto/test/src/math/ec/test/ECPointTest.cs index 1a23e0bc7..8430f437d 100644 --- a/crypto/test/src/math/ec/test/ECPointTest.cs +++ b/crypto/test/src/math/ec/test/ECPointTest.cs @@ -287,35 +287,6 @@ namespace Org.BouncyCastle.Math.EC.Tests } } - /** - * Simple shift-and-add multiplication. Serves as reference implementation - * to verify (possibly faster) implementations in - * {@link org.bouncycastle.math.ec.ECPoint ECPoint}. - * - * @param p - * The point to multiply. - * @param k - * The multiplier. - * @return The result of the point multiplication kP. - */ - private ECPoint Multiply(ECPoint p, BigInteger k) - { - ECPoint q = p.Curve.Infinity; - int t = k.BitLength; - for (int i = 0; i < t; i++) - { - if (i != 0) - { - p = p.Twice(); - } - if (k.TestBit(i)) - { - q = q.Add(p); - } - } - return q; - } - /** * Checks, if the point multiplication algorithm of the given point yields * the same result as point multiplication done by the reference @@ -331,7 +302,7 @@ namespace Org.BouncyCastle.Math.EC.Tests private void ImplTestMultiply(ECPoint p, int numBits) { BigInteger k = new BigInteger(numBits, secRand); - ECPoint reff = Multiply(p, k); + ECPoint reff = ECAlgorithms.ReferenceMultiply(p, k); ECPoint q = p.Multiply(k); AssertPointsEqual("ECPoint.Multiply is incorrect", reff, q); } @@ -355,7 +326,7 @@ namespace Org.BouncyCastle.Math.EC.Tests do { - ECPoint reff = Multiply(p, k); + ECPoint reff = ECAlgorithms.ReferenceMultiply(p, k); ECPoint q = p.Multiply(k); AssertPointsEqual("ECPoint.Multiply is incorrect", reff, q); k = k.Add(BigInteger.One); -- cgit 1.4.1