To build the MIRACL library with Visual C++ V8.0 Select New Project, Console Application Name: miracl Location: d:\myprojects (for example) Solution name: miracl Click OK Click Application settings Click on Static library. Disable precompiled headers Click on Finish Click on Header Files in the left hand pane Click on Project, and Add Existing Item Add miracl.h and mirdef.h from wherever you have unzipped the miracl distribution Click on Source Files in the left hand pane Click on Project, and Add Existing Item Add the following MIRACL source files from the miracl distribution to the project mraes.c mralloc.c mrarth0.c mrarth1.c mrarth2.c mrarth3.c mrbits.c mrbrick.c mrbuild.c mrcore.c mrcrt.c mrcurve.c mrdouble.c mrebrick.c mrec2m.c mrgf2m.c mrfast.c mrflash.c mrflsh1.c mrflsh2.c mrflsh3.c mrflsh4.c mrfrnd.c mrgcd.c mrgcm.c mrio1.c mrio2.c mrjack.c mrlucas.c mrmonty.c mrmuldv.c mrpi.c mrpower.c mrprime.c mrrand.c mrround.c mrscrt.c mrshs.c mrshs256.c mrshs512.c mrsmall.c mrsroot.c mrstrong.c mrxgcd.c mrzzn2.c mrzzn2b.c mrzzn3.c mrecn2.c Then Click on Build miracl. The library is created in directory d:\myprojects\miracl\debug\miracl.lib Alternatively create a release version in the obvious way (if desired). Close this project Again Select New Project, Win32 Console Application Name: brent Location: d:\myprojects Solution name: brent Click on OK, click on Application Settings, leave it as Console Application, and again disable precompiled headers. Click on Finish. Click on Header Files in the left hand pane Click on Project, and Add Existing Item Add miracl.h and mirdef.h from wherever you have unzipped the miracl distribution Also add zzn.h and big.h (the files required here are indicated in the comment /* Requires: big.cpp zzn.cpp */ at the start of brent.cpp) Click on Source Files in the left hand pane Right click on the automatically generated file brent.cpp, and exclude it from the project. Click on Project, and Add Existing Item Add the file brent.cpp from the miracl distribution Add the files zzn.cpp and big.cpp from the miracl distribution Click on Project, and Add Existing Item. Navigate to where-ever the miracl library has been created (d:\myprojects\miracl\debug\) and add miracl.lib to the project. Answer No to the dialog that appears. Click on Build brent The source files are compiled and linked to the miracl library. To run the program Click on Debug, and then on Start without Debugging.
如果你下载的是最新版,可能会多一个文件:mrecn2.c。这个文件实现了E(F_p^2),理论上模的效率会更高。可以直接加上。该文件详细介绍如下:
/*************************************************************************** * Copyright 2012 CertiVox IOM Ltd. * * This file is part of CertiVox MIRACL Crypto SDK. * * The CertiVox MIRACL Crypto SDK provides developers with an * extensive and efficient set of cryptographic functions. * For further information about its features and functionalities please * refer to http://www.certivox.com * * * The CertiVox MIRACL Crypto SDK is free software: you can * redistribute it and/or modify it under the terms of the * GNU Affero General Public License as published by the * Free Software Foundation, either version 3 of the License, * or (at your option) any later version. * * * The CertiVox MIRACL Crypto SDK is distributed in the hope * that it will be useful, but WITHOUT ANY WARRANTY; without even the * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Affero General Public License for more details. * * * You should have received a copy of the GNU Affero General Public * License along with CertiVox MIRACL Crypto SDK. * If not, see <http://www.gnu.org/licenses/>. * * You can be released from the requirements of the license by purchasing * a commercial license. Buying such a license is mandatory as soon as you * develop commercial activities involving the CertiVox MIRACL Crypto SDK * without disclosing the source code of your own applications, or shipping * the CertiVox MIRACL Crypto SDK with a closed source product. * * ***************************************************************************/ /* * MIRACL E(F_p^2) support functions * mrecn2.c */
添加完文件以后,直接build。失败?那就添加miracl的include文件夹到项目的包含文件目录中。重新build,生成一个lib.
以后就用该lib了,毕竟每次添加这么多源文件容易造成源码的混乱,也不利于版本维护。
新建一个项目,直接把lib copy到项目,然后用source文件夹下的brent.c文件进行测试(如编译失败,请添加miracl的include目录):

posted on
浙公网安备 33010602011771号