rippled
Loading...
Searching...
No Matches
KeyType.h
1#ifndef XRPL_PROTOCOL_KEYTYPE_H_INCLUDED
2#define XRPL_PROTOCOL_KEYTYPE_H_INCLUDED
3
4#include <optional>
5#include <string>
6
7namespace ripple {
8
9enum class KeyType {
10 secp256k1 = 0,
11 ed25519 = 1,
12};
13
16{
17 if (s == "secp256k1")
18 return KeyType::secp256k1;
19
20 if (s == "ed25519")
21 return KeyType::ed25519;
22
23 return {};
24}
25
26inline char const*
28{
29 if (type == KeyType::secp256k1)
30 return "secp256k1";
31
32 if (type == KeyType::ed25519)
33 return "ed25519";
34
35 return "INVALID";
36}
37
38template <class Stream>
39inline Stream&
40operator<<(Stream& s, KeyType type)
41{
42 return s << to_string(type);
43}
44
45} // namespace ripple
46
47#endif
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:6
std::optional< KeyType > keyTypeFromString(std::string const &s)
Definition KeyType.h:15
std::ostream & operator<<(std::ostream &out, base_uint< Bits, Tag > const &u)
Definition base_uint.h:628
KeyType
Definition KeyType.h:9
std::string to_string(base_uint< Bits, Tag > const &a)
Definition base_uint.h:611