NormalizeAll() public method

public NormalizeAll ( NBitcoin.BouncyCastle.Math.EC.ECPoint points ) : void
points NBitcoin.BouncyCastle.Math.EC.ECPoint
return void
コード例 #1
0
        internal static ECPoint ImplShamirsTrickJsf(ECPoint P, BigInteger k, ECPoint Q, BigInteger l)
        {
            ECCurve curve    = P.Curve;
            ECPoint infinity = curve.Infinity;

            // TODO conjugate co-Z addition (ZADDC) can return both of these
            ECPoint PaddQ = P.Add(Q);
            ECPoint PsubQ = P.Subtract(Q);

            var points = new ECPoint[] { Q, PsubQ, P, PaddQ };

            curve.NormalizeAll(points);

            var table = new ECPoint[] {
                points[3].Negate(), points[2].Negate(), points[1].Negate(),
                points[0].Negate(), infinity, points[0],
                points[1], points[2], points[3]
            };

            byte[] jsf = WNafUtilities.GenerateJsf(k, l);

            ECPoint R = infinity;

            int i = jsf.Length;

            while (--i >= 0)
            {
                int jsfi = jsf[i];

                // NOTE: The shifting ensures the sign is extended correctly
                int kDigit = ((jsfi << 24) >> 28), lDigit = ((jsfi << 28) >> 28);

                int index = 4 + (kDigit * 3) + lDigit;
                R = R.TwicePlus(table[index]);
            }

            return(R);
        }