-
Notifications
You must be signed in to change notification settings - Fork 1
/
no-collisions.cpp
59 lines (52 loc) · 1.47 KB
/
no-collisions.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
#include <algorithm>
#include <array>
#include <cassert>
#include <chrono>
#include <cmath>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <map>
#include <sstream>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>
#include "halftime-hash.hpp"
using namespace std;
using namespace halftime_hash;
using namespace halftime_hash::advanced;
int main(int, char**) {
map<array<uint64_t,2>, int> seen;
array<uint64_t, 22> a;
array<uint64_t, 2> result;
uint64_t entropy[5000];
for (unsigned i = 0; i < sizeof(entropy)/sizeof(entropy[0]); ++i) {
entropy[i] = rand();
entropy[i] <<= 32;
entropy[i] |= rand();
}
for (int b = 0; b < 1 << 22; ++b) {
for (int i = 0; i < 22; ++i) {
a[i] = ((b >> i) & 1) ? 1 : 0;
}
V1<2>(entropy, reinterpret_cast<const char*>(&a[0]),
22 * sizeof(uint64_t), &result[0]);
auto found = seen.find(result);
if (found != seen.end()) {
cout << hex << found->second << endl
<< b << endl
<< result[0] << ", " << result[1] << endl;
V1<2>(entropy, reinterpret_cast<const char*>(&a[0]),
22 * sizeof(uint64_t), &result[0]);
auto c = found->second;
for (int i = 0; i < 22; ++i) {
a[i] = ((c >> i) & 1) ? 1 : 0;
}
V1<2>(entropy, reinterpret_cast<const char*>(&a[0]),
22 * sizeof(uint64_t), &result[0]);
return 1;
}
seen[result] = b;
}
}