Skip to content

Commit 91b0846

Browse files
committed
Clean-up linting
Signed-off-by: Sam Stuewe <[email protected]>
1 parent b533068 commit 91b0846

File tree

9 files changed

+45
-30
lines changed

9 files changed

+45
-30
lines changed

src/uhs/transaction/transaction.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,7 @@ namespace cbdc::transaction {
252252
secp256k1_bulletproofs_generators* gens,
253253
random_source& rng,
254254
const spend_data& out_spend_data,
255-
const secp256k1_pedersen_commitment* comm)
256-
-> rangeproof_t<> {
255+
const secp256k1_pedersen_commitment* comm) -> rangeproof_t<> {
257256
rangeproof_t<> range{};
258257
size_t rangelen = range.size();
259258
static constexpr auto upper_bound = 64; // 2^64 - 1

src/uhs/transaction/transaction.hpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ namespace cbdc::transaction {
5858
/// An auxiliary value used to prove preservation of balance
5959
commitment_t m_auxiliary{};
6060
/// The rangeproof guaranteeing that the output is greater than 0
61-
/// This rangeproof is only required when functioning as a transaction output,
62-
/// and is removed when converted into a transaction input.
61+
/// This rangeproof is only required when functioning as a transaction
62+
/// output, and is removed when converted into a transaction input.
6363
std::optional<rangeproof_t<>> m_range{};
6464

6565
auto operator==(const output& rhs) const -> bool;
@@ -78,8 +78,9 @@ namespace cbdc::transaction {
7878
/// output to-be-spent
7979
/// \param put the \ref output to-be-spent
8080
/// \returns the hash serving as the UHS ID
81-
auto calculate_uhs_id(const out_point& point, const output& put, const commitment_t& value)
82-
-> hash_t;
81+
auto calculate_uhs_id(const out_point& point,
82+
const output& put,
83+
const commitment_t& value) -> hash_t;
8384

8485
/// \brief Additional information a spender needs to spend an input
8586
struct spend_data {
@@ -259,8 +260,7 @@ namespace cbdc::transaction {
259260
secp256k1_bulletproofs_generators* gens,
260261
random_source& rng,
261262
const spend_data& out_spend_data,
262-
const secp256k1_pedersen_commitment* comm)
263-
-> rangeproof_t<>;
263+
const secp256k1_pedersen_commitment* comm) -> rangeproof_t<>;
264264

265265
/// \brief Add cryptographic proof to a single output
266266
///

src/uhs/transaction/validation.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ namespace cbdc::transaction::validation {
253253
}
254254
return std::nullopt;
255255
}
256-
256+
257257
auto check_witness_count(const cbdc::transaction::full_tx& tx)
258258
-> std::optional<tx_error> {
259259
if(tx.m_inputs.size() != tx.m_witness.size()) {

src/uhs/transaction/validation.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ namespace cbdc::transaction::validation {
169169
auto check_input_set(const transaction::full_tx& tx)
170170
-> std::optional<tx_error>;
171171
auto check_proof(const compact_tx& tx,
172-
const std::vector<commitment_t>& inp_comms)
172+
const std::vector<commitment_t>& inps)
173173
-> std::optional<proof_error>;
174174
auto check_commitment_sum(
175175
const std::vector<secp256k1_pedersen_commitment>& inputs,

src/uhs/transaction/wallet.cpp

+10-6
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ namespace cbdc {
6262
std::unique_lock<std::shared_mutex> ul(m_utxos_mut);
6363
for(size_t i = 0; i < ret.m_outputs.size(); ++i) {
6464
transaction::output put = ret.m_outputs[i];
65-
put.m_range.reset(); // remove range proofs for inputs
65+
put.m_range.reset(); // remove range proofs for inputs
6666
transaction::out_point point{id, i};
6767
transaction::input inp{point,
6868
put,
@@ -127,9 +127,11 @@ namespace cbdc {
127127
return ret;
128128
}
129129

130-
auto transaction::wallet::create_seeded_transaction(size_t seed_idx,
131-
const commitment_t& comm,
132-
const rangeproof_t<>& range) -> std::optional<transaction::full_tx> {
130+
auto
131+
transaction::wallet::create_seeded_transaction(size_t seed_idx,
132+
const commitment_t& comm,
133+
const rangeproof_t<>& range)
134+
-> std::optional<transaction::full_tx> {
133135
if(m_seed_from == m_seed_to) {
134136
return std::nullopt;
135137
}
@@ -147,7 +149,8 @@ namespace cbdc {
147149
inp.m_prevout_data.m_witness_program_commitment = {0};
148150
inp.m_prevout_data.m_auxiliary = comm;
149151
inp.m_prevout_data.m_range.reset();
150-
inp.m_prevout_data.m_id = calculate_uhs_id(inp.m_prevout, inp.m_prevout_data, comm);
152+
inp.m_prevout_data.m_id
153+
= calculate_uhs_id(inp.m_prevout, inp.m_prevout_data, comm);
151154
inp.m_spend_data = {spend};
152155

153156
tx.m_inputs[0] = inp;
@@ -188,7 +191,8 @@ namespace cbdc {
188191
{},
189192
in_spend_data);
190193

191-
inp.m_prevout_data.m_auxiliary = serialize_commitment(m_secp.get(), aux.front());
194+
inp.m_prevout_data.m_auxiliary
195+
= serialize_commitment(m_secp.get(), aux.front());
192196
inp.m_prevout_data.m_id
193197
= transaction::calculate_uhs_id(inp.m_prevout,
194198
inp.m_prevout_data,

src/uhs/transaction/wallet.hpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,9 @@ namespace cbdc::transaction {
227227

228228
/// \brief todo: document overload
229229
auto create_seeded_transaction(size_t seed_idx,
230-
const commitment_t& comm,
231-
const rangeproof_t<>& range) -> std::optional<transaction::full_tx>;
230+
const commitment_t& comm,
231+
const rangeproof_t<>& range)
232+
-> std::optional<transaction::full_tx>;
232233

233234
/// Given a set of credit inputs, add the UTXOs and update the wallet's
234235
/// balance.

tests/unit/atomizer_test.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ TEST_F(atomizer_test, test_with_transactions) {
5252
cbdc::transaction::output out;
5353
out.m_witness_program_commitment = {val++};
5454
out.m_range = cbdc::rangeproof_t<>{'\0'};
55-
55+
5656
tx.m_inputs.push_back(inp);
5757
tx.m_outputs.push_back(out);
5858

tests/unit/message_test.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,10 @@ TEST_F(PacketIOTest, aggregate_tx_notify_request) {
465465

466466
TEST_F(PacketIOTest, variant) {
467467
auto outpoint = cbdc::transaction::out_point{{'a', 'b', 'c', 'd'}, 1};
468-
auto output = cbdc::transaction::output{{'b'}, {'c'}, {'d'}, cbdc::rangeproof_t<>{'e'}};
468+
auto output = cbdc::transaction::output{{'b'},
469+
{'c'},
470+
{'d'},
471+
cbdc::rangeproof_t<>{'e'}};
469472
auto var = std::variant<cbdc::transaction::out_point,
470473
cbdc::transaction::output>(outpoint);
471474
m_ser << var;

tools/shard-seeder/shard-seeder.cpp

+18-10
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
#include "uhs/transaction/transaction.hpp"
88
#include "uhs/transaction/validation.hpp"
99
#include "uhs/transaction/wallet.hpp"
10-
#include "util/common/config.hpp"
1110
#include "util/common/commitment.hpp"
11+
#include "util/common/config.hpp"
1212
#include "util/serialization/buffer_serializer.hpp"
1313
#include "util/serialization/format.hpp"
1414
#include "util/serialization/ostream_serializer.hpp"
@@ -150,16 +150,24 @@ auto main(int argc, char** argv) -> int {
150150
}
151151
auto batch_size = 0;
152152
leveldb::WriteBatch batch;
153-
auto value = cbdc::commit(secp_context.get(), cfg.m_seed_value, {}).value();
154-
auto range = cbdc::transaction::prove(secp_context.get(),
155-
bulletproof_gens.get(),
156-
rng,
157-
{{}, cfg.m_seed_value},
158-
&value);
159-
auto value_comm = cbdc::serialize_commitment(secp_context.get(), value);
153+
auto value = cbdc::commit(secp_context.get(),
154+
cfg.m_seed_value,
155+
{})
156+
.value();
157+
auto range
158+
= cbdc::transaction::prove(secp_context.get(),
159+
bulletproof_gens.get(),
160+
rng,
161+
{{}, cfg.m_seed_value},
162+
&value);
163+
auto value_comm
164+
= cbdc::serialize_commitment(secp_context.get(),
165+
value);
160166
for(size_t tx_idx = 0; tx_idx != num_utxos; tx_idx++) {
161-
auto tx
162-
= wal.create_seeded_transaction(tx_idx, value_comm, range).value();
167+
auto tx = wal.create_seeded_transaction(tx_idx,
168+
value_comm,
169+
range)
170+
.value();
163171
cbdc::transaction::compact_tx ctx(tx);
164172
const cbdc::hash_t& output_hash
165173
= cbdc::transaction::calculate_uhs_id(

0 commit comments

Comments
 (0)