New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RELEASE] Several mitigations for attacking privacy via key reusing forks #3322

Merged
merged 15 commits into from Mar 16, 2018
Jump to file or symbol
Failed to load files and symbols.
+2,609 −35
Diff settings

Always

Just for now

@@ -50,4 +50,16 @@ if(${ARCH_WIDTH} EQUAL 32)
target_compile_definitions(lmdb
PUBLIC -DMDB_VL32)
endif()
# GUI/libwallet install target
if (BUILD_GUI_DEPS)
if(IOS)
set(lib_folder lib-${ARCH})
else()
set(lib_folder lib)
endif()
install(TARGETS lmdb
ARCHIVE DESTINATION ${lib_folder}
LIBRARY DESTINATION ${lib_folder})
endif()
set_property(TARGET lmdb APPEND PROPERTY COMPILE_FLAGS "-fPIC")
@@ -1448,7 +1448,9 @@ class BlockchainDB
*
* @return false if the function returns false for any output, otherwise true
*/
virtual bool for_all_outputs(std::function<bool(uint64_t amount, const crypto::hash &tx_hash, size_t tx_idx)> f) const = 0;
virtual bool for_all_outputs(std::function<bool(uint64_t amount, const crypto::hash &tx_hash, uint64_t height, size_t tx_idx)> f) const = 0;
virtual bool for_all_outputs(uint64_t amount, const std::function<bool(uint64_t height)> &f) const = 0;
//
@@ -2564,7 +2564,7 @@ bool BlockchainLMDB::for_all_transactions(std::function<bool(const crypto::hash&
return fret;
}
bool BlockchainLMDB::for_all_outputs(std::function<bool(uint64_t amount, const crypto::hash &tx_hash, size_t tx_idx)> f) const
bool BlockchainLMDB::for_all_outputs(std::function<bool(uint64_t amount, const crypto::hash &tx_hash, uint64_t height, size_t tx_idx)> f) const
{
LOG_PRINT_L3("BlockchainLMDB::" << __func__);
check_open();
@@ -2588,7 +2588,47 @@ bool BlockchainLMDB::for_all_outputs(std::function<bool(uint64_t amount, const c
uint64_t amount = *(const uint64_t*)k.mv_data;
outkey *ok = (outkey *)v.mv_data;
tx_out_index toi = get_output_tx_and_index_from_global(ok->output_id);
if (!f(amount, toi.first, toi.second)) {
if (!f(amount, toi.first, ok->data.height, toi.second)) {
fret = false;
break;
}
}
TXN_POSTFIX_RDONLY();
return fret;
}
bool BlockchainLMDB::for_all_outputs(uint64_t amount, const std::function<bool(uint64_t height)> &f) const
{
LOG_PRINT_L3("BlockchainLMDB::" << __func__);
check_open();
TXN_PREFIX_RDONLY();
RCURSOR(output_amounts);
MDB_val_set(k, amount);
MDB_val v;
bool fret = true;
MDB_cursor_op op = MDB_SET;
while (1)
{
int ret = mdb_cursor_get(m_cur_output_amounts, &k, &v, op);
op = MDB_NEXT_DUP;
if (ret == MDB_NOTFOUND)
break;
if (ret)
throw0(DB_ERROR("Failed to enumerate outputs"));
uint64_t out_amount = *(const uint64_t*)k.mv_data;
if (amount != out_amount)
{
MERROR("Amount is not the expected amount");
fret = false;
break;
}
const outkey *ok = (const outkey *)v.mv_data;
if (!f(ok->data.height)) {
fret = false;
break;
}
@@ -255,7 +255,8 @@ class BlockchainLMDB : public BlockchainDB
virtual bool for_all_key_images(std::function<bool(const crypto::key_image&)>) const;
virtual bool for_blocks_range(const uint64_t& h1, const uint64_t& h2, std::function<bool(uint64_t, const crypto::hash&, const cryptonote::block&)>) const;
virtual bool for_all_transactions(std::function<bool(const crypto::hash&, const cryptonote::transaction&)>) const;
virtual bool for_all_outputs(std::function<bool(uint64_t amount, const crypto::hash &tx_hash, size_t tx_idx)> f) const;
virtual bool for_all_outputs(std::function<bool(uint64_t amount, const crypto::hash &tx_hash, uint64_t height, size_t tx_idx)> f) const;
virtual bool for_all_outputs(uint64_t amount, const std::function<bool(uint64_t height)> &f) const;
virtual uint64_t add_block( const block& blk
, const size_t& block_size
@@ -67,6 +67,30 @@ monero_private_headers(blockchain_export
${blockchain_export_private_headers})
set(blockchain_blackball_sources
blockchain_blackball.cpp
)
set(blockchain_blackball_private_headers
bootstrap_file.h
blocksdat_file.h
bootstrap_serialization.h
)
monero_private_headers(blockchain_blackball
${blockchain_blackball_private_headers})
set(blockchain_usage_sources
blockchain_usage.cpp
)
set(blockchain_usage_private_headers)
monero_private_headers(blockchain_usage
${blockchain_usage_private_headers})
monero_add_executable(blockchain_import
${blockchain_import_sources}
${blockchain_import_private_headers}
@@ -117,3 +141,49 @@ set_property(TARGET blockchain_export
OUTPUT_NAME "monero-blockchain-export")
install(TARGETS blockchain_export DESTINATION bin)
monero_add_executable(blockchain_blackball
${blockchain_blackball_sources}
${blockchain_blackball_private_headers})
target_link_libraries(blockchain_blackball
PRIVATE
wallet
cryptonote_core
blockchain_db
p2p
version
epee
${Boost_FILESYSTEM_LIBRARY}
${Boost_SYSTEM_LIBRARY}
${Boost_THREAD_LIBRARY}
${CMAKE_THREAD_LIBS_INIT}
${EXTRA_LIBRARIES})
set_property(TARGET blockchain_blackball
PROPERTY
OUTPUT_NAME "monero-blockchain-blackball")
install(TARGETS blockchain_blackball DESTINATION bin)
monero_add_executable(blockchain_usage
${blockchain_usage_sources}
${blockchain_usage_private_headers})
target_link_libraries(blockchain_usage
PRIVATE
cryptonote_core
blockchain_db
p2p
version
epee
${Boost_FILESYSTEM_LIBRARY}
${Boost_SYSTEM_LIBRARY}
${Boost_THREAD_LIBRARY}
${CMAKE_THREAD_LIBS_INIT}
${EXTRA_LIBRARIES})
set_property(TARGET blockchain_usage
PROPERTY
OUTPUT_NAME "monero-blockchain-usage")
install(TARGETS blockchain_usage DESTINATION bin)
Oops, something went wrong.
ProTip! Use n and p to navigate between commits in a pull request.