Skip to content

Commit 2af0c1d

Browse files
committed
refactoring
1 parent 5893ca7 commit 2af0c1d

File tree

6 files changed

+62
-84
lines changed

6 files changed

+62
-84
lines changed

include/cthash/cthash.hpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,8 @@
99
#include "sha2/sha512/t.hpp"
1010

1111
// SHA-3 (keccak) family
12-
#include "sha3/sha3-224.hpp"
13-
#include "sha3/sha3-256.hpp"
14-
#include "sha3/sha3-384.hpp"
15-
#include "sha3/sha3-512.hpp"
12+
#include "sha3/keccak.hpp"
13+
#include "sha3/sha3.hpp"
1614
#include "sha3/shake128.hpp"
1715
#include "sha3/shake256.hpp"
1816

include/cthash/sha3/sha3-224.hpp

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,6 @@
11
#ifndef CTHASH_SHA3_SHA3_224_HPP
22
#define CTHASH_SHA3_SHA3_224_HPP
33

4-
#include "common.hpp"
5-
6-
namespace cthash {
7-
8-
using sha3_224_config = sha_config<224u>;
9-
static_assert((sha3_224_config::capacity_bit + sha3_224_config::rate_bit) == 1600u);
10-
11-
using sha3_224 = cthash::keccak_hasher<sha3_224_config>;
12-
using sha3_224_value = tagged_hash_value<sha3_224_config>;
13-
14-
namespace literals {
15-
16-
template <fixed_string Value>
17-
consteval auto operator""_sha3_224() {
18-
return sha3_224_value(Value);
19-
}
20-
21-
} // namespace literals
22-
23-
} // namespace cthash
4+
#include "sha3.hpp"
245

256
#endif

include/cthash/sha3/sha3-256.hpp

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,6 @@
11
#ifndef CTHASH_SHA3_SHA3_256_HPP
22
#define CTHASH_SHA3_SHA3_256_HPP
33

4-
#include "common.hpp"
5-
6-
namespace cthash {
7-
8-
using sha3_256_config = sha_config<256u>;
9-
static_assert((sha3_256_config::capacity_bit + sha3_256_config::rate_bit) == 1600u);
10-
11-
using sha3_256 = cthash::keccak_hasher<sha3_256_config>;
12-
using sha3_256_value = tagged_hash_value<sha3_256_config>;
13-
14-
namespace literals {
15-
16-
template <fixed_string Value>
17-
consteval auto operator""_sha3_256() {
18-
return sha3_256_value(Value);
19-
}
20-
21-
} // namespace literals
22-
23-
} // namespace cthash
4+
#include "sha3.hpp"
245

256
#endif

include/cthash/sha3/sha3-384.hpp

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,6 @@
11
#ifndef CTHASH_SHA3_SHA3_384_HPP
22
#define CTHASH_SHA3_SHA3_384_HPP
33

4-
#include "common.hpp"
5-
6-
namespace cthash {
7-
8-
using sha3_384_config = sha_config<384u>;
9-
static_assert((sha3_384_config::capacity_bit + sha3_384_config::rate_bit) == 1600u);
10-
11-
using sha3_384 = cthash::keccak_hasher<sha3_384_config>;
12-
using sha3_384_value = tagged_hash_value<sha3_384_config>;
13-
14-
namespace literals {
15-
16-
template <fixed_string Value>
17-
consteval auto operator""_sha3_384() {
18-
return sha3_384_value(Value);
19-
}
20-
21-
} // namespace literals
22-
23-
} // namespace cthash
4+
#include "sha3.hpp"
245

256
#endif

include/cthash/sha3/sha3-512.hpp

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,6 @@
11
#ifndef CTHASH_SHA3_SHA3_512_HPP
22
#define CTHASH_SHA3_SHA3_512_HPP
33

4-
#include "common.hpp"
5-
6-
namespace cthash {
7-
8-
using sha3_512_config = sha_config<512u>;
9-
static_assert((sha3_512_config::capacity_bit + sha3_512_config::rate_bit) == 1600u);
10-
11-
using sha3_512 = cthash::keccak_hasher<sha3_512_config>;
12-
using sha3_512_value = tagged_hash_value<sha3_512_config>;
13-
14-
namespace literals {
15-
16-
template <fixed_string Value>
17-
consteval auto operator""_sha3_512() {
18-
return sha3_512_value(Value);
19-
}
20-
21-
} // namespace literals
22-
23-
} // namespace cthash
4+
#include "sha3.hpp"
245

256
#endif

include/cthash/sha3/sha3.hpp

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#ifndef CTHASH_SHA3_SHA3_HPP
2+
#define CTHASH_SHA3_SHA3_HPP
3+
4+
#include "common.hpp"
5+
6+
namespace cthash {
7+
8+
using sha3_224_config = sha_config<224u>;
9+
static_assert((sha3_224_config::capacity_bit + sha3_224_config::rate_bit) == 1600u);
10+
11+
using sha3_256_config = sha_config<256u>;
12+
static_assert((sha3_256_config::capacity_bit + sha3_256_config::rate_bit) == 1600u);
13+
14+
using sha3_384_config = sha_config<384u>;
15+
static_assert((sha3_384_config::capacity_bit + sha3_384_config::rate_bit) == 1600u);
16+
17+
using sha3_512_config = sha_config<512u>;
18+
static_assert((sha3_512_config::capacity_bit + sha3_512_config::rate_bit) == 1600u);
19+
20+
// hasher and value type
21+
using sha3_224 = cthash::keccak_hasher<sha3_224_config>;
22+
using sha3_224_value = tagged_hash_value<sha3_224_config>;
23+
using sha3_256 = cthash::keccak_hasher<sha3_256_config>;
24+
using sha3_256_value = tagged_hash_value<sha3_256_config>;
25+
using sha3_384 = cthash::keccak_hasher<sha3_384_config>;
26+
using sha3_384_value = tagged_hash_value<sha3_384_config>;
27+
using sha3_512 = cthash::keccak_hasher<sha3_512_config>;
28+
using sha3_512_value = tagged_hash_value<sha3_512_config>;
29+
30+
namespace literals {
31+
32+
template <fixed_string Value>
33+
consteval auto operator""_sha3_224() {
34+
return sha3_224_value(Value);
35+
}
36+
37+
template <fixed_string Value>
38+
consteval auto operator""_sha3_256() {
39+
return sha3_256_value(Value);
40+
}
41+
42+
template <fixed_string Value>
43+
consteval auto operator""_sha3_384() {
44+
return sha3_384_value(Value);
45+
}
46+
47+
template <fixed_string Value>
48+
consteval auto operator""_sha3_512() {
49+
return sha3_512_value(Value);
50+
}
51+
52+
} // namespace literals
53+
54+
} // namespace cthash
55+
56+
#endif

0 commit comments

Comments
 (0)