Esempio n. 1
0
        /* f=f^e */
        /* Note that this method requires a lot of RAM! Better to use compressed XTR method, see FP4.java */
        public static FP12 GTPow(FP12 d, BIG e)
        {
            FP12 r;

            if (USE_GS_GT)
            {
                FP12[] g = new FP12[4];
                FP2    f = new FP2(new BIG(ROM.Fra), new BIG(ROM.Frb));
                BIG    q = new BIG(ROM.CURVE_Order);
                BIG    t = new BIG(0);
                int    i, np, nn;
                BIG[]  u = GS(e);

                g[0] = new FP12(d);
                for (i = 1; i < 4; i++)
                {
                    g[i] = new FP12(0);
                    g[i].Copy(g[i - 1]);
                    g[i].Frob(f);
                }

                for (i = 0; i < 4; i++)
                {
                    np = u[i].NBits();
                    t.Copy(BIG.ModNeg(u[i], q));
                    nn = t.NBits();
                    if (nn < np)
                    {
                        u[i].Copy(t);
                        g[i].Conj();
                    }

                    u[i].Norm();
                }

                r = FP12.Pow4(g, u);
            }
            else
            {
                r = d.Pow(e);
            }

            return(r);
        }