mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-18 13:17:55 +02:00
Use new helper function to verify issuance of re-issuance tokens
This forbids the explicit issuance of 0 re-issuance tokens (like for the issuance of normal assets. The proper way to issue no re-issuance tokens is to use a null commitment for the amount.
This commit is contained in:
parent
d7abf1870a
commit
670229e060
1 changed files with 15 additions and 35 deletions
|
|
@ -863,51 +863,31 @@ bool VerifyAmounts(const CCoinsViewCache& cache, const CTransaction& tx, std::ve
|
||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only initial issuance can have reissuance tokens
|
if (!issuance.nAmount.IsValid()) {
|
||||||
if (issuance.assetBlindingNonce.IsNull() && !issuance.nInflationKeys.IsNull()) {
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
ret = secp256k1_generator_generate(secp256k1_ctx_verify_amounts, &gen, assetTokenID.begin());
|
// Process issuance of reissuance tokens
|
||||||
assert(ret == 1);
|
|
||||||
CConfidentialAsset tokenAsset(assetTokenID);
|
|
||||||
tokenAsset.vchCommitment.resize(CConfidentialAsset::nCommittedSize);
|
|
||||||
secp256k1_generator_serialize(secp256k1_ctx_verify_amounts, &tokenAsset.vchCommitment[0], &gen);
|
|
||||||
|
|
||||||
targetGenerators.push_back(gen);
|
if (!issuance.nInflationKeys.IsValid()) {
|
||||||
|
return false;
|
||||||
if (issuance.nInflationKeys.IsExplicit()) {
|
}
|
||||||
if (!MoneyRange(issuance.nInflationKeys.GetAmount())) {
|
if (!issuance.nInflationKeys.IsNull()) {
|
||||||
return false;
|
// Only initial issuance can have reissuance tokens
|
||||||
}
|
if (!issuance.assetBlindingNonce.IsNull()) {
|
||||||
|
|
||||||
if (issuance.nInflationKeys.GetAmount() == 0) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Here we have issuance.nAmount.IsCommitment() == true
|
|
||||||
ret = secp256k1_pedersen_commit(secp256k1_ctx_verify_amounts, &commit, explBlinds, issuance.nInflationKeys.GetAmount(), &gen);
|
|
||||||
// The explBlinds are all 0, and the amount is not 0. So secp256k1_pedersen_commit does not fail.
|
|
||||||
assert(ret == 1);
|
|
||||||
}
|
|
||||||
else if (issuance.nInflationKeys.IsCommitment()) {
|
|
||||||
if (secp256k1_pedersen_commitment_parse(secp256k1_ctx_verify_amounts, &commit, &issuance.nInflationKeys.vchCommitment[0]) != 1) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!VerifyIssuanceAmount(commit, gen, assetTokenID, issuance.nInflationKeys, tx.wit.vtxinwit[i].vchInflationKeysRangeproof, pvChecks, cacheStore)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
targetGenerators.push_back(gen);
|
||||||
vData.push_back(commit);
|
vData.push_back(commit);
|
||||||
vpCommitsIn.push_back(p);
|
vpCommitsIn.push_back(p);
|
||||||
p++;
|
p++;
|
||||||
|
|
||||||
if (issuance.nInflationKeys.IsCommitment() && QueueCheck(pvChecks, new CRangeCheck(&issuance.nInflationKeys, tx.wit.vtxinwit[i].vchInflationKeysRangeproof, tokenAsset.vchCommitment, CScript(), cacheStore)) != SCRIPT_ERR_OK) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} else if (!issuance.nInflationKeys.IsNull()) {
|
|
||||||
// Token amount field must be null for reissuance
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < tx.vout.size(); ++i)
|
for (size_t i = 0; i < tx.vout.size(); ++i)
|
||||||
{
|
{
|
||||||
const CConfidentialValue& val = tx.vout[i].nValue;
|
const CConfidentialValue& val = tx.vout[i].nValue;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue