[ ... ]
Exactly. There is no network, no threads, no bignum. No GUI. Nothing
really. And by the way, bignum is important. You can't do cryptology
without bignum.
Yes, you can do cryptology without bignum. In fact, you can do it quite
nicely. There are a few symmetric ciphers that use big numbers, but
bignums only come into heavy use for public-key ciphers.
In any case, the fact that something isn't in the standard library
hardly means that it doesn't exist.
Anyway, if you have GMP bignum library, can you post the c++ version
of java that I posted?
I haven't used GMP much, but with the library I normally use (NTL) it
would look something like this:
#include <NTL/zz.h>
#include <fstream>
#include <time.h>
#include <iostream>
int main() {
int bits = 1000;
std:
fstream out("prime.txt");
clock_t start = clock();
for (int i=0; i<10; i++)
out << NTL::RandomPrime_ZZ(bits) << "\n\n";
clock_t end = clock();
std::cout << "Time to generate ten "
<< bits
<< " bit prime numbers: "
<< float(end-start)/CLOCKS_PER_SEC
<< " Seconds\n";
return 0;
}
The result on my machine:
Time to generate ten 1000 bit prime numbers: 5.906 Seconds
Given the waste of space this thread constitutes in general, I suppose
including the numbers hardly makes a difference:
573222665908881845091466502342548421355689435142274936518940266894743477
413733222767241763937245479741145366326036028330221248267440197380973964
193471051085921714025259111962127334140451434217323701724156750463240092
184178704782712900793186907566913614608946012192287430915324099411931858
5172595982289
743297979050262160124590361507234251057802552296159558790449530687906086
012819339789698375941414330558978228161901837679825124685227698448719128
805787365762979897352686555912093986674111110370124513027629314405340151
847524035989122849408504775106273836612103664314605947548848599917304378
3672958178713
981424853859121698509960306466153706733858228672308093455889344619739811
673795411000453808557120560259135673647752225082952219395997357425658399
976962664708431826665500899978450997083739553986905992697177906637640455
805571998846902221093105543731215297295277450662210189013934962003504239
1814779674341
979903720903585432395761780593980883131841322654464102806914616445112724
279640101340839712033108265369504809789230299606549579135751249642827864
458981145503471038960834547560030254446690390187012965447327069752485315
364744313923379679478207783678944426611270482583722945698757838710591761
2344578879059
596790599596053296888911138030867893269833984898713137830188430061986347
237757097053584089346958636463825223033822009069074327716859180310790692
040507169713565160791658506266819685539984212852770183588414605754938667
170498068781639439555420687815354643745653591509883385976633927387856695
3289649155049
585669192532112906547638505139963499223830854918768256265800229466872344
887873308782651269814787227488957504502356536832385357751052797938284531
014686417743140474734306957381987388084066915217447894527905003886803844
023095907066370981249494571646345926631380180674807546351731560144480640
6995511826839
106890759185548666922882135258916517291668493407387545904847360302581417
354238588430742988821568026996437081046888009906066280779607592809688329
580613654724610967101923924836644089232959092934165704451851946541183139
362345178876358343660122229983074973411110065356091823719220674563393117
94752628064329
634741916523313163901118675303603480921095327705765789098192033572810249
102378196853891371494833932147723878509099246161753484541578342844672030
736988136520089676086980639986549067759482250919839138580897235250248139
975628769456346585806730760958864762087411399213719044408173061876550937
1241286199941
100261139705229304317914599756903898254394969860388432655919558814436872
694204691339061884007715404131937706091215782874966916665941991508115197
349857176366821590259377406090264343907135652761622422841981605685412918
101827273481137260872475906381578429866890990531228836218055231728157632
82500606433189
657467111127460290023894607229103006353962768843342864894035805431337357
137373981249271378545556181403491739858748095610542914895839104949626501
760168786019416356648663925507201256172862353926231013743345957695843369
414372585696129554750939592949640430609747156409968017125565006409790905
2274126349029
As I understand it, NTL _can_ use GMP for low-level primitives, but I've
never used it that way -- the time above is from NTL working on its own.