summary refs log tree commit diff
path: root/crypto/src/math/ec/multiplier/ReferenceMultiplier.cs
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2014-01-23 18:21:40 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2014-01-23 18:21:40 +0700
commit0f05a8dc4b27623d96b08f7619c056a4e65baa9b (patch)
tree18169d7c4c8fbea895811eba8fbe7a9b9e6250ab /crypto/src/math/ec/multiplier/ReferenceMultiplier.cs
parentUse ImportPoint to make sure points are on same curve (diff)
downloadBouncyCastle.NET-ed25519-0f05a8dc4b27623d96b08f7619c056a4e65baa9b.tar.xz
Port of several interrelated things from Java build:
- Z coordinates for points
- More point normalization code
- Curve management of point precomp info
- Add WNafUtilities and use in multipliers/ECAlgorithms
- Make various fields/classes protected/public
Diffstat (limited to 'crypto/src/math/ec/multiplier/ReferenceMultiplier.cs')
-rw-r--r--crypto/src/math/ec/multiplier/ReferenceMultiplier.cs61
1 files changed, 34 insertions, 27 deletions
diff --git a/crypto/src/math/ec/multiplier/ReferenceMultiplier.cs b/crypto/src/math/ec/multiplier/ReferenceMultiplier.cs
index cdccffc2d..a3763848e 100644
--- a/crypto/src/math/ec/multiplier/ReferenceMultiplier.cs
+++ b/crypto/src/math/ec/multiplier/ReferenceMultiplier.cs
@@ -1,30 +1,37 @@
 namespace Org.BouncyCastle.Math.EC.Multiplier
 {
-	internal class ReferenceMultiplier
-		: ECMultiplier
-	{
-		/**
-		* 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 factor by which to multiply.
-		* @return The result of the point multiplication <code>k * p</code>.
-		*/
-		public ECPoint Multiply(ECPoint p, BigInteger k, PreCompInfo preCompInfo)
-		{
-			ECPoint q = p.Curve.Infinity;
-			int t = k.BitLength;
-			for (int i = 0; i < t; i++)
-			{
-				if (k.TestBit(i))
-				{
-					q = q.Add(p);
-				}
-				p = p.Twice();
-			}
-			return q;
-		}
-	}
+    public class ReferenceMultiplier
+        : ECMultiplier
+    {
+        /**
+         * 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 factor by which to multiply.
+         * @return The result of the point multiplication <code>k * p</code>.
+         */
+        public virtual ECPoint Multiply(ECPoint p, BigInteger k)
+        {
+            ECPoint q = p.Curve.Infinity;
+            int t = k.BitLength;
+            if (t > 0)
+            {
+                if (k.TestBit(0))
+                {
+                    q = p;
+                }
+                for (int i = 1; i < t; i++)
+                {
+                    p = p.Twice();
+                    if (k.TestBit(i))
+                    {
+                        q = q.Add(p);
+                    }
+                }
+            }
+            return q;
+        }
+    }
 }