Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
private_key.hpp
Go to the documentation of this file.
1#pragma once
9
10namespace fc { namespace crypto {
11
12 namespace config {
13 constexpr const char* private_key_base_prefix = "PVT";
14 constexpr const char* private_key_prefix[] = {
15 "K1",
16 "R1",
17 "EM"
18 };
19 };
20
22 {
23 public:
24 using storage_type = std::variant<ecc::private_key_shim, r1::private_key_shim, em::private_key_shim>;
25
26 private_key() = default;
27 private_key( private_key&& ) = default;
28 private_key( const private_key& ) = default;
29 private_key& operator= (const private_key& ) = default;
30
32 signature sign( const sha256& digest, bool require_canonical = true ) const;
33 sha512 generate_shared_secret( const public_key& pub ) const;
34
35 template< typename KeyType = ecc::private_key_shim >
37 return private_key(storage_type(KeyType::generate()));
38 }
39
40 template< typename KeyType = r1::private_key_shim >
42 return private_key(storage_type(KeyType::generate()));
43 }
44
45 template< typename KeyType = ecc::private_key_shim >
46 static private_key regenerate( const typename KeyType::data_type& data ) {
47 return private_key(storage_type(KeyType(data)));
48 }
49
50 // serialize to/from string
51 explicit private_key(const string& base58str);
52 std::string to_string(const fc::yield_function_t& yield = fc::yield_function_t()) const;
53
54 private:
55 storage_type _storage;
56
57 private_key( storage_type&& other_storage )
58 :_storage(forward<storage_type>(other_storage))
59 {}
60
61 friend bool operator == ( const private_key& p1, const private_key& p2);
62 friend bool operator != ( const private_key& p1, const private_key& p2);
63 friend bool operator < ( const private_key& p1, const private_key& p2);
64 friend struct reflector<private_key>;
65 }; // private_key
66
67} } // fc::crypto
68
69namespace fc {
70 void to_variant(const crypto::private_key& var, variant& vo, const fc::yield_function_t& yield = fc::yield_function_t());
71
72 void from_variant(const variant& var, crypto::private_key& vo);
73} // namespace fc
74
std::string to_string(const fc::yield_function_t &yield=fc::yield_function_t()) const
std::variant< ecc::private_key_shim, r1::private_key_shim, em::private_key_shim > storage_type
friend bool operator==(const private_key &p1, const private_key &p2)
static private_key generate()
public_key get_public_key() const
signature sign(const sha256 &digest, bool require_canonical=true) const
static private_key regenerate(const typename KeyType::data_type &data)
sha512 generate_shared_secret(const public_key &pub) const
private_key(const private_key &)=default
private_key(private_key &&)=default
static private_key generate_r1()
friend bool operator!=(const private_key &p1, const private_key &p2)
friend bool operator<(const private_key &p1, const private_key &p2)
private_key & operator=(const private_key &)=default
constexpr const char * private_key_base_prefix
constexpr const char * private_key_prefix[]
namespace sysio::chain
Definition authority.cpp:3
fc::sha256 digest(const T &value)
Definition digest.hpp:9
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)
Definition authority.cpp:4
#define FC_REFLECT(TYPE, MEMBERS)
Specializes fc::reflector for TYPE.
Definition reflect.hpp:311
defines visit functions for T Unless this is specialized, visit() will not be defined for T.
Definition reflect.hpp:33