亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來(lái)到蟲(chóng)蟲(chóng)下載站! | ?? 資源下載 ?? 資源專(zhuān)輯 ?? 關(guān)于我們
? 蟲(chóng)蟲(chóng)下載站

?? ake12bna.cpp

?? 比較新的功能強(qiáng)大的rsa算法源代碼,方便使用.
?? CPP
字號(hào):
/*
 *    No matter where you got this code from, be aware that MIRACL is NOT 
 *    free software. For commercial use a license is required.
 *	  See www.shamus.ie
 *
   Scott's AKE Client/Server testbed

   See http://eprint.iacr.org/2002/164

   Compile as 
   cl /O2 /GX /DZZNS=8 ake12bna.cpp zzn12.cpp zzn6a.cpp ecn2.cpp zzn2.cpp big.cpp zzn.cpp ecn.cpp miracl.lib
   using COMBA build

   Barreto-Naehrig Curve - Ate pairing

   The curve generated is generated from a 64-bit x parameter
   This version implements that Ate pairing

   See "Pairing-Friendly Elliptic Curves of Prime Order", by Paulo S. L. M. Barreto and Michael Naehrig,
   Cryptology ePrint Archive: Report 2005/133

   NOTE: Irreducible polynomial is of the form x^6+(1+sqrt(-2))

   See bn.cpp for a program to generate suitable BN curves

   Modified to prevent sub-group confinement attack
*/

#include <iostream>
#include <fstream>
#include <string.h>
#include "ecn.h"
#include <ctime>
#include "ecn2.h"
#include "zzn12.h"


// cofactor - number of points on curve=CF.q

using namespace std;

#ifdef MR_COUNT_OPS
extern "C"
{
    int fpc=0;
    int fpa=0;
    int fpx=0;
}
#endif

Miracl precision(8,0); 

#ifdef MR_AFFINE_ONLY
    #define AFFINE
#else
    #define PROJECTIVE
#endif

// Using SHA-256 as basic hash algorithm

#define HASH_LEN 32

//
// Ate Pairing Code
//

void set_frobenius_constant(ZZn12 &X)
{
    ZZn12 x;
    Big p=get_modulus();
    x.seti((ZZn6)1);
    X=pow(x,p);
}

//
// Line from A to destination C. Let A=(x,y)
// Line Y-slope.X-c=0, through A, so intercept c=y-slope.x
// Line Y-slope.X-y+slope.x = (Y-y)-slope.(X-x) = 0
// Now evaluate at Q -> return (Qy-y)-slope.(Qx-x)
//

ZZn12 line(ECn2& A,ECn2& C,ZZn2& slope,ZZn& Qx,ZZn& Qy)
{
     ZZn12 w;
     ZZn6 nn,dd;
     ZZn2 X,Y;

#ifdef AFFINE
     A.get(X,Y);

     dd.set(slope*Qx,Y-slope*X);
     nn.set((ZZn2)-Qy);
     w.set(nn,dd);

#endif
#ifdef PROJECTIVE
    ZZn2 Z,Z2,ZZ,ZZZ;

    A.get(X,Y,Z);
    C.getZ(Z2);

    ZZ=Z*Z;
    ZZZ=ZZ*Z;

    dd.set((ZZZ*slope)*Qx,Z2*Y-Z*X*slope);
    nn.set((ZZn2)-(ZZZ*Z2)*Qy);
    w.set(nn,dd);

#endif

     return w;
}

//
// fast multiplication by p-1+t
// We know F^2-tF+p = 0
// So p.S=t.F(S)-F^2(S), where F is Frobenius Endomorphism
// So (p-1+t).S = t(F(S)+S)-F^2(S)-S
// This is just multiplication by t, which is half size of (p-1+t)
//

void cofactor(ECn2& S,ZZn12 &F,Big& t)
{
    ZZn2 x,y,w,z;
    ZZn6 h,l,W;
    ECn2 K,T;
    K=S;

    F.get(l,h);
    h.get(z);

    W=real(F*F);
    W.get1(w);

    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;
}

//
// Add A=A+B  (or A=A+A) 
// Return line function value
//

ZZn12 g(ECn2& A,ECn2& B,ZZn& Qx,ZZn& Qy)
{
    ZZn2 lam;
    ZZn12 r;
    ECn2 P=A;
 //   int fpcb=fpc;

// Evaluate line from A
    A.add(B,lam);
//cout << "point addition/doubling= " << fpc-fpcb << endl;
    if (A.iszero())   return (ZZn12)1; 
//fpcb=fpc;
    r=line(P,A,lam,Qx,Qy);
//cout << "line calculation= " << fpc-fpcb << endl;
//cout << "r= " << r << endl;
    return r;
}

//
// Ate Pairing - note denominator elimination has been applied
//
// P is a point of order q. Q(x,y) is a point of order q. 
// Note that P is a point on the sextic twist of the curve over Fp^2, Q(x,y) is a point on the 
// curve over the base field Fp
//

BOOL fast_pairing(ECn2& P,ZZn& Qx,ZZn& Qy,Big &x,ZZn12 &X,ZZn6& res)
{ 
    ECn2 A;
    int i,nb;
    Big n;
    ZZn12 w,r,a,b,c,rp;

    n=6*x*x;       // t-1
    A=P;           // remember A
 
    nb=bits(n);
    r=1;
#ifdef MR_COUNT_OPS
fpc=fpa=fpx=0;
#endif
    for (i=nb-2;i>=0;i--)
    {
        r*=r;  
        r*=g(A,A,Qx,Qy);
 
        if (bit(n,i)) 
            r*=g(A,P,Qx,Qy);  
    }
#ifdef MR_COUNT_OPS
cout << "Miller fpc= " << fpc << endl;
cout << "Miller fpa= " << fpa << endl;
cout << "Miller fpx= " << fpx << endl;
fpa=fpc=fpx=0;
#endif
    if (r.iszero()) return FALSE;

    w=r;

    r.conj();
    r/=w;    // r^(p^6-1)

    r.mark_as_unitary();

    w=r;
    r.powq(X); r.powq(X);
    r*=w;    // r^[(p^6-1)*(p^2+1)]

// New idea..

//1. Calculate a=r^(6x-5)
//2. Calculate b=a^p using Frobenius
//3. Calculate c=ab
//4. Calculate r^p, r^{p^2} and r^{p^3} using Frobenius
//5. Calculate final exponentiation as 
// r^{p^3}.[c.(r^p)^2.r^{p^2}]^(6x^2+1).c.(r^p.r)^9.a.r^4
//
// Does not require multi-exponentiation, but total exponent length is the same.
// Also does not need precomputation (x is sparse). 
//

    if (x>0) a=pow(r,6*x-5);
    else     a=inverse(pow(r,5-6*x)); // inverses are "free" for unitary values

    b=a; b.powq(X);
    b*=a;
    rp=r; rp.powq(X);
    a*=b;
    w=r; w*=w; w*=w;
    a*=w;
    c=rp*r; w=c; w*=w; w*=w; w*=w; w*=c;
    a*=w; w=(rp*rp);

    rp.powq(X);
    w*=(b*rp);

    c=pow(w,x);
    r=w*pow(c,6*x);  //    r=pow(w,6*x*x+1);   // time consuming bit...

    rp.powq(X); a*=rp;
    r*=a;
#ifdef MR_COUNT_OPS
cout << "FE fpc= " << fpc << endl;
cout << "FE fpa= " << fpa << endl;
cout << "FE fpx= " << fpx << endl;
fpa=fpc=fpx=0;
#endif
    res= real(r);                    // compress to half size...

    return TRUE;
}

//
// ecap(.) function
//

BOOL ecap(ECn2& P,ECn& Q,Big& x,ZZn12 &X,ZZn6& r)
{
    BOOL Ok;
    Big xx,yy;
    ZZn Qx,Qy;

    P.norm();
    Q.get(xx,yy); Qx=xx; Qy=yy;

    Ok=fast_pairing(P,Qx,Qy,x,X,r);

    if (Ok) return TRUE;
    return FALSE;
}

//
// Hash functions
// 

Big H1(char *string)
{ // Hash a zero-terminated string to a number < modulus
    Big h,p;
    char s[HASH_LEN];
    int i,j; 
    sha256 sh;

    shs256_init(&sh);

    for (i=0;;i++)
    {
        if (string[i]==0) break;
        shs256_process(&sh,string[i]);
    }
    shs256_hash(&sh,s);
    p=get_modulus();
    h=1; j=0; i=1;
    forever
    {
        h*=256; 
        if (j==HASH_LEN)  {h+=i++; j=0;}
        else         h+=s[j++];
        if (h>=p) break;
    }
    h%=p;
    return h;
}

Big H2(ZZn6 x)
{ // Hash an Fp6 to a big number
    sha256 sh;
    ZZn2 u,v,w;
    ZZn h,l;
    Big a,hash,p,xx[6];
    char s[HASH_LEN];
    int i,j,m;

    shs256_init(&sh);
    x.get(u,v,w);
    u.get(l,h);
    xx[0]=l; xx[1]=h;
    v.get(l,h);
    xx[2]=l; xx[3]=h;
    w.get(l,h);
    xx[4]=l; xx[5]=h;

    for (i=0;i<6;i++)
    {
        a=xx[i];
        while (a>0)
        {
            m=a%256;
            shs256_process(&sh,m);
            a/=256;
        }
    }
    shs256_hash(&sh,s);
    hash=from_binary(HASH_LEN,s);
    return hash;
}

// Hash and map a Server Identity to a curve point E_(Fp2)

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;
}     

// Hash and map a Client Identity to a curve point E_(Fp) of order q

ECn hash_and_map(char *ID)
{
    ECn Q;
    Big x0=H1(ID);

    while (!Q.set(x0,x0)) x0+=1;
   
    return Q;
}

int main()
{
    miracl* mip=&precision;
    ECn Alice,Bob,sA,sB;
    ECn2 Server,sS;
    ZZn6 sp,ap,bp,res;
    ZZn12 X;
    Big a,b,s,ss,p,q,x,y,B,cf,t;
    int i,bits,A;
    time_t seed;

    mip->IOBASE=16;
    x= (char *)"600000000000219B";  // found by BN.CPP
    
    p=36*pow(x,4)-36*pow(x,3)+24*x*x-6*x+1;
    t=6*x*x+1;
    q=p+1-t;
    cf=p-1+t;
    modulo(p);
    set_frobenius_constant(X);

    cout << "Initialised... " << endl;

    time(&seed);
    irand((long)seed);

#ifdef AFFINE
    ecurve((Big)0,(Big)3,p,MR_AFFINE);
#endif
#ifdef PROJECTIVE
    ecurve((Big)0,(Big)3,p,MR_PROJECTIVE);
#endif

    mip->IOBASE=16;
    mip->TWIST=TRUE;   // map Server to point on twisted curve E(Fp2)

    ss=rand(q);    // TA's super-secret 

    cout << "Mapping Server ID to point" << endl;
    Server=hash_and_map2((char *)"Server");
    cofactor(Server,X,t);   // fast multiplication by cf

    cout << "Mapping Alice & Bob ID's to points" << endl;
    Alice=hash_and_map((char *)"Alice");
    Bob=  hash_and_map((char *)"Robert");

    cout << "Alice, Bob and the Server visit Trusted Authority" << endl; 

    sS=ss*Server; 
    sA=ss*Alice; 
    sB=ss*Bob; 

    cout << "Alice and Server Key Exchange" << endl;

    a=rand(q);   // Alice's random number
    s=rand(q);   // Server's random number

   // for (i=0;i<1000;i++)
   
    if (!ecap(Server,sA,x,X,res)) cout << "Trouble" << endl;
    if (powl(res,q)!=(ZZn6)1)
    {
        cout << "Wrong group order - aborting" << endl;
        exit(0);
    }
    ap=powl(res,a);

    if (!ecap(sS,Alice,x,X,res)) cout << "Trouble" << endl;
    if (powl(res,q)!=(ZZn6)1)
    {
        cout << "Wrong group order - aborting" << endl;
        exit(0);
    }
    sp=powl(res,s);

    cout << "Alice  Key= " << H2(powl(sp,a)) << endl;
    cout << "Server Key= " << H2(powl(ap,s)) << endl;

    cout << "Bob and Server Key Exchange" << endl;

    b=rand(q);   // Bob's random number
    s=rand(q);   // Server's random number

    if (!ecap(Server,sB,x,X,res)) cout << "Trouble" << endl;
    if (powl(res,q)!=(ZZn6)1)
    {
        cout << "Wrong group order - aborting" << endl;
        exit(0);
    }
    bp=powl(res,b);

    if (!ecap(sS,Bob,x,X,res)) cout << "Trouble" << endl;
    if (powl(res,q)!=(ZZn6)1)
    {
        cout << "Wrong group order - aborting" << endl;
        exit(0);
    }
    sp=powl(res,s);

    cout << "Bob's  Key= " << H2(powl(sp,b)) << endl;
    cout << "Server Key= " << H2(powl(bp,s)) << endl;

    return 0;
}

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美在线短视频| 在线免费一区三区| 一区二区三区日韩精品视频| 欧美狂野另类xxxxoooo| 国产成人综合网| 亚洲国产综合在线| 国产精品久久久久久久岛一牛影视| 欧美三级电影精品| 99久久免费视频.com| 久久国产尿小便嘘嘘| 亚洲一区二区在线免费观看视频| 久久伊人中文字幕| 欧美一二三区在线观看| 色94色欧美sute亚洲线路一ni| 国产精品99久久久久| 美女尤物国产一区| 亚洲成人中文在线| 一区二区三区四区不卡视频| 中文子幕无线码一区tr| 精品日韩av一区二区| 欧美一区二区性放荡片| 欧美性生活久久| 色婷婷精品久久二区二区蜜臂av | 久久精品一区二区三区av| 在线观看三级视频欧美| 99久久精品免费看国产| 粉嫩嫩av羞羞动漫久久久| 久久丁香综合五月国产三级网站| 亚洲va国产天堂va久久en| 一区二区三区不卡视频| 亚洲视频免费观看| 日韩一区日韩二区| 国产精品成人免费在线| 欧美激情综合五月色丁香小说| 2023国产精品自拍| 精品国产一区二区精华| 欧美一区二区黄色| 日韩一区二区三| 日韩你懂的在线观看| 日韩欧美中文字幕制服| 欧美成人综合网站| 2023国产精品自拍| 欧美极品xxx| 国产精品成人午夜| 亚洲免费观看高清完整版在线观看 | 91视视频在线直接观看在线看网页在线看| 国产一级精品在线| 岛国精品一区二区| 97se狠狠狠综合亚洲狠狠| 色网综合在线观看| 欧美天堂一区二区三区| 欧美日韩国产成人在线91| 欧美日韩精品综合在线| 一区二区三区不卡视频| 亚洲精品日产精品乱码不卡| 亚洲精品ww久久久久久p站| 一区二区三区四区在线免费观看| 亚洲亚洲人成综合网络| 秋霞午夜av一区二区三区| 久久66热re国产| 国产成人av电影在线| 91免费视频观看| 欧美欧美欧美欧美| 精品国产免费人成电影在线观看四季 | 秋霞午夜av一区二区三区| 精品综合久久久久久8888| 国产成人综合自拍| 日本韩国欧美在线| 91精品国产麻豆| 国产亚洲一二三区| 一区二区三区在线观看网站| 水野朝阳av一区二区三区| 国产美女av一区二区三区| av不卡免费在线观看| 欧美精品久久久久久久多人混战 | 国产一区二区成人久久免费影院| 成人午夜短视频| 欧美日韩亚洲综合一区| 伊人开心综合网| 亚洲视频一二三| 人人狠狠综合久久亚洲| 国产精品亚洲一区二区三区在线| 91老司机福利 在线| 日韩丝袜美女视频| 国产精品福利av| 蜜桃视频在线观看一区二区| 成人国产精品免费观看视频| 欧美狂野另类xxxxoooo| 国产精品色哟哟网站| 日本免费在线视频不卡一不卡二| 粉嫩aⅴ一区二区三区四区| 欧美挠脚心视频网站| 国产农村妇女毛片精品久久麻豆 | 色天天综合色天天久久| 日韩欧美国产wwwww| 亚洲欧美日韩人成在线播放| 看片的网站亚洲| 欧美无砖专区一中文字| 国产精品不卡在线| 久久99热99| 亚洲蜜臀av乱码久久精品| 狠狠网亚洲精品| 欧美日韩在线播| 中文字幕一区免费在线观看 | 亚洲成人三级小说| 成人99免费视频| ww久久中文字幕| 天天爽夜夜爽夜夜爽精品视频| 9色porny自拍视频一区二区| 日韩精品中文字幕一区二区三区 | 日本欧美加勒比视频| 色视频成人在线观看免| 国产情人综合久久777777| 奇米在线7777在线精品 | 色国产综合视频| 国产精品精品国产色婷婷| 久久国产精品免费| 欧美一级精品在线| 日韩国产成人精品| 欧美色图第一页| 亚洲欧美激情视频在线观看一区二区三区 | 国产69精品久久久久777| 日韩一区二区麻豆国产| 亚洲一区二区三区四区五区黄 | 久久日韩粉嫩一区二区三区| 日韩国产一区二| 在线播放亚洲一区| 亚洲黄色小视频| 91小视频在线观看| 亚洲欧美综合色| 99re热这里只有精品视频| 国产欧美精品在线观看| 国产一区二区伦理片| 久久久久亚洲蜜桃| 国产精品一区二区免费不卡| 久久综合九色综合欧美就去吻| 麻豆精品新av中文字幕| 精品剧情v国产在线观看在线| 美女视频一区二区三区| 日韩一区二区免费电影| 精品在线播放午夜| 久久久久久免费| 国产成人精品免费| 国产精品国产a| 91免费版pro下载短视频| 亚洲免费在线视频一区 二区| 色噜噜狠狠一区二区三区果冻| 依依成人综合视频| 欧美男女性生活在线直播观看| 午夜免费久久看| 欧美电影免费观看完整版 | 在线视频观看一区| 亚洲123区在线观看| 欧美一区二区三区免费视频| 蜜桃视频免费观看一区| 久久久亚洲午夜电影| 成人黄色电影在线| 亚洲一区在线电影| 欧美一区二区二区| 国产成人综合在线播放| 亚洲欧美激情插| 欧美一级黄色录像| 成人爱爱电影网址| 亚洲国产精品尤物yw在线观看| 日韩一区二区中文字幕| 国产精品99久久久久久似苏梦涵| 综合久久一区二区三区| 欧美日本在线播放| 国产一区二区三区国产| 樱桃国产成人精品视频| 欧美一区二区三区视频免费播放 | 亚洲午夜在线电影| 精品奇米国产一区二区三区| 成人综合在线观看| 午夜日韩在线电影| 久久精品人人做人人综合| 色猫猫国产区一区二在线视频| 日本va欧美va欧美va精品| 国产亲近乱来精品视频| 欧美视频精品在线| 国产福利一区二区三区视频在线| 亚洲欧美激情在线| 久久影音资源网| 欧洲一区二区三区免费视频| 九九热在线视频观看这里只有精品| 国产精品亲子乱子伦xxxx裸| 欧美日韩国产精选| 成人av集中营| 美国三级日本三级久久99| 亚洲男人都懂的| 精品第一国产综合精品aⅴ| 色999日韩国产欧美一区二区| 国产一区二区三区黄视频 | 男男gaygay亚洲| 亚洲精品水蜜桃| 国产丝袜欧美中文另类| 欧美日韩精品高清| 91在线观看高清| 国产盗摄一区二区三区| 日韩高清不卡一区二区三区|