本文整理汇总了C++中ECn类的典型用法代码示例。如果您正苦于以下问题:C++ ECn类的具体用法?C++ ECn怎么用?C++ ECn使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ECn类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: g
ZZn6 g(ECn& A,ECn& B,ECn& C,ECn& D,ZZn3& Qx,ZZn3& Qy,ZZn3& Sx,ZZn3& Sy)
{
ZZn6 u;
ZZn lam;
big ptr;
ECn P;
P=A;
ptr=A.add(B);
if (ptr==NULL) return (ZZn6)1;
lam=ptr;
u=line(P,A,lam,Qx,Qy);
P=C;
ptr=C.add(D);
if (ptr==NULL) return (ZZn6)1;
lam=ptr;
return u*line(P,C,lam,Sx,Sy);
}
示例3: g
ZZn6 g(ECn& A,ECn& B,ECn& C,ECn& D,ZZn3& Qx,ZZn3& Qy,ZZn3& Sx,ZZn3& Sy)
{
ZZn6 u;
int type;
ZZn lam;
big ptr;
ECn P;
P=A;
type=A.add(B,&ptr);
if (!type) return (ZZn6)1;
lam=ptr;
u=line(P,A,lam,Qx,Qy);
P=C;
type=C.add(D,&ptr);
if (!type) return (ZZn6)1;
lam=ptr;
return u*line(P,C,lam,Sx,Sy);
}
示例4: fast_tate_pairing
BOOL fast_tate_pairing(ECn& P,ZZn2& Qx,ZZn2& Qy,Big& q,ZZn2& res)
{
int i,nb;
Big n,p;
ECn A;
// q.P = 2^17*(2^142.P +P) + P
res=1;
A=P; // reset A
#ifdef SCOTT
// we can avoid last iteration..
n=q-1;
#else
n=q;
#endif
nb=bits(n);
for (i=nb-2;i>=0;i--)
{
res*=res;
g(A,A,Qx,Qy,res);
if (bit(n,i))
g(A,P,Qx,Qy,res);
}
#ifdef SCOTT
if (A!=-P || res.iszero()) return FALSE;
#else
if (!A.iszero()) return FALSE;
#endif
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;
}
示例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);
}
示例6: PointToByteArray
void BaseOT::PointToByteArray(BYTE* pBufIdx, int field_size, ECn &point)
{
int itmp;
Big bigtmp;
//compress to x-point and y-bit and convert to byte array
itmp = point.get(bigtmp);
//first store the y-bit
pBufIdx[0] = (BYTE) (itmp & 0x01);
//then store the x-coordinate (sec-param/8 + 4 byte size)
big_to_bytes(field_size, bigtmp.getbig(), (char*) pBufIdx+1, true);
}
示例7: ecap
BOOL ecap(ECn& P,ECn& Q,Big& order,ZZn& zeta,Big& cofactor,ZZn& res)
{
BOOL Ok;
Big Qx,Qy;
ZZn bQx;
Q.get(Qx,Qy);
bQx=zeta*zeta*(ZZn)Qx;
Ok=fast_tate_pairing(P,(ZZn)Qx,(ZZn)Qy,bQx,order,cofactor,res);
if (Ok) return TRUE;
return FALSE;
}
示例8: ecap
BOOL ecap(ECn3& P,ECn& Q,Big& x,ZZn &X,ZZn18& r)
{
BOOL Ok;
Big xx,yy;
ZZn Qx,Qy;
Q.get(xx,yy); Qx=xx; Qy=yy;
Ok=fast_pairing(P,Qx,Qy,x,X,r);
if (Ok) return TRUE;
return FALSE;
}
示例9: g
void g(ECn& A,ECn& B,ZZn2& Qx,ZZn& Qy,ZZn2& num,ZZn2& denom,int as,BOOL first)
{
ZZn lam,mQy;
ZZn2 d,u;
big ptr;
ECn P=A;
if (as==ADD)
{ // Evaluate line from A, and then evaluate vertical through destination
ptr=A.add(B);
if (ptr==NULL) { num=0; return; }
else lam=ptr;
if (A.iszero()) { u=vertical(P,Qx); d=1; }
else
{
u=line(P,A,lam,Qx,Qy);
d=vertical(A,Qx);
}
}
else // as==SUB
{ // Evaluate Vertical at A, and then line from A to destination
// (Note swap num and denom, Qy=-Qy, process lines "backwards")
u=vertical(A,Qx);
ptr=A.sub(B);
if (ptr==NULL) { num=0; return; }
else lam=ptr;
if (A.iszero()) { d=u; }
else
{
mQy=-Qy;
d=line(P,A,lam,Qx,mQy);
}
}
if (first) {num= u; denom= d; }
else {num*=u; denom*=d; } // 6 ZZn muls
}
示例10: g
ZZn8 g(ECn& A,ECn& B,ZZn4& Qx,ZZn4& Qy)
{
int type;
ZZn lam;
big ptr;
ECn P=A;
// Evaluate line from A
type=A.add(B,&ptr);
if (!type) return (ZZn8)1;
lam=ptr;
return line(P,A,lam,Qx,Qy);
}
示例11: ecn_from_string
ECn CvSakke::ecn_from_string( const String& str )
{
ECn result;
size_t pos = str.find(",");
if ( pos == String::npos )
return result;
Big x, y;
String decoded;
CvBase64::Decode( str.substr( 1, pos-1 ), decoded );
x = from_binary( (int)decoded.size(), (char*)decoded.data() );
decoded.clear();
CvBase64::Decode( str.substr( pos+1, BN_BYTES ), decoded );
y = from_binary( (int)decoded.size(), (char*)decoded.data() );
result.set( x, y );
return result;
}
示例12: g
ZZn4 g(ECn& A,ECn& B,ZZn2& Qx,ZZn2& Qy)
{
int type;
ZZn lam,extra1,extra2;
big ptr,ex1,ex2;
ECn P=A;
// Evaluate line from A
type=A.add(B,&ptr,&ex1,&ex2);
if (!type) return (ZZn4)1;
lam=ptr;
extra1=ex1;
extra2=ex2;
return line(P,A,B,type,lam,extra1,extra2,Qx,Qy);
}
示例13: g
ZZn2 g(ECn& A,ECn& B,ZZn& Px,ZZn& Py)
{
int type;
ZZn lam,extra1,extra2;
ZZn2 u;
ECn P=A;
big ptr,ex1,ex2;
type=A.add(B,&ptr,&ex1,&ex2);
if (!type) return (ZZn2)1;
lam=ptr;
extra1=ex1;
extra2=ex2;
return line(P,A,B,type,lam,extra1,extra2,Px,Py);
}
示例14: g
ZZn2 g(ECn& A,ECn& B,ZZn& a,ZZn& d)
{
int type;
ZZn lam,extra1,extra2;
ECn P=A;
big ptr,ex1,ex2;
// Evaluate line from A - lam is line slope
type=A.add(B,&ptr,&ex1,&ex2);
if (!type) return (ZZn2)1;
lam=ptr; // in projective case slope = lam/A.z
extra1=ex1;
extra2=ex2;
return line(P,A,B,type,lam,extra1,extra2,a,d);
}
示例15: ecap
BOOL ecap(ECn2& P,ECn& Q,Big& x,ZZn2 &X,ZZn12& r)
{
BOOL Ok;
Big xx,yy;
ZZn Qx,Qy;
P.norm();
cout<<"P:"<<P<<endl;
Q.get(xx,yy); Qx=xx; Qy=yy;
Ok=fast_pairing(P,Qx,Qy,x,X,r);
if (Ok) return TRUE;
return FALSE;
}