本文整理汇总了C++中ZZn2类的典型用法代码示例。如果您正苦于以下问题:C++ ZZn2类的具体用法?C++ ZZn2怎么用?C++ ZZn2使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ZZn2类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: 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;
}
开发者ID:Ibrgomaa,项目名称:MIRACL,代码行数:7,代码来源:cp_pair.cpp
示例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;
}
开发者ID:Ibrgomaa,项目名称:MIRACL,代码行数:30,代码来源:cp_pair.cpp
示例3: H2
Big H2(ZZn6 y)
{ // Hash and compress an Fp6 to a big number
sha sh;
ZZn u,v,w;
ZZn2 x;
Big a,h,p,xx[2];
char s[HASH_LEN];
int i,j,m;
shs_init(&sh);
y.get(x);
x.get(u,v);
xx[0]=u; xx[1]=v;
for (i=0;i<2;i++)
{
a=xx[i];
while (a>0)
{
m=a%256;
shs_process(&sh,m);
a/=256;
}
}
shs_hash(&sh,s);
h=from_binary(HASH_LEN,s);
return h;
}
开发者ID:asgene,项目名称:sm2,代码行数:28,代码来源:ake6mnta.cpp
示例4: multi_miller
GT PFC::multi_miller(int n,G1** QQ,G1** PP)
{
GT z;
ZZn *Px,*Py;
int i,j,*k,nb;
ECn *Q,*A;
ECn P;
ZZn2 res;
Big iters=*ord-1;
Px=new ZZn[n];
Py=new ZZn[n];
Q=new ECn[n];
A=new ECn[n];
k=new int[n];
nb=bits(iters);
res=1;
for (j=0;j<n;j++)
{
k[j]=0;
P=PP[j]->g; normalise(P); Q[j]=QQ[j]->g; normalise(Q[j]);
extract(P,Px[j],Py[j]);
}
for (j=0;j<n;j++) A[j]=Q[j];
for (i=nb-2;i>=0;i--)
{
res*=res;
for (j=0;j<n;j++)
{
if (QQ[j]->ptable==NULL)
res*=g(A[j],A[j],Px[j],Py[j]);
else
res*=gp(QQ[j]->ptable,k[j],Px[j],Py[j]);
}
if (bit(iters,i)==1)
for (j=0;j<n;j++)
{
if (QQ[j]->ptable==NULL)
res*=g(A[j],Q[j],Px[j],Py[j]);
else
res*=gp(QQ[j]->ptable,k[j],Px[j],Py[j]);
}
if (res.iszero()) return 0;
}
delete [] k;
delete [] A;
delete [] Q;
delete [] Py;
delete [] Px;
z.g=res;
return z;
}
开发者ID:C00IHandLuke,项目名称:CPEN442VPN,代码行数:58,代码来源:ssp_pair.cpp
示例5: 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);
}
开发者ID:CodeMason,项目名称:skype_part3_source,代码行数:13,代码来源:ibe_exp.cpp
示例6: 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);
}
开发者ID:ferozsalam,项目名称:FYP,代码行数:15,代码来源:ake4mntt.cpp
示例7: H2
int H2(ZZn2 x,char *s)
{ // Hash an Fp2 to an n-byte string s[.]. Return n
sha256 sh;
Big a,b;
int m;
shs256_init(&sh);
x.get(a,b);
while (a>0)
{
m=a%256;
shs256_process(&sh,m);
a/=256;
}
while (b>0)
{
m=b%256;
shs256_process(&sh,m);
b/=256;
}
shs256_hash(&sh,s);
return HASH_LEN;
}
开发者ID:asgene,项目名称:sm2,代码行数:25,代码来源:ibe_dec.cpp
示例8: hash_and_map2
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;
}
开发者ID:stoneskill,项目名称:mix-O_AllWin,代码行数:16,代码来源:ake12bnx.cpp
示例9: pow
ZZn2 pow(const ZZn2& x,const Big& k)
{
int i,j,nb,n,nbw,nzs;
ZZn2 u,u2,t[16];
if (x.iszero()) return (ZZn2)0;
if (k==0) return (ZZn2)1;
u=x;
if (k==1) return u;
//
// Prepare table for windowing
//
u2=(u*u);
t[0]=u;
for (i=1;i<16;i++)
t[i]=u2*t[i-1];
// Left to right method - with windows
nb=bits(k);
if (nb>1) for (i=nb-2;i>=0;)
{
n=window(k,i,&nbw,&nzs,5);
for (j=0;j<nbw;j++) u*=u;
if (n>0) u*=t[n/2];
i-=nbw;
if (nzs)
{
for (j=0;j<nzs;j++) u*=u;
i-=nzs;
}
}
return u;
}
开发者ID:BingyZhang,项目名称:CommutEnc,代码行数:35,代码来源:zzn2.cpp
示例10: H2
Big H2(ZZn2 x)
{ // Hash an Fp2 to a big number
sha sh;
Big a,u,v;
char s[HASH_LEN];
int m;
shs_init(&sh);
x.get(u,v);
a=u;
while (a>0)
{
m=a%256;
shs_process(&sh,m);
a/=256;
}
a=v;
while (a>0)
{
m=a%256;
shs_process(&sh,m);
a/=256;
}
shs_hash(&sh,s);
a=from_binary(HASH_LEN,s);
return a;
}
开发者ID:CodeMason,项目名称:skype_part3_source,代码行数:28,代码来源:hess4.cpp
示例11: 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);
}
开发者ID:CodeMason,项目名称:skype_part3_source,代码行数:16,代码来源:hess4.cpp
示例12: g
void g(ECn& A,ECn& B,ZZn& Qx,ZZn2& Qy,ZZn2& num,BOOL precomp,ZZn* store,int& ptr)
{
ZZn lam,x,y,m,nx;
ZZn2 u;
big pointer;
if (num.iszero()) return;
if (!precomp)
{ // Store line start point and slope.
// Evaluate line from A, and then evaluate vertical through destination
extract(A,x,y);
pointer=A.add(B);
if (pointer==NULL) {num=0; return;}
lam=pointer;
store[ptr++]=x; store[ptr++]=y; store[ptr++]=lam;
if (A.iszero()) return;
// line
m=Qx; u=Qy;
m-=x; m*=lam; // 1 ZZn muls
u-=y; u-=m;
}
else
{ // extract precalculated values from the store.... - nx is a peek ahead
x=store[ptr++]; y=store[ptr++]; lam=store[ptr++]; nx=store[ptr];
if (nx.iszero()) return;
m=Qx; u=Qy;
m-=x; m*=lam; // 1 ZZn muls
u-=y; u-=m;
}
num*=u; // 3 ZZn muls
}
开发者ID:karllen,项目名称:Windows_Program,代码行数:34,代码来源:IBE_EXP.CPP
示例13: tate
BOOL tate(ECn& P,ECn& Q,Big& q,ZZn& r)
{
int i,nb,qnr;
ZZn2 res;
ZZn a,d;
Big p,x,y,n;
ECn A;
p=get_modulus();
// Note that q is fixed - q.P=2^17*(2^142.P + P) + P
normalise(Q); // make sure z=1
extract(Q,a,d);
qnr=get_mip()->qnr;
if (qnr==-2)
{
a=a/2; /* Convert off twist */
d=d/4;
}
normalise(P);
A=P; // remember A
n=q-1;
nb=bits(n);
res=1;
for (i=nb-2;i>=0;i--)
{
res*=res; // 2 modmul
res*=g(A,A,a,d);
if (bit(n,i))
res*=g(A,P,a,d); // executed just once
}
if (A != -P || res.iszero()) return FALSE;
res=conj(res)/res; // raise to power of (p-1)
r=powl(real(res),(p+1)/q); // raise to power of (p+1)/q
if (r==1) return FALSE;
return TRUE;
}
开发者ID:J0s3f,项目名称:FiSH-irssi,代码行数:47,代码来源:ake2sst.cpp
示例14: 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);
}
开发者ID:BingyZhang,项目名称:CommutEnc,代码行数:17,代码来源:bn_pair.cpp
示例15: hash2
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;
}
开发者ID:CodeMason,项目名称:skype_part3_source,代码行数:18,代码来源:hess4.cpp
示例16: 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);
}
开发者ID:apache,项目名称:incubator-milagro-crypto,代码行数:20,代码来源:romgen.cpp
示例17: 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);
}
开发者ID:BingyZhang,项目名称:CommutEnc,代码行数:19,代码来源:bn_pair.cpp
示例18: hash2
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;
}
开发者ID:ferozsalam,项目名称:FYP,代码行数:19,代码来源:ake4mntt.cpp
示例19: 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;
}
}
开发者ID:ferozsalam,项目名称:FYP,代码行数:19,代码来源:ake8cpt.cpp
示例20: fast_tate_pairing
BOOL fast_tate_pairing(ECn& P,ZZn& Qx,ZZn2& Qy,Big& q,BOOL precomp,ZZn* store,ZZn2& res)
{
int i,ptr=0;
Big p;
ECn A;
if (!precomp) get_mip()->coord=MR_AFFINE; // precompute using AFFINE
// coordinates
res=1;
// q.P = 2^17*(2^142.P +P) + P
A=P;
for (i=0;i<142;i++)
{
res*=res;
g(A,A,Qx,Qy,res,precomp,store,ptr);
} // 6 ZZn muls after first
g(A,P,Qx,Qy,res,precomp,store,ptr);
for (i=0;i<17;i++)
{
res*=res;
g(A,A,Qx,Qy,res,precomp,store,ptr);
}
g(A,P,Qx,Qy,res,precomp,store,ptr);
if (res.iszero()) return FALSE;
if (!precomp)
{
if (!A.iszero()) return FALSE;
get_mip()->coord=MR_PROJECTIVE; // reset
}
p=get_modulus(); // get p
res= pow(res,(p+1)/q); // raise to power of (p^2-1)/q
res=conj(res)/res;
if (res.isunity()) return FALSE;
return TRUE;
}
开发者ID:karllen,项目名称:Windows_Program,代码行数:42,代码来源:IBE_EXP.CPP
注:本文中的ZZn2类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论