wallet2: check key image validity domain in import_key_images

This commit is contained in:
moneromooo-monero 2017-02-21 13:57:10 +00:00
parent 694470fae7
commit a374a522df
No known key found for this signature in database
GPG key ID: 686F07454D6CEFC3

View file

@ -5274,6 +5274,10 @@ uint64_t wallet2::import_key_images(const std::vector<std::pair<crypto::key_imag
std::vector<const crypto::public_key*> pkeys;
pkeys.push_back(&pkey);
THROW_WALLET_EXCEPTION_IF(!(rct::scalarmultKey(rct::ki2rct(key_image), rct::curveOrder()) == rct::identity()),
error::wallet_internal_error, "Key image out of validity domain: input " + boost::lexical_cast<std::string>(n) + "/"
+ boost::lexical_cast<std::string>(signed_key_images.size()) + ", key image " + epee::string_tools::pod_to_hex(key_image));
THROW_WALLET_EXCEPTION_IF(!crypto::check_ring_signature((const crypto::hash&)key_image, key_image, pkeys, &signature),
error::wallet_internal_error, "Signature check failed: input " + boost::lexical_cast<std::string>(n) + "/"
+ boost::lexical_cast<std::string>(signed_key_images.size()) + ", key image " + epee::string_tools::pod_to_hex(key_image)