summary refs log tree commit diff
path: root/crypto/src/math/ec/SimpleLookupTable.cs
blob: f1e32f2150c80a68f559a8393aae3dbb0dc74d0f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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];
        }
    }
}