encryptogroup / MOTION

An efficient, user-friendly, modular, and extensible framework for mixed-protocol secure multi-party computation with two or more parties
MIT License
85 stars 40 forks source link

How to compile the example #19

Closed scg258 closed 2 years ago

scg258 commented 2 years ago

I want to compile the millionaires_problem source code myself, but errors occured. root@scg-VirtualBox:~/test_operation# g++ millionaires_problem_main.cpp common/millionaires_problem.cpp -o test -static -lmotion -lboost In file included from /usr/local/include/multiplication_triple/mt_provider.h:29, from /usr/local/include/protocols/arithmetic_gmw/arithmetic_gmw_gate.h:36, from /usr/local/include/base/backend.h:32, from /usr/local/include/base/party.h:32, from millionaires_problem_main.cpp:36: /usr/local/include/oblivious_transfer/ot_flavors.h:99:8: error: ‘span’ in namespace ‘std’ does not name a template type 99 | std::span<const BitVector<>> GetOutputs() const { | ^~~~ /usr/local/include/oblivious_transfer/ot_flavors.h:232:24: error: ‘std::span’ has not been declared 232 | void SetCorrelations(std::span<const BitVector<>> correlations) { | ^~~ /usr/local/include/oblivious_transfer/ot_flavors.h:232:33: error: expected ‘,’ or ‘...’ before ‘<’ token 232 | void SetCorrelations(std::span<const BitVector<>> correlations) { | ^ /usr/local/include/oblivious_transfer/otflavors.h:238:8: error: ‘span’ in namespace ‘std’ does not name a template type 238 | std::span<const BitVector<>> GetCorrelations() const { return correlations; } | ^~~~ /usr/local/include/oblivious_transfer/ot_flavors.h:244:8: error: ‘span’ in namespace ‘std’ does not name a template type 244 | std::span<const BitVector<>> GetOutputs() const {

Oleksandr-Tkachenko commented 2 years ago

It looks like your compiler doesn't support C++20. What compiler are you using?

scg258 commented 2 years ago

It looks like your compiler doesn't support C++20. What compiler are you using?

My compiler version is 11.1.0

No project() command is present. The top-level CMakeLists.txt file must contain a literal, direct call to the project() command. Add a line of code such as

project(ProjectName)

near the top of the file, but after cmake_minimum_required().

CMake is pretending there is a "project(Project)" command on the first line. This warning is for project developers. Use -Wno-dev to suppress it.

-- The C compiler identification is GNU 11.1.0 -- The CXX compiler identification is GNU 11.1.0 -- Check for working C compiler: /usr/bin/cc -- Check for working C compiler: /usr/bin/cc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting C compile features -- Detecting C compile features - done -- Check for working CXX compiler: /usr/bin/g++ -- Check for working CXX compiler: /usr/bin/g++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done -- Configuring done -- Generating done -- Build files have been written to: /root/test_operation/build

scg258 commented 2 years ago

It looks like your compiler doesn't support C++20. What compiler are you using?

When I added - std=c++20, the following new errors occured

g++ millionaires_problem_main.cpp common/millionaires_problem.cpp -o test -lmotion -std=c++20 In file included from /usr/include/c++/11/bits/move.h:57, from /usr/include/c++/11/bits/stl_pair.h:59, from /usr/include/c++/11/bits/stl_algobase.h:64, from /usr/include/c++/11/bits/specfun.h:45, from /usr/include/c++/11/cmath:1927, from millionaires_problem_main.cpp:25: /usr/include/c++/11/type_traits: In substitution of ‘template<bool _Cond, class _Tp> using enable_if_t = typename std::enable_if::type [with bool _Cond = false; _Tp = void]’: /usr/local/include/multiplication_triple/sp_provider.h:152:23: required from here /usr/include/c++/11/type_traits:2514:11: error: no type named ‘type’ in ‘struct std::enable_if<false, void>’ 2514 | using enable_if_t = typename enable_if<_Cond, _Tp>::type; | ^~~ In file included from /usr/local/include/protocols/arithmetic_gmw/arithmetic_gmw_gate.h:37, from /usr/local/include/base/backend.h:32, from /usr/local/include/base/party.h:32, from millionaires_problem_main.cpp:36: /usr/local/include/multiplication_triple/sp_provider.h:152:23: error: template argument 2 is invalid 152 | SpVector<__uint128_t> sps128; | ^ /usr/local/include/multiplication_triple/sp_provider.h: In member function ‘encrypto::motion::SpVector encrypto::motion::SpProvider::GetSps(std::size_t, std::size_t)’: /usr/local/include/multiplication_triple/sp_provider.h:111:20: error: no matching function for call to ‘encrypto::motion::SpProvider::GetSps(int&, const size_t&, const size_t&)’ 111 | return GetSps(sps128, offset, n); | ~~^~~~~ /usr/local/include/multiplication_triple/sp_provider.h:100:15: note: candidate: ‘template<class T, class> encrypto::motion::SpVector encrypto::motion::SpProvider::GetSps(std::size_t, std::size_t)’ 100 | SpVector GetSps(const std::size_t offset, const std::size_t n = 1) { | ^~ /usr/local/include/multiplication_triple/sp_provider.h:100:15: note: template argument deduction/substitution failed: /usr/local/include/multiplication_triple/sp_provider.h:111:20: note: candidate expects 2 arguments, 3 provided 111 | return GetSps(sps128, offset, n); | ~~^~~~~ /usr/local/include/multiplication_triple/sp_provider.h:161:22: note: candidate: ‘template<class T, class> encrypto::motion::SpVector encrypto::motion::SpProvider::GetSps(const encrypto::motion::SpVector&, std::size_t, std::size_t) const’ 161 | inline SpVector GetSps(const SpVector& sps, const std::size_t offset, | ^~ /usr/local/include/multiplication_triple/sp_provider.h:161:22: note: template argument deduction/substitution failed: /usr/local/include/multiplication_triple/sp_provider.h:111:20: note: mismatched types ‘const encrypto::motion::SpVector’ and ‘int’ 111 | return GetSps(sps128, offset, n); | ~~^~~~~ In file included from /usr/include/c++/11/bits/move.h:57, from /usr/include/c++/11/bits/stl_pair.h:59, from /usr/include/c++/11/utility:70, from /usr/include/c++/11/algorithm:60, from /usr/local/include/fmt/format.h:36, from /usr/local/include/base/party.h:27, from common/millionaires_problem.h:27, from common/millionaires_problem.cpp:25: /usr/include/c++/11/type_traits: In substitution of ‘template<bool _Cond, class _Tp> using enable_if_t = typename std::enable_if::type [with bool _Cond = false; _Tp = void]’: /usr/local/include/multiplication_triple/sp_provider.h:152:23: required from here /usr/include/c++/11/type_traits:2514:11: error: no type named ‘type’ in ‘struct std::enable_if<false, void>’ 2514 | using enable_if_t = typename enable_if<_Cond, _Tp>::type; | ^~~ In file included from /usr/local/include/protocols/arithmetic_gmw/arithmetic_gmw_gate.h:37, from /usr/local/include/base/backend.h:32, from /usr/local/include/base/party.h:32, from common/millionaires_problem.h:27, from common/millionaires_problem.cpp:25: /usr/local/include/multiplication_triple/sp_provider.h:152:23: error: template argument 2 is invalid 152 | SpVector<__uint128_t> sps128; | ^ /usr/local/include/multiplication_triple/sp_provider.h: In member function ‘encrypto::motion::SpVector encrypto::motion::SpProvider::GetSps(std::size_t, std::size_t)’: /usr/local/include/multiplication_triple/sp_provider.h:111:20: error: no matching function for call to ‘encrypto::motion::SpProvider::GetSps(int&, const size_t&, const size_t&)’ 111 | return GetSps(sps128, offset, n); | ~~^~~~~ /usr/local/include/multiplication_triple/sp_provider.h:100:15: note: candidate: ‘template<class T, class> encrypto::motion::SpVector encrypto::motion::SpProvider::GetSps(std::size_t, std::size_t)’ 100 | SpVector GetSps(const std::size_t offset, const std::size_t n = 1) { | ^~ /usr/local/include/multiplication_triple/sp_provider.h:100:15: note: template argument deduction/substitution failed: /usr/local/include/multiplication_triple/sp_provider.h:111:20: note: candidate expects 2 arguments, 3 provided 111 | return GetSps(sps128, offset, n); | ~~^~~~~ /usr/local/include/multiplication_triple/sp_provider.h:161:22: note: candidate: ‘template<class T, class> encrypto::motion::SpVector encrypto::motion::SpProvider::GetSps(const encrypto::motion::SpVector&, std::size_t, std::size_t) const’ 161 | inline SpVector GetSps(const SpVector& sps, const std::size_t offset, | ^~ /usr/local/include/multiplication_triple/sp_provider.h:161:22: note: template argument deduction/substitution failed: /usr/local/include/multiplication_triple/sp_provider.h:111:20: note: mismatched types ‘const encrypto::motion::SpVector’ and ‘int’ 111 | return GetSps(sps128, offset, n); | ~~^~~~~

Oleksandr-Tkachenko commented 2 years ago

Can you give me the commands you used to build MOTION, starting from git clone?

scg258 commented 2 years ago

Can you give me the commands you used to build MOTION, starting from git clone?

First of all, thank you for taking the time to answer my question.

Yes I can. The complete compilation process may be useful, so I'll give you all the steps.

when I compile motion in the same environment and add "- DMOTION_BUILD_EXE=On", I can get the compiled executable in PATH_TO_MOTION/build/bin. However, errors will occur when I compile the source code with g++ (g++ millionaires_problem_main.cpp common/millionaires_problem.cpp -o test -static -lmotion -lboost) . Is it something wrong with my compile command?

  1. gcc/g++11 git clone https://github.com/gcc-mirror/gcc.git git checkout releases/gcc-11.1.0 ./contrib/download_prerequisites yum install libgcc.i686 glibc-devel.i686 -y ./configure -prefix=/usr/local --enable-checking=release --enable-languages=c,c++ --enable-multilib make -j4

    cd /bin; mv gcc gcc485; mv g++ g++485; mv c++ c++485 ln -s /usr/local/bin/gcc gcc; ln -s /usr/local/bin/g++ g++; ln -s /usr/local/bin/c++ c++ cd /lib64; mv libstdc++.so.6 libstdc++.so.6.bak ln -s /usr/local/lib64/libstdc++.so.6.0.29 libstdc++.so.6

  2. OpenSSL wget https://www.openssl.org/source/openssl-1.1.1.tar.gz tar zxf openssl; cd openssl ./config shared zlib make depend make && make install

    mv /lib64/libssl.so /usr/lib64/libssl.so.bak; mv /lib64/libcrypto.so /usr/lib64/libcrypto.so.bak ln -s /usr/local/lib64/libssl.so.1.1 /lib64/libssl.so.1.1 ln -s /usr/local/lib64/libcrypto.so.1.1 /lib64/libcrypto.so.1.1 ln -s /usr/local/lib64/libssl.so /lib64/libssl.so ln -s /usr/local/lib64/libcrypto.so /lib64/libcrypto.so

  3. cmake download cmake-3.22.0.tar.gz from https://cmake.org/download tar xvf cmake; cd cmake ./bootstrap && gmake && make install

  4. boost download boost_1_79_0.tar.gz ./bootstrap.sh ./b2 --buildtype=complete install

  5. motion git clone https://github.com/encryptogroup/MOTION.git cd MOTION; mkdir build; cd build; cmake .. -DMOTION_BUILD_EXE=On make && make install

The result of the compilation [ 21%] Built target flatc [ 26%] Built target fbs-generation [ 26%] Built target motion_config [ 26%] gather information about git repository and generating version.cpp [ 26%] Built target motion_version [ 79%] Built target motion [ 81%] Built target aes128 [ 83%] Built target benchmark [ 85%] Built target benchmark_integers [ 87%] Built target benchmark_providers [ 89%] Built target example_template [ 92%] Built target sha256 [ 94%] Built target crosstabs [ 96%] Built target innerproduct [ 98%] Built target mult3 [100%] Built target millionaires_problem Install the project... -- Install configuration: "Release" -- Up-to-date: /usr/local/include/flatbuffers -- Up-to-date: /usr/local/include/flatbuffers/base.h -- Up-to-date: /usr/local/include/flatbuffers/code_generators.h -- Up-to-date: /usr/local/include/flatbuffers/flatbuffers.h -- Up-to-date: /usr/local/include/flatbuffers/flatc.h -- Up-to-date: /usr/local/include/flatbuffers/flexbuffers.h -- Up-to-date: /usr/local/include/flatbuffers/grpc.h -- Up-to-date: /usr/local/include/flatbuffers/hash.h -- Up-to-date: /usr/local/include/flatbuffers/idl.h -- Up-to-date: /usr/local/include/flatbuffers/minireflect.h -- Up-to-date: /usr/local/include/flatbuffers/reflection.h -- Up-to-date: /usr/local/include/flatbuffers/reflection_generated.h -- Up-to-date: /usr/local/include/flatbuffers/registry.h -- Up-to-date: /usr/local/include/flatbuffers/stl_emulation.h -- Up-to-date: /usr/local/include/flatbuffers/util.h -- Up-to-date: /usr/local/lib64/cmake/flatbuffers/FlatbuffersConfig.cmake -- Up-to-date: /usr/local/lib64/cmake/flatbuffers/FlatbuffersConfigVersion.cmake -- Up-to-date: /usr/local/bin/flatc -- Up-to-date: /usr/local/lib64/cmake/flatbuffers/FlatcTargets.cmake -- Up-to-date: /usr/local/lib64/cmake/flatbuffers/FlatcTargets-release.cmake -- Up-to-date: /usr/local/lib/libmotion.a -- Up-to-date: /usr/local/include/motioncore -- Up-to-date: /usr/local/include/motioncore/primitives -- Up-to-date: /usr/local/include/motioncore/primitives/aes -- Up-to-date: /usr/local/include/motioncore/primitives/aes/aesni_primitives.h -- Up-to-date: /usr/local/include/motioncore/primitives/blake2b.h -- Up-to-date: /usr/local/include/motioncore/primitives/pseudo_random_generator.h -- Up-to-date: /usr/local/include/motioncore/primitives/sharing_randomness_generator.h -- Up-to-date: /usr/local/include/motioncore/primitives/curve25519 -- Up-to-date: /usr/local/include/motioncore/primitives/curve25519/mycurve25519.h -- Up-to-date: /usr/local/include/motioncore/primitives/curve25519/mycurve25519_tables.h -- Up-to-date: /usr/local/include/motioncore/primitives/random -- Up-to-date: /usr/local/include/motioncore/primitives/random/aes128_ctr_rng.h -- Up-to-date: /usr/local/include/motioncore/primitives/random/default_rng.h -- Up-to-date: /usr/local/include/motioncore/primitives/random/openssl_rng.h -- Up-to-date: /usr/local/include/motioncore/primitives/random/rng.h -- Up-to-date: /usr/local/include/motioncore/protocols -- Up-to-date: /usr/local/include/motioncore/protocols/arithmetic_gmw -- Up-to-date: /usr/local/include/motioncore/protocols/arithmetic_gmw/arithmetic_gmw_gate.h -- Up-to-date: /usr/local/include/motioncore/protocols/arithmetic_gmw/arithmetic_gmw_share.h -- Up-to-date: /usr/local/include/motioncore/protocols/arithmetic_gmw/arithmetic_gmw_wire.h -- Up-to-date: /usr/local/include/motioncore/protocols/bmr -- Up-to-date: /usr/local/include/motioncore/protocols/bmr/bmr_data.h -- Up-to-date: /usr/local/include/motioncore/protocols/bmr/bmr_gate.h -- Up-to-date: /usr/local/include/motioncore/protocols/bmr/bmr_provider.h -- Up-to-date: /usr/local/include/motioncore/protocols/bmr/bmr_share.h -- Up-to-date: /usr/local/include/motioncore/protocols/bmr/bmr_wire.h -- Up-to-date: /usr/local/include/motioncore/protocols/boolean_gmw -- Up-to-date: /usr/local/include/motioncore/protocols/boolean_gmw/boolean_gmw_gate.h -- Up-to-date: /usr/local/include/motioncore/protocols/boolean_gmw/boolean_gmw_share.h -- Up-to-date: /usr/local/include/motioncore/protocols/boolean_gmw/boolean_gmw_wire.h -- Up-to-date: /usr/local/include/motioncore/protocols/constant -- Up-to-date: /usr/local/include/motioncore/protocols/constant/constant_gate.h -- Up-to-date: /usr/local/include/motioncore/protocols/constant/constant_share.h -- Up-to-date: /usr/local/include/motioncore/protocols/constant/constant_wire.h -- Up-to-date: /usr/local/include/motioncore/protocols/conversion -- Up-to-date: /usr/local/include/motioncore/protocols/conversion/b2a_gate.h -- Up-to-date: /usr/local/include/motioncore/protocols/conversion/conversion_gate.h -- Up-to-date: /usr/local/include/motioncore/protocols/gate.h -- Up-to-date: /usr/local/include/motioncore/protocols/share.h -- Up-to-date: /usr/local/include/motioncore/protocols/share_wrapper.h -- Up-to-date: /usr/local/include/motioncore/protocols/wire.h -- Up-to-date: /usr/local/include/motioncore/protocols/data_management -- Up-to-date: /usr/local/include/motioncore/protocols/data_management/simdify_gate.h -- Up-to-date: /usr/local/include/motioncore/protocols/data_management/subset_gate.h -- Up-to-date: /usr/local/include/motioncore/protocols/data_management/unsimdify_gate.h -- Up-to-date: /usr/local/include/motioncore/secure_type -- Up-to-date: /usr/local/include/motioncore/secure_type/secure_unsigned_integer.h -- Up-to-date: /usr/local/include/motioncore/statistics -- Up-to-date: /usr/local/include/motioncore/statistics/analysis.h -- Up-to-date: /usr/local/include/motioncore/statistics/run_time_statistics.h -- Up-to-date: /usr/local/include/motioncore/utility -- Up-to-date: /usr/local/include/motioncore/utility/bit_matrix.h -- Up-to-date: /usr/local/include/motioncore/utility/bit_vector.h -- Up-to-date: /usr/local/include/motioncore/utility/block.h -- Up-to-date: /usr/local/include/motioncore/utility/condition.h -- Up-to-date: /usr/local/include/motioncore/utility/constants.h -- Up-to-date: /usr/local/include/motioncore/utility/fiber_condition.h -- Up-to-date: /usr/local/include/motioncore/utility/fiber_thread_pool -- Up-to-date: /usr/local/include/motioncore/utility/helpers.h -- Up-to-date: /usr/local/include/motioncore/utility/locked_fiber_queue.h -- Up-to-date: /usr/local/include/motioncore/utility/locked_queue.h -- Up-to-date: /usr/local/include/motioncore/utility/logger.h -- Up-to-date: /usr/local/include/motioncore/utility/random.h -- Up-to-date: /usr/local/include/motioncore/utility/reusable_future.h -- Up-to-date: /usr/local/include/motioncore/utility/runtime_info.h -- Up-to-date: /usr/local/include/motioncore/utility/synchronized_queue.h -- Up-to-date: /usr/local/include/motioncore/utility/thread.h -- Up-to-date: /usr/local/include/motioncore/utility/type_traits.h -- Up-to-date: /usr/local/include/motioncore/utility/typedefs.h -- Up-to-date: /usr/local/include/motioncore/utility/version.h -- Up-to-date: /usr/local/include/motioncore/utility/config.h -- Up-to-date: /usr/local/include/motioncore/algorithm -- Up-to-date: /usr/local/include/motioncore/algorithm/algorithm_description.h -- Up-to-date: /usr/local/include/motioncore/algorithm/low_depth_reduce.h -- Up-to-date: /usr/local/include/motioncore/base -- Up-to-date: /usr/local/include/motioncore/base/backend.h -- Up-to-date: /usr/local/include/motioncore/base/configuration.h -- Up-to-date: /usr/local/include/motioncore/base/motion_base_provider.h -- Up-to-date: /usr/local/include/motioncore/base/output_message_handler.h -- Up-to-date: /usr/local/include/motioncore/base/party.h -- Up-to-date: /usr/local/include/motioncore/base/register.h -- Up-to-date: /usr/local/include/motioncore/cmake -- Up-to-date: /usr/local/include/motioncore/communication -- Up-to-date: /usr/local/include/motioncore/communication/base_ot_message.h -- Up-to-date: /usr/local/include/motioncore/communication/bmr_message.h -- Up-to-date: /usr/local/include/motioncore/communication/communication_layer.h -- Up-to-date: /usr/local/include/motioncore/communication/dummy_transport.h -- Up-to-date: /usr/local/include/motioncore/communication/hello_message.h -- Up-to-date: /usr/local/include/motioncore/communication/message.h -- Up-to-date: /usr/local/include/motioncore/communication/message_handler.h -- Up-to-date: /usr/local/include/motioncore/communication/ot_extension_message.h -- Up-to-date: /usr/local/include/motioncore/communication/output_message.h -- Up-to-date: /usr/local/include/motioncore/communication/shared_bits_message.h -- Up-to-date: /usr/local/include/motioncore/communication/sync_handler.h -- Up-to-date: /usr/local/include/motioncore/communication/tcp_transport.h -- Up-to-date: /usr/local/include/motioncore/communication/transport.h -- Up-to-date: /usr/local/include/motioncore/communication/fbs_headers -- Up-to-date: /usr/local/include/motioncore/communication/fbs_headers/base_ot_generated.h -- Up-to-date: /usr/local/include/motioncore/communication/fbs_headers/bmr_message_generated.h -- Up-to-date: /usr/local/include/motioncore/communication/fbs_headers/hello_message_generated.h -- Up-to-date: /usr/local/include/motioncore/communication/fbs_headers/message_generated.h -- Up-to-date: /usr/local/include/motioncore/communication/fbs_headers/ot_extension_generated.h -- Up-to-date: /usr/local/include/motioncore/communication/fbs_headers/output_message_generated.h -- Up-to-date: /usr/local/include/motioncore/communication/fbs_headers/shared_bits_message_generated.h -- Up-to-date: /usr/local/include/motioncore/data_storage -- Up-to-date: /usr/local/include/motioncore/data_storage/base_ot_data.h -- Up-to-date: /usr/local/include/motioncore/data_storage/ot_extension_data.h -- Up-to-date: /usr/local/include/motioncore/data_storage/shared_bits_data.h -- Up-to-date: /usr/local/include/motioncore/executor -- Up-to-date: /usr/local/include/motioncore/executor/gate_executor.h -- Up-to-date: /usr/local/include/motioncore/multiplication_triple -- Up-to-date: /usr/local/include/motioncore/multiplication_triple/mt_provider.h -- Up-to-date: /usr/local/include/motioncore/multiplication_triple/sb_impl.h -- Up-to-date: /usr/local/include/motioncore/multiplication_triple/sb_provider.h -- Up-to-date: /usr/local/include/motioncore/multiplication_triple/sp_provider.h -- Up-to-date: /usr/local/include/motioncore/oblivious_transfer -- Up-to-date: /usr/local/include/motioncore/oblivious_transfer/base_ots -- Up-to-date: /usr/local/include/motioncore/oblivious_transfer/base_ots/base_ot_provider.h -- Up-to-date: /usr/local/include/motioncore/oblivious_transfer/base_ots/ot.h -- Up-to-date: /usr/local/include/motioncore/oblivious_transfer/base_ots/ot_hl17.h -- Up-to-date: /usr/local/include/motioncore/oblivious_transfer/ot.h -- Up-to-date: /usr/local/include/motioncore/oblivious_transfer/ot_flavors.h -- Up-to-date: /usr/local/include/motioncore/oblivious_transfer/ot_provider.h -- Up-to-date: /usr/local/lib/cmake/MOTION/MOTIONTargets.cmake -- Up-to-date: /usr/local/lib/cmake/MOTION/MOTIONTargets-release.cmake -- Up-to-date: /usr/local/lib/cmake/MOTION/MOTIONConfig.cmake

Oleksandr-Tkachenko commented 2 years ago

I'm not sure if make install does the right thing right now. I think you're the first one who tried to use MOTION manually via the linker flag, so I don't have a solution for you, unfortunately ':) If you want to use MOTION as library for your own application, the currently best way would be by using cmake, just as in examples, e.g., here.

scg258 commented 2 years ago

I'm not sure if make install does the right thing right now. I think you're the first one who tried to use MOTION manually via the linker flag, so I don't have a solution for you, unfortunately ':) If you want to use MOTION as library for your own application, the currently best way would be by using cmake, just as in examples, e.g., here.

Thank you.