-
Notifications
You must be signed in to change notification settings - Fork 40
Expand file tree
/
Copy pathsodium.hpp
More file actions
64 lines (52 loc) · 1.95 KB
/
sodium.hpp
File metadata and controls
64 lines (52 loc) · 1.95 KB
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
56
57
58
59
60
61
62
63
64
/**
* Copyright (c) 2011-2026 libbitcoin developers (see AUTHORS)
*
* This file is part of libbitcoin.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef LIBBITCOIN_PROTOCOL_CONFIG_SODIUM_HPP
#define LIBBITCOIN_PROTOCOL_CONFIG_SODIUM_HPP
#include <bitcoin/system.hpp>
#include <bitcoin/protocol/define.hpp>
namespace libbitcoin {
namespace protocol {
/// Serialization helper for base58 sodium keys.
class BCP_API sodium
{
public:
DEFAULT_COPY_MOVE_DESTRUCT(sodium);
/// A list of base85 values.
/// This must provide operator<< for ostream in order to be used as a
/// boost::program_options default_value.
sodium() NOEXCEPT;
sodium(const std::string& base85) THROWS;
sodium(const system::hash_digest& value) NOEXCEPT;
/// True if the key is initialized.
operator bool() const NOEXCEPT;
/// Overload cast to internal type.
operator const system::hash_digest&() const NOEXCEPT;
/// Get the key as a base85 encoded (z85) string.
std::string to_string() const NOEXCEPT;
friend std::istream& operator>>(std::istream& input,
sodium& argument) THROWS;
friend std::ostream& operator<<(std::ostream& output,
const sodium& argument) THROWS;
private:
system::hash_digest value_;
};
typedef std::vector<sodium> sodiums;
} // namespace protocol
} // namespace libbitcoin
#endif