core: test key images against validity domain

This commit is contained in:
moneromooo-monero 2017-02-20 17:41:39 +00:00
parent efb72e74e2
commit d282cfcc46
No known key found for this signature in database
GPG key ID: 686F07454D6CEFC3
3 changed files with 32 additions and 0 deletions

View file

@ -616,6 +616,12 @@ namespace cryptonote
return false;
}
if (!check_tx_inputs_keyimages_domain(tx))
{
MERROR_VER("tx uses key image not in the valid domain");
return false;
}
if (tx.version >= 2)
{
const rct::rctSig &rv = tx.rct_signatures;
@ -699,6 +705,18 @@ namespace cryptonote
return true;
}
//-----------------------------------------------------------------------------------------------
bool core::check_tx_inputs_keyimages_domain(const transaction& tx) const
{
std::unordered_set<crypto::key_image> ki;
for(const auto& in: tx.vin)
{
CHECKED_GET_SPECIFIC_VARIANT(in, const txin_to_key, tokey_in, false);
if (!(rct::scalarmultKey(rct::ki2rct(tokey_in.k_image), rct::curveOrder()) == rct::identity()))
return false;
}
return true;
}
//-----------------------------------------------------------------------------------------------
bool core::add_new_tx(const transaction& tx, tx_verification_context& tvc, bool keeped_by_block, bool relayed, bool do_not_relay)
{
crypto::hash tx_hash = get_transaction_hash(tx);