示例#1
0
/* construct this from (x,y) - but set to O if not on curve */
    public ECP2(FP2 ix, FP2 iy)
    {
        x = new FP2(ix);
        y = new FP2(iy);
        z = new FP2(1);
        FP2 rhs = RHS(x);
        FP2 y2  = new FP2(y);

        y2.sqr();
        if (y2.Equals(rhs))
        {
            INF = false;
        }
        else
        {
            x.zero();
            INF = true;
        }
    }
示例#2
0
/* Test if P == Q */
    public bool Equals(ECP2 Q)
    {
        if (is_infinity() && Q.is_infinity())
        {
            return(true);
        }
        if (is_infinity() || Q.is_infinity())
        {
            return(false);
        }

        FP2 zs2 = new FP2(z);

        zs2.sqr();
        FP2 zo2 = new FP2(Q.z);

        zo2.sqr();
        FP2 zs3 = new FP2(zs2);

        zs3.mul(z);
        FP2 zo3 = new FP2(zo2);

        zo3.mul(Q.z);
        zs2.mul(Q.x);
        zo2.mul(x);
        if (!zs2.Equals(zo2))
        {
            return(false);
        }
        zs3.mul(Q.y);
        zo3.mul(y);
        if (!zs3.Equals(zo3))
        {
            return(false);
        }

        return(true);
    }
示例#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);
    }
示例#4
0
 /* test this=x? */
 public bool Equals(FP4 x)
 {
     return(a.Equals(x.a) && b.Equals(x.b));
 }
示例#5
0
        /* test this==1 ? */
        public bool IsUnity()
        {
            FP2 one = new FP2(1);

            return(a.Equals(one) && b.IsZilch());
        }
示例#6
0
/* test this==1 ? */
    public bool isunity()
    {
        FP2 one = new FP2(1);

        return(a.Equals(one) && b.iszilch());
    }