internal static ECPoint ImplSumOfMultiplies(ECPoint[] ps, ECPointMap pointMap, BigInteger[] ks)
        {
            int length = ps.Length;
            int num2   = length << 1;

            bool[]            negs  = new bool[num2];
            WNafPreCompInfo[] infos = new WNafPreCompInfo[num2];
            byte[][]          wnafs = new byte[num2][];
            for (int i = 0; i < length; i++)
            {
                int        index = i << 1;
                int        num5  = index + 1;
                BigInteger k     = ks[index];
                negs[index] = k.SignValue < 0;
                k           = k.Abs();
                BigInteger integer2 = ks[num5];
                negs[num5] = integer2.SignValue < 0;
                integer2   = integer2.Abs();
                int     width  = Math.Max(2, Math.Min(0x10, WNafUtilities.GetWindowSize(Math.Max(k.BitLength, integer2.BitLength))));
                ECPoint p      = ps[i];
                ECPoint point2 = WNafUtilities.MapPointWithPrecomp(p, width, true, pointMap);
                infos[index] = WNafUtilities.GetWNafPreCompInfo(p);
                infos[num5]  = WNafUtilities.GetWNafPreCompInfo(point2);
                wnafs[index] = WNafUtilities.GenerateWindowNaf(width, k);
                wnafs[num5]  = WNafUtilities.GenerateWindowNaf(width, integer2);
            }
            return(ImplSumOfMultiplies(negs, infos, wnafs));
        }
Beispiel #2
0
    internal static ECPoint ImplSumOfMultiplies(ECPoint[] ps, ECPointMap pointMap, BigInteger[] ks)
    {
        int num  = ps.Length;
        int num2 = num << 1;

        bool[]            array  = new bool[num2];
        WNafPreCompInfo[] array2 = new WNafPreCompInfo[num2];
        byte[][]          array3 = new byte[num2][];
        for (int i = 0; i < num; i++)
        {
            int        num3       = i << 1;
            int        num4       = num3 + 1;
            BigInteger bigInteger = ks[num3];
            array[num3] = (bigInteger.SignValue < 0);
            bigInteger  = bigInteger.Abs();
            BigInteger bigInteger2 = ks[num4];
            array[num4] = (bigInteger2.SignValue < 0);
            bigInteger2 = bigInteger2.Abs();
            int     width = Math.Max(2, Math.Min(16, WNafUtilities.GetWindowSize(Math.Max(bigInteger.BitLength, bigInteger2.BitLength))));
            ECPoint p     = ps[i];
            ECPoint p2    = WNafUtilities.MapPointWithPrecomp(p, width, includeNegated: true, pointMap);
            array2[num3] = WNafUtilities.GetWNafPreCompInfo(p);
            array2[num4] = WNafUtilities.GetWNafPreCompInfo(p2);
            array3[num3] = WNafUtilities.GenerateWindowNaf(width, bigInteger);
            array3[num4] = WNafUtilities.GenerateWindowNaf(width, bigInteger2);
        }
        return(ImplSumOfMultiplies(array, array2, array3));
    }
        internal static ECPoint ImplShamirsTrickWNaf(ECPoint P, BigInteger k, ECPointMap pointMapQ, BigInteger l)
        {
            bool flag  = k.SignValue < 0;
            bool flag2 = l.SignValue < 0;

            k = k.Abs();
            l = l.Abs();
            int             width           = Math.Max(2, Math.Min(0x10, WNafUtilities.GetWindowSize(Math.Max(k.BitLength, l.BitLength))));
            ECPoint         p               = WNafUtilities.MapPointWithPrecomp(P, width, true, pointMapQ);
            WNafPreCompInfo wNafPreCompInfo = WNafUtilities.GetWNafPreCompInfo(P);
            WNafPreCompInfo info2           = WNafUtilities.GetWNafPreCompInfo(p);

            ECPoint[] preCompP    = !flag ? wNafPreCompInfo.PreComp : wNafPreCompInfo.PreCompNeg;
            ECPoint[] preCompQ    = !flag2 ? info2.PreComp : info2.PreCompNeg;
            ECPoint[] preCompNegP = !flag ? wNafPreCompInfo.PreCompNeg : wNafPreCompInfo.PreComp;
            ECPoint[] preCompNegQ = !flag2 ? info2.PreCompNeg : info2.PreComp;
            byte[]    wnafP       = WNafUtilities.GenerateWindowNaf(width, k);
            byte[]    wnafQ       = WNafUtilities.GenerateWindowNaf(width, l);
            return(ImplShamirsTrickWNaf(preCompP, preCompNegP, wnafP, preCompQ, preCompNegQ, wnafQ));
        }
Beispiel #4
0
        internal static ECPoint ImplShamirsTrickWNaf(ECPoint P, BigInteger k, ECPointMap pointMapQ, BigInteger l)
        {
            bool negK = k.SignValue < 0, negL = l.SignValue < 0;

            k = k.Abs();
            l = l.Abs();

            int width = System.Math.Max(2, System.Math.Min(16, WNafUtilities.GetWindowSize(System.Math.Max(k.BitLength, l.BitLength))));

            ECPoint         Q     = WNafUtilities.MapPointWithPrecomp(P, width, true, pointMapQ);
            WNafPreCompInfo infoP = WNafUtilities.GetWNafPreCompInfo(P);
            WNafPreCompInfo infoQ = WNafUtilities.GetWNafPreCompInfo(Q);

            ECPoint[] preCompP    = negK ? infoP.PreCompNeg : infoP.PreComp;
            ECPoint[] preCompQ    = negL ? infoQ.PreCompNeg : infoQ.PreComp;
            ECPoint[] preCompNegP = negK ? infoP.PreComp : infoP.PreCompNeg;
            ECPoint[] preCompNegQ = negL ? infoQ.PreComp : infoQ.PreCompNeg;

            byte[] wnafP = WNafUtilities.GenerateWindowNaf(width, k);
            byte[] wnafQ = WNafUtilities.GenerateWindowNaf(width, l);

            return(ImplShamirsTrickWNaf(preCompP, preCompNegP, wnafP, preCompQ, preCompNegQ, wnafQ));
        }