store outPk/8 in the tx for speed

It avoids dividing by 8 when deserializing a tx, which is a slow
operation, and multiplies by 8 when verifying and extracing the
amount, which is much faster as well as less frequent
This commit is contained in:
moneromooo-monero 2021-02-14 17:45:04 +00:00
parent a345060ace
commit 4c94cfecfc
No known key found for this signature in database
GPG key ID: 686F07454D6CEFC3
5 changed files with 31 additions and 7 deletions

View file

@ -450,6 +450,8 @@ bool gen_multisig_tx_validation_base::generate_with(std::vector<test_event_entry
rct::ecdhTuple ecdh_info = tx.rct_signatures.ecdhInfo[n];
rct::ecdhDecode(ecdh_info, rct::sk2rct(scalar1), tx.rct_signatures.type == rct::RCTTypeBulletproof2 || tx.rct_signatures.type == rct::RCTTypeCLSAG || tx.rct_signatures.type == rct::RCTTypeBulletproofPlus);
rct::key C = tx.rct_signatures.outPk[n].mask;
if (rct::is_rct_bulletproof_plus(tx.rct_signatures.type))
C = rct::scalarmult8(C);
rct::addKeys2(Ctmp, ecdh_info.mask, ecdh_info.amount, rct::H);
CHECK_AND_ASSERT_MES(rct::equalKeys(C, Ctmp), false, "Failed to decode amount");
amount += rct::h2d(ecdh_info.amount);