#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <time.h>
#ifdef _WIN32
#include <process.h>
#endif
#include <string.h>
#include "giants.h"
#include "tools.h"
#define DCOUNT 27
int disc12[DCOUNT] = {-3, -4, -7, -8, -11, -19, -43, -67, -163, -15, -20, -24, -35, -40, -51, -52, -88, -91, -115, -123, -148, -187, -232, -235, -267, -403, -427};
#define CM_SHORTS 4096
main(int argc, char **argv) {
giant p = newgiant(CM_SHORTS);
giant u = newgiant(CM_SHORTS);
giant v = newgiant(CM_SHORTS);
giant g[6];
giant plus_order = newgiant(CM_SHORTS);
giant minus_order = newgiant(CM_SHORTS);
giant a = newgiant(CM_SHORTS);
giant b = newgiant(CM_SHORTS);
int d, dc, olen, k;
init_tools(CM_SHORTS);
printf("Give base prime p:\n"); fflush(stdout);
gin(p);
for(dc=0; dc < 6; dc++) g[dc] = newgiant(CM_SHORTS);
for(dc = 0; dc < DCOUNT; dc++) {
d = disc12[dc];
if(cornacchia4(p, d, u, v) == 0) continue;
printf("D: %d\n", d); fflush(stdout);
gtog(u, g[0]);
switch(d) {
case -3: olen = 3;
gtog(u, g[1]); gtog(v, g[2]);
addg(g[2], g[2]); addg(v, g[2]);
addg(g[2], g[1]); gshiftright(1, g[1]);
subg(u, g[2]); gshiftright(1, g[2]); absg(g[2]);
break;
case -4: olen = 2;
gtog(v, g[1]); addg(g[1], g[1]);
break;
default: olen = 1;
}
for(k=0; k < olen; k++) {
gtog(p, plus_order); iaddg(1, plus_order);
gtog(p, minus_order); iaddg(1, minus_order);
addg(g[k], plus_order);
subg(g[k], minus_order);
printf("curve orders: \n");
printf("(%d) ", prime_probable(plus_order));
gout(plus_order);
printf("(%d) ", prime_probable(minus_order));
gout(minus_order);
}
}
}