MOTION  0.01
Framework for mixed-protocol multi-party computation
bmr_provider.h
Go to the documentation of this file.
1 // MIT License
2 //
3 // Copyright (c) 2020 Lennart Braun
4 //
5 // Permission is hereby granted, free of charge, to any person obtaining a copy
6 // of this software and associated documentation files (the "Software"), to deal
7 // in the Software without restriction, including without limitation the rights
8 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 // copies of the Software, and to permit persons to whom the Software is
10 // furnished to do so, subject to the following conditions:
11 //
12 // The above copyright notice and this permission notice shall be included in all
13 // copies or substantial portions of the Software.
14 //
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 // SOFTWARE.
22 
23 #pragma once
24 
25 #include <memory>
26 #include <vector>
27 
28 #include "utility/bit_vector.h"
29 #include "utility/block.h"
31 
33 
34 class CommunicationLayer;
35 
36 } // namespace encrypto::motion::communication
37 
39 
40 struct Data;
41 
42 class Provider {
43  public:
44  Provider(communication::CommunicationLayer& communication_layer);
45  ~Provider();
46  const Block128& GetGlobalOffset() const { return global_offset_; }
48  std::size_t gate_id,
49  std::size_t bitlength);
50  std::vector<ReusableFiberFuture<BitVector<>>> RegisterForInputPublicValues(std::size_t gate_id,
51  std::size_t bitlength);
52  std::vector<ReusableFiberFuture<Block128Vector>> RegisterForInputKeys(std::size_t gate_id,
53  std::size_t number_blocks);
54  std::vector<ReusableFiberFuture<Block128Vector>> RegisterForGarbledRows(
55  std::size_t gate_id, std::size_t number_blocks);
56 
57  private:
58  communication::CommunicationLayer& communication_layer_;
59  std::size_t my_id_;
60  std::size_t number_of_parties_;
61  std::vector<std::unique_ptr<Data>> data_;
62  Block128 global_offset_;
63 };
64 
65 } // namespace encrypto::motion::proto::bmr
encrypto::motion::communication::MessageType::kBmrInputGate1
@ kBmrInputGate1
encrypto::motion::proto::bmr::Provider::GetGlobalOffset
const Block128 & GetGlobalOffset() const
Definition: bmr_provider.h:46
encrypto::motion::proto::bmr::Provider::~Provider
~Provider()
Definition: bmr_provider.cpp:70
encrypto::motion::ReusableFuture
Definition: reusable_future.h:129
encrypto::motion::communication::GetMessage
const encrypto::motion::communication::Message * GetMessage(const void *buf)
Definition: message_generated.h:146
reusable_future.h
bit_vector.h
encrypto::motion::proto::bmr::Provider
Definition: bmr_provider.h:42
encrypto::motion::proto::bmr::Provider::RegisterForInputPublicValues
ReusableFiberFuture< BitVector<> > RegisterForInputPublicValues(std::size_t input_owner, std::size_t gate_id, std::size_t bitlength)
Definition: bmr_provider.cpp:76
encrypto::motion::communication::MessageType::kBmrInputGate0
@ kBmrInputGate0
block.h
encrypto::motion::proto::bmr::Data::MessageReceived
void MessageReceived(const std::uint8_t *message, const DataType type, const std::size_t i)
Definition: bmr_data.cpp:30
encrypto::motion::communication::MessageType::kBmrAndGate
@ kBmrAndGate
encrypto::motion::proto::bmr::Provider::Provider
Provider(communication::CommunicationLayer &communication_layer)
Definition: bmr_provider.cpp:49
encrypto::motion::communication::CommunicationLayer::RegisterMessageHandler
void RegisterMessageHandler(MessageHandlerFunction, const std::vector< MessageType > &message_types)
Definition: communication_layer.cpp:393
bmr_message_generated.h
encrypto::motion::proto::bmr::MessageHandler::ReceivedMessage
void ReceivedMessage(std::size_t, std::vector< std::uint8_t > &&message) override
Definition: bmr_provider.cpp:19
encrypto::motion::proto::bmr
Definition: backend.h:50
communication_layer.h
bmr_provider.h
encrypto::motion::proto::bmr::Provider::RegisterForGarbledRows
std::vector< ReusableFiberFuture< Block128Vector > > RegisterForGarbledRows(std::size_t gate_id, std::size_t number_blocks)
Definition: bmr_provider.cpp:109
encrypto::motion::proto::bmr::kInputStep0
@ kInputStep0
Definition: bmr_data.h:39
encrypto::motion::communication::GetBmrMessage
const encrypto::motion::communication::BmrMessage * GetBmrMessage(const void *buf)
Definition: bmr_message_generated.h:80
encrypto::motion::Block128
Block of aligned 128 bit / 16 B.
Definition: block.h:34
encrypto::motion::communication::CommunicationLayer::GetMyId
std::size_t GetMyId() const
Definition: communication_layer.h:66
encrypto::motion::proto::bmr::Data
Definition: bmr_data.h:41
encrypto::motion::communication::MessageHandler
Definition: message_handler.h:38
encrypto::motion::communication::CommunicationLayer
Definition: communication_layer.h:58
encrypto::motion::proto::bmr::kAndGate
@ kAndGate
Definition: bmr_data.h:39
message_handler.h
encrypto::motion::proto::bmr::MessageHandler
Definition: bmr_provider.cpp:10
encrypto::motion::communication
Definition: backend.h:37
encrypto::motion::proto::bmr::MessageHandler::MessageHandler
MessageHandler(Data &data)
Definition: bmr_provider.cpp:12
encrypto::motion::proto::bmr::kInputStep1
@ kInputStep1
Definition: bmr_data.h:39
encrypto::motion::communication::CommunicationLayer::DeregisterMessageHandler
void DeregisterMessageHandler(const std::vector< MessageType > &message_types)
Definition: communication_layer.cpp:414
bmr_data.h
encrypto::motion::proto::bmr::Provider::RegisterForInputKeys
std::vector< ReusableFiberFuture< Block128Vector > > RegisterForInputKeys(std::size_t gate_id, std::size_t number_blocks)
Definition: bmr_provider.cpp:96