MOTION  0.01
Framework for mixed-protocol multi-party computation
test_helpers.h
Go to the documentation of this file.
1 // MIT License
2 //
3 // Copyright (c) 2019 Oleksandr Tkachenko, Lennart Braun
4 // Cryptography and Privacy Engineering Group (ENCRYPTO)
5 // TU Darmstadt, Germany
6 //
7 // Permission is hereby granted, free of charge, to any person obtaining a copy
8 // of this software and associated documentation files (the "Software"), to deal
9 // in the Software without restriction, including without limitation the rights
10 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 // copies of the Software, and to permit persons to whom the Software is
12 // furnished to do so, subject to the following conditions:
13 //
14 // The above copyright notice and this permission notice shall be included in all
15 // copies or substantial portions of the Software.
16 //
17 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 // SOFTWARE.
24 
25 #include <openssl/rand.h>
26 #include <algorithm>
27 #include <limits>
28 #include <vector>
29 
30 template <typename T>
31 inline T Rand() {
32  unsigned char buf[sizeof(T)];
33  RAND_bytes(buf, sizeof(T));
34  return *reinterpret_cast<T*>(buf);
35 }
36 
37 template <typename T>
38 inline std::vector<T> RandomVector(std::size_t size) {
39  std::vector<T> v(size);
40  std::generate(v.begin(), v.end(), Rand<T>);
41  return v;
42 }
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::ShareWrapper
Definition: share_wrapper.h:44
party.h
TEST_P
TEST_P(CommunicationLayerTest, Tcp)
Definition: test_communication_layer.cpp:95
encrypto::motion::communication::DummyTransport
Definition: dummy_transport.h:30
encrypto::motion::BitVector::SecureRandom
static BitVector SecureRandom(const std::size_t size) noexcept
Returns a random BitVector.
Definition: bit_vector.cpp:893
kDetailedLoggingEnabled
constexpr auto kDetailedLoggingEnabled
Definition: test_constants.h:30
encrypto::motion::MpcProtocol::kBmr
@ kBmr
bmr_wire.h
encrypto::motion::communication::DummyTransport::MakeTransportPair
static std::pair< std::unique_ptr< DummyTransport >, std::unique_ptr< DummyTransport > > MakeTransportPair()
Definition: dummy_transport.cpp:37
encrypto::motion::BitVector<>
encrypto::motion::MpcProtocol::kBooleanGmw
@ kBooleanGmw
boolean_gmw_wire.h
mt_provider.h
share_wrapper.h
encrypto::motion
Definition: algorithm_description.cpp:35
Rand
T Rand()
Definition: test_helpers.h:31
dummy_transport.h
encrypto::motion::SharePointer
std::shared_ptr< Share > SharePointer
Definition: conversion_gate.h:49
encrypto::motion::ShareWrapper::Convert
ShareWrapper Convert() const
Definition: share_wrapper.cpp:322
INSTANTIATE_TEST_SUITE_P
INSTANTIATE_TEST_SUITE_P(CommunicationLayerTcpTests, CommunicationLayerTest, testing::Bool(), [](auto &info) { return info.param ? "ipv6" :"ipv4";})
RandomVector
std::vector< T > RandomVector(std::size_t size)
Definition: test_helpers.h:38
TEST
TEST(DummyTransport, Dummy)
Definition: test_dummy_transport.cpp:29
typedefs.h
encrypto::motion::communication
Definition: backend.h:37
encrypto::motion::MpcProtocol::kArithmeticGmw
@ kArithmeticGmw
kPortOffset
constexpr auto kPortOffset
Definition: test_constants.h:31
test_constants.h