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