hyperledger/iroha
Iroha - A simple, decentralized ledger http://iroha.tech
keys_manager_impl.hpp
Go to the documentation of this file.
1 
6 #ifndef IROHA_KEYS_MANAGER_IMPL_HPP
7 #define IROHA_KEYS_MANAGER_IMPL_HPP
8 
10 
11 #include <boost/filesystem.hpp>
12 #include <boost/optional.hpp>
13 #include "cryptography/keypair.hpp"
14 #include "logger/logger_fwd.hpp"
15 
16 namespace iroha {
17 
18  class KeysManagerImpl : public KeysManager {
19  public:
27  KeysManagerImpl(const std::string &account_id,
28  const boost::filesystem::path &path_to_keypair,
29  logger::LoggerPtr log);
30 
36  KeysManagerImpl(const std::string account_id, logger::LoggerPtr log);
37 
38  bool createKeys() override;
39 
40  bool createKeys(const std::string &pass_phrase) override;
41 
42  boost::optional<shared_model::crypto::Keypair> loadKeys() override;
43 
44  boost::optional<shared_model::crypto::Keypair> loadKeys(
45  const std::string &pass_phrase) override;
46 
47  static const std::string kPublicKeyExtension;
48  static const std::string kPrivateKeyExtension;
49 
50  private:
56  bool validate(const shared_model::crypto::Keypair &keypair) const;
57 
63  boost::optional<std::string> loadFile(
64  const boost::filesystem::path &path) const;
65 
72  bool store(const std::string &pub, const std::string &priv);
73 
74  boost::filesystem::path path_to_keypair_;
75  std::string account_id_;
76  logger::LoggerPtr log_;
77  };
78 } // namespace iroha
79 #endif // IROHA_KEYS_MANAGER_IMPL_HPP
Definition: keys_manager.hpp:18
Definition: keypair.hpp:19
bool createKeys() override
Definition: keys_manager_impl.cpp:115
boost::optional< shared_model::crypto::Keypair > loadKeys() override
Definition: keys_manager_impl.cpp:92
std::shared_ptr< Logger > LoggerPtr
Definition: logger_fwd.hpp:22
Definition: keys_manager_impl.hpp:18
static const std::string kPublicKeyExtension
Definition: keys_manager_impl.hpp:47
KeysManagerImpl(const std::string &account_id, const boost::filesystem::path &path_to_keypair, logger::LoggerPtr log)
Definition: keys_manager_impl.cpp:45
Definition: block_query.hpp:14
static const std::string kPrivateKeyExtension
Definition: keys_manager_impl.hpp:48