MOTION
0.01
Framework for mixed-protocol multi-party computation
|
Go to the documentation of this file.
29 #include <flatbuffers/flatbuffers.h>
35 static_assert(FLATBUFFERS_LITTLEENDIAN);
88 class Backend :
public std::enable_shared_from_this<Backend> {
105 void Send(std::size_t party_id, flatbuffers::FlatBufferBuilder&& message);
166 template <
typename T,
typename = std::enable_if_t<std::is_
unsigned_v<T>>>
171 template <
typename T,
typename = std::enable_if_t<std::is_
unsigned_v<T>>>
173 auto input_gate = std::make_shared<proto::ConstantArithmeticInputGate<T>>(input_vector, *
this);
175 return std::static_pointer_cast<Share>(input_gate->GetOutputAsShare());
178 template <
typename T,
typename = std::enable_if_t<std::is_
unsigned_v<T>>>
181 std::make_shared<proto::ConstantArithmeticInputGate<T>>(std::move(input_vector), *
this);
183 return std::static_pointer_cast<Share>(input_gate->GetOutputAsShare());
186 template <
typename T,
typename = std::enable_if_t<std::is_
unsigned_v<T>>>
188 std::vector<T> input_vector{input};
192 template <
typename T,
typename = std::enable_if_t<std::is_
unsigned_v<T>>>
195 std::make_shared<proto::arithmetic_gmw::InputGate<T>>(input_vector, party_id, *
this);
196 auto input_gate_cast = std::static_pointer_cast<InputGate>(input_gate);
198 return std::static_pointer_cast<Share>(input_gate->GetOutputAsArithmeticShare());
201 template <
typename T,
typename = std::enable_if_t<std::is_
unsigned_v<T>>>
203 auto input_gate = std::make_shared<proto::arithmetic_gmw::InputGate<T>>(std::move(input_vector),
205 auto input_gate_cast = std::static_pointer_cast<InputGate>(input_gate);
207 return std::static_pointer_cast<Share>(input_gate->GetOutputAsArithmeticShare());
210 template <
typename T,
typename = std::enable_if_t<std::is_
unsigned_v<T>>>
212 std::size_t output_owner) {
214 auto output_gate = std::make_shared<proto::arithmetic_gmw::OutputGate<T>>(parent, output_owner);
215 auto out_gate_cast = std::static_pointer_cast<Gate>(output_gate);
217 return std::static_pointer_cast<Share>(output_gate->GetOutputAsArithmeticShare());
220 template <
typename T,
typename = std::enable_if_t<std::is_
unsigned_v<T>>>
223 auto casted_parent_pointer = std::dynamic_pointer_cast<proto::arithmetic_gmw::Share<T>>(parent);
224 assert(casted_parent_pointer);
228 template <
typename T,
typename = std::enable_if_t<std::is_
unsigned_v<T>>>
233 auto wire_a = a->GetArithmeticWire();
234 auto wire_b = b->GetArithmeticWire();
235 auto addition_gate = std::make_shared<proto::arithmetic_gmw::AdditionGate<T>>(wire_a, wire_b);
236 auto addition_gate_cast = std::static_pointer_cast<Gate>(addition_gate);
238 return std::static_pointer_cast<Share>(addition_gate->GetOutputAsArithmeticShare());
241 template <
typename T,
typename = std::enable_if_t<std::is_
unsigned_v<T>>>
245 auto casted_parent_a_ptr = std::dynamic_pointer_cast<proto::arithmetic_gmw::Share<T>>(a);
246 auto casted_parent_b_ptr = std::dynamic_pointer_cast<proto::arithmetic_gmw::Share<T>>(b);
247 assert(casted_parent_a_ptr);
248 assert(casted_parent_b_ptr);
252 template <
typename T,
typename = std::enable_if_t<std::is_
unsigned_v<T>>>
257 auto wire_a = a->GetArithmeticWire();
258 auto wire_b = b->GetArithmeticWire();
259 auto sub_gate = std::make_shared<proto::arithmetic_gmw::SubtractionGate<T>>(wire_a, wire_b);
260 auto sub_gate_cast = std::static_pointer_cast<Gate>(sub_gate);
262 return std::static_pointer_cast<Share>(sub_gate->GetOutputAsArithmeticShare());
265 template <
typename T,
typename = std::enable_if_t<std::is_
unsigned_v<T>>>
269 auto casted_parent_a_ptr = std::dynamic_pointer_cast<proto::arithmetic_gmw::Share<T>>(a);
270 auto casted_parent_b_ptr = std::dynamic_pointer_cast<proto::arithmetic_gmw::Share<T>>(b);
271 assert(casted_parent_a_ptr);
272 assert(casted_parent_b_ptr);
285 std::pair<ReceiverMessage, SenderMessage>
ExportBaseOts(std::size_t i);
310 std::list<RunTimeStatistics> run_time_statistics_;
313 std::shared_ptr<Logger> logger_;
316 std::unique_ptr<GateExecutor> gate_executor_;
318 std::unique_ptr<BaseProvider> motion_base_provider_;
319 std::unique_ptr<BaseOtProvider> base_ot_provider_;
320 std::unique_ptr<OtProviderManager> ot_provider_manager_;
321 std::shared_ptr<MtProvider> mt_provider_;
322 std::shared_ptr<SpProvider> sp_provider_;
323 std::shared_ptr<SbProvider> sb_provider_;
324 std::unique_ptr<proto::bmr::Provider> bmr_provider_;
326 bool require_base_ots_{
false};
327 bool base_ots_finished_{
false};
328 bool ot_extension_finished_{
false};
void Synchronize()
Definition: communication_layer.cpp:302
SharePointer BooleanGmwXor(const proto::boolean_gmw::SharePointer &a, const proto::boolean_gmw::SharePointer &b)
Definition: backend.cpp:202
const LoggerPointer & GetLogger() const noexcept
Definition: backend.cpp:92
SharePointer BooleanGmwInput(std::size_t party_id, bool input=false)
Definition: backend.cpp:175
SharePointer ArithmeticGmwInput(std::size_t party_id, std::vector< T > &&input_vector)
Definition: backend.h:202
SharePointer ConstantArithmeticGmwInput(const std::vector< T > &input_vector)
Definition: backend.h:172
const auto & GetRunTimeStatistics() const
Definition: backend.h:305
SharePointer BmrOutput(const SharePointer &parent, std::size_t output_owner)
Definition: backend.cpp:300
const std::vector< GatePointer > & GetInputGates() const
Definition: backend.cpp:167
auto & GetBaseOtProvider()
Definition: backend.h:295
Definition: ot_provider.h:204
Definition: base_ot_provider.h:58
void RegisterGate(const GatePointer &gate)
Definition: backend.cpp:106
SharePointer BooleanGmwOutput(const SharePointer &parent, std::size_t output_owner)
Definition: backend.cpp:265
Definition: sb_provider.h:50
Definition: base_ot_provider.h:48
Definition: bmr_provider.h:42
Definition: boolean_gmw_share.h:31
SharePointer ConstantArithmeticGmwInput(T input=0)
Definition: backend.h:167
SharePointer BooleanGmwAnd(const proto::boolean_gmw::SharePointer &a, const proto::boolean_gmw::SharePointer &b)
Definition: backend.cpp:221
void EvaluateSequential()
Definition: backend.cpp:157
auto & GetMutableRunTimeStatistics()
Definition: backend.h:307
Definition: mt_provider.h:48
SharePointer ArithmeticGmwOutput(const proto::arithmetic_gmw::SharePointer< T > &parent, std::size_t output_owner)
Definition: backend.h:211
Class representing a series of bits and providing single bit access.
Definition: bit_vector.h:64
Definition: ot_provider.h:316
void Start()
Definition: communication_layer.cpp:281
std::shared_ptr< Share > SharePointer
Definition: backend.h:46
auto & GetSbProvider()
Definition: backend.h:303
SharePointer ArithmeticGmwInput(std::size_t party_id, const std::vector< T > &input_vector)
Definition: backend.h:193
std::shared_ptr< Backend > BackendPointer
Definition: backend.h:333
std::shared_ptr< Configuration > ConfigurationPointer
Definition: backend.h:81
proto::bmr::Provider & GetBmrProvider()
Definition: backend.h:293
SharePointer ArithmeticGmwAddition(const SharePointer &a, const SharePointer &b)
Definition: backend.h:242
std::shared_ptr< Register > RegisterPointer
Definition: backend.h:84
std::size_t GetNumberOfParties() const
Definition: communication_layer.h:65
void RegisterInputGate(const InputGatePointer &input_gate)
Definition: backend.cpp:101
SharePointer ArithmeticGmwSubtraction(const SharePointer &a, const SharePointer &b)
Definition: backend.h:266
const RegisterPointer & GetRegister() const noexcept
Definition: backend.h:101
const ConfigurationPointer & GetConfiguration() const noexcept
Definition: backend.h:97
std::size_t NextGateId() const
Definition: backend.cpp:94
Definition: sp_provider.h:52
Definition: algorithm_description.cpp:35
void Synchronize()
Blocking wait for synchronizing between parties. Called in Clear() and Reset()
Definition: backend.cpp:308
std::pair< ReceiverMessage, SenderMessage > ExportBaseOts(std::size_t i)
Definition: backend.cpp:326
std::shared_ptr< Share > SharePointer
Definition: conversion_gate.h:49
std::shared_ptr< Gate > GatePointer
Definition: backend.h:64
void SendMessage(std::size_t party_id, std::vector< std::uint8_t > &&message)
Definition: communication_layer.cpp:331
void OtExtensionSetup()
Definition: backend.cpp:331
std::size_t GetMyId() const
Definition: communication_layer.h:66
Definition: run_time_statistics.h:32
Definition: communication_layer.h:58
std::shared_ptr< Share< T > > SharePointer
Definition: arithmetic_gmw_share.h:156
SharePointer ConstantArithmeticGmwInput(std::vector< T > &&input_vector)
Definition: backend.h:179
std::shared_ptr< Logger > LoggerPointer
Definition: backend.h:78
void ComputeBaseOts()
Definition: backend.cpp:310
Definition: register.h:48
SharePointer ArithmeticGmwInput(std::size_t party_id, T input=0)
Definition: backend.h:187
communication::CommunicationLayer & GetCommunicationLayer()
Definition: backend.h:289
OtProvider & GetOtProvider(std::size_t party_id)
Definition: backend.cpp:373
Definition: base_ot_provider.h:53
void ImportBaseOts(std::size_t i, const ReceiverMessage &messages)
Definition: backend.cpp:318
Definition: motion_base_provider.h:48
void Send(std::size_t party_id, flatbuffers::FlatBufferBuilder &&message)
Definition: backend.cpp:97
SharePointer BmrInput(std::size_t party_id, bool input=false)
Definition: backend.cpp:273
void EvaluateParallel()
Definition: backend.cpp:161
SharePointer ArithmeticGmwOutput(const SharePointer &parent, std::size_t output_owner)
Definition: backend.h:221
BaseProvider & GetBaseProvider()
Definition: backend.h:291
auto & GetMtProvider()
Definition: backend.h:299
Definition: configuration.h:32
SharePointer BooleanGmwMux(const proto::boolean_gmw::SharePointer &a, const proto::boolean_gmw::SharePointer &b, const proto::boolean_gmw::SharePointer &selection)
Definition: backend.cpp:240
SharePointer ArithmeticGmwAddition(const proto::arithmetic_gmw::SharePointer< T > &a, const proto::arithmetic_gmw::SharePointer< T > &b)
Definition: backend.h:229
constexpr bool kDebug
Definition: config.h:36
void Clear()
Definition: backend.cpp:173
SharePointer ArithmeticGmwSubtraction(const proto::arithmetic_gmw::SharePointer< T > &a, const proto::arithmetic_gmw::SharePointer< T > &b)
Definition: backend.h:253
auto & GetSpProvider()
Definition: backend.h:301
Definition: gate_executor.h:36
const GatePointer & GetGate(std::size_t gate_id) const
Definition: backend.cpp:163
std::shared_ptr< InputGate > InputGatePointer
Definition: backend.h:66
void RunPreprocessing()
Definition: backend.cpp:120
void Reset()
Definition: backend.cpp:171
void SetLogger(std::shared_ptr< Logger > logger)
Definition: communication_layer.cpp:494