Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
fc::crypto Namespace Reference

Namespaces

namespace  config
 
namespace  r1
 
namespace  webauthn
 

Classes

struct  base58_str_parser
 
struct  base58_str_parser< std::variant< Ts... >, Prefixes >
 
struct  base58_str_parser_impl
 
struct  base58_str_parser_impl< Result, Prefixes, Position >
 
struct  base58_str_parser_impl< Result, Prefixes, Position, KeyType, Rem... >
 
struct  base58str_visitor
 
struct  checksummed_data
 
struct  eq_comparator
 
struct  eq_comparator< std::variant< Ts... > >
 
struct  eq_comparator< webauthn::public_key >
 
struct  eq_comparator< webauthn::signature >
 
struct  generate_shared_secret_visitor
 
struct  hash_visitor
 
struct  is_valid_visitor
 
struct  less_comparator
 
struct  less_comparator< std::variant< Ts... > >
 
struct  less_comparator< webauthn::public_key >
 
struct  less_comparator< webauthn::signature >
 
struct  overloaded
 
class  private_key
 
class  public_key
 
struct  public_key_visitor
 
struct  recovery_visitor
 
struct  shim
 
struct  sign_visitor
 
class  signature
 

Functions

bool prefix_matches (const char *prefix, const std::string &str)
 
size_t hash_value (const signature &b)
 
template<typename Data >
string to_wif (const Data &secret, const fc::yield_function_t &yield)
 
template<typename Data >
Data from_wif (const string &wif_key)
 
std::ostream & operator<< (std::ostream &s, const private_key &k)
 
bool operator== (const private_key &p1, const private_key &p2)
 
bool operator< (const private_key &p1, const private_key &p2)
 
std::ostream & operator<< (std::ostream &s, const public_key &k)
 
bool operator== (const public_key &p1, const public_key &p2)
 
bool operator!= (const public_key &p1, const public_key &p2)
 
bool operator< (const public_key &p1, const public_key &p2)
 
template<class... Ts>
 overloaded (Ts...) -> overloaded< Ts... >
 
std::ostream & operator<< (std::ostream &s, const signature &k)
 
bool operator== (const signature &p1, const signature &p2)
 
bool operator!= (const signature &p1, const signature &p2)
 
bool operator< (const signature &p1, const signature &p2)
 

Function Documentation

◆ from_wif()

template<typename Data >
Data fc::crypto::from_wif ( const string & wif_key)

Definition at line 77 of file private_key.cpp.

78 {
79 auto wif_bytes = from_base58(wif_key);
80 FC_ASSERT(wif_bytes.size() >= 5);
81 auto key_bytes = vector<char>(wif_bytes.begin() + 1, wif_bytes.end() - 4);
82 fc::sha256 check = fc::sha256::hash(wif_bytes.data(), wif_bytes.size() - 4);
83 fc::sha256 check2 = fc::sha256::hash(check);
84
85 FC_ASSERT(memcmp( (char*)&check, wif_bytes.data() + wif_bytes.size() - 4, 4 ) == 0 ||
86 memcmp( (char*)&check2, wif_bytes.data() + wif_bytes.size() - 4, 4 ) == 0 );
87
88 return Data(fc::variant(key_bytes).as<typename Data::data_type>());
89 }
static sha256 hash(const char *d, uint32_t dlen)
Definition sha256.cpp:44
stores null, int64, uint64, double, bool, string, std::vector<variant>, and variant_object's.
Definition variant.hpp:191
#define FC_ASSERT(TEST,...)
Checks a condition and throws an assert_exception if the test is FALSE.
std::vector< char > from_base58(const std::string &base58_str)
Definition base58.cpp:628
Definition zm2.cpp:48
Here is the call graph for this function:

◆ hash_value()

size_t fc::crypto::hash_value ( const signature & b)

Definition at line 81 of file signature.cpp.

81 {
82 return std::visit(hash_visitor(), b._storage);
83 }
Here is the caller graph for this function:

◆ operator!=() [1/2]

bool fc::crypto::operator!= ( const public_key & p1,
const public_key & p2 )

Definition at line 96 of file public_key.cpp.

96 {
97 return !(p1 == p2);
98 }

◆ operator!=() [2/2]

bool fc::crypto::operator!= ( const signature & p1,
const signature & p2 )

Definition at line 72 of file signature.cpp.

72 {
73 return !eq_comparator<signature::storage_type>::apply(p1._storage, p2._storage);
74 }

◆ operator<() [1/3]

bool fc::crypto::operator< ( const private_key & p1,
const private_key & p2 )

Definition at line 136 of file private_key.cpp.

137 {
138 return less_comparator<private_key::storage_type>::apply(p1._storage, p2._storage);
139 }

◆ operator<() [2/3]

bool fc::crypto::operator< ( const public_key & p1,
const public_key & p2 )

Definition at line 100 of file public_key.cpp.

◆ operator<() [3/3]

bool fc::crypto::operator< ( const signature & p1,
const signature & p2 )

Definition at line 76 of file signature.cpp.

77 {
78 return less_comparator<signature::storage_type>::apply(p1._storage, p2._storage);
79 }

◆ operator<<() [1/3]

std::ostream & fc::crypto::operator<< ( std::ostream & s,
const private_key & k )

Definition at line 127 of file private_key.cpp.

127 {
128 s << "private_key(" << k.to_string() << ')';
129 return s;
130 }
std::string to_string(const fc::yield_function_t &yield=fc::yield_function_t()) const
char * s
Here is the call graph for this function:

◆ operator<<() [2/3]

std::ostream & fc::crypto::operator<< ( std::ostream & s,
const public_key & k )

Definition at line 87 of file public_key.cpp.

87 {
88 s << "public_key(" << k.to_string() << ')';
89 return s;
90 }
std::string to_string(const fc::yield_function_t &yield=fc::yield_function_t()) const

◆ operator<<() [3/3]

std::ostream & fc::crypto::operator<< ( std::ostream & s,
const signature & k )

Definition at line 63 of file signature.cpp.

63 {
64 s << "signature(" << k.to_string() << ')';
65 return s;
66 }
std::string to_string(const fc::yield_function_t &yield=fc::yield_function_t()) const
Definition signature.cpp:56
Here is the call graph for this function:

◆ operator==() [1/3]

bool fc::crypto::operator== ( const private_key & p1,
const private_key & p2 )

Definition at line 132 of file private_key.cpp.

132 {
133 return eq_comparator<private_key::storage_type>::apply(p1._storage, p2._storage);
134 }

◆ operator==() [2/3]

bool fc::crypto::operator== ( const public_key & p1,
const public_key & p2 )

Definition at line 92 of file public_key.cpp.

◆ operator==() [3/3]

bool fc::crypto::operator== ( const signature & p1,
const signature & p2 )

Definition at line 68 of file signature.cpp.

68 {
69 return eq_comparator<signature::storage_type>::apply(p1._storage, p2._storage);
70 }

◆ overloaded()

template<class... Ts>
fc::crypto::overloaded ( Ts... ) -> overloaded< Ts... >

◆ prefix_matches()

bool fc::crypto::prefix_matches ( const char * prefix,
const std::string & str )
inline

Definition at line 27 of file common.hpp.

27 {
28 auto prefix_len = const_strlen(prefix);
29 return str.size() > prefix_len && str.substr(0, prefix_len).compare(prefix) == 0;
30 }
Here is the call graph for this function:

◆ to_wif()

template<typename Data >
string fc::crypto::to_wif ( const Data & secret,
const fc::yield_function_t & yield )

Definition at line 63 of file private_key.cpp.

64 {
65 const size_t size_of_data_to_hash = sizeof(typename Data::data_type) + 1;
66 const size_t size_of_hash_bytes = 4;
67 char data[size_of_data_to_hash + size_of_hash_bytes];
68 data[0] = (char)0x80; // this is the Bitcoin MainNet code
69 memcpy(&data[1], (const char*)&secret.serialize(), sizeof(typename Data::data_type));
70 sha256 digest = sha256::hash(data, size_of_data_to_hash);
71 digest = sha256::hash(digest);
72 memcpy(data + size_of_data_to_hash, (char*)&digest, size_of_hash_bytes);
73 return to_base58(data, sizeof(data), yield);
74 }
std::string to_base58(const char *d, size_t s, const fc::yield_function_t &yield)
Definition base58.cpp:618
fc::sha256 digest(const T &value)
Definition digest.hpp:9
memcpy((char *) pInfo->slotDescription, s, l)
Here is the call graph for this function:
Here is the caller graph for this function: