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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? sea_cpp.txt

?? 基于共開密鑰加密算法ECC加密的源程序
?? TXT
?? 第 1 頁 / 共 4 頁
字號:
// Schoof-Elkies-Atkin Algorithm!
// Mike Scott August 1999   mike@compapp.dcu.ie
// Counts points on GF(p) Elliptic Curve, y^2=x^3+Ax+B a prerequisite 
// for implemention of  Elliptic Curve Cryptography
// This program is intended as an aid to Cryptographers in generating 
// suitable curves (ideally with a prime number of points) with respect 
// to prime moduli from 160 to 512 bits in length. This can be done with
// relatively modest computing facilities - the average home computer and
// a little patience will suffice.
//
// An "ideal" curve is defined as one with with prime number of points.
//
// First the credits
//
// Basic algorithm is due to Schoof
// 1. "Elliptic Curves Over Finite Fields and the Computation of Square Roots 
//     mod p", Rene Schoof, Math. Comp., Vol. 44 pp 483-494
// 
// Elkies-Atkin ideas are described in
//
// 2. "Counting points on Elliptic Curves over Finite Fields", Rene Schoof, 
//    Jl. de Theorie des Nombres de Bordeaux 7 (1995) pp 219-254
//
// The particular variation implemented here is due to Mueller. See his thesis
//
// 3. "Ein Algorithmus zur Bestimmung der Punktanzahl elliptischer Kurven
//    uber endlichen Korpern der Charakteristik grosser drei",  
//    available from Volker Mueller's home page 
//    www.informatik.th-darmstadt.de/TI/Mitarbeiter/vmueller.html
//
// Other useful English-language publications are available from this site.
// Strongly recommended is the recent book 
//
// 4. "Elliptic Curves in Cryptography"
//     by Blake, Seroussi and Smart, London Mathematical Society Lecture Note 
//     Series 265, Cambridge University Press. ISBN 0 521 65374 6 
//
// Another useful reference is
// 5.  Elliptic Curve Public Key Cryptosystems", Menezes, 
//     Kluwer Academic Publishers, Chapter 7
//
// The Kangaroo continuation is due to Pollard:-
//
// 6. "Monte Carlo Methods for Index Computation"
//    by J.M. Pollard in Math. Comp. Vol. 32 1978 pp 918-924
//
// Fast FFT methods are largely as described by Shoup
//
// 7. "A New Polynomial Factorisation Algorithm and its implementation",
//     Victor Shoup, Jl. Symbolic Computation, 1996 
//
// A potentially more effective way of using Atkin primes is described in 
//
// 8. "Remarks on the Schoof-Elkies-Atkin Algorithm", L. Dewaghe, Math. Comp.
//    Vol. 67, 223, July 1998, pp 1247-1252
//
// Thanks are due to Richard Crandall for his encouragment, and the idea of 
// using projective co-ordinates.
//
// NOTE: Only for use on curves over large prime modulus P. 
// For smaller P use schoof.exe utility available from the same source.
//
// This first version does not process so-called Atkin primes
// Schoof's original algorithm is used for primes 3, 5 and 7 (this facilitates
// "early abort" using the -s option).
//
// After that only Elkies primes are used.  It is therefore not as fast as it 
// could be, particularly for smaller values of the prime modulus P. 
// However when the asymptotics kick-in, it starts to get competitive (when 
// you need it to). Since the average Cryptographer will only wish to 
// generate a few curves for practical use, this is deemed to be adequate. 
// The final continuation uses Pollard's Lambda ("kangaroo") algorithm.
//
// It is envisaged that from time-to-time this program will be modified
// and hopefully improved - that is speeded up.
// In particular it is planned to exploit Atkin Primes to allow two herds of 
// kangaroos complete the job more efficiently
//
// Asyptotically the algorithm should take time O(log(p)^5)
// However the Kangaroo continuation favours "smaller" curves, while
// the asymptotic behaviour is more accurate for "bigger" curves
//
// Timings in minutes:- random curves 180MHz Pentium Pro 
// (ignoring time to generate Modular Polynomials)
//
//               C1      C2      C3     Ave  Asymptotic multiplier wrt 160 bits
// 160-bit       2.5     3.0     2.0    2.5         1
// 192-bit       5.5     5.5     3.5    4.8         2.5
// 224-bit       9       7.5    10      8.8         5.4
// 256-bit      13.5    21.5    23     19.3        10.5
// 384-bit      86     108     120    105          60
// 512-bit     600     357     398    452         336
//
// As can be seen the asymptotic behaviour of the program would appear to 
// be about right. The wide variations in timing for the same size of curve
// is typical - it depends on how "lucky" you are finding Elkies Primes
//
// ****************
// Download Instructions
//
// To access the Windows 'NT/95/98 executables directly, point your
// browser at ftp://ftp.compapp.dcu.ie/pub/crypto, and download
//
// mueller.exe
// modpol.exe
// process.exe
// sea.exe
//
// The main program source file for these programs may be found in the
// same place, with .cpp extensions.
//
// To obtain the full source code first look at
// the README file on the ftp site, and then download
//
// ftp://ftp.compapp.dcu.ie/pub/crypto/miracl.zip
// To recompile, see the file sea.txt
//
// For more information:-
//
// http://indigo.ie/~mscott
//
// ****************
// Instructions for use
//
// First run the utility "mueller" to build up a collection of Modular 
// Polynomials. Each modular polynomial is associated with a small odd prime. 
// This needs to be done once only - ever, but you can from time 
// to time augment your collection of Polynomials by running it again. 
// Its quite time consuming, but in less than an hour you should have enough 
// to get started. The more you have, the bigger the prime modulus that you 
// can use.
//
// Then run the utility "process" to process the raw polynomial file with 
// respect to your chosen prime modulus P. This need to be done just once for
// every prime modulus of interest to you. This takes only a few minutes at 
// most.
//
// An alternative is to use instead the "modpol" application, which is a
// composite of "mueller" and "process". It directly generates the Modular 
// Polynomials reduced wrt a pre-specified prime modulus, suitable for 
// immediate use by "sea". If working with limited computing resources such 
// that sufficient generic Modular Polynomials cannot be generated by 
// "mueller", this may be your only alternative.
//
// Finally run this program "sea" specifying the A and B parameters of the 
// particular curve. This program can also search through many curves for 
// a curve ideal for cryptographic use (with a prime number of points).
//
// For example try:-
//
// mueller 0 120 -o mueller.raw
// process -f 65112*2#144-1 -i mueller.raw -o test160.pol
// sea -3 49 -i test160.pol
//
// Here the "mueller" program generates modular polynomials for all odd primes
// in the range 0 - 120 into the file mueller.raw. The "process" application
// reduces these 'raw' polynomials wrt the 160 bit prime modulus 
// P = 65112*2^144-1 to a file test160.pol. The "sea" application uses this 
// file to count the points on the curve Y^2 = X^3 - 3X + 49 mod P 
//
// Alternatively:-
//
// modpol -f 65112*2#144-1 0 120 -o test160.pol
// sea -3 49 -i test160.pol
//
// The number of Modular Polynomials required depends on the size of the 
// prime modulus P. It is also random in the sense that it depends on the 
// probability of each small prime being an "Elkies" prime wrt the given curve. 
// In the vast majority of cases the range suggested to "mueller" or "modpol" 
// should be 0 to bits(P), where bits(P) is the number of bits in P. However 
// you might get away with a much smaller value if you are lucky with your 
// "Elkies" primes. If modular polynomials could not be generated for all
// primes in the range, due to the use of the -s2, -s3 or -s6 flag in 
// "mueller" or "modpol" (see comments in mueller.cpp), then a somewhat 
// larger range might be needed.
//
// When using the "sea" program, the -s option is particularly useful
// and allows automatic search for an "ideal" curve. If a curve order is
// exactly divisible by a small prime, that curve is immediately abandoned, 
// and the program moves on to the next, incrementing the B parameter of 
// the curve. This is a fairly arbitrary but simple way of moving on to 
// the "next" curve. 
//
// Note that if a prime q is an Atkin prime, then we know at least that q 
// is not a factor of NP, in other words that NP mod q != 0.
// This can be easily proved.
//
// NOTE: The output file can be used directly with for example the ECDSA
// programs IF AND ONLY IF an ideal curve is found. If you wish to use
// a less-than-ideal curve, you will first have to factor NP completely, and
// find a random point of large prime order.
//
// ****************
//
// Rev. 1 September 1999  -  Faster and more Kangaroos!
// Rev. 2 October   1999  -  Poly class revamped. Faster search for tau mod lp
// Rev. 3 October   1999  -  Eliminated calculation of X^P
// Rev. 4 December  1999  -  Various optimizations
//
// This implementation is free. No terms, no conditions. It requires 
// version 4.24 or greater of the MIRACL library (a Shareware, Commercial 
// product, but free for non-profit making use), 
// available from ftp://ftp.compapp.dcu.ie/pub/crypto/miracl.zip 
//
// However this program may be freely used (unmodified!) to generate curves 
// for commercial use. It may be recompiled for this purpose on any hardware.
//
// 32-bit build only
//
// Note that is a little faster to use an integer-only build of MIRACL.
// See mirdef.hio
//
// Copyright Shamus Software Ltd. 1999
//

#include <iostream>
#include <iomanip>
#include <fstream>
#include <cstring>
#include "ecn.h"         // Elliptic Curve Class
#include "crt.h"         // Chinese Remainder Theorem Class

//
// poly.h implements polynomial arithmetic. FFT methods are used for maximum
// speed, as the polynomials can get very big. 
// But all that gruesome detail is hidden away.
//
// polymod.h implements polynomial arithmetic wrt to a preset poynomial 
// modulus. This looks a bit neater. Function setmod() sets the modulus 
// to be used. Again fast FFT methods are used.
//
// polyxy.h implements a bivariate polynomial class
//

#include "poly.h"
#include "polymod.h"
#include "polyxy.h"

using namespace std;

#ifndef MR_NOFULLWIDTH
Miracl precision=18;            // max. 18x32 bits per big number
#else
Miracl precision(18,MAXBASE); 
#endif

PolyMod MY2,MY4;

ZZn A,B;         // Here ZZn are integers mod the prime p
                 // Montgomery representation is used internally

// Elliptic curve Point duplication formula

void elliptic_dup(PolyMod& X,PolyMod& Y,PolyMod& Z)
{ // (X,Y,Z)=2.(X,Y,Z)
    PolyMod W1,W2,W3,W4;

    W2=Z*Z;           // 1
    W3=A*(W2*W2);     // 2
    W1=X*X;           // 3
    W4=3*W1+W3;
    Z*=(2*Y);          // 4   Z has an implied y
    W2=MY2*(Y*Y);     // 5
    W3=4*X*W2;        // 6
    W1=W4*W4;         // 7
    X=W1-2*W3;
    W2*=W2;
    W2*=8;     // 8
    W3-=X;
    W3*=W4;         // 9  polynomial multiplications
    Y=W3-W2;    
    X*=MY2;          // fix up - move implied y from Z to Y
    Y*=MY2;
    Z*=MY2;
}

//
// This is addition formula for two distinct points on an elliptic curve
// Works with projective coordinates which are automatically reduced wrt a 
// polynomial modulus
// Remember that the expression for the Y coordinate of each point 
// (a function of X) is implicitly multiplied by Y.
// We know Y^2=X^3+AX+B, but we don't have an expression for Y
// So if Y^2 ever crops up - substitute for it 
//

void elliptic_add(PolyMod& XT,PolyMod& YT,PolyMod& ZT,PolyMod& X,PolyMod& Y)
{ // add (X,Y,1) to (XT,YT,ZT)
  // on an elliptic curve 
    PolyMod W1,W2,W4,W5,W6;

    W1=XT;
    W6=ZT*ZT;       // 1
    W4=X*W6;        // 2  * 
    W1-=W4;

    W2=YT;          // W2 has an implied y
    W6*=ZT;         // 3
    W5=Y*W6;        // 4  * W5 has an implied y 
    W2-=W5;
    if (iszero(W1))
    {
        if (iszero(W2)) 
        { // should have doubled
            elliptic_dup(XT,YT,ZT);
            return;
        }
        else
        { // point at infinity
            ZT.clear();
            return;    
        }
    }

    W4=W1+2*W4;     // W4=2*W4+W1 
    W5=W2+2*W5;     // W5=2*W5+W2

    ZT*=W1;       // 5

    W6=W1*W1;       // 6
    W1*=W6;         // 7
    W6*=W4;         // 8
    W4=MY2*(W2*W2);   // 9 Substitute for Y^2

    XT=W4-W6;

    W6=W6-2*XT;
    W2*=W6;       // 10
    W1*=W5;       // 11  polynomial multiplications
    W5=W2-W1;

    YT=W5/(ZZn)2;   

    return;
}

//
//   Program to compute the order of a point on an elliptic curve
//   using Pollard's lambda method for catching kangaroos. 
//
//   As a way of counting points on an elliptic curve, this
//   has complexity O(p^(1/4))
//
//   However Schoof puts a spring in the step of the kangaroos
//   allowing them to make bigger jumps, and lowering overall complexity
//   to O(p^(1/4)/sqrt(L)) where L is the product of the Schoof primes
//
//   See "Monte Carlo Methods for Index Computation"
//   by J.M. Pollard in Math. Comp. Vol. 32 1978 pp 918-924
//
//   This code has been considerably speeded up using ideas from
//   "Parallel Collision Search with Cryptographic Applications", van Oorchot 
//   and Wiener, J. Crypto., Vol. 12, 1-28, 1999
//

#define STORE 80
#define HERD 5

ECn wild[STORE],tame[STORE];
Big wdist[STORE],tdist[STORE];
int wname[STORE],tname[STORE];

Big kangaroo(Big p,Big order,Big ordermod)
{
    ECn ZERO,K[2*HERD],TE[2*HERD],X,P,G,table[128],trap;
    Big start[2*HERD],txc,wxc,mean,leaps,upper,lower,middle,a,b,x,y,n,w,t,nrp;
    int i,jj,j,m,sp,nw,nt,cw,ct,k,distinguished,nbits;
    Big D[2*HERD],s,distance[128],real_order;
    BOOL bad,collision,abort;
    forever
    {
// find a random point on the curve
        do
        {
            x=rand(p);
        } while (!P.set(x,x));

        lower=p+1-2*sqrt(p)-3; // lower limit of search
        upper=p+1+2*sqrt(p)+3; // upper limit of search

        w=1+(upper-lower)/ordermod;
        leaps=sqrt(w);
        mean=HERD*leaps/2;      // ideal mean for set S=1/2*w^(0.5)
        nbits=bits(leaps/16);
        if (nbits>30) nbits=30;
        distinguished=1<<nbits;
        for (s=1,m=1;;m++)
        { /* find table size */
            distance[m-1]=s*ordermod;
            s*=2;
            if ((2*s/m)>mean) break;
        }
        table[0]=ordermod*P;
        for (i=1;i<m;i++)
        { // double last entry
            table[i]=table[i-1];
            table[i]+=table[i-1];

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
精品动漫一区二区三区在线观看| 天天影视涩香欲综合网| 久久久久99精品一区| 欧美va亚洲va| 欧美mv日韩mv亚洲| 欧美大黄免费观看| 欧美精品一区二区精品网| 日韩三级伦理片妻子的秘密按摩| 欧美刺激午夜性久久久久久久| 欧美一级片在线看| 欧美成人video| 久久免费看少妇高潮| 久久久青草青青国产亚洲免观| 久久久美女毛片| 中文字幕高清不卡| 国产精品久久福利| 一区二区三区不卡在线观看| 亚洲成精国产精品女| 亚洲国产成人高清精品| 亚洲国产精品一区二区www在线| 日韩一区欧美小说| 亚洲乱码国产乱码精品精小说 | 国产精品水嫩水嫩| 欧美国产在线观看| 国产精品国产自产拍高清av| 中文字幕第一区第二区| 精品久久久久久综合日本欧美| 日韩欧美激情一区| 久久久91精品国产一区二区三区| 久久精品视频一区| 国产精品麻豆久久久| 精品福利一区二区三区| 欧美va亚洲va在线观看蝴蝶网| 日韩欧美一区二区在线视频| 日韩欧美一区二区在线视频| 久久久久久夜精品精品免费| 国产网站一区二区| 国产精品电影院| 亚洲一区中文日韩| 午夜伊人狠狠久久| 蜜臂av日日欢夜夜爽一区| 国产资源在线一区| 成人动漫一区二区在线| 91豆麻精品91久久久久久| 91精品国产综合久久久久 | 亚洲综合色区另类av| 午夜电影网一区| 国产精品一区二区三区乱码| 成人a区在线观看| 在线一区二区三区做爰视频网站| 欧美欧美欧美欧美| 精品成人一区二区| 国产精品久久久久久久久免费相片| 亚洲欧美另类小说| 日本欧美一区二区| 粉嫩高潮美女一区二区三区| 日本久久一区二区| 日韩欧美区一区二| 中文字幕一区视频| 日本美女一区二区三区视频| 麻豆精品国产91久久久久久 | 精品欧美一区二区久久| 一色屋精品亚洲香蕉网站| 亚洲成人免费视频| 国产精品一区专区| 欧美三级韩国三级日本三斤| 久久先锋影音av| 亚洲国产成人av| 国产成人综合自拍| 7777精品久久久大香线蕉| 中文字幕av一区 二区| 亚洲成人动漫av| 国产成人av一区二区| 欧美日韩精品系列| 最新日韩在线视频| 精品一区二区三区欧美| fc2成人免费人成在线观看播放| 成人国产精品免费网站| 欧美mv日韩mv国产| 婷婷成人综合网| 北条麻妃一区二区三区| 日韩精品自拍偷拍| 亚洲成人激情社区| 97se亚洲国产综合在线| 亚洲精品一线二线三线无人区| 亚洲精品成a人| 成人丝袜18视频在线观看| 日韩久久精品一区| 日韩成人av影视| 色嗨嗨av一区二区三区| 日本一区二区视频在线| 久久电影网电视剧免费观看| 99久久精品国产毛片| 日韩欧美中文字幕精品| 日韩国产欧美在线观看| 色婷婷精品大在线视频 | 久久99久久精品| 欧美日韩第一区日日骚| 亚洲桃色在线一区| 福利一区二区在线| 国产欧美一区二区精品久导航| 裸体健美xxxx欧美裸体表演| 欧美日韩精品福利| 亚洲一级在线观看| 在线视频国产一区| 亚洲人成网站精品片在线观看| 夫妻av一区二区| 精品国产髙清在线看国产毛片| 免费在线观看一区二区三区| 欧美日韩国产一级| 亚洲国产成人porn| 精品视频在线免费看| 亚洲在线观看免费| 欧美色网一区二区| 亚洲国产va精品久久久不卡综合| 色噜噜狠狠色综合欧洲selulu| 中文字幕在线播放不卡一区| 成人av电影在线| 国产精品对白交换视频| 99视频一区二区| 亚洲欧美激情一区二区| 色吧成人激情小说| 欧美国产日韩一二三区| 国产激情一区二区三区桃花岛亚洲| 精品日韩欧美在线| 国内欧美视频一区二区| 久久理论电影网| 成人午夜私人影院| 中文字幕一区日韩精品欧美| 成人av资源站| 亚洲欧美aⅴ...| 91激情在线视频| 丝袜亚洲另类欧美综合| 日韩一区二区不卡| 韩国一区二区三区| 中文字幕精品一区二区三区精品| 成熟亚洲日本毛茸茸凸凹| 国产精品欧美一区喷水| 91在线视频在线| 亚洲精品日韩综合观看成人91| 欧美嫩在线观看| 久久国产人妖系列| 国产欧美日韩另类视频免费观看| www.亚洲国产| 亚洲无人区一区| 日韩免费视频一区二区| 国产成人日日夜夜| 亚洲欧美日韩久久| 欧美日本免费一区二区三区| 蜜桃av一区二区在线观看| 久久久777精品电影网影网| 成人国产精品免费观看动漫| 亚洲一区二区三区在线播放| 欧美在线观看视频一区二区| 亚洲va欧美va人人爽| 日韩手机在线导航| 国产成人免费在线观看不卡| 亚洲女人小视频在线观看| 欧美日韩免费一区二区三区| 久久国产三级精品| 国产精品白丝在线| 欧美精品v国产精品v日韩精品| 狠狠狠色丁香婷婷综合激情| ...av二区三区久久精品| 91精品国产综合久久精品图片 | 国产一区二区在线观看免费| 国产精品久久久久一区| 欧美精品tushy高清| 成人不卡免费av| 午夜久久福利影院| 国产精品免费免费| 6080午夜不卡| av中文字幕在线不卡| 日本欧美大码aⅴ在线播放| 国产精品欧美极品| 欧美丰满嫩嫩电影| 国产a级毛片一区| 看电影不卡的网站| 亚洲精选视频免费看| 久久久亚洲精华液精华液精华液| 欧美综合在线视频| 国产精品一区二区黑丝| 亚洲大片精品永久免费| 国产精品短视频| 亚洲精品在线观看视频| 欧美日韩高清一区二区不卡| 国产高清久久久| 精品在线一区二区三区| 亚洲1区2区3区视频| 国产精品传媒视频| 久久毛片高清国产| 日韩一区二区免费在线电影| 在线精品国精品国产尤物884a| 国产精品一二三四| 久久精品国产在热久久| 亚洲永久免费av| 一区二区日韩av| 国产精品超碰97尤物18| 久久久av毛片精品| 国产三级一区二区|