Skip to content

Commit 86b90b4

Browse files
committed
Comment style.
1 parent a5e0b68 commit 86b90b4

1 file changed

Lines changed: 82 additions & 109 deletions

File tree

include/bitcoin/system/wallet/keys/encrypted_keys.hpp

Lines changed: 82 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
/**
2-
* Copyright (c) 2011-2025 libbitcoin developers (see AUTHORS)
2+
/// Copyright (c) 2011-2025 libbitcoin developers (see AUTHORS)
33
*
4-
* This file is part of libbitcoin.
4+
/// This file is part of libbitcoin.
55
*
6-
* This program is free software: you can redistribute it and/or modify
7-
* it under the terms of the GNU Affero General Public License as published by
8-
* the Free Software Foundation, either version 3 of the License, or
9-
* (at your option) any later version.
6+
/// This program is free software: you can redistribute it and/or modify
7+
/// it under the terms of the GNU Affero General Public License as published by
8+
/// the Free Software Foundation, either version 3 of the License, or
9+
/// (at your option) any later version.
1010
*
11-
* This program is distributed in the hope that it will be useful,
12-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14-
* GNU Affero General Public License for more details.
11+
/// This program is distributed in the hope that it will be useful,
12+
/// but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
/// GNU Affero General Public License for more details.
1515
*
16-
* You should have received a copy of the GNU Affero General Public License
17-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
/// You should have received a copy of the GNU Affero General Public License
17+
/// along with this program. If not, see <http://www.gnu.org/licenses/>.
1818
*/
1919
#ifndef LIBBITCOIN_SYSTEM_WALLET_KEYS_ENCRYPTED_KEYS_HPP
2020
#define LIBBITCOIN_SYSTEM_WALLET_KEYS_ENCRYPTED_KEYS_HPP
@@ -29,56 +29,42 @@ namespace libbitcoin {
2929
namespace system {
3030
namespace wallet {
3131

32-
/**
33-
* The maximum lot and sequence values for encrypted key token creation.
34-
*/
32+
/// The maximum lot and sequence values for encrypted key token creation.
3533
static constexpr uint32_t ek_max_lot = 1048575;
3634
static constexpr uint32_t ek_max_sequence = 4095;
3735

38-
/**
39-
* A seed for use in creating an intermediate passphrase (token).
40-
*/
36+
/// A seed for use in creating an intermediate passphrase (token).
4137
static constexpr size_t ek_salt_size = 4;
4238
typedef data_array<ek_salt_size> ek_salt;
4339

44-
/**
45-
* A seed for use in creating an intermediate passphrase (token).
46-
*/
40+
/// A seed for use in creating an intermediate passphrase (token).
4741
static constexpr size_t ek_entropy_size = 8;
4842
typedef data_array<ek_entropy_size> ek_entropy;
4943

50-
/**
51-
* A seed for use in creating a key pair.
52-
*/
44+
/// A seed for use in creating a key pair.
5345
static constexpr size_t ek_seed_size = 24;
5446
typedef data_array<ek_seed_size> ek_seed;
5547

56-
/**
57-
* An intermediate passphrase (token) type (checked but not base58 encoded).
58-
*/
48+
/// An intermediate passphrase (token) type (checked but not base58 encoded).
5949
static constexpr size_t encrypted_token_encoded_size = 72;
6050
static constexpr size_t encrypted_token_decoded_size = 53;
6151
typedef data_array<encrypted_token_decoded_size> encrypted_token;
6252

63-
/**
64-
* An encrypted private key type (checked but not base58 encoded).
65-
*/
53+
/// An encrypted private key type (checked but not base58 encoded).
6654
static constexpr size_t ek_private_encoded_size = 58;
6755
static constexpr size_t ek_private_decoded_size = 43;
6856
typedef data_array<ek_private_decoded_size> encrypted_private;
6957

70-
/**
71-
* DEPRECATED
72-
* An encrypted public key type (checked but not base58 encoded).
73-
* This is refered to as a confirmation code in bip38.
74-
*/
58+
/// DEPRECATED
59+
/// An encrypted public key type (checked but not base58 encoded).
60+
/// This is refered to as a confirmation code in bip38.
7561
static constexpr size_t encrypted_public_encoded_size = 75;
7662
static constexpr size_t encrypted_public_decoded_size = 55;
7763
typedef data_array<encrypted_public_decoded_size> encrypted_public;
7864

79-
// BIP38
80-
// It is requested that the unused flag bytes NOT be used for denoting that
81-
// the key belongs to an alt-chain [This shoud read "flag bits"].
65+
/// BIP38
66+
/// It is requested that the unused flag bytes NOT be used for denoting that
67+
/// the key belongs to an alt-chain [This shoud read "flag bits"].
8268
enum ek_flag : uint8_t
8369
{
8470
lot_sequence_key = 1 << 2,
@@ -90,101 +76,88 @@ enum ek_flag : uint8_t
9076
ec_non_multiplied = (ec_non_multiplied_low | ec_non_multiplied_high)
9177
};
9278

93-
/**
94-
* Create an encrypted private key from an intermediate passphrase.
95-
* The `out_point` parameter is always compressed, so to use it it should be
96-
* decompressed as necessary to match the state of the `compressed` parameter.
97-
* @param[out] out_private The new encrypted private key.
98-
* @param[out] out_point The ec compressed public key of the new key pair.
99-
* @param[in] token An intermediate passphrase string.
100-
* @param[in] seed A random value for use in the encryption.
101-
* @param[in] version The coin address version byte.
102-
* @param[in] compressed Set true to associate ec public key compression.
103-
* @return false if the token checksum is not valid.
104-
*/
79+
80+
/// Create an encrypted private key from an intermediate passphrase.
81+
/// The `out_point` parameter is always compressed, so to use it it should be
82+
/// decompressed as necessary to match the state of the `compressed` parameter.
83+
/// @param[out] out_private The new encrypted private key.
84+
/// @param[out] out_point The ec compressed public key of the new key pair.
85+
/// @param[in] token An intermediate passphrase string.
86+
/// @param[in] seed A random value for use in the encryption.
87+
/// @param[in] version The coin address version byte.
88+
/// @param[in] compressed Set true to associate ec public key compression.
89+
/// @return false if the token checksum is not valid.
10590
BC_API bool create_key_pair(encrypted_private& out_private,
10691
ec_compressed& out_point, const encrypted_token& token,
10792
const ek_seed& seed, uint8_t version, bool compressed=true) NOEXCEPT;
10893

109-
/**
110-
* DEPRECATED (scenario)
111-
* Create an encrypted key pair from an intermediate passphrase.
112-
* The `out_point` parameter is always compressed, so to use it it should be
113-
* decompressed as necessary to match the state of the `compressed` parameter.
114-
* @param[out] out_private The new encrypted private key.
115-
* @param[out] out_public The new encrypted public key.
116-
* @param[out] out_point The compressed ec public key of the new key pair.
117-
* @param[in] token An intermediate passphrase string.
118-
* @param[in] seed A random value for use in the encryption.
119-
* @param[in] version The coin address version byte.
120-
* @param[in] compressed Set true to associate ec public key compression.
121-
* @return false if the token checksum is not valid.
122-
*/
94+
/// DEPRECATED (scenario)
95+
/// Create an encrypted key pair from an intermediate passphrase.
96+
/// The `out_point` parameter is always compressed, so to use it it should be
97+
/// decompressed as necessary to match the state of the `compressed` parameter.
98+
/// @param[out] out_private The new encrypted private key.
99+
/// @param[out] out_public The new encrypted public key.
100+
/// @param[out] out_point The compressed ec public key of the new key pair.
101+
/// @param[in] token An intermediate passphrase string.
102+
/// @param[in] seed A random value for use in the encryption.
103+
/// @param[in] version The coin address version byte.
104+
/// @param[in] compressed Set true to associate ec public key compression.
105+
/// @return false if the token checksum is not valid.
123106
BC_API bool create_key_pair(encrypted_private& out_private,
124107
encrypted_public& out_public, ec_compressed& out_point,
125108
const encrypted_token& token, const ek_seed& seed, uint8_t version,
126109
bool compressed=true) NOEXCEPT;
127110

128-
/**
129-
* Create an intermediate passphrase for subsequent key pair generation.
130-
* @param[out] out_token The new intermediate passphrase.
131-
* @param[in] passphrase A passphrase for use in the encryption.
132-
* @param[in] entropy A random value for use in the encryption.
133-
* @return false if the token could not be created from the entropy.
134-
*/
111+
/// Create an intermediate passphrase for subsequent key pair generation.
112+
/// @param[out] out_token The new intermediate passphrase.
113+
/// @param[in] passphrase A passphrase for use in the encryption.
114+
/// @param[in] entropy A random value for use in the encryption.
115+
/// @return false if the token could not be created from the entropy.
135116
BC_API bool create_token(encrypted_token& out_token,
136117
const std::string& passphrase, const ek_entropy& entropy) NOEXCEPT;
137118

138-
/**
139-
* Create an intermediate passphrase for subsequent key pair generation.
140-
* @param[out] out_token The new intermediate passphrase.
141-
* @param[in] passphrase A passphrase for use in the encryption.
142-
* @param[in] salt A random value for use in the encryption.
143-
* @param[in] lot A lot, max allowed value 1048575 (2^20-1).
144-
* @param[in] sequence A sequence, max allowed value 4095 (2^12-1).
145-
* @return false if the lot and/or sequence are out of range or the token
146-
* could not be created from the entropy.
147-
*/
119+
/// Create an intermediate passphrase for subsequent key pair generation.
120+
/// @param[out] out_token The new intermediate passphrase.
121+
/// @param[in] passphrase A passphrase for use in the encryption.
122+
/// @param[in] salt A random value for use in the encryption.
123+
/// @param[in] lot A lot, max allowed value 1048575 (2^20-1).
124+
/// @param[in] sequence A sequence, max allowed value 4095 (2^12-1).
125+
/// @return false if the lot and/or sequence are out of range or the token
126+
/// could not be created from the entropy.
148127
BC_API bool create_token(encrypted_token& out_token,
149128
const std::string& passphrase, const ek_salt& salt, uint32_t lot,
150129
uint32_t sequence) NOEXCEPT;
151130

152-
/**
153-
* Encrypt the ec secret to an encrypted public key using the passphrase.
154-
* @param[out] out_private The new encrypted private key.
155-
* @param[in] secret An ec secret to encrypt.
156-
* @param[in] passphrase A passphrase for use in the encryption.
157-
* @param[in] version The coin address version byte.
158-
* @param[in] compressed Set true to associate ec public key compression.
159-
* @return false if the secret could not be converted to a public key.
160-
*/
131+
/// Encrypt the ec secret to an encrypted public key using the passphrase.
132+
/// @param[out] out_private The new encrypted private key.
133+
/// @param[in] secret An ec secret to encrypt.
134+
/// @param[in] passphrase A passphrase for use in the encryption.
135+
/// @param[in] version The coin address version byte.
136+
/// @param[in] compressed Set true to associate ec public key compression.
137+
/// @return false if the secret could not be converted to a public key.
161138
BC_API bool encrypt(encrypted_private& out_private, const ec_secret& secret,
162139
const std::string& passphrase, uint8_t version,
163140
bool compressed=true) NOEXCEPT;
164141

165-
/**
166-
* Decrypt the ec secret associated with the encrypted private key.
167-
* @param[out] out_secret The decrypted ec secret.
168-
* @param[out] out_version The coin address version.
169-
* @param[out] out_compressed The compression of the associated ec public key.
170-
* @param[in] key An encrypted private key.
171-
* @param[in] passphrase The passphrase from the encryption or token.
172-
* @return false if the key checksum or passphrase is not valid.
173-
*/
142+
/// Decrypt the ec secret associated with the encrypted private key.
143+
/// @param[out] out_secret The decrypted ec secret.
144+
/// @param[out] out_version The coin address version.
145+
/// @param[out] out_compressed The compression of the associated ec public key.
146+
/// @param[in] key An encrypted private key.
147+
/// @param[in] passphrase The passphrase from the encryption or token.
148+
/// @return false if the key checksum or passphrase is not valid.
174149
BC_API bool decrypt(ec_secret& out_secret, uint8_t& out_version,
175150
bool& out_compressed, const encrypted_private& key,
176151
const std::string& passphrase) NOEXCEPT;
177152

178-
/**
179-
* DEPRECATED (scenario)
180-
* Decrypt the ec point associated with the encrypted public key.
181-
* @param[out] out_point The decrypted ec compressed point.
182-
* @param[out] out_version The coin address version of the public key.
183-
* @param[out] out_compressed The public key specified compression state.
184-
* @param[in] key An encrypted public key.
185-
* @param[in] passphrase The passphrase of the associated token.
186-
* @return false if the key checksum or passphrase is not valid.
187-
*/
153+
/// DEPRECATED (scenario)
154+
/// Decrypt the ec point associated with the encrypted public key.
155+
/// @param[out] out_point The decrypted ec compressed point.
156+
/// @param[out] out_version The coin address version of the public key.
157+
/// @param[out] out_compressed The public key specified compression state.
158+
/// @param[in] key An encrypted public key.
159+
/// @param[in] passphrase The passphrase of the associated token.
160+
/// @return false if the key checksum or passphrase is not valid.
188161
BC_API bool decrypt(ec_compressed& out_point, uint8_t& out_version,
189162
bool& out_compressed, const encrypted_public& key,
190163
const std::string& passphrase) NOEXCEPT;

0 commit comments

Comments
 (0)