This repository has been archived by the owner on Aug 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain_noprep.cpp
77 lines (61 loc) · 1.98 KB
/
main_noprep.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include <iostream>
#define NOPREP
#include "main.h"
#ifndef CONFIG_SET
constexpr uint32_t BENCHES = 5;
constexpr uint32_t BENCHESMULT = 100000;
constexpr uint32_t n = 20;
constexpr uint32_t r = 30;
constexpr uint32_t m = 2;
constexpr uint32_t threads = 1;
// standard config.
// constexpr uint32_t s = 100;
// constexpr uint32_t t = 40;
// IMPORTANT. Make sure r is dividable by 3
constexpr uint32_t s = uint32_t(1) << r/3;
constexpr uint32_t t = uint32_t(1) << r/3;
#endif
#include "src.h"
static constexpr ConfigPrecompute configLegendre(n, r, s, t, m, threads);
static constexpr ConfigPrecomputeDLog configDLog(n, r, s, t, m, threads);
Precompute<configLegendre> leg;
PrecomputeDlog<configDLog> dlog;
void LegendreAttack() {
double time = 0;
uint64_t loops = 0, loop, steps = 0, relations=0, too_longs=0;
for (uint32_t i = 0; i < BENCHES; i++) {
leg.generate_instance();
double t0 = ((double)clock()/CLOCKS_PER_SEC);
loop = leg.noprep_attack();
if (loop == -1)
continue;
time += ((double)clock()/CLOCKS_PER_SEC) - t0;
loops += loop;
steps += leg.steps;
relations += leg.rel_ctr;
too_longs += leg.too_long;
}
std::cout << "l," << r << "," << t << "," << s << "," << m << "," << time << "," << loops << "," << steps << "," << relations << "," << too_longs << "," << BENCHES << "\n" << std::flush;
}
void DLogAttack() {
double time = 0;
uint64_t loops = 0, loop, steps = 0, relations=0, too_longs=0;
for (uint32_t i = 0; i < BENCHES; i++) {
dlog.generate_instance();
double t0 = ((double)clock()/CLOCKS_PER_SEC);
loop = dlog.noprep_attack();
if (loop == -1)
continue;
time += ((double)clock()/CLOCKS_PER_SEC) - t0;
loops += loop;
steps += dlog.steps;
relations += dlog.rel_ctr;
too_longs += dlog.too_long;
}
std::cout << "d," << r << "," << t << "," << s << "," << m << "," << time << "," << loops << "," << steps << "," << relations << "," << too_longs << "," << BENCHES << "\n" << std::flush;
}
int main() {
LegendreAttack();
DLogAttack();
return 0;
}