- 下载
好多年没有更新了。
GitHub - miracl/MIRACL: MIRACL Cryptographic SDK: Multiprecision Integer and Rational Arithmetic Cryptographic Library is a C software library that is widely regarded by developers as the gold standard open source SDK for elliptic curve cryptography (ECC).
- 解压
新建miracl目录下,把压缩包放到这个目录下。
unzip -j -aa -L MIRACL-master.zip
- 编译
bash linux64
- 测试
$ ./pk-demo
First Diffie-Hellman Key exchange .... Alice's offline calculation
Bob's offline calculation
Alice calculates Key=
95776947707681712039853310107712781517080654215383057845233803806987905723713007098862369877716781169834969633820109892438639190585234030900793381795482387123261351954188737655127825732655295762206584977099770481611905854787250935738105432056090239287378711591899788658601922420340997792779975849446030765198
Bob calculates Key=
95776947707681712039853310107712781517080654215383057845233803806987905723713007098862369877716781169834969633820109892438639190585234030900793381795482387123261351954188737655127825732655295762206584977099770481611905854787250935738105432056090239287378711591899788658601922420340997792779975849446030765198
Alice and Bob's keys should be the same!Lets try that again using elliptic curves....
Alice's offline calculation
Bob's offline calculation
Alice calculates Key=
921595368158387884735776557577229275112136448512534735861
Bob calculates Key=
921595368158387884735776557577229275112136448512534735861
Alice and Bob's keys should be the same! (but much smaller)Testing El Gamal's public key method
Ciphertext=
65137208724491682198612506211445652797279202578309247355336440971969043214737163899333844383466632901253493559232427071743846720346467585012989807892302032897291043482015801332541221890586314101177937459281018696443789297571963821224147415644587987193085495483403421428034679877673393708572968431717770028341
62635677969506292948514342234061774636815084633777086347360137616564633259235281302480305437021389501472695922421915394861293673467342482263628690291537172380025669420616805961646777842076637294012779545311280669432584692938010203325643578910589511083790958900086404734148445925977329304613364774651055316481
Plaintext=
MIRACL - Best multi-precision library in the World!Now generating 512-bit random primes p and q
8515992756890835063994281762929655715309120326740849372055665318911997535204057870310716603309396428002957460034263194469458329916113932048025806505642167
7463562085888280771725768490613436457320403425385087286587797537794010884333586296729157217765035328726131112355308514425170218037205179378684693451054239
n = p.q =
63559640664029651685718315765331030749438611013931588027737198970778488380088573865620273332627959303041280083258675196565884462131460808089820249392157669429972514633020192275635716318034155377023194509300918375175702470542393700483193800116667197820666504230972068087028954197404583069391384013407842495913
Encrypting test string
Ciphertext=
14526192676144004597054808428867738618581140023714118359204538517516134900072011452054590063566750533946794505042299195291139023396263023915807377784742355417907600387129337218303601867974210618435119324137285093587659624290903944415788513382805114074517578042108180066114037207762631326805938246314659245628
Decrypting test string
Plaintext=
MIRACL - Best multi-precision library in the World!
测试代码
#include "miracl.h"void main()
{big a, b, c;miracl *mip = mirsys(5000, 16);a=mirvar(8);b=mirvar(7);c=mirvar(0);add(a, b, c);cotnum(c, stdout);
}
- 编译
gcc test.c miracl.a -o test
- 执行
$ ./test
15