Beispiel #1
0
        /* this=this^e */
        public FP4 Pow(BIG e)
        {
            Norm();
            e.Norm();
            FP4 w = new FP4(this);
            BIG z = new BIG(e);
            FP4 r = new FP4(1);

            while (true)
            {
                int bt = z.Parity();
                z.FShr(1);
                if (bt == 1)
                {
                    r.Mul(w);
                }
                if (z.IsZilch())
                {
                    break;
                }
                w.Sqr();
            }
            r.Reduce();
            return(r);
        }
Beispiel #2
0
        public FP4 ComPow(BIG e, BIG r)
        {
            FP12 g1 = new FP12(0);
            FP12 g2 = new FP12(0);
            FP2  f  = new FP2(new BIG(ROM.Fra), new BIG(ROM.Frb));
            BIG  q  = new BIG(ROM.Modulus);

            BIG m = new BIG(q);

            m.Mod(r);

            BIG a = new BIG(e);

            a.Mod(m);

            BIG b = new BIG(e);

            b.Div(m);

            g1.Copy(this);
            g2.Copy(this);

            FP4 c = g1.Trace();

            if (b.IsZilch())
            {
                c = c.Xtr_Pow(e);
                return(c);
            }

            g2.Frob(f);
            FP4 cp = g2.Trace();

            g1.Conj();
            g2.mul(g1);
            FP4 cpm1 = g2.Trace();

            g2.mul(g1);
            FP4 cpm2 = g2.Trace();

            c = c.Xtr_Pow2(cp, cpm1, cpm2, a, b);

            return(c);
        }