From 06b74ae3f50e4c1ee4e4557fac5f418bf9e5de92 Mon Sep 17 00:00:00 2001 From: jeffro256 Date: Sat, 3 May 2025 11:57:22 -0500 Subject: [PATCH] ringct & cryptonote_basic: detangle dependencies `libringct` was linking against `libcryptonote_basic` for a single, one-line convenience function: `cryptonote::get_blob_hash`. Since `cryptonote_basic.h` includes `rctTypes.h`, this one function effectively made an explicit circular dependency between the two libraries. `cryptonote_format_utils.cpp` was including header `rctSigs.h` from `libringct`, when only `rctOps.h` from `libringct_basic` needed to be included. `libcryptonote_basic` wasn't explictly linking against `libringct_basic` nor `libringct` like it should have. And `libblockchain_db` wasn't linking against `libcryptonote_basic` like it should have. We can also downgrade `libblockchain_db`'s dependency on `libringct` to `libringct_basic`. --- src/blockchain_db/CMakeLists.txt | 3 ++- src/cryptonote_basic/CMakeLists.txt | 1 + src/cryptonote_basic/cryptonote_format_utils.cpp | 2 +- src/ringct/CMakeLists.txt | 1 - src/ringct/rctSigs.cpp | 9 ++++++--- 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/blockchain_db/CMakeLists.txt b/src/blockchain_db/CMakeLists.txt index e94705b22..1e2f06809 100644 --- a/src/blockchain_db/CMakeLists.txt +++ b/src/blockchain_db/CMakeLists.txt @@ -45,7 +45,8 @@ target_link_libraries(blockchain_db PUBLIC common cncrypto - ringct + cryptonote_basic + ringct_basic ${LMDB_LIBRARY} ${Boost_FILESYSTEM_LIBRARY} ${Boost_THREAD_LIBRARY} diff --git a/src/cryptonote_basic/CMakeLists.txt b/src/cryptonote_basic/CMakeLists.txt index 639c5a654..5b4a84b67 100644 --- a/src/cryptonote_basic/CMakeLists.txt +++ b/src/cryptonote_basic/CMakeLists.txt @@ -71,6 +71,7 @@ target_link_libraries(cryptonote_basic checkpoints cryptonote_format_utils_basic device + ringct_basic ${Boost_DATE_TIME_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY} ${Boost_SERIALIZATION_LIBRARY} diff --git a/src/cryptonote_basic/cryptonote_format_utils.cpp b/src/cryptonote_basic/cryptonote_format_utils.cpp index edbe76fef..d3c7dba48 100644 --- a/src/cryptonote_basic/cryptonote_format_utils.cpp +++ b/src/cryptonote_basic/cryptonote_format_utils.cpp @@ -38,7 +38,7 @@ #include "cryptonote_config.h" #include "crypto/crypto.h" #include "crypto/hash.h" -#include "ringct/rctSigs.h" +#include "ringct/rctOps.h" using namespace epee; diff --git a/src/ringct/CMakeLists.txt b/src/ringct/CMakeLists.txt index 656ef494a..8a6ed9f8f 100644 --- a/src/ringct/CMakeLists.txt +++ b/src/ringct/CMakeLists.txt @@ -69,7 +69,6 @@ target_link_libraries(ringct PUBLIC common cncrypto - cryptonote_basic device PRIVATE ${OPENSSL_LIBRARIES} diff --git a/src/ringct/rctSigs.cpp b/src/ringct/rctSigs.cpp index 663730295..206a9a51d 100644 --- a/src/ringct/rctSigs.cpp +++ b/src/ringct/rctSigs.cpp @@ -28,16 +28,18 @@ // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#include "rctSigs.h" + #include "misc_log_ex.h" #include "misc_language.h" #include "common/perf_timer.h" #include "common/threadpool.h" #include "common/util.h" -#include "rctSigs.h" #include "bulletproofs.h" #include "bulletproofs_plus.h" -#include "cryptonote_basic/cryptonote_format_utils.h" #include "cryptonote_config.h" +#include "device/device.hpp" +#include "serialization/crypto.h" using namespace crypto; using namespace std; @@ -612,7 +614,8 @@ namespace rct { key prehash; CHECK_AND_ASSERT_THROW_MES(const_cast(rv).serialize_rctsig_base(ba, inputs, outputs), "Failed to serialize rctSigBase"); - cryptonote::get_blob_hash(ss.str(), h); + const std::string sig_base_blob = ss.str(); + cn_fast_hash(sig_base_blob.data(), sig_base_blob.size(), h); hashes.push_back(hash2rct(h)); keyV kv;