5namespace fc {
namespace crypto {
7 template<
typename SigType>
9 static_assert(
sizeof(sig._data.data) == 65,
"sig size is expected to be 65");
11 return *(
size_t*)&sig._data.data[32-
sizeof(
size_t)] + *(
size_t*)&sig._data.data[64-
sizeof(
size_t)];
19 static signature::storage_type sig_parse_base58(
const std::string& base58str)
21 constexpr auto prefix = config::signature_base_prefix;
23 const auto pivot = base58str.find(
'_');
24 FC_ASSERT(pivot != std::string::npos,
"No delimiter in string, cannot determine type: ${str}", (
"str", base58str));
26 const auto prefix_str = base58str.substr(0, pivot);
27 FC_ASSERT(prefix == prefix_str,
"Signature Key has invalid prefix: ${str}", (
"str", base58str)(
"prefix_str", prefix_str));
29 auto data_str = base58str.substr(pivot + 1);
30 FC_ASSERT(!data_str.empty(),
"Signature has no data: ${str}", (
"str", base58str));
31 return base58_str_parser<signature::storage_type, config::signature_prefix>::apply(data_str);
34 signature::signature(
const std::string& base58str)
35 :_storage(sig_parse_base58(base58str))
38 size_t signature::which()
const {
39 return _storage.index();
42 template<
class... Ts>
struct overloaded : Ts... {
using Ts::operator()...; };
45 size_t signature::variable_size()
const {
47 [&](
const auto& k1r1) {
48 return static_cast<size_t>(0);
51 return static_cast<size_t>(
wa.variable_size());
60 return std::string(config::signature_base_prefix) +
"_" + data_str;
std::string to_string(const fc::yield_function_t &yield=fc::yield_function_t()) const
stores null, int64, uint64, double, bool, string, std::vector<variant>, and variant_object's.
Defines exception's used by fc.
#define FC_ASSERT(TEST,...)
Checks a condition and throws an assert_exception if the test is FALSE.
#define FC_RETHROW_EXCEPTIONS(LOG_LEVEL, FORMAT,...)
Catchs all exception's, std::exceptions, and ... and rethrows them after appending the provided log m...
std::ostream & operator<<(std::ostream &s, const private_key &k)
overloaded(Ts...) -> overloaded< Ts... >
bool operator<(const private_key &p1, const private_key &p2)
size_t hash_value(const signature &b)
bool operator!=(const public_key &p1, const public_key &p2)
bool operator==(const private_key &p1, const private_key &p2)
void from_variant(const fc::variant &v, sysio::chain::chain_id_type &cid)
void to_variant(const sysio::chain::shared_public_key &var, fc::variant &vo)
static bool apply(const T &a, const T &b)
size_t operator()(const webauthn::signature &sig) const
size_t operator()(const SigType &sig) const
static bool apply(const T &a, const T &b)