本文整理汇总了C++中ECn2::set方法的典型用法代码示例。如果您正苦于以下问题:C++ ECn2::set方法的具体用法?C++ ECn2::set怎么用?C++ ECn2::set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ECn2
的用法示例。
在下文中一共展示了ECn2::set方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: q_power_frobenius
void q_power_frobenius(ECn2 &A,ZZn2 &F)
{
// Fast multiplication of A by q (for Trace-Zero group members only)
ZZn2 x,y,z,w,r;
#ifdef AFFINE
A.get(x,y);
#else
A.get(x,y,z);
#endif
w=F*F;
r=F;
if (get_mip()->TWIST==MR_SEXTIC_M) r=inverse(F); // could be precalculated
if (get_mip()->TWIST==MR_SEXTIC_D) r=F;
w=r*r;
x=w*conj(x);
y=r*w*conj(y);
#ifdef AFFINE
A.set(x,y);
#else
z.conj();
A.set(x,y,z);
#endif
}
示例2: q_power_frobenius
void q_power_frobenius(ECn2 &A,ZZn2 &F)
{
// Fast multiplication of A by q (for Trace-Zero group members only)
ZZn2 x,y,z,w,r;
// Faster method
#ifdef AFFINE
A.get(x,y);
#else
A.get(x,y,z);
#endif
w=F*F;
r=F;
x=w*conj(x);
y=r*w*conj(y);
#ifdef AFFINE
A.set(x,y);
#else
z=conj(z);
A.set(x,y,z);
#endif
/*
// First "untwist" the point A to (X,Y) where X,Y in F_p^{12}
A.get(x,y);
h.clear();
l.set1(x);
X.set(l,h);
l.clear();
h.set1(y);
Y.set(l,h);
// Apply the Frobenius..
X.powq(F);
Y.powq(F);
// Now "twist" it back to A
X.get(l,h);
l.get1(x);
Y.get(l,h);
h.get1(y);
A.set(x,y);
*/
}
示例3: q_power_frobenius
void q_power_frobenius(ECn2 &A,ZZn2 &F)
{
ZZn2 x,y,z,w,r;
A.get(x,y,z);
w=F*F;
r=F;
x=w*conj(x);
y=r*w*conj(y);
z.conj();
A.set(x,y,z);
}
示例4: q_power_frobenius
void q_power_frobenius(ECn2 &A,ZZn2 &F)
{
// Fast multiplication of A by q (for Trace-Zero group members only)
ZZn2 x,y,z,w,r;
#ifdef AFFINE
A.get(x,y);
#else
A.get(x,y,z);
#endif
w=F*F;
r=F;
x=w*conj(x);
y=r*w*conj(y);
#ifdef AFFINE
A.set(x,y);
#else
z.conj();
A.set(x,y,z);
#endif
}
示例5:
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;
}
示例6: 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;
}
示例7: 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;
}
示例8:
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;
}
示例9: cofactor
void cofactor(ECn2& S,ZZn2 &F,Big& t)
{
ZZn2 x,y,w,z;
ECn2 K,T;
K=S;
z=F;
w=F*F;
S.get(x,y);
x=w*conj(x);
y=z*w*conj(y);
S.set(x,y);
x=w*conj(x);
y=z*w*conj(y);
T.set(x,y);
S+=K;
S*=t;
S-=T;
S-=K;
S.norm();
}
示例10: main
int main()
{
miracl *mip=&precision;
Big s,x,q,p,t,A,B,cf,X,Y,sru,n,best_s,f;
Big T,P,F,m1,m2;
ECn W;
ECn2 Q;
ZZn2 r;
mip->IOBASE=16;
int i,ns,sign,best_ham=1000;
sign=1; // 1= positive, 2=negative for +/- x solutions
s="1400000000000000";
ns=1;
for (i=0;i<100;i++)
{
forever
{
forever
{
sign=3-sign; // always looking for +ve x solutions.
if (sign==1) s+=1;
if (sign==1) x=5+30*s;
else x=5-30*s;
t=(2*pow(x,3) - 11*x + 15)/15;
q=(pow(x,4) - 8*pow(x,2) + 25)/450;
cf=(5*x*x+10*x+25)/2;
n=cf*q;
p=cf*q+t-1; // avoids overflow..
if (p%8!=5) continue; // p will be 1 mod 4
if (!prime(q)) continue;
if (!prime(p)) continue;
break;
}
T=t*t-2*p;
P=p*p;
F=(4*P-T*T);
F=sqrt(F);
m1=P+1-F; // Wrong Curve
m2=P+1+F;
A=0; B=0;
forever
{
A+=1;
do
{
X=rand(p);
Y=sqrt(X*X*X+A*X,p);
} while (Y==0);
ecurve(A,B,p,MR_AFFINE);
W.set(X,Y);
W*=cf;
if ((q*W).iszero()) break;
}
mip->TWIST=MR_QUARTIC_M;
do
{
r=randn2();
} while (!Q.set(r));
Q*=(m2/q);
if ((q*Q).iszero()) break;
mip->TWIST=MR_QUARTIC_D;
do
{
r=randn2();
} while (!Q.set(r));
Q*=(m2/q);
if ((q*Q).iszero()) break;
cout << "Something wrong!" << endl;
exit(0);
}
cout << "solution " << ns << endl;
cout << "irreducible polynomial = X^4 - [0,1]" << endl;
if (sign==1)
{
cout << "s= +" << s << endl;
cout << "s%12= " << s%12 << endl;
}
else
{
cout << "s= -" << s << endl;
cout << "s%12= " << 12-(s%12) << endl;
}
cout << "x= " << x << " ham(x)= " << ham(x) << endl;
//.........这里部分代码省略.........
示例11: main
//.........这里部分代码省略.........
p=pow((Big)2,mbits)-pow((Big)2,32)-977; // Modulus
mip->IOBASE=16;
r=(char *)"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141"; // group order
curve_b=(char *)"7"; // curve B parameter
gx=(char *)"79BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798"; // generator point
gy=(char *)"483ADA7726A3C4655DA4FBFC0E1108A8FD17B448A68554199C47D08FFB10D4B8";
}
if (strcmp(curvename,"BN254")==0)
{
curve=18;
printf("Curve= BN254\n");
strcpy(fieldname,curvename);
mbits=254;
words=(1+((mbits-1)/bb));
curvetype=WEIERSTRASS;
modtype=NOT_SPECIAL;
curve_a=0;
mip->IOBASE=16;
x=(char *)"4080000000000001"; // Fast but not GT_STRONG parameter
p=36*pow(x,4)-36*pow(x,3)+24*x*x-6*x+1; // Modulus
t=6*x*x+1;
r=p+1-t; // Group order
curve_b=2;
gx=p-1; // generator point in G1
gy=1;
cof=1;
ecurve((Big)0,curve_b,p,MR_AFFINE);
mip->TWIST=MR_SEXTIC_D; // twist type
Xa.set((ZZn)0,(ZZn)-1);
Ya.set((ZZn)1,ZZn(0));
Q.set(Xa,Ya);
Q=(p-1+t)*Q; // generator point in G2
cru=(18*pow(x,3)-18*x*x+9*x-2); // cube root of unity for GLV method
}
if (strcmp(curvename,"BN254CX")==0)
{
curve=19;
printf("Curve= BN254CX\n");
strcpy(fieldname,curvename);
mbits=254;
words=(1+((mbits-1)/bb));
curvetype=WEIERSTRASS;
modtype=NOT_SPECIAL;
curve_a=0;
mip->IOBASE=16;
x=(char *)"4000000003C012B1";
p=36*pow(x,4)-36*pow(x,3)+24*x*x-6*x+1;
t=6*x*x+1;
r=p+1-t;
curve_b=2;
gx=p-1;
gy=1;
cof=1;
ecurve((Big)0,curve_b,p,MR_AFFINE);
mip->TWIST=MR_SEXTIC_D;
Xa.set((ZZn)0,(ZZn)-1);
示例12: cofactor
void cofactor(ECn2& S,ZZn2 &F,Big& t)
{
ZZn2 x,y,w,z;
ZZn6 h,l,W;
ECn2 K,T;
K=S;
z=F;
w=F*F;
S.get(x,y);
x=w*conj(x);
y=z*w*conj(y);
S.set(x,y);
x=w*conj(x);
y=z*w*conj(y);
T.set(x,y);
S+=K;
S*=t;
S-=T;
S-=K;
S.norm();
// First "untwist" the point A to (X,Y) where X,Y in F_p^{12}
/*
K=S;
ZZn12 X,Y,X2,Y2;
S.get(x,y);
h.clear();
l.set1(x);
X.set(l,h);
l.clear();
h.set1(y);
Y.set(l,h);
// Apply the Frobenius..
X.powq(F);
Y.powq(F);
X2=X; X2.powq(F);
Y2=Y; Y2.powq(F);
// Now "twist" it back to S
X.get(l,h);
l.get1(x);
Y.get(l,h);
h.get1(y);
S.set(x,y);
// untwist unto T
X2.get(l,h);
l.get1(x);
Y2.get(l,h);
h.get1(y);
T.set(x,y);
S+=K;
S*=t;
S-=T;
S-=K;
*/
}