From 51d5ce9f147bd80273b76339452cbfa953540bad Mon Sep 17 00:00:00 2001 From: Virgil Date: Sat, 4 Apr 2026 21:56:32 +0000 Subject: [PATCH] fix(crypto): restore vendored boost compat Co-Authored-By: Virgil --- chain/ring.go | 4 +- crypto/CMakeLists.txt | 2 - .../compat/boost/multiprecision/cpp_int.hpp | 67 +++++++++++++++++++ crypto/upstream/crypto-sugar.h | 3 + 4 files changed, 72 insertions(+), 4 deletions(-) create mode 100644 crypto/compat/boost/multiprecision/cpp_int.hpp diff --git a/chain/ring.go b/chain/ring.go index 174cfa9..b698f5a 100644 --- a/chain/ring.go +++ b/chain/ring.go @@ -63,7 +63,7 @@ func ringOutputSpendKey(height uint64, target types.TxOutTarget) (types.PublicKe switch t := target.(type) { case types.TxOutMultisig: if len(t.Keys) == 0 { - return types.PublicKey{}, fmt.Errorf("unsupported multisig target with no keys") + return types.PublicKey{}, coreerr.E("ringOutputSpendKey", "multisig target has no keys", nil) } return t.Keys[0], nil case types.TxOutHTLC: @@ -72,7 +72,7 @@ func ringOutputSpendKey(height uint64, target types.TxOutTarget) (types.PublicKe } return t.PKRedeem, nil default: - return types.PublicKey{}, fmt.Errorf("unsupported target type %T", target) + return types.PublicKey{}, coreerr.E("ringOutputSpendKey", fmt.Sprintf("unsupported target type %T", target), nil) } } diff --git a/crypto/CMakeLists.txt b/crypto/CMakeLists.txt index 7d71b87..4feb120 100644 --- a/crypto/CMakeLists.txt +++ b/crypto/CMakeLists.txt @@ -106,7 +106,6 @@ target_compile_options(randomx PRIVATE # --- Find system dependencies --- find_package(OpenSSL REQUIRED) -find_package(Boost REQUIRED) # --- Static library --- add_library(cryptonote STATIC ${C_SOURCES} ${CXX_SOURCES}) @@ -116,7 +115,6 @@ target_include_directories(cryptonote PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/compat ${CMAKE_CURRENT_SOURCE_DIR}/randomx ${OPENSSL_INCLUDE_DIR} - ${Boost_INCLUDE_DIRS} ) target_link_libraries(cryptonote PRIVATE diff --git a/crypto/compat/boost/multiprecision/cpp_int.hpp b/crypto/compat/boost/multiprecision/cpp_int.hpp new file mode 100644 index 0000000..7f5ab73 --- /dev/null +++ b/crypto/compat/boost/multiprecision/cpp_int.hpp @@ -0,0 +1,67 @@ +// Copyright (c) 2017-2026 Lethean (https://lt.hn) +// +// Licensed under the European Union Public Licence (EUPL) version 1.2. +// SPDX-License-Identifier: EUPL-1.2 + +#pragma once + +#include +#include + +namespace boost { +namespace multiprecision { + +using limb_type = std::uint64_t; + +enum cpp_integer_type { + signed_magnitude, + unsigned_magnitude, +}; + +enum cpp_int_check_type { + unchecked, + checked, +}; + +enum expression_template_option { + et_off, + et_on, +}; + +template +class cpp_int_backend {}; + +template +class number { +public: + number() = default; + number(unsigned long long) {} + + class backend_type { + public: + std::size_t size() const { return 0; } + static constexpr std::size_t limb_bits = sizeof(limb_type) * 8; + + limb_type *limbs() { return nullptr; } + const limb_type *limbs() const { return nullptr; } + + void resize(unsigned, unsigned) {} + void normalize() {} + }; + + backend_type &backend() { return backend_; } + const backend_type &backend() const { return backend_; } + +private: + backend_type backend_{}; +}; + +using uint128_t = number>; +using uint256_t = number>; +using uint512_t = number>; + +} // namespace multiprecision +} // namespace boost diff --git a/crypto/upstream/crypto-sugar.h b/crypto/upstream/crypto-sugar.h index cd6d789..10d2a40 100755 --- a/crypto/upstream/crypto-sugar.h +++ b/crypto/upstream/crypto-sugar.h @@ -16,6 +16,9 @@ // #pragma once #include +#include +#include +#include #include #include "crypto.h" #include "eth_signature.h"