MOTION  0.01
Framework for mixed-protocol multi-party computation
base_ot_data.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 #pragma once
26 
27 #include <array>
28 #include <atomic>
29 #include <boost/container/vector.hpp>
30 #include <cstddef>
31 #include <memory>
32 #include <vector>
33 #include "utility/bit_vector.h"
34 
35 namespace encrypto::motion {
36 
37 class FiberCondition;
38 
39 enum BaseOtDataType : unsigned int { kHL17R = 0, kHL17S = 1, kBaseOtInvalidDataType = 2 };
40 
43  ~BaseOtReceiverData() = default;
44 
46  std::array<std::array<std::byte, 16>, 128> messages_c;
47 
48  std::vector<std::array<std::byte, 32>> S;
49  boost::container::vector<bool> received_S;
50  std::vector<std::unique_ptr<FiberCondition>> received_S_condition;
51 
52  // number of used rows;
53  std::size_t consumed_offset{0};
54 
55  std::atomic<bool> is_ready{false};
56  std::unique_ptr<FiberCondition> is_ready_condition;
57 };
58 
61  ~BaseOtSenderData() = default;
62 
63  std::array<std::array<std::byte, 16>, 128> messages_0;
64  std::array<std::array<std::byte, 16>, 128> messages_1;
65 
66  std::vector<std::array<std::byte, 32>> R;
67  boost::container::vector<bool> received_R;
68  std::vector<std::unique_ptr<FiberCondition>> received_R_condition;
69 
70  // number of used rows;
71  std::size_t consumed_offset{0};
72 
73  std::unique_ptr<FiberCondition> is_ready_condition;
74  std::atomic<bool> is_ready{false};
75 };
76 
77 struct BaseOtData {
78  void MessageReceived(const std::uint8_t* message, const BaseOtDataType type,
79  const std::size_t ot_id = 0);
80 
84  const BaseOtSenderData& GetSenderData() const { return sender_data; }
85 
88 };
89 
90 } // namespace encrypto::motion
encrypto::motion::BaseOtReceiverData::BaseOtReceiverData
BaseOtReceiverData()
Definition: base_ot_data.cpp:30
encrypto::motion::BaseOtSenderData::messages_0
std::array< std::array< std::byte, 16 >, 128 > messages_0
Definition: base_ot_data.h:63
encrypto::motion::BaseOtData
Definition: base_ot_data.h:77
encrypto::motion::BaseOtReceiverData::c
BitVector c
Definition: base_ot_data.h:45
fiber_condition.h
encrypto::motion::BaseOtSenderData
Definition: base_ot_data.h:59
encrypto::motion::BaseOtSenderData::received_R
boost::container::vector< bool > received_R
Definition: base_ot_data.h:67
encrypto::motion::BaseOtReceiverData::is_ready_condition
std::unique_ptr< FiberCondition > is_ready_condition
Definition: base_ot_data.h:56
encrypto::motion::BaseOtDataType
BaseOtDataType
Definition: base_ot_data.h:39
bit_vector.h
geninput.type
type
Definition: geninput.py:149
encrypto::motion::BaseOtSenderData::is_ready_condition
std::unique_ptr< FiberCondition > is_ready_condition
Definition: base_ot_data.h:73
encrypto::motion::BaseOtReceiverData::received_S_condition
std::vector< std::unique_ptr< FiberCondition > > received_S_condition
Definition: base_ot_data.h:50
encrypto::motion::BaseOtReceiverData::is_ready
std::atomic< bool > is_ready
Definition: base_ot_data.h:55
encrypto::motion::BitVector<>
encrypto::motion::BaseOtSenderData::received_R_condition
std::vector< std::unique_ptr< FiberCondition > > received_R_condition
Definition: base_ot_data.h:68
encrypto::motion::BaseOtSenderData::messages_1
std::array< std::array< std::byte, 16 >, 128 > messages_1
Definition: base_ot_data.h:64
encrypto::motion::BaseOtSenderData::is_ready
std::atomic< bool > is_ready
Definition: base_ot_data.h:74
base_ot_data.h
encrypto::motion::kHL17R
@ kHL17R
Definition: base_ot_data.h:39
encrypto::motion::BaseOtReceiverData::~BaseOtReceiverData
~BaseOtReceiverData()=default
encrypto::motion::BaseOtData::sender_data
BaseOtSenderData sender_data
Definition: base_ot_data.h:87
encrypto::motion
Definition: algorithm_description.cpp:35
encrypto::motion::BaseOtReceiverData::S
std::vector< std::array< std::byte, 32 > > S
Definition: base_ot_data.h:48
encrypto::motion::BaseOtReceiverData::received_S
boost::container::vector< bool > received_S
Definition: base_ot_data.h:49
encrypto::motion::kHL17S
@ kHL17S
Definition: base_ot_data.h:39
encrypto::motion::BaseOtReceiverData
Definition: base_ot_data.h:41
encrypto::motion::BaseOtReceiverData::consumed_offset
std::size_t consumed_offset
Definition: base_ot_data.h:53
encrypto::motion::kBaseOtInvalidDataType
@ kBaseOtInvalidDataType
Definition: base_ot_data.h:39
encrypto::motion::BaseOtData::MessageReceived
void MessageReceived(const std::uint8_t *message, const BaseOtDataType type, const std::size_t ot_id=0)
Definition: base_ot_data.cpp:50
encrypto::motion::BaseOtData::GetReceiverData
const BaseOtReceiverData & GetReceiverData() const
Definition: base_ot_data.h:82
encrypto::motion::BaseOtData::GetSenderData
const BaseOtSenderData & GetSenderData() const
Definition: base_ot_data.h:84
encrypto::motion::BaseOtSenderData::~BaseOtSenderData
~BaseOtSenderData()=default
encrypto::motion::BaseOtReceiverData::messages_c
std::array< std::array< std::byte, 16 >, 128 > messages_c
choice bits
Definition: base_ot_data.h:46
encrypto::motion::BaseOtData::GetSenderData
BaseOtSenderData & GetSenderData()
Definition: base_ot_data.h:83
encrypto::motion::BaseOtSenderData::consumed_offset
std::size_t consumed_offset
Definition: base_ot_data.h:71
encrypto::motion::BaseOtData::GetReceiverData
BaseOtReceiverData & GetReceiverData()
Definition: base_ot_data.h:81
encrypto::motion::BaseOtSenderData::R
std::vector< std::array< std::byte, 32 > > R
Definition: base_ot_data.h:66
encrypto::motion::BaseOtData::receiver_data
BaseOtReceiverData receiver_data
Definition: base_ot_data.h:86
encrypto::motion::BaseOtSenderData::BaseOtSenderData
BaseOtSenderData()
Definition: base_ot_data.cpp:40