예제 #1
0
        /* Multiply P by e in group G1 */
        public static ECP G1Mul(ECP P, BIG e)
        {
            ECP R;

            if (USE_GLV)
            {
                //P.affine();
                R = new ECP();
                R.Copy(P);
                int np, nn;
                ECP Q = new ECP();
                Q.Copy(P);
                Q.Affine();
                BIG   q   = new BIG(ROM.CURVE_Order);
                FP    cru = new FP(new BIG(ROM.CURVE_Cru));
                BIG   t   = new BIG(0);
                BIG[] u   = Glv(e);
                Q.GetX().Mul(cru);

                np = u[0].NBits();
                t.Copy(BIG.ModNeg(u[0], q));
                nn = t.NBits();
                if (nn < np)
                {
                    u[0].Copy(t);
                    R.Neg();
                }

                np = u[1].NBits();
                t.Copy(BIG.ModNeg(u[1], q));
                nn = t.NBits();
                if (nn < np)
                {
                    u[1].Copy(t);
                    Q.Neg();
                }

                u[0].Norm();
                u[1].Norm();
                R = R.Mul2(u[0], Q, u[1]);
            }
            else
            {
                R = P.Mul(e);
            }

            return(R);
        }