25 {
26
27 using compress_test = std::tuple<std::vector<string>, std::variant<fc::blake2b_error, bytes>>;
28
29 const std::vector<compress_test> tests {
30
31 {
32 {
33 "00000000",
34 "48c9bdf267e6096a3ba7ca8485ae67bb2bf894fe72f36e3cf1361d5f3af54fa5d182e6ad7f520e511f6c3e2b8c68059b6bbd41fbabd9831f79217e1319cde05b",
35 "6162630000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
36 "0300000000000000",
37 "0000000000000000",
38 "01",
39 },
40 to_bytes(
"08c9bcf367e6096a3ba7ca8485ae67bb2bf894fe72f36e3cf1361d5f3af54fa5d282e6ad7f520e511f6c3e2b8c68059b9442be0454267ce079217e1319cde05b")
41 },
42
43
44 {
45 {
46 "0000000c",
47 "48c9bdf267e6096a3ba7ca8485ae67bb2bf894fe72f36e3cf1361d5f3af54fa5d182e6ad7f520e511f6c3e2b8c68059b6bbd41fbabd9831f79217e1319cde05b",
48 "6162630000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
49 "0300000000000000",
50 "0000000000000000",
51 "01",
52 },
53 to_bytes(
"ba80a53f981c4d0d6a2797b69f12f6e94c212f14685ac4b74b12bb6fdbffa2d17d87c5392aab792dc252d5de4533cc9518d38aa8dbf1925ab92386edd4009923")
54 },
55
56
57 {
58 {
59 "0000000c",
60 "48c9bdf267e6096a3ba7ca8485ae67bb2bf894fe72f36e3cf1361d5f3af54fa5d182e6ad7f520e511f6c3e2b8c68059b6bbd41fbabd9831f79217e1319cde05b",
61 "6162630000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
62 "0300000000000000",
63 "0000000000000000",
64 "00",
65 },
66 to_bytes(
"75ab69d3190a562c51aef8d88f1c2775876944407270c42c9844252c26d2875298743e7f6d5ea2f2d3e8d226039cd31b4e426ac4f2d3d666a610c2116fde4735")
67 },
68
69
70 {
71 {
72 "00000001",
73 "48c9bdf267e6096a3ba7ca8485ae67bb2bf894fe72f36e3cf1361d5f3af54fa5d182e6ad7f520e511f6c3e2b8c68059b6bbd41fbabd9831f79217e1319cde05b",
74 "6162630000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
75 "0300000000000000",
76 "0000000000000000",
77 "01",
78 },
79 to_bytes(
"b63a380cb2897d521994a85234ee2c181b5f844d2c624c002677e9703449d2fba551b3a8333bcdf5f2f7e08993d53923de3d64fcc68c034e717b9293fed7a421")
80 },
81
82
83 {
84 {
85 "00000000",
86 "c9bdf267e6096a3ba7ca8485ae67bb2bf894fe72f36e3cf1361d5f3af54fa5d182e6ad7f520e511f6c3e2b8c68059b6bbd41fbabd9831f79217e1319cde05b",
87 "6162630000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
88 "0300000000000000",
89 "0000000000000000",
90 "01",
91 },
92 blake2b_error::input_len_error
93 },
94 };
95
97
98 for(const auto& test : tests) {
99
100 const auto&
params = std::get<0>(test);
102
103 BOOST_REQUIRE(
params.size() == 6);
104
110 bool _f =
params[5] ==
"00" ? false :
true;
111
112 auto res =
blake2b(_rounds, _h, _m, _t0_offset, _t1_offset, _f, yield);
113
115 }
116
thread_local yield_t yield
std::vector< char > bytes
std::variant< blake2b_error, bytes > blake2b(uint32_t _rounds, const bytes &_h, const bytes &_m, const bytes &_t0_offset, const bytes &_t1_offset, bool _f, const yield_function_t &yield)
const unsigned char expected_result[]
uint32_t to_uint32(const std::string &s)
bytes to_bytes(const std::string &source)