summary refs log tree commit diff
path: root/crypto/src/math/ec/SimpleLookupTable.cs
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/src/math/ec/SimpleLookupTable.cs')
-rw-r--r--crypto/src/math/ec/SimpleLookupTable.cs35
1 files changed, 35 insertions, 0 deletions
diff --git a/crypto/src/math/ec/SimpleLookupTable.cs b/crypto/src/math/ec/SimpleLookupTable.cs
new file mode 100644
index 000000000..f1e32f215
--- /dev/null
+++ b/crypto/src/math/ec/SimpleLookupTable.cs
@@ -0,0 +1,35 @@
+using System;
+
+namespace Org.BouncyCastle.Math.EC
+{
+    public class SimpleLookupTable
+        : ECLookupTable
+    {
+        private static ECPoint[] Copy(ECPoint[] points, int off, int len)
+        {
+            ECPoint[] result = new ECPoint[len];
+            for (int i = 0; i < len; ++i)
+            {
+                result[i] = points[off + i];
+            }
+            return result;
+        }
+
+        private readonly ECPoint[] points;
+
+        public SimpleLookupTable(ECPoint[] points, int off, int len)
+        {
+            this.points = Copy(points, off, len);
+        }
+
+        public virtual int Size
+        {
+            get { return points.Length; }
+        }
+
+        public virtual ECPoint Lookup(int index)
+        {
+            return points[index];
+        }
+    }
+}