本文整理汇总了C++中ZZn2::set方法的典型用法代码示例。如果您正苦于以下问题:C++ ZZn2::set方法的具体用法?C++ ZZn2::set怎么用?C++ ZZn2::set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ZZn2
的用法示例。
在下文中一共展示了ZZn2::set方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: line
ZZn2 line(ECn& A,ECn& C,ECn& B,int type,ZZn& slope,ZZn& ex1,ZZn& ex2,ZZn& a,ZZn& d)
{
ZZn2 w;
ZZn x,y,z,t,n=a;
#ifdef AFFINE
extract(A,x,y);
n+=x; n*=slope;
w.set(y,-d); w-=n;
#endif
#ifdef PROJECTIVE
if (type==MR_ADD)
{
ZZn x2,y2,x3,z3;
extract(B,x2,y2);
extract(C,x3,x3,z3);
w.set(slope*(a+x2)-z3*y2,z3*d);
return w;
}
if (type==MR_DOUBLE)
{
ZZn x,y,x3,z3;
extract(A,x,y);
extract(C,x3,x3,z3);
w.set(-(slope*ex2)*a-slope*x+ex1,-(z3*ex2)*d);
return w;
}
#endif
return w;
}
示例2: line
ZZn2 line(ECn& A,ECn& C,ECn& B,int type,ZZn& slope,ZZn& ex1,ZZn& ex2,ZZn& Px,ZZn& Py)
{
ZZn2 w;
ZZn x,y,z3;
extractZ(C,z3);
if (type==MR_ADD)
{
extract(B,x,y);
w.set(slope*(x+Px)-z3*y,z3*Py);
}
if (type==MR_DOUBLE)
{
extract(A,x,y);
w.set(-(slope*ex2)*Px-slope*x+ex1,-(z3*ex2)*Py);
}
/*
extract(A,x,y,z);
x*=z; t=z; z*=z; z*=t; // 9 ZZn muls
n*=z; n+=x; n*=slope;
d*=z; w.set(-y,d);
extractZ(C,z3);
w*=z3; w+=n;
*/
// w.set(Px*z*z*z*slope+slope*x*z-y*z3,Py*z*z*z*z3);
return w;
}
示例3: set_frobenius_constant
void set_frobenius_constant(ZZn2 &X)
{
Big p=get_modulus();
switch (get_mip()->pmod8)
{
case 5:
X.set((Big)0,(Big)1); // = (sqrt(-2)^(p-1)/2
break;
case 3: // = (1+sqrt(-1))^(p-1)/2
case 7: // = (1+sqrt(-2))^(p-1)/2
X.set((Big)1,(Big)1);
default: break;
}
X=pow(X,(p-1)/2);
}
示例4: get_frobenius_constant
ZZn2 get_frobenius_constant()
{
ZZn2 Fr;
Big p=get_modulus();
switch (get_mip()->pmod8)
{
case 5:
Fr.set((Big)0,(Big)1); // = (sqrt(-2)^(p-1)/2
break;
case 3: // = (1+sqrt(-1))^(p-1)/2
case 7: // = (1+sqrt(-2))^(p-1)/2
Fr.set((Big)1,(Big)1);
default: break;
}
return pow(Fr,(p-1)/2);
}
示例5: memcpy
ZZn2
charToZZn2 (char *c, int *totLen)
{
ZZn2 z;
int len;
Big a,b;
char *orig = c;
memcpy (&len, c, sizeof (int));
c += sizeof (int);
a = from_binary (len, c);
c += len;
// cout << "chartozzn2 a: (" << len << ") "
// << a << "\n";
memcpy (&len, c, sizeof (int));
c += sizeof (int);
b = from_binary (len, c);
// cout << "chartozzn2 b: (" << len << ") "
// << b << "\n";
c += len;
z.set (a, b);
*totLen = c - orig;
return z;
}
示例6: gp
ZZn2 gp(ZZn* ptable,int &j,ZZn& Px,ZZn& Py)
{
ZZn2 w;
w.set(ptable[j]*Px+ptable[j+1],Py);
j+=2;
return w;
}
示例7: set_frobenius_constant
// set Frobenius constant - depends on embedding degree
void set_frobenius_constant(ZZn2 &X, int ed)
{
Big p=get_modulus();
switch (get_mip()->pmod8)
{
case 5:
X.set((Big)0,(Big)1); // = (sqrt(-2)^(p-1)/2
break;
case 3: // = (1+sqrt(-1))^(p-1)/2
X.set((Big)1,(Big)1);
break;
case 7:
X.set((Big)2,(Big)1); // = (2+sqrt(-1))^(p-1)/2
default: break;
}
if (ed==12) X=pow(X,(p-1)/6);
if (ed==24) X=pow(X,(p-7)/12);
if (ed==48) X=pow(X,(p-19)/24);
}
示例8: set_frobenius_constant
void set_frobenius_constant(ZZn2 &X)
{
Big p=get_modulus();
switch (get_mip()->pmod8)
{
case 5:
X.set((Big)0,(Big)1); // = (sqrt(sqrt(-2))^(p-1)/4
X=pow(X,(p-1)/4);
break;
case 3:
X.set((Big)1,(Big)1);
X=pow(X,(p-3)/4);
break;
case 7:
X.set((Big)2,(Big)1);
X=pow(X,(p-3)/4); // note that 4 does not divide p-1, so this is the best we can do...
default: break;
}
}
示例9: ecap
BOOL ecap(ECn& P,ECn& Q,Big& order,BOOL precomp,ZZn *store,ZZn2& res)
{
ZZn Qx;
ZZn2 Qy;
Big xx,yy;
Q.get(xx,yy);
Qx=-xx;
Qy.set((Big)0,yy);
return fast_tate_pairing(P,Qx,Qy,order,precomp,store,res);
}
示例10:
ECn2 hash_and_map2(char *ID)
{
int i;
ECn2 S;
ZZn2 X;
Big x0=H1(ID);
forever
{
x0+=1;
X.set((ZZn)1,(ZZn)x0);
if (!S.set(X)) continue;
break;
}
return S;
}
示例11: hash_and_map
void PFC::hash_and_map(G2& w,char *ID)
{
int i;
ZZn2 X;
Big x0=H1(ID);
forever
{
x0+=1;
X.set((ZZn)1,(ZZn)x0);
if (!w.g.set(X)) continue;
break;
}
map(w.g,*x,*frob);
}
示例12: while
ECn2 hash2(char *ID,Big cof2)
{
ECn2 T;
ZZn2 x;
Big x0,y0=0;
x0=H1(ID);
do
{
x.set(x0,y0);
x0+=1;
}
while (!is_on_curve(x));
T.set(x);
T*=cof2;
return T;
}
示例13: while
ECn2 hash2(char *ID)
{
ECn2 T;
ZZn2 x;
Big x0,y0=0;
x0=H1(ID);
do
{
x.set(x0,y0);
x0+=1;
}
while (!is_on_curve(x));
T.set(x);
// cout << "T= " << T << endl;
return T;
}
示例14: random
void PFC::random(G2& w)
{
int i;
ZZn2 X;
Big x0;
if (RNG==NULL) x0=rand(*mod);
else x0=strong_rand(RNG, *mod);
forever
{
x0+=1;
X.set((ZZn)1,(ZZn)x0);
if (!w.g.set(X)) continue;
break;
}
map(w.g,*x,*frob);
}
示例15:
ECn2 hash_and_map2(char *ID)
{
int i;
ECn2 S;
ZZn2 X;
Big x0=H1(ID);
forever
{
x0+=1;
X.set((ZZn)0,(ZZn)x0);
//cout << "X= " << X << endl;
if (!S.set(X)) continue;
break;
}
// cout << "S= " << S << endl;
return S;
}