-
Notifications
You must be signed in to change notification settings - Fork 94
Expand file tree
/
Copy pathsignature.hpp
More file actions
71 lines (56 loc) · 2.17 KB
/
signature.hpp
File metadata and controls
71 lines (56 loc) · 2.17 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
#pragma once
#include <fc/static_variant.hpp>
#include <fc/crypto/elliptic.hpp>
#include <fc/crypto/elliptic_r1.hpp>
#include <fc/crypto/elliptic_webauthn.hpp>
#include <fc/reflect/reflect.hpp>
#include <fc/reflect/variant.hpp>
namespace fc { namespace crypto {
namespace config {
constexpr const char* signature_base_prefix = "SIG";
constexpr const char* signature_prefix[] = {
"K1",
"R1",
"WA"
};
};
class signature
{
public:
using storage_type = std::variant<ecc::signature_shim, r1::signature_shim, webauthn::signature>;
signature() = default;
signature( signature&& ) = default;
signature( const signature& ) = default;
signature& operator= (const signature& ) = default;
// serialize to/from string
explicit signature(const string& base58str);
std::string to_string(const fc::yield_function_t& yield = fc::yield_function_t()) const;
int which() const;
size_t variable_size() const;
private:
storage_type _storage;
signature( storage_type&& other_storage )
:_storage(std::forward<storage_type>(other_storage))
{}
friend bool operator == ( const signature& p1, const signature& p2);
friend bool operator != ( const signature& p1, const signature& p2);
friend bool operator < ( const signature& p1, const signature& p2);
friend std::size_t hash_value(const signature& b); //not cryptographic; for containers
friend struct reflector<signature>;
friend class private_key;
friend class public_key;
}; // public_key
size_t hash_value(const signature& b);
} } // fc::crypto
namespace fc {
void to_variant(const crypto::signature& var, variant& vo, const fc::yield_function_t& yield = fc::yield_function_t());
void from_variant(const variant& var, crypto::signature& vo);
} // namespace fc
namespace std {
template <> struct hash<fc::crypto::signature> {
std::size_t operator()(const fc::crypto::signature& k) const {
return fc::crypto::hash_value(k);
}
};
} // std
FC_REFLECT(fc::crypto::signature, (_storage) )