60{
61#if !defined(_M1_) && !defined(_M2_) && !defined(_M3_) && !defined(_M4_) && !defined(_M5_)
62 printf("\nNOT using radical 3-isogenies (original dCTIDH).\n\n");
63#else
64 printf(
"\nUsing 2^%ld radical 3-isogenies.\n\n",
batch_start[0] - 1);
65#endif
66 if (argc == 3)
67 {
68 if (strcmp(argv[1], "-bact") == 0)
69 {
70 run_benchmark_action(atoi(argv[2]), 10);
71 }
72 else if (strcmp(argv[1], "-bkey") == 0)
73 {
74 run_benchmark_keygen(atoi(argv[2]), 10);
75 }
76 else if (strcmp(argv[1], "-bkey") == 0)
77 {
78 run_benchmark_fp(atoi(argv[2]));
79 }
80 else
81 {
82 printf("usage: \t%s\t\t\t\t// for a quick test\n\t%s -bact [number of runs]\t//run benchmark for the action\n\t%s -bfp [number of runs]\t//run benchmark for fp_mul", argv[0], argv[0], argv[0]);
83 }
84 return 0;
85 }
86 else if (argc == 2)
87 {
88
89 if (strcmp(argv[1], "-fp2test") == 0)
90 {
91 printf("Starting fp^2 test ...\n");
92 fflush(stdout);
94 printf("All tests passed!\n");
95 return 0;
96 }
97 else
98 {
99 printf("usage: \t%s\t\t\t\t// for a quick test\n\t%s -bact [number of runs]\t//run benchmark for the action\n\t%s -bfp [number of runs]\t//run benchmark for fp_mul", argv[0], argv[0], argv[0]);
100 }
101 }
102
103 ticks cc0, cc1;
104
105
106
107
108
109
110
111
112
113 printf("\033[0;33m// --------------\033[0m\n");
114 printf("\033[0;33m// Key generation\033[0m\n");
115
116 printf(
"sizeof private key = %lu \n",
sizeof(
private_key));
117 printf(
"sizeof public key = %lu \n",
sizeof(
public_key));
118
119
120
121 printf("\n\033[0;35m// Alice\033[0m\n");
122
124 cc0 = getticks();
126 cc1 = getticks();
129 cprintf(
"Running-time (millions): %2.03lfM + %2.03lfS + %2.03lfa = \033[1;35m%2.03lfM\033[0m\n", (1.0 * fpmul) / 1000000.0, (1.0 * fpsqr) / 1000000.0, (1.0 * fpadd) / 1000000.0, (1.0 * (fpmul + fpsqr)) / 1000000.0);
130 printf("Clock cycles (millions): \033[1;35m%7.03lf\033[0m\n", (1.0 * (cc1 - cc0)) / 1000000.0);
131
132
133 printf("\n\033[0;34m// Bob\033[0m\n");
135 cc0 = getticks();
137 cc1 = getticks();
140 cprintf(
"Running-time (millions): %2.03lfM + %2.03lfS + %2.03lfa = \033[1;34m%2.03lfM\033[0m\n", (1.0 * fpmul) / 1000000.0, (1.0 * fpsqr) / 1000000.0, (1.0 * fpadd) / 1000000.0, (1.0 * (fpmul + fpsqr)) / 1000000.0);
141 printf("Clock cycles (millions): \033[1;34m%7.03lf\033[0m\n", (1.0 * (cc1 - cc0)) / 1000000.0);
142
143 fflush(stdout);
144
145
146 printf("\n\033[0;33m// -------------------------\033[0m\n");
147 printf("\033[0;33m// Secret sharing generation\033[0m\n");
148
149
150
151 printf("\n\033[0;35m// Alice\033[0m\n");
152 cc0 = getticks();
154 cc1 = getticks();
155 ss_print(ss_a,
"ss_a",
SS_SIZE);
156 cprintf(
"Running-time (millions) [without validation]: %2.03lfM + %2.03lfS + %2.03lfa = \033[1;35m%2.03lfM\033[0m\n",
157 (1.0 * fpmul) / 1000000.0, (1.0 * fpsqr) / 1000000.0, (1.0 * fpadd) / 1000000.0, (1.0 * (fpmul + fpsqr)) / 1000000.0);
158 printf("Clock cycles (millions) [including validation]: \033[1;35m%7.03lf\033[0m\n", (1.0 * (cc1 - cc0)) / 1000000.0);
159
160 fflush(stdout);
161
162
163 printf("\n\033[0;34m// Bob\033[0m\n");
164 cc0 = getticks();
166 cc1 = getticks();
167 ss_print(ss_b,
"ss_b",
SS_SIZE);
168 cprintf(
"Running-time (millions) [without validation]: %2.03lfM + %2.03lfS + %2.03lfa = \033[1;34m%ld\033[0m\n",
169 (1.0 * fpmul) / 1000000.0, (1.0 * fpsqr) / 1000000.0, (1.0 * fpadd) / 1000000.0, (fpmul + fpsqr));
170 printf("Clock cycles (millions) [including validation]: \033[1;34m%7.03lf\033[0m\n", (1.0 * (cc1 - cc0)) / 1000000.0);
171 fflush(stdout);
172
173
175
176
177 printf("\n\033[0;32m// Successfully secret sharing computation!\033[0m\n");
178 return 0;
179}