Fabcoin Core
0.16.2
P2P Digital Currency
|
High-level manager of password-encrypted keys for Ethereum. More...
#include <KeyManager.h>
Public Types | |
enum | NewKeyType { NewKeyType::DirectICAP = 0, NewKeyType::NoVanity, NewKeyType::FirstTwo, NewKeyType::FirstTwoNextTwo, NewKeyType::FirstThree, NewKeyType::FirstFour } |
Public Member Functions | |
KeyManager (std::string const &_keysFile=defaultPath(), std::string const &_secretsPath=SecretStore::defaultPath()) | |
~KeyManager () | |
void | setSecretsPath (std::string const &_secretsPath) |
void | setKeysFile (std::string const &_keysFile) |
std::string const & | keysFile () const |
bool | exists () const |
void | create (std::string const &_pass) |
bool | load (std::string const &_pass) |
void | save (std::string const &_pass) const |
void | notePassword (std::string const &_pass) |
void | noteHint (std::string const &_pass, std::string const &_hint) |
bool | haveHint (std::string const &_pass) const |
Addresses | accounts () const |
AddressHash | accountsHash () const |
bool | hasAccount (Address const &_address) const |
std::string const & | accountName (Address const &_address) const |
std::string const & | passwordHint (Address const &_address) const |
void | changeName (Address const &_address, std::string const &_name) |
Should be called to change password. More... | |
bool | haveKey (Address const &_a) const |
h128 | uuid (Address const &_a) const |
Address | address (h128 const &_uuid) const |
h128 | import (Secret const &_s, std::string const &_accountName, std::string const &_pass, std::string const &_passwordHint) |
h128 | import (Secret const &_s, std::string const &_accountName) |
Address | importBrain (std::string const &_seed, std::string const &_accountName, std::string const &_seedHint) |
void | importExistingBrain (Address const &_a, std::string const &_accountName, std::string const &_seedHint) |
SecretStore & | store () |
void | importExisting (h128 const &_uuid, std::string const &_accountName, std::string const &_pass, std::string const &_passwordHint) |
void | importExisting (h128 const &_uuid, std::string const &_accountName) |
void | importExisting (h128 const &_uuid, std::string const &_accountName, Address const &_addr, h256 const &_passHash=h256(), std::string const &_passwordHint=std::string()) |
Secret | secret (Address const &_address, std::function< std::string()> const &_pass=DontKnowThrow, bool _usePasswordCache=true) const |
Secret | secret (h128 const &_uuid, std::function< std::string()> const &_pass=DontKnowThrow, bool _usePasswordCache=true) const |
bool | recode (Address const &_address, SemanticPassword _newPass, std::function< std::string()> const &_pass=DontKnowThrow, KDF _kdf=KDF::Scrypt) |
bool | recode (Address const &_address, std::string const &_newPass, std::string const &_hint, std::function< std::string()> const &_pass=DontKnowThrow, KDF _kdf=KDF::Scrypt) |
void | kill (h128 const &_id) |
void | kill (Address const &_a) |
Static Public Member Functions | |
static std::string | defaultPath () |
static KeyPair | presaleSecret (std::string const &_json, std::function< std::string(bool)> const &_password) |
Extracts the secret key from the presale wallet. More... | |
static Secret | brain (std::string const &_seed) |
static Secret | subkey (Secret const &_s, unsigned _index) |
static KeyPair | newKeyPair (NewKeyType _type) |
Private Member Functions | |
std::string | getPassword (h128 const &_uuid, std::function< std::string()> const &_pass=DontKnowThrow) const |
std::string | getPassword (h256 const &_passHash, std::function< std::string()> const &_pass=DontKnowThrow) const |
std::string | defaultPassword (std::function< std::string()> const &_pass=DontKnowThrow) const |
h256 | hashPassword (std::string const &_pass) const |
void | cachePassword (std::string const &_password) const |
Stores the password by its hash in the password cache. More... | |
bool | write () const |
bool | write (std::string const &_keysFile) const |
void | write (std::string const &_pass, std::string const &_keysFile) const |
void | write (SecureFixedHash< 16 > const &_key, std::string const &_keysFile) const |
Private Attributes | |
std::unordered_map< h128, Address > | m_uuidLookup |
Mapping key uuid -> address. More... | |
std::unordered_map< Address, h128 > | m_addrLookup |
Mapping address -> key uuid. More... | |
std::unordered_map< Address, KeyInfo > | m_keyInfo |
Mapping address -> key info. More... | |
std::unordered_map< h256, std::string > | m_passwordHint |
Mapping password hash -> password hint. More... | |
std::unordered_map< h256, std::string > | m_cachedPasswords |
std::string | m_defaultPasswordDeprecated |
std::string | m_keysFile |
SecureFixedHash< 16 > | m_keysFileKey |
h256 | m_master |
SecretStore | m_store |
High-level manager of password-encrypted keys for Ethereum.
Usage:
Call exists() to check whether there is already a database. If so, get the master password from the user and call load() with it. If not, get a new master password from the user (get them to type it twice and keep some hint around!) and call create() with it.
Uses a "key file" (and a corresponding .salt file) that contains encrypted information about the keys and a directory called "secrets path" that contains a file for each key.
Definition at line 72 of file KeyManager.h.
|
strong |
Enumerator | |
---|---|
DirectICAP | |
NoVanity | |
FirstTwo | |
FirstTwoNextTwo | |
FirstThree | |
FirstFour |
Definition at line 75 of file KeyManager.h.
KeyManager::KeyManager | ( | std::string const & | _keysFile = defaultPath() , |
std::string const & | _secretsPath = SecretStore::defaultPath() |
||
) |
KeyManager::~KeyManager | ( | ) |
Definition at line 48 of file KeyManager.cpp.
string const & KeyManager::accountName | ( | Address const & | _address | ) | const |
Definition at line 351 of file KeyManager.cpp.
Addresses KeyManager::accounts | ( | ) | const |
Definition at line 328 of file KeyManager.cpp.
|
inline |
Definition at line 96 of file KeyManager.h.
Definition at line 205 of file KeyManager.cpp.
|
static |
Definition at line 227 of file KeyManager.cpp.
|
private |
Stores the password by its hash in the password cache.
Definition at line 394 of file KeyManager.cpp.
void KeyManager::changeName | ( | Address const & | _address, |
std::string const & | _name | ||
) |
Should be called to change password.
Definition at line 363 of file KeyManager.cpp.
void KeyManager::create | ( | std::string const & | _pass | ) |
Definition at line 56 of file KeyManager.cpp.
|
inlineprivate |
Definition at line 152 of file KeyManager.h.
|
inlinestatic |
Definition at line 136 of file KeyManager.h.
bool KeyManager::exists | ( | ) | const |
Definition at line 51 of file KeyManager.cpp.
|
private |
|
private |
bool KeyManager::hasAccount | ( | Address const & | _address | ) | const |
|
private |
Definition at line 388 of file KeyManager.cpp.
|
inline |
|
inline |
Definition at line 107 of file KeyManager.h.
h128 dev::eth::KeyManager::import | ( | Secret const & | _s, |
std::string const & | _accountName, | ||
std::string const & | _pass, | ||
std::string const & | _passwordHint | ||
) |
Definition at line 114 of file KeyManager.h.
Address KeyManager::importBrain | ( | std::string const & | _seed, |
std::string const & | _accountName, | ||
std::string const & | _seedHint | ||
) |
void dev::eth::KeyManager::importExisting | ( | h128 const & | _uuid, |
std::string const & | _accountName, | ||
std::string const & | _pass, | ||
std::string const & | _passwordHint | ||
) |
|
inline |
Definition at line 120 of file KeyManager.h.
void dev::eth::KeyManager::importExisting | ( | h128 const & | _uuid, |
std::string const & | _accountName, | ||
Address const & | _addr, | ||
h256 const & | _passHash = h256() , |
||
std::string const & | _passwordHint = std::string() |
||
) |
void KeyManager::importExistingBrain | ( | Address const & | _a, |
std::string const & | _accountName, | ||
std::string const & | _seedHint | ||
) |
|
inline |
|
inline |
Definition at line 133 of file KeyManager.h.
void KeyManager::kill | ( | Address const & | _a | ) |
bool KeyManager::load | ( | std::string const & | _pass | ) |
Definition at line 88 of file KeyManager.cpp.
|
static |
Definition at line 441 of file KeyManager.cpp.
|
inline |
|
inline |
string const & KeyManager::passwordHint | ( | Address const & | _address | ) | const |
Definition at line 373 of file KeyManager.cpp.
|
static |
Extracts the secret key from the presale wallet.
Definition at line 298 of file KeyManager.cpp.
bool dev::eth::KeyManager::recode | ( | Address const & | _address, |
SemanticPassword | _newPass, | ||
std::function< std::string()> const & | _pass = DontKnowThrow , |
||
KDF | _kdf = KDF::Scrypt |
||
) |
bool dev::eth::KeyManager::recode | ( | Address const & | _address, |
std::string const & | _newPass, | ||
std::string const & | _hint, | ||
std::function< std::string()> const & | _pass = DontKnowThrow , |
||
KDF | _kdf = KDF::Scrypt |
||
) |
|
inline |
Secret dev::eth::KeyManager::secret | ( | Address const & | _address, |
std::function< std::string()> const & | _pass = DontKnowThrow , |
||
bool | _usePasswordCache = true |
||
) | const |
Secret dev::eth::KeyManager::secret | ( | h128 const & | _uuid, |
std::function< std::string()> const & | _pass = DontKnowThrow , |
||
bool | _usePasswordCache = true |
||
) | const |
|
inline |
|
inline |
Definition at line 80 of file KeyManager.h.
|
inline |
Definition at line 239 of file KeyManager.cpp.
Definition at line 197 of file KeyManager.cpp.
|
inlineprivate |
Definition at line 160 of file KeyManager.h.
|
private |
|
private |
|
private |
Mapping address -> key uuid.
Definition at line 170 of file KeyManager.h.
|
mutableprivate |
Definition at line 177 of file KeyManager.h.
|
private |
Definition at line 184 of file KeyManager.h.
Mapping address -> key info.
Definition at line 172 of file KeyManager.h.
|
mutableprivate |
Definition at line 186 of file KeyManager.h.
|
mutableprivate |
Definition at line 187 of file KeyManager.h.
|
mutableprivate |
Definition at line 188 of file KeyManager.h.
|
private |
Mapping password hash -> password hint.
Definition at line 174 of file KeyManager.h.
|
private |
Definition at line 189 of file KeyManager.h.
Mapping key uuid -> address.
Definition at line 168 of file KeyManager.h.