From 32a4cf2d0092290791be5a3e6aa107836de430a2 Mon Sep 17 00:00:00 2001 From: Eli Baum Date: Sun, 22 Nov 2026 11:37:29 -0500 Subject: [PATCH 01/11] additional attempted fixes --- .github/workflows/run-3pc-tests.yml | 2 +- CMakeLists.txt | 21 ++++++++---- scripts/_setup_securejoin.sh | 50 ++++++++++++++++++++++++----- scripts/cmake/FindlibOTe.cmake | 40 ----------------------- 4 files changed, 58 insertions(+), 55 deletions(-) delete mode 100644 scripts/cmake/FindlibOTe.cmake diff --git a/.github/workflows/run-3pc-tests.yml b/.github/workflows/run-3pc-tests.yml index c22bf34..4bdf682 100644 --- a/.github/workflows/run-3pc-tests.yml +++ b/.github/workflows/run-3pc-tests.yml @@ -110,7 +110,7 @@ jobs: with: path: | build/secure-join-install - key: secrecy-securejoin-${{ hashFiles('scripts/_setup_libote.sh', 'scripts/_clone_libote.sh', 'scripts/_setup_securejoin.sh', 'scripts/cmake/FindlibOTe.cmake') }} + key: secrecy-securejoin-${{ hashFiles('scripts/_setup_libote.sh', 'scripts/_clone_libote.sh', 'scripts/_setup_securejoin.sh', 'scripts/cmake/securejoin-libote.cmake') }} # cache miss, so install from scratch - if: ${{ steps.cache-securejoin.outputs.cache-hit != 'true' }} diff --git a/CMakeLists.txt b/CMakeLists.txt index 53a3c60..7c6c3b3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,6 +2,11 @@ cmake_minimum_required(VERSION 3.16) project(Orq VERSION 1.0.0 LANGUAGES CXX) +# Imported packages (libOTe, cryptoTools) must be the headers we found. +# CMake otherwise marks their include directories as system, and a copy +# under /usr/local/include is searched first. +set(CMAKE_NO_SYSTEM_FROM_IMPORTED ON) + set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(OPT_LEVEL "2" CACHE STRING "Optimization level (0-3)") @@ -120,22 +125,24 @@ set(LINK_LIBRARIES "${MPI_LIBRARIES}" "${SODIUM_LIBRARY}" "${NTL_LIBRARY}") # Add libOTe and SecureJoin for 2pc only if (PROTOCOL EQUAL "2" AND LINK_LIBOTE) - find_package(libOTe REQUIRED HINTS + find_package(libOTe REQUIRED NO_DEFAULT_PATH HINTS libOTe-install/lib/cmake/libOTe/ libOTe-install/lib64/cmake/libOTe/ build/libOTe-install/lib/cmake/libOTe/ build/libOTe-install/lib64/cmake/libOTe/) list(APPEND LINK_LIBRARIES "oc::libOTe") - find_package(secureJoin REQUIRED HINTS + find_package(secureJoin REQUIRED NO_DEFAULT_PATH HINTS secure-join-install/lib/cmake/secureJoin/ secure-join-install/lib64/cmake/secureJoin/ build/secure-join-install/lib/cmake/secureJoin/ build/secure-join-install/lib64/cmake/secureJoin/) - link_directories(${CMAKE_CURRENT_SOURCE_DIR}/build/secure-join-install/lib) + # The installed config file does not include the exported target. + include("${secureJoin_DIR}/secureJoinTargets.cmake") + get_filename_component(SECUREJOIN_PREFIX "${secureJoin_DIR}/../../.." ABSOLUTE) endif () -find_package(cryptoTools REQUIRED HINTS +find_package(cryptoTools REQUIRED NO_DEFAULT_PATH HINTS libOTe-install/lib/cmake/cryptoTools/ libOTe-install/lib64/cmake/cryptoTools/ build/libOTe-install/lib/cmake/cryptoTools/ @@ -144,8 +151,10 @@ list(APPEND LINK_LIBRARIES "oc::cryptoTools") function(add_secure_join target_name) if(PROTOCOL EQUAL "2" AND LINK_LIBOTE) - target_link_libraries(${target_name} secureJoin) - target_include_directories(${target_name} SYSTEM PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/build/secure-join-install/include/secureJoin/) + target_link_libraries(${target_name} visa::secureJoin) + # Headers live at include/secureJoin/secure-join/. The exported include + # directory is the install prefix's include/, one level too high. + target_include_directories(${target_name} SYSTEM PRIVATE "${SECUREJOIN_PREFIX}/include/secureJoin") endif() endfunction() diff --git a/scripts/_setup_securejoin.sh b/scripts/_setup_securejoin.sh index 332d523..3ab2a27 100755 --- a/scripts/_setup_securejoin.sh +++ b/scripts/_setup_securejoin.sh @@ -3,14 +3,22 @@ # abort if any command fails set -e -## Set up SecureJoin +## Set up SecureJoin against the libOTe install from scripts/_setup_libote.sh. echo "==== Building SecureJoin..." SECUREJOIN_REPO="https://github.com/CASP-Systems-BU/secure-join.git" -# Latest commit from the update branch (official libOTe pin + API fixes). # This file needs to change with every new commit to trigger a new build on GitHub CI SECUREJOIN_COMMIT="86ca35dc81e086e5bbee15cb4eebab770afb5971" +script_dir=$(cd "$(dirname "$0")" && pwd) +# Invoked from the build directory, same as the other setup scripts. +libote_prefix="$(pwd)/libOTe-install" +if [[ ! -f "${libote_prefix}/lib/cmake/libOTe/libOTeConfig.cmake" \ + && ! -f "${libote_prefix}/lib64/cmake/libOTe/libOTeConfig.cmake" ]]; then + echo "libOTe is not installed at ${libote_prefix}. Run scripts/_setup_libote.sh first." >&2 + exit 1 +fi + mkdir -p secure-join-install if [ ! -d secure-join ]; then @@ -21,25 +29,51 @@ cd secure-join git fetch origin git checkout "$SECUREJOIN_COMMIT" -if [[ $(uname -m) == x86_64 ]]; then - SSE_OPTION="-DENABLE_SSE=ON" +if [[ $(uname -m) == x86_64 || $(uname -m) == amd64 || $(uname -m) == AMD64 ]]; then + SSE_OPTION="-DENABLE_SSE=ON -DSECUREJOIN_ENABLE_SSE=ON" else SSE_OPTION="-DENABLE_SSE=OFF -DENABLE_AVX=OFF -DSECUREJOIN_ENABLE_SSE=OFF" fi -# Secure-join builds the pinned libOTe in-tree, so it needs the same compiler and flags. +# A cached CI binary must not be compiled -march=native. That flag is what +# produced illegal-instruction failures when the cache moved between runners. +NATIVE_OPTION= +if [[ -n "${GITHUB_ACTIONS:-}" ]]; then + NATIVE_OPTION="-DNO_ARCH_NATIVE=ON" +fi + +# libOTe's headers need , and SecureJoin is C++20. if ! echo '#include ' | ${CXX:-g++} -std=c++20 -x c++ -E - >/dev/null 2>&1; then if command -v g++-13 >/dev/null 2>&1; then export CXX=g++-13 export CC=gcc-13 else - echo "libOTe requires GCC 13 or newer (missing ). Install g++-13 and rerun." >&2 + echo "SecureJoin requires GCC 13 or newer (missing ). Install g++-13 and rerun." >&2 exit 1 fi fi -python3 build.py -DSODIUM_MONTGOMERY=false -DENABLE_LOGVOLE=OFF -DENABLE_ALL_OT=ON --install=../secure-join-install \ +# --noauto is SecureJoin's switch for "use a libOTe that is already installed." +# build.py does not check cmake's exit status, so the install is checked below. +python3 build.py --noauto \ + -DCMAKE_PREFIX_PATH="${libote_prefix}" \ + -DCMAKE_PROJECT_secureJoin_INCLUDE="${script_dir}/cmake/securejoin-libote.cmake" \ + -DCMAKE_NO_SYSTEM_FROM_IMPORTED=ON \ + -DNO_CMAKE_SYSTEM_PATH=ON \ + -DSODIUM_MONTGOMERY=false \ -DCMAKE_CXX_FLAGS=-DBOOST_ASIO_DISABLE_SERIAL_PORT \ - $SSE_OPTION + --install=../secure-join-install \ + $SSE_OPTION $NATIVE_OPTION + +install_prefix="$(pwd)/../secure-join-install" +if [[ ! -f "${install_prefix}/lib/libsecureJoin.a" \ + && ! -f "${install_prefix}/lib64/libsecureJoin.a" ]]; then + echo "SecureJoin did not install libsecureJoin.a" >&2 + exit 1 +fi +if [[ ! -f "${install_prefix}/include/secureJoin/secure-join/Prf/AltModPrf.h" ]]; then + echo "SecureJoin did not install its headers" >&2 + exit 1 +fi echo "==== SecureJoin installed" diff --git a/scripts/cmake/FindlibOTe.cmake b/scripts/cmake/FindlibOTe.cmake deleted file mode 100644 index 4dae45f..0000000 --- a/scripts/cmake/FindlibOTe.cmake +++ /dev/null @@ -1,40 +0,0 @@ -# SecureJoin calls find_package(libOTe) and then links the target name libOTe. -# That target exists when SecureJoin builds libOTe with add_subdirectory. An -# install from scripts/_setup_libote.sh exports oc::libOTe instead, and that -# imported target does not carry cryptoTools' headers. Point this search at -# that install and publish the target names SecureJoin already uses. -# -# scripts/_setup_securejoin.sh passes -DCMAKE_MODULE_PATH to this directory -# and -DLIBOTE_INSTALL_PREFIX to the install root. --noauto makes SecureJoin -# take this find_package path instead of compiling libOTe again. - -if(NOT LIBOTE_INSTALL_PREFIX) - message(FATAL_ERROR "LIBOTE_INSTALL_PREFIX is not set") -endif() - -message(STATUS "Using installed libOTe at ${LIBOTE_INSTALL_PREFIX}") - -# The caller asked for components (no_asan, sse, ...). The installed config -# does not mark those components found. A nested find_package of this same -# name inherits them while libOTe_FIND_MODULE is on, and then rejects the -# install. Remember the names, and turn that inheritance off for the search. -set(_orq_libote_components ${libOTe_FIND_COMPONENTS}) -set(libOTe_FIND_MODULE OFF) - -find_package(libOTe CONFIG REQUIRED HINTS "${LIBOTE_INSTALL_PREFIX}") -find_package(cryptoTools CONFIG REQUIRED HINTS "${LIBOTE_INSTALL_PREFIX}") - -if(NOT TARGET libOTe) - add_library(libOTe INTERFACE) - target_link_libraries(libOTe INTERFACE oc::libOTe oc::cryptoTools) -endif() - -if(TARGET oc::tests_cryptoTools AND NOT TARGET tests_cryptoTools) - add_library(tests_cryptoTools INTERFACE) - target_link_libraries(tests_cryptoTools INTERFACE oc::tests_cryptoTools) -endif() - -foreach(comp IN LISTS _orq_libote_components) - set(libOTe_${comp}_FOUND TRUE) -endforeach() -set(libOTe_FOUND TRUE) From 98e227fdcd9af979a6e71d8854a4f302e5cd5a6e Mon Sep 17 00:00:00 2001 From: Eli Baum Date: Sun, 22 Nov 2026 11:53:55 -0500 Subject: [PATCH 02/11] oops, forgot file --- scripts/cmake/securejoin-libote.cmake | 27 +++++++++++++++++++++++++++ scripts/setup.sh | 1 - 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 scripts/cmake/securejoin-libote.cmake diff --git a/scripts/cmake/securejoin-libote.cmake b/scripts/cmake/securejoin-libote.cmake new file mode 100644 index 0000000..9d9f09a --- /dev/null +++ b/scripts/cmake/securejoin-libote.cmake @@ -0,0 +1,27 @@ +# Included at the end of SecureJoin's project() via +# CMAKE_PROJECT_secureJoin_INCLUDE. SecureJoin is configured with --noauto, +# so it finds the libOTe we already installed instead of compiling another one. +# +# That install exports oc::libOTe and oc::tests_cryptoTools. SecureJoin's +# CMakeLists links the names add_subdirectory() would have created. Alias +# those names to the imported targets. Do not make a new library: install(EXPORT) +# accepts an imported target, and the alias is resolved to it. + +if(NOT TARGET oc::libOTe) + # The prefix from --noauto. Do not accept a libOTe installed under /usr/local. + find_package(libOTe CONFIG REQUIRED NO_DEFAULT_PATH PATHS ${CMAKE_PREFIX_PATH}) +endif() + +message(STATUS "SecureJoin using installed libOTe from ${libOTe_DIR}") + +if(NOT TARGET libOTe) + add_library(libOTe ALIAS oc::libOTe) +endif() + +if(NOT TARGET oc::tests_cryptoTools) + find_package(cryptoTools CONFIG REQUIRED NO_DEFAULT_PATH PATHS ${CMAKE_PREFIX_PATH}) +endif() + +if(NOT TARGET tests_cryptoTools) + add_library(tests_cryptoTools ALIAS oc::tests_cryptoTools) +endif() diff --git a/scripts/setup.sh b/scripts/setup.sh index 8391129..b551b4b 100755 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -7,4 +7,3 @@ $scripts_dir/_setup_cryptotools.sh $scripts_dir/_setup_ntl.sh $scripts_dir/_setup_libote.sh $scripts_dir/_setup_securejoin.sh -$scripts_dir/_setup_blaze.sh From fec6908de5d12e3ff2d1b58858885174f231056e Mon Sep 17 00:00:00 2001 From: Eli Baum Date: Sun, 22 Nov 2026 12:25:54 -0500 Subject: [PATCH 03/11] i128 issue --- include/backend/common/util.h | 9 ++++++++- include/core/containers/dummy_vector.h | 5 +++-- include/core/containers/mapping_access_vector.h | 8 +++++--- include/core/protocols/protocol.h | 2 +- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/include/backend/common/util.h b/include/backend/common/util.h index cc04704..afa9cb6 100644 --- a/include/backend/common/util.h +++ b/include/backend/common/util.h @@ -3,8 +3,15 @@ #include #include +// GCC 15's libstdc++ does not treat __int128 as std::integral. Clang does. +// These are the same types as __int128_t and __uint128_t. +template +concept extended_integral = std::same_as, __int128> || + std::same_as, unsigned __int128>; + template && !std::is_same_v, bool>)> + bool UseUnsigned = ((std::integral || extended_integral) && + !std::is_same_v, bool>)> struct UnsignedTypeSelector { using type = U; }; diff --git a/include/core/containers/dummy_vector.h b/include/core/containers/dummy_vector.h index 04446f5..673290e 100644 --- a/include/core/containers/dummy_vector.h +++ b/include/core/containers/dummy_vector.h @@ -72,7 +72,8 @@ namespace service { template class Vector { template && !std::is_same_v, bool>)> + bool UseUnsigned = ((std::integral || extended_integral) && + !std::is_same_v, bool>)> struct UnsignedTypeSelector { using type = U; }; @@ -161,7 +162,7 @@ class Vector { * conversion. Default is 16. */ template - requires std::integral + requires std::integral || extended_integral Vector(const std::vector& _other, int fixed_point_precision = 16) : Vector(static_cast(_other.size())) { precision = fixed_point_precision; diff --git a/include/core/containers/mapping_access_vector.h b/include/core/containers/mapping_access_vector.h index ef77ed9..02adf46 100644 --- a/include/core/containers/mapping_access_vector.h +++ b/include/core/containers/mapping_access_vector.h @@ -38,7 +38,8 @@ struct is_ntl_gf2e : std::true_type {}; } // namespace orq template -concept arithmetic = std::integral or std::floating_point or orq::is_ntl_gf2e::value; +concept arithmetic = std::integral or extended_integral or std::floating_point or + orq::is_ntl_gf2e::value; /** * @brief Define a binary operation between two vectors, such as `a - b`. @@ -249,7 +250,8 @@ static inline void setBitMask(T& share, const bool& value, const std::make_unsig template class Vector { template && !std::is_same_v, bool>)> + bool UseUnsigned = ((std::integral || extended_integral) && + !std::is_same_v, bool>)> struct UnsignedTypeSelector { using type = U; }; @@ -418,7 +420,7 @@ class Vector { * conversion. Default is 16. */ template - requires std::integral + requires std::integral || extended_integral Vector(const std::vector& _other, int fixed_point_precision = 16) : Vector(static_cast(_other.size())) { precision = fixed_point_precision; diff --git a/include/core/protocols/protocol.h b/include/core/protocols/protocol.h index d807caa..f30f0df 100644 --- a/include/core/protocols/protocol.h +++ b/include/core/protocols/protocol.h @@ -692,7 +692,7 @@ class Protocol : public ProtocolBase { * @param x - The shared vector to truncate. */ virtual void truncate(EVector& x) { - if constexpr (!std::integral) { + if constexpr (!(std::integral || extended_integral)) { // Only integral types support fixed point (no NTL types) return; } else { From 7c5c39b5711f2f0f9df3b9237e5e1d21e46400a8 Mon Sep 17 00:00:00 2001 From: Eli Baum Date: Sun, 22 Nov 2026 12:30:25 -0500 Subject: [PATCH 04/11] formatting --- include/backend/common/util.h | 5 ++--- include/core/containers/dummy_vector.h | 5 ++--- include/core/containers/mapping_access_vector.h | 7 +++---- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/include/backend/common/util.h b/include/backend/common/util.h index afa9cb6..c5f6d99 100644 --- a/include/backend/common/util.h +++ b/include/backend/common/util.h @@ -9,9 +9,8 @@ template concept extended_integral = std::same_as, __int128> || std::same_as, unsigned __int128>; -template || extended_integral) && - !std::is_same_v, bool>)> +template || extended_integral) && + !std::is_same_v, bool>)> struct UnsignedTypeSelector { using type = U; }; diff --git a/include/core/containers/dummy_vector.h b/include/core/containers/dummy_vector.h index 673290e..bee1a5c 100644 --- a/include/core/containers/dummy_vector.h +++ b/include/core/containers/dummy_vector.h @@ -71,9 +71,8 @@ namespace service { */ template class Vector { - template || extended_integral) && - !std::is_same_v, bool>)> + template || extended_integral) && + !std::is_same_v, bool>)> struct UnsignedTypeSelector { using type = U; }; diff --git a/include/core/containers/mapping_access_vector.h b/include/core/containers/mapping_access_vector.h index 02adf46..1c79b73 100644 --- a/include/core/containers/mapping_access_vector.h +++ b/include/core/containers/mapping_access_vector.h @@ -39,7 +39,7 @@ struct is_ntl_gf2e : std::true_type {}; template concept arithmetic = std::integral or extended_integral or std::floating_point or - orq::is_ntl_gf2e::value; + orq::is_ntl_gf2e::value; /** * @brief Define a binary operation between two vectors, such as `a - b`. @@ -249,9 +249,8 @@ static inline void setBitMask(T& share, const bool& value, const std::make_unsig */ template class Vector { - template || extended_integral) && - !std::is_same_v, bool>)> + template || extended_integral) && + !std::is_same_v, bool>)> struct UnsignedTypeSelector { using type = U; }; From ef59be2b6f2fabf5a16dad69e5fd631d789b8a5d Mon Sep 17 00:00:00 2001 From: Eli Baum Date: Sun, 22 Nov 2026 12:51:39 -0500 Subject: [PATCH 05/11] Fix __int128 unsigned conversion on GCC 15. libstdc++ leaves std::make_unsigned incomplete for __int128, so use a local trait for the unsigned form and signedness checks. Co-authored-by: Cursor --- bench/micro/micro_comm_batch.cpp | 2 +- bench/micro/micro_comm_threads.cpp | 2 +- bench/micro/micro_primitives.cpp | 2 +- bench/micro/thread_test.cpp | 2 +- bench/queries/other/comorbidity.cpp | 2 +- bench/queries/other/distinct_patients.cpp | 2 +- bench/queries/tpch/tpch_dbgen.h | 2 +- examples/ex4_wagegap.cpp | 2 +- include/backend/common/util.h | 35 ++++++++++++++++--- include/core/containers/b_shared_vector.h | 2 +- include/core/containers/dummy_vector.h | 2 +- .../core/containers/mapping_access_vector.h | 10 +++--- include/core/containers/permutation.h | 2 +- include/core/math/util.h | 12 ++++--- include/core/operators/circuits.h | 14 ++++---- include/core/operators/join.h | 2 +- include/core/operators/sorting.h | 2 +- include/core/protocols/dummy_0pc.h | 2 +- include/core/protocols/plaintext_1pc.h | 2 +- include/core/random/correlation/gilboa_crt.h | 2 +- include/core/random/correlation/gilboa_ole.h | 2 +- .../core/random/correlation/ole_generator.h | 2 +- include/core/random/correlation/silent_ot.h | 2 +- include/debug/orq_debug.h | 2 +- tests/test_correlated.cpp | 2 +- tests/test_libote.cpp | 12 +++---- tests/test_operators.cpp | 8 ++--- tests/test_primitives.cpp | 8 ++--- tests/test_table_operators.cpp | 8 ++--- 29 files changed, 89 insertions(+), 60 deletions(-) diff --git a/bench/micro/micro_comm_batch.cpp b/bench/micro/micro_comm_batch.cpp index 3a37c22..4ace70d 100644 --- a/bench/micro/micro_comm_batch.cpp +++ b/bench/micro/micro_comm_batch.cpp @@ -41,7 +41,7 @@ int main(int argc, char** argv) { comm_suffix = "NoCopyComm (" + std::to_string(NOCOPY_COMMUNICATOR_THREADS) + ")"; single_cout( - "Vector: " << test_size << " x " << std::numeric_limits>::digits + "Vector: " << test_size << " x " << std::numeric_limits>::digits << "b | Sample count: " << SAMPLE_COUNT << " | Communicator: " << comm_suffix); orq::Vector send_batch(test_size), recv_batch(test_size); diff --git a/bench/micro/micro_comm_threads.cpp b/bench/micro/micro_comm_threads.cpp index 50b5986..c050999 100644 --- a/bench/micro/micro_comm_threads.cpp +++ b/bench/micro/micro_comm_threads.cpp @@ -74,7 +74,7 @@ int main(int argc, char** argv) { comm_suffix = "NoCopyComm (" + std::to_string(NOCOPY_COMMUNICATOR_THREADS) + ")"; single_cout( - "Vector: " << test_size << " x " << std::numeric_limits>::digits + "Vector: " << test_size << " x " << std::numeric_limits>::digits << "b | Sample count: " << SAMPLE_COUNT << " | Communicator: " << comm_suffix); #ifdef CORRECTNESS_CHECK diff --git a/bench/micro/micro_primitives.cpp b/bench/micro/micro_primitives.cpp index ff77d78..297793f 100644 --- a/bench/micro/micro_primitives.cpp +++ b/bench/micro/micro_primitives.cpp @@ -26,7 +26,7 @@ int main(int argc, char** argv) { ASharedVector x(test_size), y(test_size); single_cout("Vector " << test_size << " x " - << std::numeric_limits>::digits << "b"); + << std::numeric_limits>::digits << "b"); stopwatch::timepoint("Start"); diff --git a/bench/micro/thread_test.cpp b/bench/micro/thread_test.cpp index d989dec..82d37a2 100644 --- a/bench/micro/thread_test.cpp +++ b/bench/micro/thread_test.cpp @@ -34,7 +34,7 @@ int main(int argc, char** argv) { BSharedVector a(test_size), b(test_size); - const int bw = std::numeric_limits>::digits; + const int bw = std::numeric_limits>::digits; single_cout("Test " << test_size << " x " << bw << " " << op << "\n"); diff --git a/bench/queries/other/comorbidity.cpp b/bench/queries/other/comorbidity.cpp index 9e12cb5..148c14c 100644 --- a/bench/queries/other/comorbidity.cpp +++ b/bench/queries/other/comorbidity.cpp @@ -47,7 +47,7 @@ using sec = duration; #endif using T = int64_t; -using uT = std::make_unsigned_t; +using uT = orq::make_unsigned_t; // Setting these up to be roughly similar in size to TPCH, SF 1 -> ~5M rows // Update later based on dataset if required diff --git a/bench/queries/other/distinct_patients.cpp b/bench/queries/other/distinct_patients.cpp index 92b1958..38005a2 100644 --- a/bench/queries/other/distinct_patients.cpp +++ b/bench/queries/other/distinct_patients.cpp @@ -49,7 +49,7 @@ using sec = duration; #endif using T = int64_t; -using uT = std::make_unsigned_t; +using uT = orq::make_unsigned_t; // Setting these up to be roughly similar in size to TPCH, SF 1 -> ~5M rows // Update later based on dataset if required diff --git a/bench/queries/tpch/tpch_dbgen.h b/bench/queries/tpch/tpch_dbgen.h index effd7c0..f739d22 100644 --- a/bench/queries/tpch/tpch_dbgen.h +++ b/bench/queries/tpch/tpch_dbgen.h @@ -77,7 +77,7 @@ class TPCDatabase { * @return Vector */ Vector randomColumn(size_t size, T min_val, T max_val) { - using uT = std::make_unsigned_t; + using uT = orq::make_unsigned_t; Vector uvec(size); runTime->populateLocalRandom(uvec); diff --git a/examples/ex4_wagegap.cpp b/examples/ex4_wagegap.cpp index 70dcd66..a317b71 100644 --- a/examples/ex4_wagegap.cpp +++ b/examples/ex4_wagegap.cpp @@ -64,7 +64,7 @@ int main(int argc, char **argv) { auto pID = runTime->getPartyID(); using D = int32_t; - using uD = std::make_unsigned_t; + using uD = orq::make_unsigned_t; std::vector schema = { "Salary", // in USD diff --git a/include/backend/common/util.h b/include/backend/common/util.h index c5f6d99..0a152b3 100644 --- a/include/backend/common/util.h +++ b/include/backend/common/util.h @@ -3,12 +3,39 @@ #include #include -// GCC 15's libstdc++ does not treat __int128 as std::integral. Clang does. -// These are the same types as __int128_t and __uint128_t. +// GCC 15's libstdc++ does not treat __int128 as an integral type, so +// std::integral, std::make_unsigned, and std::is_signed reject it. Clang +// still accepts it. __int128 and unsigned __int128 are __int128_t and +// __uint128_t. template concept extended_integral = std::same_as, __int128> || std::same_as, unsigned __int128>; +namespace orq { + +template +struct make_unsigned { + using type = std::make_unsigned_t; +}; + +template +struct make_unsigned { + using type = unsigned __int128; +}; + +template +using make_unsigned_t = typename make_unsigned::type; + +template +inline constexpr bool is_signed_v = + std::is_signed_v || std::same_as, __int128>; + +template +inline constexpr bool is_unsigned_v = + std::is_unsigned_v || std::same_as, unsigned __int128>; + +} // namespace orq + template || extended_integral) && !std::is_same_v, bool>)> struct UnsignedTypeSelector { @@ -17,5 +44,5 @@ struct UnsignedTypeSelector { template struct UnsignedTypeSelector { - using type = std::make_unsigned_t; -}; \ No newline at end of file + using type = orq::make_unsigned_t; +}; diff --git a/include/core/containers/b_shared_vector.h b/include/core/containers/b_shared_vector.h index 20db7f1..711f357 100644 --- a/include/core/containers/b_shared_vector.h +++ b/include/core/containers/b_shared_vector.h @@ -48,7 +48,7 @@ using unique_B = std::unique_ptr>; */ template class BSharedVector : public SharedVector { - static const uint MAX_BITS_NUMBER = std::numeric_limits>::digits; + static const uint MAX_BITS_NUMBER = std::numeric_limits>::digits; static const uint LOG_MAX_BITS_NUMBER = std::bit_width(MAX_BITS_NUMBER - 1); using unique_B = std::unique_ptr; diff --git a/include/core/containers/dummy_vector.h b/include/core/containers/dummy_vector.h index bee1a5c..471a021 100644 --- a/include/core/containers/dummy_vector.h +++ b/include/core/containers/dummy_vector.h @@ -79,7 +79,7 @@ class Vector { template struct UnsignedTypeSelector { - using type = std::make_unsigned_t; + using type = orq::make_unsigned_t; }; /** diff --git a/include/core/containers/mapping_access_vector.h b/include/core/containers/mapping_access_vector.h index 1c79b73..dd7a77b 100644 --- a/include/core/containers/mapping_access_vector.h +++ b/include/core/containers/mapping_access_vector.h @@ -181,7 +181,7 @@ static inline T getBit(const T& share, int bitIndex) { if constexpr (_use_bmi && std::numeric_limits::digits <= 64) { return _bextr_u64(share, bitIndex, 1); } else { - using Unsigned_type = typename std::make_unsigned::type; + using Unsigned_type = orq::make_unsigned_t; return ((Unsigned_type)share >> bitIndex) & (Unsigned_type)1; } } @@ -195,7 +195,7 @@ static inline T getBit(const T& share, int bitIndex) { */ template static inline void setBit(T& share, const T& bit, int bitIndex) { - using Unsigned_type = typename std::make_unsigned::type; + using Unsigned_type = orq::make_unsigned_t; share = (share & ~(((Unsigned_type)1 << bitIndex))) | (bit << bitIndex); } @@ -208,7 +208,7 @@ static inline void setBit(T& share, const T& bit, int bitIndex) { */ template static inline void clrBit(T& share, int bitIndex) { - using Unsigned_type = typename std::make_unsigned::type; + using Unsigned_type = orq::make_unsigned_t; share &= ~((Unsigned_type)1 << bitIndex); } @@ -239,7 +239,7 @@ static inline void setBitValue(T& share, const T& value, int bitIndex) { * @param mask which bits to modify */ template -static inline void setBitMask(T& share, const bool& value, const std::make_unsigned_t& mask) { +static inline void setBitMask(T& share, const bool& value, const orq::make_unsigned_t& mask) { share = (share & ~mask) | (-value & mask); } @@ -257,7 +257,7 @@ class Vector { template struct UnsignedTypeSelector { - using type = std::make_unsigned_t; + using type = orq::make_unsigned_t; }; /** diff --git a/include/core/containers/permutation.h b/include/core/containers/permutation.h index db0f512..dbe407b 100644 --- a/include/core/containers/permutation.h +++ b/include/core/containers/permutation.h @@ -88,7 +88,7 @@ class ElementwisePermutation { ElementwisePermutation(const SharedVector &v) : sharedVector(v.vector, v.encoding) { // ensure we're not discarding data when converting to 32 bits - const int bit_length = std::numeric_limits>::digits; + const int bit_length = std::numeric_limits>::digits; static_assert(bit_length <= 32); } diff --git a/include/core/math/util.h b/include/core/math/util.h index 029de5b..4143b1e 100644 --- a/include/core/math/util.h +++ b/include/core/math/util.h @@ -11,6 +11,8 @@ #include #include +#include "backend/common/util.h" + namespace orq::math { static_assert(std::numeric_limits::digits == 64, "unsigned long must be 64 bits"); @@ -37,7 +39,7 @@ NTL::ZZ to_ZZ(T x) { return NTL::ZZ(x); } else { // 128-bit - using U = std::make_unsigned_t; + using U = orq::make_unsigned_t; static_assert(std::numeric_limits::digits == 128); U ux = static_cast(x); @@ -45,7 +47,7 @@ NTL::ZZ to_ZZ(T x) { auto hi = static_cast(ux >> 64); NTL::ZZ res = (NTL::to_ZZ(hi) << 64) | NTL::to_ZZ(lo); - if constexpr (std::is_signed_v) { + if constexpr (orq::is_signed_v) { if (x < 0) { // handle 2s compl res -= pow_128; @@ -66,17 +68,17 @@ NTL::ZZ to_ZZ(T x) { template T from_ZZ(NTL::ZZ x) { if constexpr (sizeof(T) <= sizeof(long)) { - if constexpr (std::is_signed_v) { + if constexpr (orq::is_signed_v) { return static_cast(NTL::to_long(x)); } else { return static_cast(NTL::to_ulong(x)); } } else { // 128-bit - using U = std::make_unsigned_t; + using U = orq::make_unsigned_t; static_assert(std::numeric_limits::digits == 128); - if constexpr (std::is_signed_v) { + if constexpr (orq::is_signed_v) { if (x < 0) { // handle 2s compl x += pow_128; diff --git a/include/core/operators/circuits.h b/include/core/operators/circuits.h index dbc6da3..b54a7b2 100644 --- a/include/core/operators/circuits.h +++ b/include/core/operators/circuits.h @@ -37,7 +37,7 @@ template static unique_B ripple_carry_adder(const BSharedVector& a, const BSharedVector& b, const bool carry_in) { - static const size_t MAX_BITS_NUMBER = std::numeric_limits>::digits; + static const size_t MAX_BITS_NUMBER = std::numeric_limits>::digits; size_t compressed_size = math::div_ceil(a.size(), MAX_BITS_NUMBER); // Compressed vectors @@ -96,7 +96,7 @@ static unique_B rca_compare(const BSharedVector& a, const BSharedVec // compute a + (~b) + 1 auto nb = ~b; - static const size_t MAX_BITS_NUMBER = std::numeric_limits>::digits; + static const size_t MAX_BITS_NUMBER = std::numeric_limits>::digits; size_t compressed_size = math::div_ceil(a.size(), MAX_BITS_NUMBER); // Compressed vectors @@ -180,7 +180,7 @@ std::pair, BSharedVector> prefix_sum( template unique_B parallel_prefix_adder(const BSharedVector& current, const BSharedVector& other, const bool carry_in) { - static const uint MAX_BITS_NUMBER = std::numeric_limits>::digits; + static const uint MAX_BITS_NUMBER = std::numeric_limits>::digits; static const uint LOG_MAX_BITS_NUMBER = std::bit_width(MAX_BITS_NUMBER - 1); BSharedVector p = current ^ other, g = current & other, propagate(current.size()); @@ -234,7 +234,7 @@ static void linear_compare(const BSharedVector& current, const BSharedVect assert(size == other.size()); // Number of bits in the share representation - const size_t MAX_BITS_NUMBER = std::numeric_limits>::digits; + const size_t MAX_BITS_NUMBER = std::numeric_limits>::digits; auto compressed_size = math::div_ceil(size, MAX_BITS_NUMBER); BSharedVector b1(compressed_size), b2(compressed_size), r(compressed_size); @@ -259,7 +259,7 @@ static void linear_compare(const BSharedVector& current, const BSharedVect gt_bits.bit_xor(gt_bits); // If the shares are signed numbers, we need to treat the sign bits differently - if (std::is_signed::value) { + if (orq::is_signed_v) { // Extract MSB (sign bit), compressed b1.pack_from(current, MAX_BITS_NUMBER - 1); b2.pack_from(other, MAX_BITS_NUMBER - 1); @@ -316,7 +316,7 @@ void orq::BSharedVector::_compare(const orq::BSharedVector& other, } // Number of bits in the share representation - const size_t MAX_BITS_NUMBER = std::numeric_limits>::digits; + const size_t MAX_BITS_NUMBER = std::numeric_limits>::digits; auto compressed_size = math::div_ceil(size, MAX_BITS_NUMBER); @@ -340,7 +340,7 @@ void orq::BSharedVector::_compare(const orq::BSharedVector& other, gt_bits.bit_xor(gt_bits); // If the shares are signed numbers, we need to treat the sign bits differently - if (std::is_signed::value) { + if (orq::is_signed_v) { BSharedVector s1(compressed_size), s2(compressed_size), r(compressed_size); // Extract MSB (sign bit), compressed diff --git a/include/core/operators/join.h b/include/core/operators/join.h index 80a16af..394b13a 100644 --- a/include/core/operators/join.h +++ b/include/core/operators/join.h @@ -195,7 +195,7 @@ TABLE_T TABLE_T::_join(TABLE_T &right, std::vector keys, Aggregatio auto L = size(); auto R = right.size(); - auto w = std::numeric_limits>::digits; + auto w = std::numeric_limits>::digits; auto c = schema.size() - 1; // don't count valid if (R < (L * (w + c - 1) / (c + 2))) { diff --git a/include/core/operators/sorting.h b/include/core/operators/sorting.h index c30b171..caa4373 100644 --- a/include/core/operators/sorting.h +++ b/include/core/operators/sorting.h @@ -30,7 +30,7 @@ namespace operators { template static ElementwisePermutation radix_sort( BSharedVector& v, SortOrder order = SortOrder::ASC, - const size_t bits = std::numeric_limits>::digits, + const size_t bits = std::numeric_limits>::digits, bool no_invert = false); // \endcond DOXYGEN_IGNORE diff --git a/include/core/protocols/dummy_0pc.h b/include/core/protocols/dummy_0pc.h index 5169506..9b79c16 100644 --- a/include/core/protocols/dummy_0pc.h +++ b/include/core/protocols/dummy_0pc.h @@ -64,7 +64,7 @@ class Dummy_0PC : public Protocol { }) ->second; - auto bits = std::numeric_limits>::digits; + auto bits = std::numeric_limits>::digits; uint64_t max_count_width = std::ceil(std::log10(max_count * bits)); diff --git a/include/core/protocols/plaintext_1pc.h b/include/core/protocols/plaintext_1pc.h index e49dea3..f55e0aa 100644 --- a/include/core/protocols/plaintext_1pc.h +++ b/include/core/protocols/plaintext_1pc.h @@ -68,7 +68,7 @@ class Plaintext_1PC : public Protocol { }) ->second; - auto bits = std::numeric_limits>::digits; + auto bits = std::numeric_limits>::digits; uint64_t max_count_width = std::ceil(std::log10(max_count * bits)); diff --git a/include/core/random/correlation/gilboa_crt.h b/include/core/random/correlation/gilboa_crt.h index 1663aff..cfdd291 100644 --- a/include/core/random/correlation/gilboa_crt.h +++ b/include/core/random/correlation/gilboa_crt.h @@ -169,7 +169,7 @@ namespace internal { */ template class GilboaCRT : public OLEGenerator { - static constexpr int L = std::numeric_limits>::digits; + static constexpr int L = std::numeric_limits>::digits; using OLEBase = OLEGenerator; diff --git a/include/core/random/correlation/gilboa_ole.h b/include/core/random/correlation/gilboa_ole.h index 9f89e24..296cb38 100644 --- a/include/core/random/correlation/gilboa_ole.h +++ b/include/core/random/correlation/gilboa_ole.h @@ -38,7 +38,7 @@ class GilboaOLE : public OLEGenerator { std::unique_ptr recv; std::unique_ptr send; - static constexpr size_t L = std::numeric_limits>::digits; + static constexpr size_t L = std::numeric_limits>::digits; /** * @brief Sender side of an additive correlated OT. libOTe provides XOR-correlations; we diff --git a/include/core/random/correlation/ole_generator.h b/include/core/random/correlation/ole_generator.h index 848fea2..55d0711 100644 --- a/include/core/random/correlation/ole_generator.h +++ b/include/core/random/correlation/ole_generator.h @@ -130,7 +130,7 @@ class OLEGenerator : public CorrelationGenerator, Vector */ template class OLEmodPrimeInterface { - static_assert(std::is_unsigned_v, "OLEmodPrimeInterface: T must be unsigned!"); + static_assert(orq::is_unsigned_v, "OLEmodPrimeInterface: T must be unsigned!"); public: using wide_t = typename DoubleWidth::type; diff --git a/include/core/random/correlation/silent_ot.h b/include/core/random/correlation/silent_ot.h index 4f020af..05318d0 100644 --- a/include/core/random/correlation/silent_ot.h +++ b/include/core/random/correlation/silent_ot.h @@ -173,7 +173,7 @@ class SilentOT : public OTGenerator { bool isServer; int thread; - size_t L = std::numeric_limits>::digits; + size_t L = std::numeric_limits>::digits; public: /** diff --git a/include/debug/orq_debug.h b/include/debug/orq_debug.h index 05238d9..02dea7f 100644 --- a/include/debug/orq_debug.h +++ b/include/debug/orq_debug.h @@ -508,7 +508,7 @@ static void print_table(const std::pair>& ta template T get_bit(const T& s, int i) { - using Unsigned_type = typename std::make_unsigned::type; + using Unsigned_type = orq::make_unsigned_t; return ((Unsigned_type)s >> i) & (Unsigned_type)1; } diff --git a/tests/test_correlated.cpp b/tests/test_correlated.cpp index 828ff59..868d749 100644 --- a/tests/test_correlated.cpp +++ b/tests/test_correlated.cpp @@ -15,7 +15,7 @@ const size_t test_size = 1 << 12; template class C> void checkCorrelation(std::string label) { - auto L = std::numeric_limits>::digits; + auto L = std::numeric_limits>::digits; single_cout_nonl("Checking length " << test_size << " " << L << "-bit " << label << "... "); auto gen = runTime->rand0()->template getCorrelation>(); diff --git a/tests/test_libote.cpp b/tests/test_libote.cpp index e175234..a71f275 100644 --- a/tests/test_libote.cpp +++ b/tests/test_libote.cpp @@ -53,7 +53,7 @@ inline auto eval(macoro::task<>& t0, macoro::task<>& t1) { */ template void test_noisy_vole_local(u64 n) { - auto L = std::numeric_limits>::digits; + auto L = std::numeric_limits>::digits; std::cout << "Local Noisy VOLE " << L << "-bit... "; std::vector A(n), B(n), C(n); @@ -108,7 +108,7 @@ void test_noisy_vole_local(u64 n) { */ template void test_silent_vole_local(u64 n) { - auto L = std::numeric_limits>::digits; + auto L = std::numeric_limits>::digits; std::cout << "Local Silent VOLE " << L << "-bit... "; using VecF = typename Ctx::template Vec; @@ -155,7 +155,7 @@ const uint LOG_OT_BLOCK_SIZE = std::bit_width(OT_BLOCK_SIZE) - 1; template void test_silent_ot_local(u64 n) { assert(n % OT_BLOCK_SIZE == 0); - auto L = std::numeric_limits>::digits; + auto L = std::numeric_limits>::digits; std::cout << "Local Silent OT " << L << "-bit... "; PRNG prng(sysRandomSeed()); @@ -236,7 +236,7 @@ void test_silent_ot_local(u64 n) { */ template void test_silent_vole_loopback(u64 n) { - auto L = std::numeric_limits>::digits; + auto L = std::numeric_limits>::digits; single_cout_nonl("LAN Silent OLE " << L << "-bit... "); using VecF = typename Ctx::template Vec; @@ -304,7 +304,7 @@ void test_silent_vole_loopback(u64 n) { template void test_silent_ot_loopback(u64 n) { assert(n % OT_BLOCK_SIZE == 0); - auto L = std::numeric_limits>::digits; + auto L = std::numeric_limits>::digits; bool isServer = (runTime->getPartyID() == 0); @@ -399,7 +399,7 @@ void test_silent_ot_loopback(u64 n) { template void test_silent_ot_chosen(u64 n) { - auto L = std::numeric_limits>::digits; + auto L = std::numeric_limits>::digits; bool isServer = (runTime->getPartyID() == 0); diff --git a/tests/test_operators.cpp b/tests/test_operators.cpp index e4a855b..0d29da6 100644 --- a/tests/test_operators.cpp +++ b/tests/test_operators.cpp @@ -58,7 +58,7 @@ void test_minimal_agg_example() { template void test_vector_aggregation(const size_t test_size = 32) { - single_cout("Testing " << std::numeric_limits>::digits + single_cout("Testing " << std::numeric_limits>::digits << "-bit vector aggregation..."); std::vector data(test_size); // TODO: random values @@ -199,7 +199,7 @@ void test_vector_aggregation(const size_t test_size = 32) { template void test_distinct(const int test_size = 32) { - single_cout("Testing " << std::numeric_limits>::digits + single_cout("Testing " << std::numeric_limits>::digits << "-bit distinct..."); orq::Vector data(test_size); orq::Vector truth(test_size); @@ -237,7 +237,7 @@ void test_distinct(const int test_size = 32) { template void test_multi_distinct() { - single_cout("Testing " << std::numeric_limits>::digits + single_cout("Testing " << std::numeric_limits>::digits << "-bit multi-key distinct..."); auto pid = runTime->getPartyID(); std::vector> c1 = {{0, 0, 0, 1, 1, 1, 2}, {0, 0, 1, 1, 1, 0, 2}, Vector(7)}; @@ -259,7 +259,7 @@ void test_multi_distinct() { // TODO: auto generate tables and test results as above. template void test_table_operators() { - single_cout("Testing " << std::numeric_limits>::digits + single_cout("Testing " << std::numeric_limits>::digits << "-bit tables..."); const std::vector schema = { diff --git a/tests/test_primitives.cpp b/tests/test_primitives.cpp index a0d8174..fd7241e 100644 --- a/tests/test_primitives.cpp +++ b/tests/test_primitives.cpp @@ -43,7 +43,7 @@ void test_b2a(int test_size) { #define DEFINE_TEST_BINARY_OP(_op_, shareType, name) \ template \ void test_##name(int test_size) { \ - auto L = std::numeric_limits>::digits; \ + auto L = std::numeric_limits>::digits; \ single_cout_nonl(L << "-bit " #name "... "); \ orq::Vector x(test_size); \ orq::Vector y(test_size); \ @@ -83,7 +83,7 @@ DEFINE_TEST_BINARY_OP(<, BSharedVector, less_than); template void test_private_division(int test_size) { - using uT = std::make_unsigned_t; + using uT = orq::make_unsigned_t; auto L = std::numeric_limits::digits; single_cout_nonl("Boolean long division, " << L << "-bit... "); @@ -120,7 +120,7 @@ void test_private_division(int test_size) { template void test_dot_product(int test_size, const int aggSize = 7) { - auto L = std::numeric_limits>::digits; + auto L = std::numeric_limits>::digits; single_cout_nonl(L << "-bit dot product(" << aggSize << ")... "); if (test_size % aggSize != 0) { @@ -149,7 +149,7 @@ void test_dot_product(int test_size, const int aggSize = 7) { template void test_equals(int test_size) { - auto L = std::numeric_limits>::digits; + auto L = std::numeric_limits>::digits; single_cout_nonl(L << "-bit equals..."); orq::Vector x(test_size), y(test_size); diff --git a/tests/test_table_operators.cpp b/tests/test_table_operators.cpp index 8fa823e..6b6c79c 100644 --- a/tests/test_table_operators.cpp +++ b/tests/test_table_operators.cpp @@ -29,7 +29,7 @@ void assert_table_schema(EncodedTable table, size_t column_count) { template void test_add_columns() { - single_cout_nonl("Testing " << std::numeric_limits>::digits + single_cout_nonl("Testing " << std::numeric_limits>::digits << "-bit: addColumns... "); EncodedTable table = create_test_table(1); @@ -47,7 +47,7 @@ void test_add_columns() { template void test_delete_columns() { - single_cout_nonl("Testing " << std::numeric_limits>::digits + single_cout_nonl("Testing " << std::numeric_limits>::digits << "-bit: deleteColumns... "); EncodedTable table = create_test_table(6); @@ -69,7 +69,7 @@ void test_delete_columns() { template void test_project() { - single_cout_nonl("Testing " << std::numeric_limits>::digits + single_cout_nonl("Testing " << std::numeric_limits>::digits << "-bit: project... "); // Project single column @@ -91,7 +91,7 @@ void test_project() { template void test_resize() { - single_cout_nonl("Testing " << std::numeric_limits>::digits + single_cout_nonl("Testing " << std::numeric_limits>::digits << "-bit: resize... "); const size_t n_rows = 10000; From dda61cb7042c1d87082e3ae34c46553b178804ab Mon Sep 17 00:00:00 2001 From: Eli Baum Date: Sun, 22 Nov 2026 13:07:00 -0500 Subject: [PATCH 06/11] more 128b fixes --- include/backend/common/util.h | 29 +++++++++++++++++++ .../core/containers/mapping_access_vector.h | 2 +- .../core/random/correlation/ole_generator.h | 2 +- 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/include/backend/common/util.h b/include/backend/common/util.h index 0a152b3..687fc9a 100644 --- a/include/backend/common/util.h +++ b/include/backend/common/util.h @@ -1,6 +1,8 @@ #pragma once +#include #include +#include #include // GCC 15's libstdc++ does not treat __int128 as an integral type, so @@ -34,6 +36,33 @@ template inline constexpr bool is_unsigned_v = std::is_unsigned_v || std::same_as, unsigned __int128>; +// std::popcount and std::bit_width require __unsigned_integer, which also +// excludes unsigned __int128 on GCC 15. +constexpr int popcount(unsigned __int128 x) { + return std::popcount(static_cast(x)) + + std::popcount(static_cast(x >> 64)); +} + +template + requires(!extended_integral) +constexpr int popcount(T x) { + return std::popcount(x); +} + +constexpr int bit_width(unsigned __int128 x) { + auto hi = static_cast(x >> 64); + if (hi != 0) { + return 64 + std::bit_width(hi); + } + return std::bit_width(static_cast(x)); +} + +template + requires(!extended_integral) +constexpr int bit_width(T x) { + return std::bit_width(x); +} + } // namespace orq template || extended_integral) && diff --git a/include/core/containers/mapping_access_vector.h b/include/core/containers/mapping_access_vector.h index dd7a77b..298ed5c 100644 --- a/include/core/containers/mapping_access_vector.h +++ b/include/core/containers/mapping_access_vector.h @@ -509,7 +509,7 @@ class Vector { Vector res = this->construct_like(); for (VectorSizeType i = 0; i < size; ++i) { - res[i] = std::popcount(static_cast((*this)[i])) & 1; + res[i] = orq::popcount(static_cast((*this)[i])) & 1; } return res; diff --git a/include/core/random/correlation/ole_generator.h b/include/core/random/correlation/ole_generator.h index 55d0711..7f6f648 100644 --- a/include/core/random/correlation/ole_generator.h +++ b/include/core/random/correlation/ole_generator.h @@ -148,7 +148,7 @@ class OLEmodPrimeInterface { T getPrime() const { return prime; } - int primeBits() const { return std::bit_width(prime); } + int primeBits() const { return orq::bit_width(prime); } using ole_t = std::tuple, Vector>; From 0e3feafede9a5a316c94d70d2b2f498ad255e7a2 Mon Sep 17 00:00:00 2001 From: Eli Baum Date: Sun, 22 Nov 2026 13:45:55 -0500 Subject: [PATCH 07/11] oprf attempt fix --- include/core/random/correlation/oprf.h | 32 +++++++++++++++----------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/include/core/random/correlation/oprf.h b/include/core/random/correlation/oprf.h index a089651..28514d6 100644 --- a/include/core/random/correlation/oprf.h +++ b/include/core/random/correlation/oprf.h @@ -10,6 +10,8 @@ #include "secure-join/Prf/AltModPrf.h" #include "secure-join/Prf/AltModPrfProto.h" +#include + // shift up past OLE and past OT const int OPRF_BASE_PORT = GILBOA_OLE_BASE_PORT + (MAX_POSSIBLE_THREADS * 32); @@ -142,19 +144,19 @@ class OPRF { std::vector y(n); - // initialize the OLE generators - ole.init(sock_ole_send->fork(), prng, !isServer, 1, 1 << 18, 0); - - // handle the thread pool, not quite sure what this does + // One thread runs the PRF and the OLE generator. The work guard keeps + // the pool alive while both tasks are scheduled on it. macoro::thread_pool pool; - auto e = pool.make_work(); // this line is CRITICAL, even though e is never used (reference - // counting) + auto work = pool.make_work(); pool.create_threads(1); + // fork() copies the current executor. Install it first so OLE + // completions resume on this pool, same as the PRF task. An empty + // executor resumes on the Asio thread and races the generator. sock_main_send->setExecutor(pool); sock_ole_send->setExecutor(pool); + ole.init(sock_ole_send->fork(), prng, !isServer, 1, 1 << 18, 0); - // evaluate sender->init(n, ole, secJoin::AltModPrfKeyMode::SenderOnly, secJoin::AltModPrfInputMode::ReceiverOnly, key, rk); sender->preprocess(); @@ -162,6 +164,10 @@ class OPRF { auto r = coproto::sync_wait(coproto::when_all_ready( ole.start() | macoro::start_on(pool), sender->evaluate({}, y, *sock_main_send, prng) | macoro::start_on(pool))); + // when_all_ready does not rethrow. An unchecked failure leaves y zero + // and the correctness test fails with no protocol error. + std::get<0>(r).result(); + std::get<1>(r).result(); oc::cp::sync_wait(sock_main_send->flush()); // flush the socket oc::cp::sync_wait(sock_ole_send->flush()); // flush the socket @@ -202,19 +208,15 @@ class OPRF { std::vector x(reinterpret_cast(x_vec.data()), reinterpret_cast(x_vec.data() + n)); - // initialize the OLE generators - ole.init(sock_ole_recv->fork(), prng, !isServer, 1, 1 << 18, 0); - - // handle the thread pool, not quite sure what this does macoro::thread_pool pool; - auto e = pool.make_work(); // this line is CRITICAL, even though e is never used (reference - // counting) + auto work = pool.make_work(); pool.create_threads(1); + // Same ordering as evaluate_sender: executor before fork. sock_main_recv->setExecutor(pool); sock_ole_recv->setExecutor(pool); + ole.init(sock_ole_recv->fork(), prng, !isServer, 1, 1 << 18, 0); - // evaluate receiver->init(n, ole, secJoin::AltModPrfKeyMode::SenderOnly, secJoin::AltModPrfInputMode::ReceiverOnly, {}, sk); receiver->preprocess(); @@ -222,6 +224,8 @@ class OPRF { auto r = coproto::sync_wait(coproto::when_all_ready( ole.start() | macoro::start_on(pool), receiver->evaluate(x, y, *sock_main_recv, prng) | macoro::start_on(pool))); + std::get<0>(r).result(); + std::get<1>(r).result(); oc::cp::sync_wait(sock_main_recv->flush()); // flush the socket oc::cp::sync_wait(sock_ole_recv->flush()); // flush the socket From 88b7830a7b29c59fd93f809eba9fd7acfdbca0df Mon Sep 17 00:00:00 2001 From: Eli Baum Date: Sun, 22 Nov 2026 13:47:52 -0500 Subject: [PATCH 08/11] fmt --- include/core/random/correlation/oprf.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/core/random/correlation/oprf.h b/include/core/random/correlation/oprf.h index 28514d6..65ad360 100644 --- a/include/core/random/correlation/oprf.h +++ b/include/core/random/correlation/oprf.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "backend/common/libote_io.h" #include "constants.h" #include "coproto/Socket/AsioSocket.h" @@ -10,8 +12,6 @@ #include "secure-join/Prf/AltModPrf.h" #include "secure-join/Prf/AltModPrfProto.h" -#include - // shift up past OLE and past OT const int OPRF_BASE_PORT = GILBOA_OLE_BASE_PORT + (MAX_POSSIBLE_THREADS * 32); From 41cebb546424a855415433214f043ca1322cff36 Mon Sep 17 00:00:00 2001 From: Eli Baum Date: Sun, 22 Nov 2026 15:12:27 -0500 Subject: [PATCH 09/11] Turn off coproto's always-on Asio debug log. That log vector is written from io threads and throws std::length_error in test_libote. Wait for both parties before the LAN tests so one does not connect early. Co-authored-by: Cursor --- .github/workflows/run-3pc-tests.yml | 4 ++-- scripts/_setup_libote.sh | 3 +++ scripts/cmake/coproto-asio-log.cmake | 24 ++++++++++++++++++++++++ tests/test_libote.cpp | 4 ++++ 4 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 scripts/cmake/coproto-asio-log.cmake diff --git a/.github/workflows/run-3pc-tests.yml b/.github/workflows/run-3pc-tests.yml index 4bdf682..9885e21 100644 --- a/.github/workflows/run-3pc-tests.yml +++ b/.github/workflows/run-3pc-tests.yml @@ -95,7 +95,7 @@ jobs: with: path: | build/libOTe-install - key: secrecy-libote-${{ hashFiles('scripts/_setup_libote.sh', 'scripts/_clone_libote.sh') }} + key: secrecy-libote-${{ hashFiles('scripts/_setup_libote.sh', 'scripts/_clone_libote.sh', 'scripts/cmake/coproto-asio-log.cmake') }} # cache miss, so install from scratch - if: ${{ steps.cache-deps.outputs.cache-hit != 'true' }} @@ -110,7 +110,7 @@ jobs: with: path: | build/secure-join-install - key: secrecy-securejoin-${{ hashFiles('scripts/_setup_libote.sh', 'scripts/_clone_libote.sh', 'scripts/_setup_securejoin.sh', 'scripts/cmake/securejoin-libote.cmake') }} + key: secrecy-securejoin-${{ hashFiles('scripts/_setup_libote.sh', 'scripts/_clone_libote.sh', 'scripts/_setup_securejoin.sh', 'scripts/cmake/securejoin-libote.cmake', 'scripts/cmake/coproto-asio-log.cmake') }} # cache miss, so install from scratch - if: ${{ steps.cache-securejoin.outputs.cache-hit != 'true' }} diff --git a/scripts/_setup_libote.sh b/scripts/_setup_libote.sh index a782cb6..34ac550 100755 --- a/scripts/_setup_libote.sh +++ b/scripts/_setup_libote.sh @@ -42,7 +42,10 @@ if [[ ! -f "${termios_header}" ]]; then fi TERMIOS_CXX_FLAGS="-DCMAKE_CXX_FLAGS=-include${termios_header}" +# coproto leaves COPROTO_ASIO_LOG defined in every build. That log vector +# is updated from Asio's io threads and throws std::length_error. python3 build.py --par=4 --boost --sodium --relic -DSODIUM_MONTGOMERY=false --all --install=../libOTe-install \ + -DCMAKE_PROJECT_coproto_INCLUDE="${script_dir}/cmake/coproto-asio-log.cmake" \ $SSE_OPTION $TERMIOS_CXX_FLAGS $AVX512_FLAG echo "==== libOTe installed" diff --git a/scripts/cmake/coproto-asio-log.cmake b/scripts/cmake/coproto-asio-log.cmake new file mode 100644 index 0000000..df082c8 --- /dev/null +++ b/scripts/cmake/coproto-asio-log.cmake @@ -0,0 +1,24 @@ +# coproto's AsioSocket.h defines COPROTO_ASIO_LOG and COPROTO_ASIO_DEBUG +# outside its NDEBUG guard, so they are on in every build. The log vector +# is written from Asio's io threads and eventually throws +# std::length_error ("vector"). Included via CMAKE_PROJECT_coproto_INCLUDE, +# which runs at the end of project(coproto), before that project compiles. +if(NOT DEFINED COPROTO_SOURCE_DIR) + set(COPROTO_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}") +endif() + +set(_asio "${COPROTO_SOURCE_DIR}/coproto/Socket/AsioSocket.h") +if(NOT EXISTS "${_asio}") + message(FATAL_ERROR "coproto AsioSocket.h not found at ${_asio}") +endif() +file(READ "${_asio}" _hdr) +string(REGEX REPLACE + "#define COPROTO_ASIO_LOG" + "#undef COPROTO_ASIO_LOG" + _hdr "${_hdr}") +string(REGEX REPLACE + "#define COPROTO_ASIO_DEBUG" + "#undef COPROTO_ASIO_DEBUG" + _hdr "${_hdr}") +file(WRITE "${_asio}" "${_hdr}") +message(STATUS "coproto: COPROTO_ASIO_LOG and COPROTO_ASIO_DEBUG disabled") diff --git a/tests/test_libote.cpp b/tests/test_libote.cpp index a71f275..fa8f7c9 100644 --- a/tests/test_libote.cpp +++ b/tests/test_libote.cpp @@ -521,6 +521,10 @@ int main(int argc, char** argv) { test_silent_ot_local(test_size); } + // Party 0 runs the in-process tests above before it listens. Party 1 + // would otherwise connect, retry, and speak to whatever accepts first. + MPI_Barrier(MPI_COMM_WORLD); + // 2PC tests of Silent VOLE test_silent_vole_loopback(test_size); test_silent_vole_loopback(test_size); From a2c4de1e7810b0a99027a142c43bac63cb41931c Mon Sep 17 00:00:00 2001 From: Eli Baum Date: Mon, 23 Nov 2026 21:15:47 -0500 Subject: [PATCH 10/11] a different approach --- .github/workflows/run-3pc-tests.yml | 4 +- CMakeLists.txt | 43 +++++++------------- scripts/_setup_cryptotools.sh | 14 +------ scripts/_setup_libote.sh | 56 +++++++++------------------ scripts/_setup_securejoin.sh | 50 ++++-------------------- scripts/cmake/coproto-asio-log.cmake | 24 ------------ scripts/cmake/securejoin-libote.cmake | 27 ------------- 7 files changed, 45 insertions(+), 173 deletions(-) delete mode 100644 scripts/cmake/coproto-asio-log.cmake delete mode 100644 scripts/cmake/securejoin-libote.cmake diff --git a/.github/workflows/run-3pc-tests.yml b/.github/workflows/run-3pc-tests.yml index 9885e21..82cd355 100644 --- a/.github/workflows/run-3pc-tests.yml +++ b/.github/workflows/run-3pc-tests.yml @@ -95,7 +95,7 @@ jobs: with: path: | build/libOTe-install - key: secrecy-libote-${{ hashFiles('scripts/_setup_libote.sh', 'scripts/_clone_libote.sh', 'scripts/cmake/coproto-asio-log.cmake') }} + key: secrecy-libote-${{ hashFiles('scripts/_setup_libote.sh', 'scripts/_clone_libote.sh') }} # cache miss, so install from scratch - if: ${{ steps.cache-deps.outputs.cache-hit != 'true' }} @@ -110,7 +110,7 @@ jobs: with: path: | build/secure-join-install - key: secrecy-securejoin-${{ hashFiles('scripts/_setup_libote.sh', 'scripts/_clone_libote.sh', 'scripts/_setup_securejoin.sh', 'scripts/cmake/securejoin-libote.cmake', 'scripts/cmake/coproto-asio-log.cmake') }} + key: secrecy-securejoin-${{ hashFiles('scripts/_setup_libote.sh', 'scripts/_clone_libote.sh', 'scripts/_setup_securejoin.sh') }} # cache miss, so install from scratch - if: ${{ steps.cache-securejoin.outputs.cache-hit != 'true' }} diff --git a/CMakeLists.txt b/CMakeLists.txt index 7c6c3b3..1456ec0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,15 +2,10 @@ cmake_minimum_required(VERSION 3.16) project(Orq VERSION 1.0.0 LANGUAGES CXX) -# Imported packages (libOTe, cryptoTools) must be the headers we found. -# CMake otherwise marks their include directories as system, and a copy -# under /usr/local/include is searched first. -set(CMAKE_NO_SYSTEM_FROM_IMPORTED ON) - set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(OPT_LEVEL "2" CACHE STRING "Optimization level (0-3)") -set(CMAKE_CXX_FLAGS "-O${OPT_LEVEL} -pthread -fwrapv") +set(CMAKE_CXX_FLAGS "-O${OPT_LEVEL} -g -pthread -fwrapv") add_compile_options(-Wno-deprecated-declarations) @@ -30,13 +25,7 @@ endif (PERF) if (NOT NO_X86_SSE) if (CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|AMD64") - # ubuntu-latest runners are a mix of AVX2-only and AVX-512 machines, and - # x86-64-v3 (common ancestor) is sufficient for our purposes. - if(DEFINED ENV{GITHUB_ACTIONS}) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mbmi -march=x86-64-v3") - else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mbmi -march=native") - endif() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mbmi -march=native") endif() endif (NOT NO_X86_SSE) @@ -101,6 +90,10 @@ find_package(Threads REQUIRED) # Adding Dependencies # add_subdirectory(src/external-lib/sql-parser) +# Skip MPI C++ bindings: RELIC (via libOTe/SecureJoin) #define's DOUBLE, +# which collides with OpenMPI's MPI::DOUBLE when the CXX headers are pulled in. +add_compile_definitions(OMPI_SKIP_MPICXX MPICH_SKIP_MPICXX) + # Adding MPI Library find_package(MPI REQUIRED) if (MPI_FOUND) @@ -125,24 +118,20 @@ set(LINK_LIBRARIES "${MPI_LIBRARIES}" "${SODIUM_LIBRARY}" "${NTL_LIBRARY}") # Add libOTe and SecureJoin for 2pc only if (PROTOCOL EQUAL "2" AND LINK_LIBOTE) - find_package(libOTe REQUIRED NO_DEFAULT_PATH HINTS + find_package(libOTe REQUIRED HINTS libOTe-install/lib/cmake/libOTe/ libOTe-install/lib64/cmake/libOTe/ build/libOTe-install/lib/cmake/libOTe/ build/libOTe-install/lib64/cmake/libOTe/) list(APPEND LINK_LIBRARIES "oc::libOTe") - find_package(secureJoin REQUIRED NO_DEFAULT_PATH HINTS + find_package(secureJoin REQUIRED HINTS secure-join-install/lib/cmake/secureJoin/ - secure-join-install/lib64/cmake/secureJoin/ - build/secure-join-install/lib/cmake/secureJoin/ - build/secure-join-install/lib64/cmake/secureJoin/) - # The installed config file does not include the exported target. - include("${secureJoin_DIR}/secureJoinTargets.cmake") - get_filename_component(SECUREJOIN_PREFIX "${secureJoin_DIR}/../../.." ABSOLUTE) + build/secure-join-install/lib/cmake/secureJoin/) + link_directories(${CMAKE_CURRENT_SOURCE_DIR}/build/secure-join-install/lib) endif () -find_package(cryptoTools REQUIRED NO_DEFAULT_PATH HINTS +find_package(cryptoTools REQUIRED HINTS libOTe-install/lib/cmake/cryptoTools/ libOTe-install/lib64/cmake/cryptoTools/ build/libOTe-install/lib/cmake/cryptoTools/ @@ -150,12 +139,10 @@ find_package(cryptoTools REQUIRED NO_DEFAULT_PATH HINTS list(APPEND LINK_LIBRARIES "oc::cryptoTools") function(add_secure_join target_name) - if(PROTOCOL EQUAL "2" AND LINK_LIBOTE) - target_link_libraries(${target_name} visa::secureJoin) - # Headers live at include/secureJoin/secure-join/. The exported include - # directory is the install prefix's include/, one level too high. - target_include_directories(${target_name} SYSTEM PRIVATE "${SECUREJOIN_PREFIX}/include/secureJoin") - endif() + if(PROTOCOL EQUAL "2" AND LINK_LIBOTE) + target_link_libraries(${target_name} secureJoin) + target_include_directories(${target_name} SYSTEM PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/build/secure-join-install/include/secureJoin/) + endif() endfunction() # Option: switch between custom 4PC and original Dalskov et al. protocol diff --git a/scripts/_setup_cryptotools.sh b/scripts/_setup_cryptotools.sh index a2fb737..d1eef7f 100755 --- a/scripts/_setup_cryptotools.sh +++ b/scripts/_setup_cryptotools.sh @@ -4,16 +4,4 @@ source $(dirname $0)/_clone_libote.sh cd cryptoTools -# prevent illegal instruction issue -case "$(uname -m)" in - x86_64|amd64|AMD64) - ISA_FLAGS= - if [[ -n "${GITHUB_ACTIONS:-}" ]]; then - ISA_FLAGS="-DENABLE_AVX512=OFF" - fi - ;; - *) - ISA_FLAGS="-DENABLE_SSE=OFF -DENABLE_AVX=OFF -DENABLE_AVX512=OFF" - ;; -esac -python3 build.py --par=4 --install=../../libOTe-install $ISA_FLAGS \ No newline at end of file +python3 build.py --par=4 --install=../../libOTe-install diff --git a/scripts/_setup_libote.sh b/scripts/_setup_libote.sh index 34ac550..f1726f4 100755 --- a/scripts/_setup_libote.sh +++ b/scripts/_setup_libote.sh @@ -6,46 +6,28 @@ set -e ## Set up libOTe echo "==== Building libOTe..." -# Resolve before _clone_libote.sh, which cds into libOTe. -script_dir=$(cd "$(dirname "$0")" && pwd) -source "${script_dir}/_clone_libote.sh" +source $(dirname $0)/_clone_libote.sh -case "$(uname -m)" in - x86_64|amd64|AMD64) - SSE_OPTION="-DENABLE_SSE=ON" - # Do not cache an AVX-512 libOTe and run it on an AVX2-only runner. - # Leave host detection alone on other x86 machines. - AVX512_FLAG= - if [[ -n "${GITHUB_ACTIONS:-}" ]]; then - AVX512_FLAG="-DENABLE_AVX512=OFF" - fi - ;; - *) - # SSE, AVX, and AVX-512 are x86. ARM builds use the scalar paths. - SSE_OPTION="-DENABLE_SSE=OFF -DENABLE_AVX=OFF -DENABLE_AVX512=OFF -DENABLE_SPIN=OFF" - AVX512_FLAG= - ;; -esac +if [[ $(uname -m) == x86_64 ]]; then + SSE_OPTION="-DENABLE_SSE=ON" +else + SSE_OPTION="-DENABLE_SSE=OFF -DENABLE_AVX=OFF " +fi -# #defines B0 as the baud rate 0. macOS has always done this, and -# glibc does too (bits/termios.h). libOTe tests declare variables named B0 -# after Boost.Asio has included termios.h, so the preprocessor turns B0(n) -# into a numeric constant. Force-include a header that keeps B0 usable both -# as an identifier and as Asio's baud-rate constant. The compiler is launched -# from per-target directories under out/build, at different depths, so a -# relative -include path cannot resolve. Pass an absolute path with no space: -# build.py joins arguments into a shell command. -termios_header="${script_dir}/mac_undef_termios.h" -if [[ ! -f "${termios_header}" ]]; then - echo "missing termios workaround header: ${termios_header}" >&2 - exit 1 +# is in libstdc++ from GCC 13. Use g++-13 when the default compiler is older. +if ! echo '#include ' | ${CXX:-g++} -std=c++20 -x c++ -E - >/dev/null 2>&1; then + if command -v g++-13 >/dev/null 2>&1; then + export CXX=g++-13 + export CC=gcc-13 + else + echo "libOTe requires GCC 13 or newer (missing ). Install g++-13 and rerun." >&2 + exit 1 + fi fi -TERMIOS_CXX_FLAGS="-DCMAKE_CXX_FLAGS=-include${termios_header}" -# coproto leaves COPROTO_ASIO_LOG defined in every build. That log vector -# is updated from Asio's io threads and throws std::length_error. -python3 build.py --par=4 --boost --sodium --relic -DSODIUM_MONTGOMERY=false --all --install=../libOTe-install \ - -DCMAKE_PROJECT_coproto_INCLUDE="${script_dir}/cmake/coproto-asio-log.cmake" \ - $SSE_OPTION $TERMIOS_CXX_FLAGS $AVX512_FLAG +# Boost.Asio includes , and that header's B0 macro breaks the libOTe tests. +python3 build.py --par=4 --boost --sodium --relic -DSODIUM_MONTGOMERY=false -DENABLE_LOGVOLE=OFF --all --install=../libOTe-install \ + -DCMAKE_CXX_FLAGS=-DBOOST_ASIO_DISABLE_SERIAL_PORT \ + $SSE_OPTION echo "==== libOTe installed" diff --git a/scripts/_setup_securejoin.sh b/scripts/_setup_securejoin.sh index 3ab2a27..332d523 100755 --- a/scripts/_setup_securejoin.sh +++ b/scripts/_setup_securejoin.sh @@ -3,22 +3,14 @@ # abort if any command fails set -e -## Set up SecureJoin against the libOTe install from scripts/_setup_libote.sh. +## Set up SecureJoin echo "==== Building SecureJoin..." SECUREJOIN_REPO="https://github.com/CASP-Systems-BU/secure-join.git" +# Latest commit from the update branch (official libOTe pin + API fixes). # This file needs to change with every new commit to trigger a new build on GitHub CI SECUREJOIN_COMMIT="86ca35dc81e086e5bbee15cb4eebab770afb5971" -script_dir=$(cd "$(dirname "$0")" && pwd) -# Invoked from the build directory, same as the other setup scripts. -libote_prefix="$(pwd)/libOTe-install" -if [[ ! -f "${libote_prefix}/lib/cmake/libOTe/libOTeConfig.cmake" \ - && ! -f "${libote_prefix}/lib64/cmake/libOTe/libOTeConfig.cmake" ]]; then - echo "libOTe is not installed at ${libote_prefix}. Run scripts/_setup_libote.sh first." >&2 - exit 1 -fi - mkdir -p secure-join-install if [ ! -d secure-join ]; then @@ -29,51 +21,25 @@ cd secure-join git fetch origin git checkout "$SECUREJOIN_COMMIT" -if [[ $(uname -m) == x86_64 || $(uname -m) == amd64 || $(uname -m) == AMD64 ]]; then - SSE_OPTION="-DENABLE_SSE=ON -DSECUREJOIN_ENABLE_SSE=ON" +if [[ $(uname -m) == x86_64 ]]; then + SSE_OPTION="-DENABLE_SSE=ON" else SSE_OPTION="-DENABLE_SSE=OFF -DENABLE_AVX=OFF -DSECUREJOIN_ENABLE_SSE=OFF" fi -# A cached CI binary must not be compiled -march=native. That flag is what -# produced illegal-instruction failures when the cache moved between runners. -NATIVE_OPTION= -if [[ -n "${GITHUB_ACTIONS:-}" ]]; then - NATIVE_OPTION="-DNO_ARCH_NATIVE=ON" -fi - -# libOTe's headers need , and SecureJoin is C++20. +# Secure-join builds the pinned libOTe in-tree, so it needs the same compiler and flags. if ! echo '#include ' | ${CXX:-g++} -std=c++20 -x c++ -E - >/dev/null 2>&1; then if command -v g++-13 >/dev/null 2>&1; then export CXX=g++-13 export CC=gcc-13 else - echo "SecureJoin requires GCC 13 or newer (missing ). Install g++-13 and rerun." >&2 + echo "libOTe requires GCC 13 or newer (missing ). Install g++-13 and rerun." >&2 exit 1 fi fi -# --noauto is SecureJoin's switch for "use a libOTe that is already installed." -# build.py does not check cmake's exit status, so the install is checked below. -python3 build.py --noauto \ - -DCMAKE_PREFIX_PATH="${libote_prefix}" \ - -DCMAKE_PROJECT_secureJoin_INCLUDE="${script_dir}/cmake/securejoin-libote.cmake" \ - -DCMAKE_NO_SYSTEM_FROM_IMPORTED=ON \ - -DNO_CMAKE_SYSTEM_PATH=ON \ - -DSODIUM_MONTGOMERY=false \ +python3 build.py -DSODIUM_MONTGOMERY=false -DENABLE_LOGVOLE=OFF -DENABLE_ALL_OT=ON --install=../secure-join-install \ -DCMAKE_CXX_FLAGS=-DBOOST_ASIO_DISABLE_SERIAL_PORT \ - --install=../secure-join-install \ - $SSE_OPTION $NATIVE_OPTION - -install_prefix="$(pwd)/../secure-join-install" -if [[ ! -f "${install_prefix}/lib/libsecureJoin.a" \ - && ! -f "${install_prefix}/lib64/libsecureJoin.a" ]]; then - echo "SecureJoin did not install libsecureJoin.a" >&2 - exit 1 -fi -if [[ ! -f "${install_prefix}/include/secureJoin/secure-join/Prf/AltModPrf.h" ]]; then - echo "SecureJoin did not install its headers" >&2 - exit 1 -fi + $SSE_OPTION echo "==== SecureJoin installed" diff --git a/scripts/cmake/coproto-asio-log.cmake b/scripts/cmake/coproto-asio-log.cmake deleted file mode 100644 index df082c8..0000000 --- a/scripts/cmake/coproto-asio-log.cmake +++ /dev/null @@ -1,24 +0,0 @@ -# coproto's AsioSocket.h defines COPROTO_ASIO_LOG and COPROTO_ASIO_DEBUG -# outside its NDEBUG guard, so they are on in every build. The log vector -# is written from Asio's io threads and eventually throws -# std::length_error ("vector"). Included via CMAKE_PROJECT_coproto_INCLUDE, -# which runs at the end of project(coproto), before that project compiles. -if(NOT DEFINED COPROTO_SOURCE_DIR) - set(COPROTO_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}") -endif() - -set(_asio "${COPROTO_SOURCE_DIR}/coproto/Socket/AsioSocket.h") -if(NOT EXISTS "${_asio}") - message(FATAL_ERROR "coproto AsioSocket.h not found at ${_asio}") -endif() -file(READ "${_asio}" _hdr) -string(REGEX REPLACE - "#define COPROTO_ASIO_LOG" - "#undef COPROTO_ASIO_LOG" - _hdr "${_hdr}") -string(REGEX REPLACE - "#define COPROTO_ASIO_DEBUG" - "#undef COPROTO_ASIO_DEBUG" - _hdr "${_hdr}") -file(WRITE "${_asio}" "${_hdr}") -message(STATUS "coproto: COPROTO_ASIO_LOG and COPROTO_ASIO_DEBUG disabled") diff --git a/scripts/cmake/securejoin-libote.cmake b/scripts/cmake/securejoin-libote.cmake deleted file mode 100644 index 9d9f09a..0000000 --- a/scripts/cmake/securejoin-libote.cmake +++ /dev/null @@ -1,27 +0,0 @@ -# Included at the end of SecureJoin's project() via -# CMAKE_PROJECT_secureJoin_INCLUDE. SecureJoin is configured with --noauto, -# so it finds the libOTe we already installed instead of compiling another one. -# -# That install exports oc::libOTe and oc::tests_cryptoTools. SecureJoin's -# CMakeLists links the names add_subdirectory() would have created. Alias -# those names to the imported targets. Do not make a new library: install(EXPORT) -# accepts an imported target, and the alias is resolved to it. - -if(NOT TARGET oc::libOTe) - # The prefix from --noauto. Do not accept a libOTe installed under /usr/local. - find_package(libOTe CONFIG REQUIRED NO_DEFAULT_PATH PATHS ${CMAKE_PREFIX_PATH}) -endif() - -message(STATUS "SecureJoin using installed libOTe from ${libOTe_DIR}") - -if(NOT TARGET libOTe) - add_library(libOTe ALIAS oc::libOTe) -endif() - -if(NOT TARGET oc::tests_cryptoTools) - find_package(cryptoTools CONFIG REQUIRED NO_DEFAULT_PATH PATHS ${CMAKE_PREFIX_PATH}) -endif() - -if(NOT TARGET tests_cryptoTools) - add_library(tests_cryptoTools ALIAS oc::tests_cryptoTools) -endif() From c3547a5592210af7b51b7cf958ae1f0cbb7a461c Mon Sep 17 00:00:00 2001 From: Eli Baum Date: Mon, 23 Nov 2026 22:20:54 -0500 Subject: [PATCH 11/11] maybe just try u24 --- .github/workflows/run-3pc-tests.yml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/run-3pc-tests.yml b/.github/workflows/run-3pc-tests.yml index 82cd355..fbfb04a 100644 --- a/.github/workflows/run-3pc-tests.yml +++ b/.github/workflows/run-3pc-tests.yml @@ -22,9 +22,7 @@ jobs: test-all-3pc: if: github.event.pull_request.draft == false - # ubuntu-latest, for private repos, only gives us 2 cores - # see github docs for more info - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 # Bumping this because apt install is slow (and we need coproto installed) timeout-minutes: 30 @@ -64,7 +62,7 @@ jobs: test-2pc: if: github.event.pull_request.draft == false - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 # This should be more than enough time to run tests, but also need enough # time to install libOTe + save cache, where necessary @@ -140,9 +138,9 @@ jobs: test-others: if: github.event.pull_request.draft == false - # ubuntu-latest, for private repos, only gives us 2 cores + # for private repos, only gives us 2 cores # see github docs for more info - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 timeout-minutes: 10