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

#include <private_key.hpp>

Public Types

using storage_type = std::variant<ecc::private_key_shim, r1::private_key_shim, em::private_key_shim>
 

Public Member Functions

 private_key ()=default
 
 private_key (private_key &&)=default
 
 private_key (const private_key &)=default
 
private_keyoperator= (const private_key &)=default
 
public_key get_public_key () const
 
signature sign (const sha256 &digest, bool require_canonical=true) const
 
sha512 generate_shared_secret (const public_key &pub) const
 
 private_key (const string &base58str)
 
std::string to_string (const fc::yield_function_t &yield=fc::yield_function_t()) const
 

Static Public Member Functions

template<typename KeyType = ecc::private_key_shim>
static private_key generate ()
 
template<typename KeyType = r1::private_key_shim>
static private_key generate_r1 ()
 
template<typename KeyType = ecc::private_key_shim>
static private_key regenerate (const typename KeyType::data_type &data)
 

Friends

struct reflector< private_key >
 
bool operator== (const private_key &p1, const private_key &p2)
 
bool operator!= (const private_key &p1, const private_key &p2)
 
bool operator< (const private_key &p1, const private_key &p2)
 

Detailed Description

Definition at line 21 of file private_key.hpp.

Member Typedef Documentation

◆ storage_type

Constructor & Destructor Documentation

◆ private_key() [1/4]

fc::crypto::private_key::private_key ( )
default
Here is the caller graph for this function:

◆ private_key() [2/4]

fc::crypto::private_key::private_key ( private_key && )
default

◆ private_key() [3/4]

fc::crypto::private_key::private_key ( const private_key & )
default

◆ private_key() [4/4]

fc::crypto::private_key::private_key ( const string & base58str)
explicit

Definition at line 110 of file private_key.cpp.

111 :_storage(priv_parse_base58(base58str))
112 {}

Member Function Documentation

◆ generate()

template<typename KeyType = ecc::private_key_shim>
static private_key fc::crypto::private_key::generate ( )
inlinestatic

Definition at line 36 of file private_key.hpp.

36 {
37 return private_key(storage_type(KeyType::generate()));
38 }
std::variant< ecc::private_key_shim, r1::private_key_shim, em::private_key_shim > storage_type
Here is the call graph for this function:
Here is the caller graph for this function:

◆ generate_r1()

template<typename KeyType = r1::private_key_shim>
static private_key fc::crypto::private_key::generate_r1 ( )
inlinestatic

Definition at line 41 of file private_key.hpp.

41 {
42 return private_key(storage_type(KeyType::generate()));
43 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ generate_shared_secret()

sha512 fc::crypto::private_key::generate_shared_secret ( const public_key & pub) const

Definition at line 57 of file private_key.cpp.

58 {
59 return std::visit(generate_shared_secret_visitor(pub._storage), _storage);
60 }
bool pub

◆ get_public_key()

public_key fc::crypto::private_key::get_public_key ( ) const

Definition at line 16 of file private_key.cpp.

17 {
18 return public_key(std::visit(public_key_visitor(), _storage));
19 }
Here is the caller graph for this function:

◆ operator=()

private_key & fc::crypto::private_key::operator= ( const private_key & )
default

◆ regenerate()

template<typename KeyType = ecc::private_key_shim>
static private_key fc::crypto::private_key::regenerate ( const typename KeyType::data_type & data)
inlinestatic

Definition at line 46 of file private_key.hpp.

46 {
47 return private_key(storage_type(KeyType(data)));
48 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ sign()

signature fc::crypto::private_key::sign ( const sha256 & digest,
bool require_canonical = true ) const

Definition at line 37 of file private_key.cpp.

38 {
39 return signature(std::visit(sign_visitor(digest, require_canonical), _storage));
40 }
fc::sha256 digest(const T &value)
Definition digest.hpp:9
bytes signature
Definition pke.hpp:17
Here is the call graph for this function:

◆ to_string()

std::string fc::crypto::private_key::to_string ( const fc::yield_function_t & yield = fc::yield_function_t()) const

Definition at line 114 of file private_key.cpp.

115 {
116 auto which = _storage.index();
117
118 if (which == 0) {
119 using default_type = std::variant_alternative_t<0, private_key::storage_type>;
120 return to_wif(std::template get<default_type>(_storage), yield);
121 }
122
123 auto data_str = std::visit(base58str_visitor<storage_type, config::private_key_prefix>(yield), _storage);
124 return std::string(config::private_key_base_prefix) + "_" + data_str;
125 }
string to_wif(const Data &secret, const fc::yield_function_t &yield)
Here is the call graph for this function:
Here is the caller graph for this function:

Friends And Related Symbol Documentation

◆ operator!=

bool operator!= ( const private_key & p1,
const private_key & p2 )
friend

◆ operator<

bool operator< ( const private_key & p1,
const private_key & p2 )
friend

Definition at line 136 of file private_key.cpp.

137 {
138 return less_comparator<private_key::storage_type>::apply(p1._storage, p2._storage);
139 }
static bool apply(const T &a, const T &b)
Definition common.hpp:147

◆ operator==

bool operator== ( const private_key & p1,
const private_key & p2 )
friend

Definition at line 132 of file private_key.cpp.

132 {
133 return eq_comparator<private_key::storage_type>::apply(p1._storage, p2._storage);
134 }
static bool apply(const T &a, const T &b)
Definition common.hpp:119

◆ reflector< private_key >

friend struct reflector< private_key >
friend

Definition at line 63 of file private_key.hpp.


The documentation for this class was generated from the following files: