Esempio n. 1
0
/* this=1/this */
    public void inverse()
    {
        norm();

        FP2 t1 = new FP2(a);
        FP2 t2 = new FP2(b);

        t1.sqr();
        t2.sqr();
        t2.mul_ip();
        t1.sub(t2);
        t1.inverse();
        a.mul(t1);
        t1.neg();
        b.mul(t1);
    }
Esempio n. 2
0
/* normalises m-array of ECP2 points. Requires work vector of m FP2s */

    public static void multiaffine(int m, ECP2[] P)
    {
        int i;
        FP2 t1 = new FP2(0);
        FP2 t2 = new FP2(0);

        FP2[] work = new FP2[m];
        work[0] = new FP2(1);
        work[1] = new FP2(P[0].z);
        for (i = 2; i < m; i++)
        {
            work[i] = new FP2(work[i - 1]);
            work[i].mul(P[i - 1].z);
        }

        t1.copy(work[m - 1]);
        t1.mul(P[m - 1].z);

        t1.inverse();

        t2.copy(P[m - 1].z);
        work[m - 1].mul(t1);

        for (i = m - 2;; i--)
        {
            if (i == 0)
            {
                work[0].copy(t1);
                work[0].mul(t2);
                break;
            }
            work[i].mul(t2);
            work[i].mul(t1);
            t2.mul(P[i].z);
        }
/* now work[] contains inverses of all Z coordinates */

        for (i = 0; i < m; i++)
        {
            P[i].z.one();
            t1.copy(work[i]);
            t1.sqr();
            P[i].x.mul(t1);
            t1.mul(work[i]);
            P[i].y.mul(t1);
        }
    }
Esempio n. 3
0
/* set to Affine - (x,y,z) to (x,y) */
    public void affine()
    {
        if (is_infinity())
        {
            return;
        }
        FP2 one = new FP2(1);

        if (z.Equals(one))
        {
            return;
        }
        z.inverse();

        FP2 z2 = new FP2(z);

        z2.sqr();
        x.mul(z2);
        x.reduce();
        y.mul(z2);
        y.mul(z);
        y.reduce();
        z.copy(one);
    }