MOTION  0.01
Framework for mixed-protocol multi-party computation
thread.h
Go to the documentation of this file.
1 // Copyright 2019 Lennart Braun
2 //
3 // Permission is hereby granted, free of charge, to any person obtaining a copy
4 // of this software and associated documentation files (the "Software"), to
5 // deal in the Software without restriction, including without limitation the
6 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7 // sell copies of the Software, and to permit persons to whom the Software is
8 // furnished to do so, subject to the following conditions:
9 //
10 // The above copyright notice and this permission notice shall be included in
11 // all copies or substantial portions of the Software.
12 //
13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
19 // IN THE SOFTWARE.
20 
21 #pragma once
22 
23 #include <string>
24 #include <thread>
25 
26 namespace encrypto::motion {
27 
28 // Sets the name of a given thread using pthread_setname_np which can be useful for debugging.
29 // - name.size() <= 16
30 void ThreadSetName(std::thread& thread, const std::string& name);
31 
32 } // namespace encrypto::motion
encrypto::motion::MakeLocallyConnectedParties
std::vector< std::unique_ptr< Party > > MakeLocallyConnectedParties(const std::size_t number_of_parties, std::uint16_t, const bool)
constructs number_of_parties motion::Party's locally connected via TCP.
Definition: party.cpp:227
encrypto::motion::IsUnsignedInt
std::enable_if_t< std::conjunction_v< std::is_integral< T >, std::is_unsigned< T >, std::negation< std::is_same< T, bool > >> > IsUnsignedInt
Definition: type_traits.h:31
condition.h
TEST_P
TEST_P(TcpTransportTest, dummy)
Definition: test_tcp_transport.cpp:31
encrypto::motion::ShareWrapper::Out
ShareWrapper Out(std::size_t output_owner=std::numeric_limits< std::int64_t >::max()) const
constructs an output gate, which reconstructs the cleartext result. The default parameter for the out...
Definition: share_wrapper.cpp:414
encrypto::motion::ShareWrapper
Definition: share_wrapper.h:44
CalculateDepth::operator()
T operator()(const T &left, const T &right) const
Definition: test_low_depth_reduce.cpp:33
party.h
encrypto::motion::OpenSslRng::RandomBlocksAligned
virtual void RandomBlocksAligned(std::byte *output, std::size_t number_of_blocks) override
Definition: openssl_rng.cpp:37
TEST_P
TEST_P(CommunicationLayerTest, Tcp)
Definition: test_communication_layer.cpp:95
encrypto::motion::ShareWrapper::Get
SharePointer & Get()
Definition: share_wrapper.h:107
motion_base_provider.h
encrypto::motion::Block128Vector::MakeRandom
static Block128Vector MakeRandom(std::size_t size)
Creates a vector of size elements filled with random data.
Definition: block.h:315
OtFlavorTest::ot_provider_wrappers_
std::vector< std::unique_ptr< encrypto::motion::OtProviderManager > > ot_provider_wrappers_
Definition: test_ot_flavors.cpp:99
encrypto::motion::OpenSslRng::SampleKey
virtual void SampleKey() override
Definition: openssl_rng.cpp:35
encrypto::motion::ShareWrapper::As
T As() const
converts the information on the wires to T. Boolean and arithmetic GMW returns the secret-shared valu...
Definition: share_wrapper.cpp:616
TYPED_TEST_SUITE
TYPED_TEST_SUITE(AcOtTest, integer_types)
encrypto::motion::SpVector
Definition: sp_provider.h:46
encrypto::motion::BitVector::SecureRandom
static BitVector SecureRandom(const std::size_t size) noexcept
Returns a random BitVector.
Definition: bit_vector.cpp:893
encrypto::motion::OtProvider
Definition: ot_provider.h:204
encrypto::motion::ReusableFuture
Definition: reusable_future.h:129
kDetailedLoggingEnabled
constexpr auto kDetailedLoggingEnabled
Definition: test_constants.h:30
encrypto::motion::MpcProtocol::kBmr
@ kBmr
encrypto::motion::Condition::NotifyOne
void NotifyOne() noexcept
Unblocks one thread waiting for condition_variable_.
Definition: condition.h:66
sb_impl.h
config.h
reusable_future.h
encrypto::motion::AddVectors
std::vector< T > AddVectors(const std::vector< T > &a, const std::vector< T > &b)
Adds each element in a and b and returns the result.
Definition: helpers.h:100
TYPED_TEST
TYPED_TEST(AcOtTest, AcOt)
Definition: test_ot_flavors.cpp:163
bit_vector.h
kNumberOfPartiesList
constexpr auto kNumberOfPartiesList
Definition: test_constants.h:32
OtFlavorTest::sender_i_
const std::size_t sender_i_
Definition: test_ot_flavors.cpp:92
AcOtTest
Definition: test_ot_flavors.cpp:155
TEST_F
TEST_F(OtFlavorTest, FixedXcOt128)
Definition: test_ot_flavors.cpp:102
encrypto::motion::ThreadSetName
void ThreadSetName(std::thread &thread, const std::string &name)
Definition: thread.cpp:29
bmr_wire.h
algorithm_description.h
CalculateDepth
Definition: test_low_depth_reduce.cpp:32
encrypto::motion::ReusablePromise::get_future
ReusableFuture< R, MutexType, ConditionVariableType > get_future()
Definition: reusable_future.h:242
encrypto::motion::Aes128CtrRng::SampleKey
virtual void SampleKey() override
Definition: aes128_ctr_rng.cpp:41
encrypto::motion::PrimitiveOperationType::kXor
@ kXor
encrypto::motion::SpVector::a
std::vector< T > a
Definition: sp_provider.h:47
backend.h
encrypto::motion::PrimitiveOperationType::kAnd
@ kAnd
encrypto::motion::Aes128CtrRng::GetThreadInstance
static Aes128CtrRng & GetThreadInstance()
Definition: aes128_ctr_rng.h:56
block.h
LowDepthReduce
T LowDepthReduce(std::vector< T > input, BinaryOperation operation)
Definition: low_depth_reduce.h:40
encrypto::motion::BitVector<>
encrypto::motion::MpcProtocol::kBooleanGmw
@ kBooleanGmw
OtFlavorTest::RunOtExtensionSetup
void RunOtExtensionSetup()
Definition: test_ot_flavors.cpp:79
aes128_ctr_rng.h
encrypto::motion::communication::MakeDummyCommunicationLayers
std::vector< std::unique_ptr< CommunicationLayer > > MakeDummyCommunicationLayers(std::size_t number_of_parties)
Definition: communication_layer.cpp:503
encrypto::motion::communication::TcpSetupHelper
Definition: tcp_transport.h:69
encrypto::motion::OpenSslRng
Definition: openssl_rng.h:37
geninput.choices
choices
Definition: geninput.py:153
communication_layer.h
boolean_gmw_wire.h
OtFlavorTest::base_ot_providers_
std::vector< std::unique_ptr< encrypto::motion::BaseOtProvider > > base_ot_providers_
Definition: test_ot_flavors.cpp:97
INSTANTIATE_TEST_SUITE_P
INSTANTIATE_TEST_SUITE_P(LowDepthReduceTestParameters, LowDepthReduceTest, testing::Values(1, 2, 3, 4, 7, 8, 16, 17, 23, 32, 53, 64, 100, 999999))
encrypto::motion::OpenSslRng::GetThreadInstance
static Rng & GetThreadInstance()
Definition: openssl_rng.h:63
main
int main(int argc, char **argv)
Definition: test_motion_main.cpp:27
base_ot_data.h
thread.h
encrypto::motion::BitVector::RandomSeeded
static BitVector RandomSeeded(const std::size_t size, const std::size_t seed=0) noexcept
Returns a random BitVector using an input seed. Internally uses Mersenne twister, do not use as crypt...
Definition: bit_vector.cpp:870
LowDepthReduceTest::boolean_values
std::vector< bool > boolean_values
Definition: test_low_depth_reduce.cpp:56
ot_provider.h
LowDepthReduceTest::size
int size
Definition: test_low_depth_reduce.cpp:54
OtFlavorTest
Definition: test_ot_flavors.cpp:35
OtFlavorTest::receiver_i_
const std::size_t receiver_i_
Definition: test_ot_flavors.cpp:93
secure_unsigned_integer.h
kTestIterations
constexpr auto kTestIterations
Definition: test_constants.h:29
mt_provider.h
encrypto::motion::AlgorithmDescription
Definition: algorithm_description.h:43
encrypto::motion::Aes128CtrRng
Definition: aes128_ctr_rng.h:32
share_wrapper.h
encrypto::motion
Definition: algorithm_description.cpp:35
encrypto::motion::ReusableFuture::valid
bool valid() const noexcept
Definition: reusable_future.h:166
TEST
TEST(AesNi128, KeyExpansion)
Definition: test_aesni.cpp:31
INSTANTIATE_TEST_SUITE_P
INSTANTIATE_TEST_SUITE_P(CommunicationLayerTcpTests, CommunicationLayerTest, testing::Bool(), [](auto &info) { return info.param ? "ipv6" :"ipv4";})
TEST
TEST(ReusableFuture, SetAfterGetFuture)
Definition: test_reusable_future.cpp:29
ot_flavors.h
LowDepthReduceTest
Definition: test_low_depth_reduce.cpp:39
encrypto::motion::SecureUnsignedInteger
Definition: secure_unsigned_integer.h:33
base_ot_provider.h
encrypto::motion::AlgorithmDescription::FromBristol
static AlgorithmDescription FromBristol(const std::string &path)
Definition: algorithm_description.cpp:37
sb_provider.h
encrypto::motion::SecureUnsignedInteger::Out
SecureUnsignedInteger Out(std::size_t output_owner=std::numeric_limits< std::int64_t >::max()) const
constructs an output gate, which reconstructs the cleartext result. The default parameter for the out...
Definition: secure_unsigned_integer.cpp:272
encrypto::motion::Aes128CtrRng::RandomBlocksAligned
virtual void RandomBlocksAligned(std::byte *output, std::size_t number_of_blocks) override
Definition: aes128_ctr_rng.cpp:55
encrypto::motion::Condition
Wraps a std::condition_variable with a std::mutex and a condition checking function.
Definition: condition.h:35
openssl_rng.h
OtFlavorTest::motion_base_providers_
std::vector< std::unique_ptr< encrypto::motion::BaseProvider > > motion_base_providers_
Definition: test_ot_flavors.cpp:98
encrypto::motion::ReusablePromise
Definition: reusable_future.h:123
encrypto::motion::detail::invert
T invert(std::size_t k, T a)
Definition: sb_impl.h:82
TcpTransportTest
Definition: test_tcp_transport.cpp:29
encrypto::motion::ShareWrapper::Simdify
static ShareWrapper Simdify(std::span< SharePointer > input)
constructs a SimdifyGate that composes the shares in input into a "larger" share with all the input s...
Definition: share_wrapper.cpp:907
OtFlavorTest::GetReceiverProvider
encrypto::motion::OtProvider & GetReceiverProvider()
Definition: test_ot_flavors.cpp:75
encrypto::motion::kRootDir
constexpr std::string_view kRootDir
Definition: config.h:39
encrypto::motion::MpcProtocol::kArithmeticGmw
@ kArithmeticGmw
integer_types
::testing::Types< std::uint8_t, std::uint16_t, std::uint32_t, std::uint64_t, __uint128_t > integer_types
Definition: test_ot_flavors.cpp:160
LowDepthReduceTest::SetUp
void SetUp() override
Definition: test_low_depth_reduce.cpp:41
encrypto::motion::Block128::MakeRandom
static Block128 MakeRandom()
Create a random-initialized Block128.
Definition: block.h:70
encrypto::motion::SecureUnsignedInteger::Get
ShareWrapper & Get()
Definition: secure_unsigned_integer.h:67
tcp_transport.h
INSTANTIATE_TEST_SUITE_P
INSTANTIATE_TEST_SUITE_P(TcpTransportSuite, TcpTransportTest, testing::Values("127.0.0.1", "::1"), [](auto &info) { return info.param=="::1" ? "ipv6" :"ipv4";})
TEST
TEST(Aes128CtrRng, NoTrivialOutput)
Definition: test_rng.cpp:31
party_0
struct Attributes party_0
encrypto::motion::ReusablePromise::set_value
void set_value(const R &value)
Definition: reusable_future.h:226
OtFlavorTest::GetSenderProvider
encrypto::motion::OtProvider & GetSenderProvider()
Definition: test_ot_flavors.cpp:71
low_depth_reduce.h
LowDepthReduceTest::integer_values
std::vector< std::uint32_t > integer_values
Definition: test_low_depth_reduce.cpp:55
kPortOffset
constexpr auto kPortOffset
Definition: test_constants.h:31
test_constants.h
encrypto::motion::SpVector::c
std::vector< T > c
Definition: sp_provider.h:47
encrypto::motion::detail::sqrt
T sqrt(size_t k, T a)
Definition: sb_impl.h:43
OtFlavorTest::TearDown
void TearDown() override
Definition: test_ot_flavors.cpp:62
OtFlavorTest::communication_layers_
std::vector< std::unique_ptr< encrypto::motion::communication::CommunicationLayer > > communication_layers_
Definition: test_ot_flavors.cpp:96
encrypto::motion::ToInput
std::vector< BitVector< Allocator > > ToInput(IntegralType integral_value)
Definition: bit_vector.cpp:1189
TEST_P
TEST_P(LowDepthReduceTest, OperationDepth)
Definition: test_low_depth_reduce.cpp:76
encrypto::motion::communication::TcpSetupHelper::SetupConnections
std::vector< std::unique_ptr< Transport > > SetupConnections()
Definition: tcp_transport.cpp:203
encrypto::motion::ReusableFuture::get
R get()
Definition: reusable_future.h:155
OtFlavorTest::SetUp
void SetUp() override
Definition: test_ot_flavors.cpp:37
sp_provider.h