Beispiel #1
0
    internal static ECPoint ImplSumOfMultipliesGlv(ECPoint[] ps, BigInteger[] ks, GlvEndomorphism glvEndomorphism)
    {
        BigInteger order = ps[0].Curve.Order;
        int        num   = ps.Length;

        BigInteger[] array = new BigInteger[num << 1];
        int          i     = 0;
        int          num2  = 0;

        for (; i < num; i++)
        {
            BigInteger[] array2 = glvEndomorphism.DecomposeScalar(ks[i].Mod(order));
            array[num2++] = array2[0];
            array[num2++] = array2[1];
        }
        ECPointMap pointMap = glvEndomorphism.PointMap;

        if (glvEndomorphism.HasEfficientPointMap)
        {
            return(ImplSumOfMultiplies(ps, pointMap, array));
        }
        ECPoint[] array3 = new ECPoint[num << 1];
        int       j      = 0;
        int       num5   = 0;

        for (; j < num; j++)
        {
            ECPoint eCPoint  = ps[j];
            ECPoint eCPoint2 = pointMap.Map(eCPoint);
            array3[num5++] = eCPoint;
            array3[num5++] = eCPoint2;
        }
        return(ImplSumOfMultiplies(array3, array));
    }
Beispiel #2
0
        internal static ECPoint ImplSumOfMultipliesGlv(ECPoint[] ps, BigInteger[] ks, GlvEndomorphism glvEndomorphism)
        {
            BigInteger n = ps[0].Curve.Order;

            int len = ps.Length;

            BigInteger[] abs = new BigInteger[len << 1];
            for (int i = 0, j = 0; i < len; ++i)
            {
                BigInteger[] ab = glvEndomorphism.DecomposeScalar(ks[i].Mod(n));
                abs[j++] = ab[0];
                abs[j++] = ab[1];
            }

            ECPointMap pointMap = glvEndomorphism.PointMap;

            if (glvEndomorphism.HasEfficientPointMap)
            {
                return(ECAlgorithms.ImplSumOfMultiplies(ps, pointMap, abs));
            }

            ECPoint[] pqs = new ECPoint[len << 1];
            for (int i = 0, j = 0; i < len; ++i)
            {
                ECPoint p = ps[i], q = pointMap.Map(p);
                pqs[j++] = p;
                pqs[j++] = q;
            }

            return(ECAlgorithms.ImplSumOfMultiplies(pqs, abs));
        }
        internal static ECPoint ImplSumOfMultipliesGlv(ECPoint[] ps, BigInteger[] ks, GlvEndomorphism glvEndomorphism)
        {
            BigInteger n = ps[0].Curve.Order;

            int len = ps.Length;

            BigInteger[] abs = new BigInteger[len << 1];
            for (int i = 0, j = 0; i < len; ++i)
            {
                BigInteger[] ab = glvEndomorphism.DecomposeScalar(ks[i].Mod(n));
                abs[j++] = ab[0];
                abs[j++] = ab[1];
            }

            if (glvEndomorphism.HasEfficientPointMap)
            {
                return(ImplSumOfMultiplies(glvEndomorphism, ps, abs));
            }

            ECPoint[] pqs = new ECPoint[len << 1];
            for (int i = 0, j = 0; i < len; ++i)
            {
                ECPoint p = ps[i];
                ECPoint q = EndoUtilities.MapPoint(glvEndomorphism, p);
                pqs[j++] = p;
                pqs[j++] = q;
            }

            return(ImplSumOfMultiplies(pqs, abs));
        }
Beispiel #4
0
        protected override ECPoint MultiplyPositive(ECPoint p, BigInteger k)
        {
            if (!curve.Equals(p.Curve))
            {
                throw new InvalidOperationException();
            }
            BigInteger order = p.Curve.Order;

            BigInteger[] array    = glvEndomorphism.DecomposeScalar(k.Mod(order));
            BigInteger   k2       = array[0];
            BigInteger   l        = array[1];
            ECPointMap   pointMap = glvEndomorphism.PointMap;

            if (glvEndomorphism.HasEfficientPointMap)
            {
                return(ECAlgorithms.ImplShamirsTrickWNaf(p, k2, pointMap, l));
            }
            return(ECAlgorithms.ImplShamirsTrickWNaf(p, k2, pointMap.Map(p), l));
        }
Beispiel #5
0
        protected override ECPoint MultiplyPositive(ECPoint p, BigInteger k)
        {
            if (!curve.Equals(p.Curve))
            {
                throw new InvalidOperationException();
            }

            BigInteger n = p.Curve.Order;

            BigInteger[] ab = glvEndomorphism.DecomposeScalar(k.Mod(n));
            BigInteger   a = ab[0], b = ab[1];

            if (glvEndomorphism.HasEfficientPointMap)
            {
                return(ECAlgorithms.ImplShamirsTrickWNaf(glvEndomorphism, p, a, b));
            }

            ECPoint q = EndoUtilities.MapPoint(glvEndomorphism, p);

            return(ECAlgorithms.ImplShamirsTrickWNaf(p, a, q, b));
        }
        internal static ECPoint ImplSumOfMultipliesGlv(ECPoint[] ps, BigInteger[] ks, GlvEndomorphism glvEndomorphism)
        {
            BigInteger order  = ps[0].Curve.Order;
            int        length = ps.Length;

            BigInteger[] integerArray = new BigInteger[length << 1];
            int          index        = 0;
            int          num3         = 0;

            while (index < length)
            {
                BigInteger[] integerArray2 = glvEndomorphism.DecomposeScalar(ks[index].Mod(order));
                integerArray[num3++] = integerArray2[0];
                integerArray[num3++] = integerArray2[1];
                index++;
            }
            ECPointMap pointMap = glvEndomorphism.PointMap;

            if (glvEndomorphism.HasEfficientPointMap)
            {
                return(ImplSumOfMultiplies(ps, pointMap, integerArray));
            }
            ECPoint[] pointArray = new ECPoint[length << 1];
            int       num4       = 0;
            int       num5       = 0;

            while (num4 < length)
            {
                ECPoint p      = ps[num4];
                ECPoint point2 = pointMap.Map(p);
                pointArray[num5++] = p;
                pointArray[num5++] = point2;
                num4++;
            }
            return(ImplSumOfMultiplies(pointArray, integerArray));
        }
        internal static ECPoint ImplSumOfMultipliesGlv(ECPoint[] ps, BigInteger[] ks, GlvEndomorphism glvEndomorphism)
        {
            BigInteger n = ps[0].Curve.Order;

            int len = ps.Length;

            BigInteger[] abs = new BigInteger[len << 1];
            for (int i = 0, j = 0; i < len; ++i)
            {
                BigInteger[] ab = glvEndomorphism.DecomposeScalar(ks[i].Mod(n));
                abs[j++] = ab[0];
                abs[j++] = ab[1];
            }

            ECPointMap pointMap = glvEndomorphism.PointMap;
            if (glvEndomorphism.HasEfficientPointMap)
            {
                return ECAlgorithms.ImplSumOfMultiplies(ps, pointMap, abs);
            }

            ECPoint[] pqs = new ECPoint[len << 1];
            for (int i = 0, j = 0; i < len; ++i)
            {
                ECPoint p = ps[i], q = pointMap.Map(p);
                pqs[j++] = p;
                pqs[j++] = q;
            }

            return ECAlgorithms.ImplSumOfMultiplies(pqs, abs);
        }