ringct: check the size of amount_keys is the same as destinations
This commit is contained in:
parent
836669d276
commit
ffd8c41f36
3 changed files with 6 additions and 2 deletions
|
@ -610,6 +610,7 @@ namespace rct {
|
||||||
// Thus the amounts vector will be "one" longer than the destinations vectort
|
// Thus the amounts vector will be "one" longer than the destinations vectort
|
||||||
rctSig genRct(const key &message, const ctkeyV & inSk, const keyV & destinations, const vector<xmr_amount> & amounts, const ctkeyM &mixRing, const keyV &amount_keys, unsigned int index, ctkeyV &outSk) {
|
rctSig genRct(const key &message, const ctkeyV & inSk, const keyV & destinations, const vector<xmr_amount> & amounts, const ctkeyM &mixRing, const keyV &amount_keys, unsigned int index, ctkeyV &outSk) {
|
||||||
CHECK_AND_ASSERT_THROW_MES(amounts.size() == destinations.size() || amounts.size() == destinations.size() + 1, "Different number of amounts/destinations");
|
CHECK_AND_ASSERT_THROW_MES(amounts.size() == destinations.size() || amounts.size() == destinations.size() + 1, "Different number of amounts/destinations");
|
||||||
|
CHECK_AND_ASSERT_THROW_MES(amount_keys.size() == destinations.size(), "Different number of amount_keys/destinations");
|
||||||
CHECK_AND_ASSERT_THROW_MES(index < mixRing.size(), "Bad index into mixRing");
|
CHECK_AND_ASSERT_THROW_MES(index < mixRing.size(), "Bad index into mixRing");
|
||||||
for (size_t n = 0; n < mixRing.size(); ++n) {
|
for (size_t n = 0; n < mixRing.size(); ++n) {
|
||||||
CHECK_AND_ASSERT_THROW_MES(mixRing[n].size() == inSk.size(), "Bad mixRing size");
|
CHECK_AND_ASSERT_THROW_MES(mixRing[n].size() == inSk.size(), "Bad mixRing size");
|
||||||
|
@ -671,6 +672,7 @@ namespace rct {
|
||||||
CHECK_AND_ASSERT_THROW_MES(inamounts.size() > 0, "Empty inamounts");
|
CHECK_AND_ASSERT_THROW_MES(inamounts.size() > 0, "Empty inamounts");
|
||||||
CHECK_AND_ASSERT_THROW_MES(inamounts.size() == inSk.size(), "Different number of inamounts/inSk");
|
CHECK_AND_ASSERT_THROW_MES(inamounts.size() == inSk.size(), "Different number of inamounts/inSk");
|
||||||
CHECK_AND_ASSERT_THROW_MES(outamounts.size() == destinations.size(), "Different number of amounts/destinations");
|
CHECK_AND_ASSERT_THROW_MES(outamounts.size() == destinations.size(), "Different number of amounts/destinations");
|
||||||
|
CHECK_AND_ASSERT_THROW_MES(amount_keys.size() == destinations.size(), "Different number of amount_keys/destinations");
|
||||||
CHECK_AND_ASSERT_THROW_MES(index.size() == inSk.size(), "Different number of index/inSk");
|
CHECK_AND_ASSERT_THROW_MES(index.size() == inSk.size(), "Different number of index/inSk");
|
||||||
CHECK_AND_ASSERT_THROW_MES(mixRing.size() == inSk.size(), "Different number of mixRing/inSk");
|
CHECK_AND_ASSERT_THROW_MES(mixRing.size() == inSk.size(), "Different number of mixRing/inSk");
|
||||||
for (size_t n = 0; n < mixRing.size(); ++n) {
|
for (size_t n = 0; n < mixRing.size(); ++n) {
|
||||||
|
|
|
@ -246,7 +246,6 @@ TEST(ringct, range_proofs_with_fee)
|
||||||
//add txn fee for 1
|
//add txn fee for 1
|
||||||
//has no corresponding destination..
|
//has no corresponding destination..
|
||||||
amounts.push_back(1);
|
amounts.push_back(1);
|
||||||
amount_keys.push_back(hash_to_scalar(zero()));
|
|
||||||
|
|
||||||
//add output for 12500
|
//add output for 12500
|
||||||
amounts.push_back(12500);
|
amounts.push_back(12500);
|
||||||
|
@ -356,10 +355,12 @@ static rct::rctSig make_sample_rct_sig(int n_inputs, const uint64_t input_amount
|
||||||
|
|
||||||
for (int n = 0; n < n_outputs; ++n) {
|
for (int n = 0; n < n_outputs; ++n) {
|
||||||
amounts.push_back(output_amounts[n]);
|
amounts.push_back(output_amounts[n]);
|
||||||
amount_keys.push_back(rct::hash_to_scalar(rct::zero()));
|
|
||||||
skpkGen(Sk, Pk);
|
skpkGen(Sk, Pk);
|
||||||
if (n < n_outputs - 1 || !last_is_fee)
|
if (n < n_outputs - 1 || !last_is_fee)
|
||||||
|
{
|
||||||
destinations.push_back(Pk);
|
destinations.push_back(Pk);
|
||||||
|
amount_keys.push_back(rct::hash_to_scalar(rct::zero()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return genRct(rct::zero(), sc, pc, destinations, amounts, amount_keys, 3);;
|
return genRct(rct::zero(), sc, pc, destinations, amounts, amount_keys, 3);;
|
||||||
|
|
|
@ -559,6 +559,7 @@ TEST(Serialization, serializes_ringct_types)
|
||||||
rct::keyV amount_keys;
|
rct::keyV amount_keys;
|
||||||
//add output 500
|
//add output 500
|
||||||
amounts.push_back(500);
|
amounts.push_back(500);
|
||||||
|
amount_keys.push_back(rct::hash_to_scalar(rct::zero()));
|
||||||
rct::keyV destinations;
|
rct::keyV destinations;
|
||||||
rct::key Sk, Pk;
|
rct::key Sk, Pk;
|
||||||
rct::skpkGen(Sk, Pk);
|
rct::skpkGen(Sk, Pk);
|
||||||
|
|
Loading…
Reference in a new issue