MOTION  0.01
Framework for mixed-protocol multi-party computation
base_ot_provider.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 <cstddef>
29 
31 #include "utility/bit_vector.h"
32 #include "utility/constants.h"
33 
35 
36 class CommunicationLayer;
37 
38 } // namespace encrypto::motion::communication
39 
40 namespace encrypto::motion {
41 
42 class Configuration;
43 class Logger;
44 class Register;
45 
46 using BaseOtMessages = std::array<std::array<std::byte, 16>, kKappa>;
47 
48 struct SenderMessage {
51 };
52 
56 };
57 
59  public:
60  BaseOtProvider(communication::CommunicationLayer&, std::shared_ptr<Logger>);
62  void ComputeBaseOts();
63  void ImportBaseOts(std::size_t party_id, const ReceiverMessage& messages);
64  void ImportBaseOts(std::size_t party_id, const SenderMessage& messages);
65  std::pair<ReceiverMessage, SenderMessage> ExportBaseOts(std::size_t party_id);
66  BaseOtData& GetBaseOtsData(std::size_t party_id) { return data_.at(party_id); }
67  const BaseOtData& GetBaseOtsData(std::size_t party_id) const { return data_.at(party_id); }
68 
69  private:
70  communication::CommunicationLayer& communication_layer_;
71  std::size_t number_of_parties_;
72  std::size_t my_id_;
73  std::vector<BaseOtData> data_;
74  std::shared_ptr<Logger> logger_;
75  bool finished_;
76 
77  Logger& GetLogger();
78 };
79 
80 } // namespace encrypto::motion
encrypto::motion::BaseOtData
Definition: base_ot_data.h:77
encrypto::motion::BaseOtProvider::GetBaseOtsData
BaseOtData & GetBaseOtsData(std::size_t party_id)
Definition: base_ot_provider.h:66
encrypto::motion::BaseOtMessageHandler::GetBaseOtsData
BaseOtData & GetBaseOtsData()
Definition: base_ot_provider.cpp:50
encrypto::motion::BitVector::SecureRandom
static BitVector SecureRandom(const std::size_t size) noexcept
Returns a random BitVector.
Definition: bit_vector.cpp:893
fiber_condition.h
encrypto::motion::BaseOtProvider
Definition: base_ot_provider.h:58
encrypto::motion::Logger
Definition: logger.h:40
encrypto::motion::communication::GetBaseROtMessage
const encrypto::motion::communication::BaseROtMessage * GetBaseROtMessage(const void *buf)
Definition: base_ot_generated.h:80
encrypto::motion::BaseOtMessages
std::array< std::array< std::byte, 16 >, kKappa > BaseOtMessages
Definition: base_ot_provider.h:46
encrypto::motion::communication::GetMessage
const encrypto::motion::communication::Message * GetMessage(const void *buf)
Definition: message_generated.h:146
bit_vector.h
configuration.h
encrypto::motion::SenderMessage
Definition: base_ot_provider.h:48
encrypto::motion::kKappa
constexpr std::size_t kKappa
Definition: constants.h:65
encrypto::motion::BitVector<>
encrypto::motion::BaseOtProvider::ComputeBaseOts
void ComputeBaseOts()
Definition: base_ot_provider.cpp:97
encrypto::motion::BaseOtProvider::GetBaseOtsData
const BaseOtData & GetBaseOtsData(std::size_t party_id) const
Definition: base_ot_provider.h:67
encrypto::motion::communication::CommunicationLayer::RegisterMessageHandler
void RegisterMessageHandler(MessageHandlerFunction, const std::vector< MessageType > &message_types)
Definition: communication_layer.cpp:393
geninput.choices
choices
Definition: geninput.py:153
communication_layer.h
base_ot_data.h
encrypto::motion::kHL17R
@ kHL17R
Definition: base_ot_data.h:39
register.h
logger.h
encrypto::motion
Definition: algorithm_description.cpp:35
encrypto::motion::communication::MessageType::kBaseROtMessageSender
@ kBaseROtMessageSender
encrypto::motion::communication::CommunicationLayer::SendMessage
void SendMessage(std::size_t party_id, std::vector< std::uint8_t > &&message)
Definition: communication_layer.cpp:331
encrypto::motion::communication::MessageHandler
Definition: message_handler.h:38
encrypto::motion::communication::CommunicationLayer
Definition: communication_layer.h:58
encrypto::motion::ReceiverMessage::messages_c
BaseOtMessages messages_c
Definition: base_ot_provider.h:54
base_ot_provider.h
message_handler.h
encrypto::motion::ReceiverMessage::c
BitVector c
Definition: base_ot_provider.h:55
encrypto::motion::kHL17S
@ kHL17S
Definition: base_ot_data.h:39
encrypto::motion::BaseOtMessageHandler::ReceivedMessage
void ReceivedMessage(std::size_t, std::vector< std::uint8_t > &&message) override
Definition: base_ot_provider.cpp:57
encrypto::motion::ReceiverMessage
Definition: base_ot_provider.h:53
base_ot_generated.h
encrypto::motion::BaseOtProvider::BaseOtProvider
BaseOtProvider(communication::CommunicationLayer &, std::shared_ptr< Logger >)
Definition: base_ot_provider.cpp:75
encrypto::motion::SenderMessage::messages_0
BaseOtMessages messages_0
Definition: base_ot_provider.h:49
encrypto::motion::communication
Definition: backend.h:37
ot_hl17.h
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::BaseOtMessageHandler
Definition: base_ot_provider.cpp:41
constants.h
encrypto::motion::communication::MessageType::kBaseROtMessageReceiver
@ kBaseROtMessageReceiver
encrypto::motion::kDebug
constexpr bool kDebug
Definition: config.h:36
encrypto::motion::BaseOtProvider::ImportBaseOts
void ImportBaseOts(std::size_t party_id, const ReceiverMessage &messages)
Definition: base_ot_provider.cpp:166
message_generated.h
encrypto::motion::communication::CommunicationLayer::DeregisterMessageHandler
void DeregisterMessageHandler(const std::vector< MessageType > &message_types)
Definition: communication_layer.cpp:414
encrypto::motion::BaseOtProvider::~BaseOtProvider
~BaseOtProvider()
Definition: base_ot_provider.cpp:91
encrypto::motion::BaseOtProvider::ExportBaseOts
std::pair< ReceiverMessage, SenderMessage > ExportBaseOts(std::size_t party_id)
Definition: base_ot_provider.cpp:198
encrypto::motion::BaseOtMessageHandler::BaseOtMessageHandler
BaseOtMessageHandler(std::shared_ptr< Logger > logger, BaseOtData &base_ots_data)
Definition: base_ot_provider.cpp:44
encrypto::motion::SenderMessage::messages_1
BaseOtMessages messages_1
Definition: base_ot_provider.h:50