Example #1
0
ZZn6 line(ECn3& A,ECn3& C,ECn3& B,int type,ZZn3& slope,ZZn3& ex1,ZZn3& ex2,ZZn& Px,ZZn& Py)
{
    ZZn6 w;
	ZZn3 d;
#ifdef AFFINE
    ZZn3 x,y;
    A.get(x,y);
    d.set1(Py);
	w=shuffle(y-slope*(Px+x),d);

#endif
#ifdef PROJECTIVE
	ZZn3 x,y,z,z3,t;
	C.getZ(z3);
	d.set1(Py);

	if (type==MR_ADD)
	{ // exploit that B is in affine
		ZZn3 x2,y2;
		B.get(x2,y2);
		y2*=z3; d*=z3; 
		w=shuffle(y2-slope*(Px+x2),d);
	}
	if (type==MR_DOUBLE)
	{ // use extra information from point doubling
		A.get(x,y,z);
		w=shuffle(ex1-slope*(Px*ex2+x),d*z3*ex2);	
	}
#endif

    return w;
}
Example #2
0
ZZn6 gp(ZZn3* ptable,int &j,ZZn& Px,ZZn& Py)
{
	ZZn6 w;
	ZZn3 d;
	d.set1(Py);
	w=shuffle(ptable[j]*Px+ptable[j+1],d);
	j+=2;
	return w;
}
Example #3
0
ZZn3 txd(const ZZn3& w)
{
    ZZn3 u;
    ZZn wa,wb,wc;
    w.get(wa,wb,wc);

    u.set(wb,wc,(wa/get_mip()->cnr));

    return u;
}
Example #4
0
void unshuffle(ZZn6 &S,ZZn3 &first,ZZn3 &second)
{ // unshuffle a ZZn6 into two ZZn3's 
	ZZn x0,x1,x2,x3,x4,x5;
	ZZn2 t0,t1,t2;
	S.get(t0,t1,t2);
	t0.get(x0,x3);
	t1.get(x1,x4);
	t2.get(x2,x5);
	first.set(x0,x2,x4);
	second.set(x1,x3,x5);
}
Example #5
0
ZZn6 shuffle(ZZn3 &first, ZZn3 &second)
{ // shuffle from a pair ZZn3's to three ZZn2's, as required by ZZn6
	ZZn6 w;
	ZZn x0,x1,x2,x3,x4,x5;
	ZZn2 t0,t1,t2;
	first.get(x0,x2,x4);
	second.get(x1,x3,x5);
	t0.set(x0,x3);
	t1.set(x1,x4);
	t2.set(x2,x5);
	w.set(t0,t1,t2);
	return w;
}
Example #6
0
void PFC::hash_and_map(G2& w,char *ID)
{
    int i;
    ZZn3 XX;
	Big X=*x;
 
    Big x0=H1(ID);
    forever
    {
        x0+=1;
        XX.set((ZZn)0,(ZZn)x0,(ZZn)0);
        if (!w.g.set(XX)) continue;
        break;
    }
	w.g=HashG2(w.g,X,*frob);
}
Example #7
0
void PFC::random(G2& w)
{
    int i;
    ZZn3 XX;
	Big X=*x;
 
    Big x0=rand(*mod);
    forever
    {
        x0+=1;
        XX.set2((ZZn)x0);
        if (!w.g.set(XX)) continue;

        break;
    }
	map(w.g,X,*frob);
}
Example #8
0
ECn3 hash_and_map3(char *ID)
{
    int i;
    ECn3 S;
    ZZn3 X;
 
    Big x0=H1(ID);
    forever
    {
        x0+=1;
        X.set((ZZn)0,(ZZn)x0,(ZZn)0);
        if (!S.set(X)) continue;
        break;
    }
  
    return S;
}     
Example #9
0
void PFC::random(G2 &w)
{
    int i;
    ZZn3 XX;
	Big X=*x;
 
    Big x0=rand(*mod);
    forever
    {
        x0+=1;
        XX.set((ZZn)0,(ZZn)x0,(ZZn)0);
        if (!w.g.set(X)) continue;
        break;
    }

	w.g=HashG2(w.g,X,*frob);
}
Example #10
0
BOOL ECn3::set(const ZZn3& xx)
{ 
	ZZn3 w;

	w=rhs(xx);

	if (!w.iszero())
	{
		w=sqrt(w); 
		if (w.iszero()) return FALSE;
	}

	x=xx;
	y=w;

	marker=MR_EPOINT_NORMALIZED;
	return TRUE;
}
Example #11
0
ECn3 hash_and_map3(char *ID)
{
    int i;
    ECn3 S;
    ZZn3 X;
 
    Big x0=H1(ID);
    forever
    {
        x0+=1;
        X.set2((ZZn)x0);
        if (!S.set(X)) continue;

        break;
    }

//    cout << "S= " << S << endl;
    return S;
}