Skip to content

Commit

Permalink
Merge #545: fix vector length calculation for targets in BlindTransac…
Browse files Browse the repository at this point in the history
…tion

93f49ed fix vector length calculation for targets in BlindTransaction (Dmitry Petukhov)

Pull request description:

  port of #514

Tree-SHA512: 5e082bb2590c1dde70b67607524d974f435f673777459b638ca10193040b45239fcb4302cc47d4aa7dbd0a25627294e7ca4f11658a4e41cfcd001c8ca51faf3b
  • Loading branch information
stevenroose committed Apr 1, 2019
2 parents 298c2fb + 93f49ed commit 6e2751c
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/blind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,6 @@ int BlindTransaction(std::vector<uint256 >& input_value_blinding_factors, const
assert(tx.vin.size() == input_asset_blinding_factors.size());
assert(tx.vin.size() == input_assets.size());
assert(tx.vin.size() == input_amounts.size());
if (auxiliary_generators) {
assert(auxiliary_generators->size() >= tx.vin.size());
}

std::vector<unsigned char*> value_blindptrs;
std::vector<const unsigned char*> asset_blindptrs;
Expand All @@ -255,8 +252,16 @@ int BlindTransaction(std::vector<uint256 >& input_value_blinding_factors, const

// Needed to construct the proof itself. Generators must match final transaction to be valid
std::vector<secp256k1_generator> target_asset_generators;
surjection_targets.resize(tx.vin.size()*3);
target_asset_generators.resize(tx.vin.size()*3);

// maxTargets is a strict upper-bound for the size of target vectors.
// The vectors will be shrunk later according to final count of totalTargets
size_t maxTargets = tx.vin.size()*3;
if (auxiliary_generators) {
assert(auxiliary_generators->size() >= tx.vin.size());
maxTargets += auxiliary_generators->size() - tx.vin.size();
}
surjection_targets.resize(maxTargets);
target_asset_generators.resize(maxTargets);

// input_asset_blinding_factors is only for inputs, not for issuances(0 by def)
// but we need to create surjection proofs against this list so we copy and insert 0's
Expand Down

0 comments on commit 6e2751c

Please sign in to comment.