rct: add the tx prefix hash into the MLSAG

to protect the non-signatures parts of the tx from tampering.
This commit is contained in:
moneromooo-monero 2016-06-28 16:03:28 +01:00
parent 35dce5c70c
commit 6d0e47148b
No known key found for this signature in database
GPG key ID: 686F07454D6CEFC3
6 changed files with 43 additions and 9 deletions

View file

@ -685,9 +685,6 @@ namespace cryptonote
if (amount_in > amount_out)
amounts.push_back(amount_in - amount_out);
LOG_PRINT_L1("Signing tx: " << obj_to_json_str(tx));
tx.rct_signatures = rct::genRct(inSk, destinations, amounts, mixRing, sources[0].real_output); // same index assumption
// zero out all amounts to mask rct outputs, real amounts are now encrypted
for (size_t i = 0; i < tx.vin.size(); ++i)
{
@ -697,6 +694,10 @@ namespace cryptonote
for (size_t i = 0; i < tx.vout.size(); ++i)
tx.vout[i].amount = 0;
crypto::hash tx_prefix_hash;
get_transaction_prefix_hash(tx, tx_prefix_hash);
tx.rct_signatures = rct::genRct(inSk, destinations, amounts, mixRing, rct::hash2rct(tx_prefix_hash), sources[0].real_output); // same index assumption
LOG_PRINT2("construct_tx.log", "transaction_created: " << get_transaction_hash(tx) << ENDL << obj_to_json_str(tx) << ENDL, LOG_LEVEL_3);
}