Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
sysio::wallet::yubihsm_wallet Class Referencefinal

#include <yubihsm_wallet.hpp>

Inheritance diagram for sysio::wallet::yubihsm_wallet:
Collaboration diagram for sysio::wallet::yubihsm_wallet:

Public Member Functions

 yubihsm_wallet (const string &connector, const uint16_t authkey)
 
 ~yubihsm_wallet ()
 
private_key_type get_private_key (public_key_type pubkey) const override
 
bool is_locked () const override
 
void lock () override
 
void unlock (string password) override
 
void check_password (string password) override
 
void set_password (string password) override
 
map< public_key_type, private_key_typelist_keys () override
 
flat_set< public_key_typelist_public_keys () override
 
bool import_key (string wif_key) override
 
string create_key (string key_type) override
 
bool remove_key (string key) override
 
std::optional< signature_typetry_sign_digest (const digest_type digest, const public_key_type public_key) override
 
- Public Member Functions inherited from sysio::wallet::wallet_api
virtual ~wallet_api ()
 

Detailed Description

Definition at line 15 of file yubihsm_wallet.hpp.

Constructor & Destructor Documentation

◆ yubihsm_wallet()

sysio::wallet::yubihsm_wallet::yubihsm_wallet ( const string & connector,
const uint16_t authkey )

Definition at line 212 of file yubihsm_wallet.cpp.

212 : my(new detail::yubihsm_wallet_impl(connector, authkey)) {
213}

◆ ~yubihsm_wallet()

sysio::wallet::yubihsm_wallet::~yubihsm_wallet ( )

Definition at line 215 of file yubihsm_wallet.cpp.

215 {
216}

Member Function Documentation

◆ check_password()

void sysio::wallet::yubihsm_wallet::check_password ( string password)
overridevirtual

Checks the password of the wallet

Validates the password on a wallet even if the wallet is already unlocked, throws if bad password given.

Parameters
passwordthe password previously set with set_password()

Implements sysio::wallet::wallet_api.

Definition at line 233 of file yubihsm_wallet.cpp.

233 {
234 //just leave this as a noop for now; remove_key from wallet_mgr calls through here
235}

◆ create_key()

string sysio::wallet::yubihsm_wallet::create_key ( string key_type)
overridevirtual

Creates a key within the wallet to be used to sign transactions by an account.

example: create_key K1

Parameters
key_typethe key type to create. May be empty to allow wallet to pick appropriate/"best" key type

Implements sysio::wallet::wallet_api.

Definition at line 253 of file yubihsm_wallet.cpp.

253 {
254 SYS_ASSERT(key_type.empty() || key_type == "R1", chain::unsupported_key_type_exception, "YubiHSM wallet only supports R1 keys");
255 return my->create().to_string();
256}
#define SYS_ASSERT(expr, exc_type, FORMAT,...)
Definition exceptions.hpp:7
struct @108 key_type

◆ get_private_key()

private_key_type sysio::wallet::yubihsm_wallet::get_private_key ( public_key_type pubkey) const
overridevirtual

Get the private key corresponding to a public key. The private key must already be in the wallet.

Implements sysio::wallet::wallet_api.

Definition at line 218 of file yubihsm_wallet.cpp.

218 {
219 FC_THROW_EXCEPTION(chain::wallet_exception, "Obtaining private key for a key stored in YubiHSM is impossible");
220}
#define FC_THROW_EXCEPTION(EXCEPTION, FORMAT,...)

◆ import_key()

bool sysio::wallet::yubihsm_wallet::import_key ( string wif_key)
overridevirtual

Imports a WIF Private Key into the wallet to be used to sign transactions by an account.

example: import_key 5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3

Parameters
wif_keythe WIF Private Key to import

Implements sysio::wallet::wallet_api.

Definition at line 249 of file yubihsm_wallet.cpp.

249 {
250 FC_THROW_EXCEPTION(chain::wallet_exception, "It is not possible to import a key in to the YubiHSM wallet");
251}

◆ is_locked()

bool sysio::wallet::yubihsm_wallet::is_locked ( ) const
overridevirtual

Checks whether the wallet is locked (is unable to use its private keys).

This state can be changed by calling lock() or unlock().

Returns
true if the wallet is locked

Implements sysio::wallet::wallet_api.

Definition at line 222 of file yubihsm_wallet.cpp.

222 {
223 return my->is_locked();
224}
Here is the caller graph for this function:

◆ list_keys()

map< public_key_type, private_key_type > sysio::wallet::yubihsm_wallet::list_keys ( )
overridevirtual

Dumps all private keys owned by the wallet.

The keys are printed in WIF format. You can import these keys into another wallet using import_key()

Returns
a map containing the private keys, indexed by their public key

Implements sysio::wallet::wallet_api.

Definition at line 240 of file yubihsm_wallet.cpp.

240 {
241 FC_THROW_EXCEPTION(chain::wallet_exception, "Getting the private keys from the YubiHSM wallet is impossible");
242}

◆ list_public_keys()

flat_set< public_key_type > sysio::wallet::yubihsm_wallet::list_public_keys ( )
overridevirtual

Dumps all public keys owned by the wallet.

Returns
a vector containing the public keys

Implements sysio::wallet::wallet_api.

Definition at line 243 of file yubihsm_wallet.cpp.

243 {
244 flat_set<public_key_type> keys;
245 boost::copy(my->_keys | boost::adaptors::map_keys, std::inserter(keys, keys.end()));
246 return keys;
247}

◆ lock()

void sysio::wallet::yubihsm_wallet::lock ( )
overridevirtual

Locks the wallet immediately

Implements sysio::wallet::wallet_api.

Definition at line 225 of file yubihsm_wallet.cpp.

225 {
227 my->lock();
228}
bool is_locked() const override
#define FC_ASSERT(TEST,...)
Checks a condition and throws an assert_exception if the test is FALSE.
Here is the call graph for this function:

◆ remove_key()

bool sysio::wallet::yubihsm_wallet::remove_key ( string key)
overridevirtual

Removes a key from the wallet.

example: remove_key SYS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV

Parameters
keythe Public Key to remove

Implements sysio::wallet::wallet_api.

Definition at line 258 of file yubihsm_wallet.cpp.

258 {
260 FC_THROW_EXCEPTION(chain::wallet_exception, "YubiHSM wallet does not currently support removal of keys");
261 return true;
262}
Here is the call graph for this function:

◆ set_password()

void sysio::wallet::yubihsm_wallet::set_password ( string password)
overridevirtual

Sets a new password on the wallet.

The wallet must be either 'new' or 'unlocked' to execute this command.

Implements sysio::wallet::wallet_api.

Definition at line 236 of file yubihsm_wallet.cpp.

236 {
237 FC_THROW_EXCEPTION(chain::wallet_exception, "YubiHSM wallet cannot have a password set");
238}

◆ try_sign_digest()

std::optional< signature_type > sysio::wallet::yubihsm_wallet::try_sign_digest ( const digest_type digest,
const public_key_type public_key )
overridevirtual

Returns a signature given the digest and public_key, if this wallet can sign via that public key

Implements sysio::wallet::wallet_api.

Definition at line 264 of file yubihsm_wallet.cpp.

264 {
265 return my->try_sign_digest(digest, public_key);
266}
fc::sha256 digest(const T &value)
Definition digest.hpp:9
Here is the call graph for this function:

◆ unlock()

void sysio::wallet::yubihsm_wallet::unlock ( string password)
overridevirtual

Unlocks the wallet.

The wallet remain unlocked until the lock is called or the program exits.

Parameters
passwordthe password previously set with set_password()

Implements sysio::wallet::wallet_api.

Definition at line 230 of file yubihsm_wallet.cpp.

230 {
231 my->unlock(password);
232}

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