Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFC] Remove GetNumIssuance from BlindTransaction assert #846

Merged
merged 2 commits into from
Apr 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 2 additions & 18 deletions src/blind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,28 +206,12 @@ void CreateValueCommitment(CConfidentialValue& conf_value, secp256k1_pedersen_co
assert(conf_value.IsValid());
}

size_t GetNumIssuances(const CTransaction& tx)
{
unsigned int num_issuances = 0;
for (unsigned int i = 0; i < tx.vin.size(); i++) {
if (!tx.vin[i].assetIssuance.IsNull()) {
if (!tx.vin[i].assetIssuance.nAmount.IsNull()) {
num_issuances++;
}
if (!tx.vin[i].assetIssuance.nInflationKeys.IsNull()) {
num_issuances++;
}
}
}
return num_issuances;
}

int BlindTransaction(std::vector<uint256 >& input_value_blinding_factors, const std::vector<uint256 >& input_asset_blinding_factors, const std::vector<CAsset >& input_assets, const std::vector<CAmount >& input_amounts, std::vector<uint256 >& out_val_blind_factors, std::vector<uint256 >& out_asset_blind_factors, const std::vector<CPubKey>& output_pubkeys, const std::vector<CKey>& issuance_blinding_privkey, const std::vector<CKey>& token_blinding_privkey, CMutableTransaction& tx, std::vector<std::vector<unsigned char> >* auxiliary_generators)
{
// Sanity check input data and output_pubkey size, clear other output data
assert(tx.vout.size() >= output_pubkeys.size());
assert(tx.vin.size()+GetNumIssuances(CTransaction(tx)) >= issuance_blinding_privkey.size());
assert(tx.vin.size()+GetNumIssuances(CTransaction(tx)) >= token_blinding_privkey.size());
assert(tx.vin.size() >= issuance_blinding_privkey.size());
assert(tx.vin.size() >= token_blinding_privkey.size());
out_val_blind_factors.clear();
out_val_blind_factors.resize(tx.vout.size());
out_asset_blind_factors.clear();
Expand Down
2 changes: 0 additions & 2 deletions src/blind.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,4 @@ int BlindTransaction(std::vector<uint256 >& input_value_blinding_factors, const
*/
void RawFillBlinds(CMutableTransaction& tx, std::vector<uint256>& output_value_blinds, std::vector<uint256>& output_asset_blinds, std::vector<CPubKey>& output_pubkeys);

size_t GetNumIssuances(const CTransaction& tx);

#endif //BITCOIN_BLIND_H
16 changes: 16 additions & 0 deletions src/issuance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,22 @@
#include <primitives/transaction.h>
#include <amount.h>

size_t GetNumIssuances(const CTransaction& tx)
{
unsigned int num_issuances = 0;
for (unsigned int i = 0; i < tx.vin.size(); i++) {
if (!tx.vin[i].assetIssuance.IsNull()) {
if (!tx.vin[i].assetIssuance.nAmount.IsNull()) {
num_issuances++;
}
if (!tx.vin[i].assetIssuance.nInflationKeys.IsNull()) {
num_issuances++;
}
}
}
return num_issuances;
}

void GenerateAssetEntropy(uint256& entropy, const COutPoint& prevout, const uint256& contracthash)
{
// E : entropy
Expand Down
5 changes: 5 additions & 0 deletions src/issuance.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
#include <hash.h>
#include <consensus/merkle.h>

/**
* Get the number of issuances in the given transaction.
*/
size_t GetNumIssuances(const CTransaction& tx);

/**
* Calculate the asset entropy from an COutPoint and a tx-author specified
* Ricardian contract. See Definition 18 of the confidential assets paper.
Expand Down