forked from hyperledger-iroha/iroha-dco
-
Notifications
You must be signed in to change notification settings - Fork 0
/
keys_manager.hpp
55 lines (46 loc) · 1.72 KB
/
keys_manager.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/**
* Copyright Soramitsu Co., Ltd. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef IROHA_KEYS_MANAGER_HPP
#define IROHA_KEYS_MANAGER_HPP
#include <string>
#include <boost/optional.hpp>
#include "cryptography/keypair.hpp"
namespace iroha {
/**
* Interface provides facilities to create and store keypair on disk.
*/
class KeysManager {
public:
virtual ~KeysManager() = default;
/**
* Create keys of a new keypair and store them on disk
* @return false if keys creation was failed
*/
virtual bool createKeys() = 0;
/**
* Create keys of a new keypair and store it encrypted on disk
* @param pass_phrase is used for private key encryption
* @return false if keys creation was failed
*/
virtual bool createKeys(const std::string &pass_phrase) = 0;
/**
* Load keys associated with the manager, then validate loaded keypair by
* signing and verifying the signature of a test message
* @return nullopt if no keypair found locally, or in case of verification
* failure. Otherwise - the keypair will be returned
*/
virtual boost::optional<shared_model::crypto::Keypair> loadKeys() = 0;
/**
* Load encrypted keys associated with the manager, then validate loaded
* keypair by signing and verifying the signature of a test message
* @param pass_phrase is a password for decryption
* @return nullopt if no keypair found locally, or in case of verification
* failure. Otherwise - the keypair will be returned
*/
virtual boost::optional<shared_model::crypto::Keypair> loadKeys(
const std::string &pass_phrase) = 0;
};
} // namespace iroha
#endif // IROHA_KEYS_MANAGER_HPP