-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathisd.cpp
More file actions
84 lines (70 loc) · 1.98 KB
/
isd.cpp
File metadata and controls
84 lines (70 loc) · 1.98 KB
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
78
79
80
81
82
83
84
#include <gtest/gtest.h>
#include <iostream>
#include "decoding/challenges/100.h"
#include "mitm.h"
using ::testing::EmptyTestEventListener;
using ::testing::InitGoogleTest;
using ::testing::Test;
using ::testing::TestEventListeners;
using ::testing::TestInfo;
using ::testing::TestPartResult;
using ::testing::UnitTest;
TEST(EnumHashMapConfig, print) {
static constexpr ConfigISD config{.n=n,.k=k,.q=2,.w=w,.p=2,.l=10,.c=0,.threads=1};
config.print();
}
TEST(EnumHashMap, fromstring) {
static constexpr ConfigISD config{.n=n,.k=k,.q=2,.w=w,.p=2,.l=10,.c=0,.threads=1};
ISDInstance<uint64_t, config> isd{};
isd.from_string(h, s);
isd.print();
}
TEST(EnumHashMap, random) {
static constexpr ConfigISD config{.n=n,.k=k,.q=2,.w=w,.p=2,.l=10,.c=0,.threads=1};
ISDInstance<uint64_t, config> isd{};
isd.random();
isd.wA.print();
isd.s.print();
isd.e.print();
}
TEST(EnumHashMap, step) {
constexpr uint32_t l = 10;
static constexpr ConfigISD config{.n=n,.k=k,.q=2,.w=w,.p=2,.l=l,.c=20,.threads=1};
ISDInstance<uint64_t, config> isd{};
isd.from_string(h, s);
for (size_t i = 0; i < 1; ++i) {
isd.step();
// check systemized
for (uint32_t j = 0; j < n-k; ++j) {
for (uint32_t m = 0; m < n-k-l; ++m) {
EXPECT_EQ(isd.wA.get(j, m), j == m);
}
}
// check syndrome, note: swapped
for (uint32_t j = 0; j < n - k; ++j) {
EXPECT_EQ(isd.wA.get(j, n), isd.ws.get(n-k-j-1));
}
// note swapped
for (uint32_t j = 0; j < l; ++j) {
EXPECT_EQ(isd.ws.get(j), (isd.syndrome >> j) & 1u);
}
// check submatrix, note H is swapped
for (uint32_t j = 0; j < n-k; ++j) {
for (uint32_t m = 0; m < k+l; ++m) {
EXPECT_EQ(isd.wA.get(j, m+(n-k-l)), isd.H.get(n-k-j-1, m));
}
}
// check transpose/swap
for (uint32_t j = 0; j < n-k; ++j) {
for (uint32_t m = 0; m < k+l; ++m) {
EXPECT_EQ(isd.H.get(j, m), isd.HT.get(m, j));
}
}
}
}
int main(int argc, char **argv) {
InitGoogleTest(&argc, argv);
srand(time(NULL));
random_seed(rand());
return RUN_ALL_TESTS();
}