Beispiel #1
0
/* this+=this */
    public int dbl()
    {
        if (INF)
        {
            return(-1);
        }
        if (y.iszilch())
        {
            inf();
            return(-1);
        }

        FP2 w1 = new FP2(x);
        FP2 w2 = new FP2(0);
        FP2 w3 = new FP2(x);
        FP2 w8 = new FP2(x);

        w1.sqr();
        w8.copy(w1);
        w8.imul(3);

        w2.copy(y);
        w2.sqr();
        w3.copy(x);
        w3.mul(w2);
        w3.imul(4);
        w1.copy(w3);
        w1.neg();
        //	w1.norm();

        x.copy(w8);
        x.sqr();
        x.add(w1);
        x.add(w1);
        x.norm();

        z.mul(y);
        z.add(z);

        w2.add(w2);
        w2.sqr();
        w2.add(w2);
        w3.sub(x);
        y.copy(w8);
        y.mul(w3);
        //	w2.norm();
        y.sub(w2);

        y.norm();
        z.norm();

        return(1);
    }
Beispiel #2
0
/* set this=-this */
    public void neg()
    {
        FP2 m = new FP2(a);
        FP2 t = new FP2(0);

        m.add(b);
        m.neg();
        m.norm();
        t.copy(m);
        t.add(b);
        b.copy(m);
        b.add(a);
        a.copy(t);
    }
Beispiel #3
0
/* Calculate RHS of twisted curve equation x^3+B/i */
    public static FP2 RHS(FP2 x)
    {
        x.norm();
        FP2 r = new FP2(x);

        r.sqr();
        FP2 b = new FP2(new BIG(ROM.CURVE_B));

        b.div_ip();
        r.mul(x);
        r.add(b);

        r.reduce();
        return(r);
    }
Beispiel #4
0
/* normalise all components of this mod Modulus */
    public void norm()
    {
        a.norm();
        b.norm();
    }