当前位置: 首页>>代码示例>>C++>>正文


C++ ECn2::set方法代码示例

本文整理汇总了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
}
开发者ID:stoneskill,项目名称:mix-O_AllWin,代码行数:29,代码来源:ake12bnx.cpp

示例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);

*/
}
开发者ID:BingyZhang,项目名称:CommutEnc,代码行数:56,代码来源:ake12bnr.cpp

示例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);
}
开发者ID:BingyZhang,项目名称:CommutEnc,代码行数:12,代码来源:bn_pair.cpp

示例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
}
开发者ID:asgene,项目名称:sm2,代码行数:24,代码来源:ake12bnx.cpp

示例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;
}     
开发者ID:stoneskill,项目名称:mix-O_AllWin,代码行数:16,代码来源:ake12bnx.cpp

示例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;
}     
开发者ID:CodeMason,项目名称:skype_part3_source,代码行数:18,代码来源:hess4.cpp

示例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;
}     
开发者ID:ferozsalam,项目名称:FYP,代码行数:19,代码来源:ake4mntt.cpp

示例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;
}     
开发者ID:J0s3f,项目名称:FiSH-irssi,代码行数:20,代码来源:ake12bna.cpp

示例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();
}
开发者ID:asgene,项目名称:sm2,代码行数:23,代码来源:ake12bnx.cpp

示例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;
//.........这里部分代码省略.........
开发者ID:BingyZhang,项目名称:CommutEnc,代码行数:101,代码来源:kss8.cpp

示例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);
开发者ID:apache,项目名称:incubator-milagro-crypto,代码行数:67,代码来源:romgen.cpp

示例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;
*/
}
开发者ID:BingyZhang,项目名称:CommutEnc,代码行数:73,代码来源:ake12bnr.cpp


注:本文中的ECn2::set方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。