mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-18 13:17:55 +02:00
Merge #489: Fix UnblindConfidentialPair: use IsFullyValid() for ephemeral_key
07f2178add test: UnblindConfidentialPair: invalid pubk in nNonce.vchCommitment (Dmitry Petukhov)f8a9d8bFix UnblindConfidentialPair: use IsFullyValid() for ephemeral_key (Dmitry Petukhov)
This commit is contained in:
commit
2300bcf1b5
2 changed files with 15 additions and 1 deletions
|
|
@ -45,7 +45,7 @@ bool UnblindConfidentialPair(const CKey &key, const CConfidentialValue& confValu
|
|||
return false;
|
||||
}
|
||||
CPubKey ephemeral_key(nNonce.vchCommitment);
|
||||
if (nNonce.vchCommitment.size() > 0 && !ephemeral_key.IsValid()) {
|
||||
if (nNonce.vchCommitment.size() > 0 && !ephemeral_key.IsFullyValid()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -302,6 +302,20 @@ BOOST_AUTO_TEST_CASE(naive_blinding_test)
|
|||
BOOST_CHECK(asset_out == unblinded_id);
|
||||
BOOST_CHECK(unblinded_amount == 50);
|
||||
|
||||
// Make invalid public keys in nonce commitment, first of right size
|
||||
tx4.vout[2].nNonce.vchCommitment = std::vector<unsigned char>(33, 0);
|
||||
tx4.vout[2].nNonce.vchCommitment[0] = 0x03;
|
||||
BOOST_CHECK(UnblindConfidentialPair(key2, tx4.vout[2].nValue, tx4.vout[2].nAsset, tx4.vout[2].nNonce, scriptCommit, tx4.wit.vtxoutwit[2].vchRangeproof, unblinded_amount, blind4, asset_out, asset_blinder_out) == 0);
|
||||
|
||||
// Next, leading byte claiming to be 33 bytes in size
|
||||
tx4.vout[2].nNonce.vchCommitment.resize(1);
|
||||
BOOST_CHECK(UnblindConfidentialPair(key2, tx4.vout[2].nValue, tx4.vout[2].nAsset, tx4.vout[2].nNonce, scriptCommit, tx4.wit.vtxoutwit[2].vchRangeproof, unblinded_amount, blind4, asset_out, asset_blinder_out) == 0);
|
||||
|
||||
// Last, blank
|
||||
tx4.vout[2].nNonce.vchCommitment.clear();
|
||||
BOOST_CHECK(UnblindConfidentialPair(key2, tx4.vout[2].nValue, tx4.vout[2].nAsset, tx4.vout[2].nNonce, scriptCommit, tx4.wit.vtxoutwit[2].vchRangeproof, unblinded_amount, blind4, asset_out, asset_blinder_out) == 0);
|
||||
|
||||
|
||||
CCoinsModifier in4 = cache.ModifyCoins(ArithToUint256(4));
|
||||
in4->vout.resize(4);
|
||||
in4->vout[0] = tx4.vout[0];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue