MOTION
0.01
Framework for mixed-protocol multi-party computation
|
Go to the documentation of this file.
88 static_assert(!std::is_same_v<T, bool>);
93 fmt::format(
"Created a ConstantArithmeticInputGate with global id {}",
gate_id_));
98 auto gate_info = fmt::format(
"uint{}_t type, gate id {}",
sizeof(T) * 8,
gate_id_);
100 "Allocated a ConstantArithmeticInputGate with following properties: {}", gate_info));
117 template <
typename T,
typename = std::enable_if_t<std::is_
unsigned_v<T>>>
127 parent_a_ = {std::static_pointer_cast<Wire>(a)};
128 parent_b_ = {std::static_pointer_cast<Wire>(b)};
130 assert(
parent_a_.at(0)->GetNumberOfSimdValues() ==
parent_b_.at(0)->GetNumberOfSimdValues());
149 auto w = std::make_shared<arithmetic_gmw::Wire<T>>(
backend_, a->GetNumberOfSimdValues());
155 fmt::format(
"uint{}_t type, gate id {}, parents: {}, {}",
sizeof(T) * 8,
gate_id_,
158 "Created an ConstantArithmeticAdditionGate with following properties: {}", gate_info));
172 parent_a_.at(0)->GetIsReadyCondition().Wait();
173 parent_b_.at(0)->GetIsReadyCondition().Wait();
175 auto non_constant_wire_origin =
parent_a_.at(0);
176 auto constant_wire_origin =
parent_b_.at(0);
178 auto non_constant_wire =
179 std::dynamic_pointer_cast<const arithmetic_gmw::Wire<T>>(non_constant_wire_origin);
181 std::dynamic_pointer_cast<const ConstantArithmeticWire<T>>(constant_wire_origin);
183 assert(non_constant_wire);
184 assert(constant_wire);
186 std::vector<T> output;
189 output =
RestrictAddVectors(constant_wire->GetValues(), non_constant_wire->GetValues());
191 output = non_constant_wire->GetValues();
194 auto arithmetic_wire = std::dynamic_pointer_cast<arithmetic_gmw::Wire<T>>(
output_wires_.at(0));
195 arithmetic_wire->GetMutableValues() = std::move(output);
198 fmt::format(
"Evaluated arithmetic_gmw::AdditionGate with id#{}",
gate_id_));
206 auto arithmetic_wire = std::dynamic_pointer_cast<arithmetic_gmw::Wire<T>>(
output_wires_.at(0));
207 assert(arithmetic_wire);
208 auto result = std::make_shared<arithmetic_gmw::Share<T>>(arithmetic_wire);
217 template <
typename T,
typename = std::enable_if_t<std::is_
unsigned_v<T>>>
227 parent_a_ = {std::static_pointer_cast<Wire>(a)};
228 parent_b_ = {std::static_pointer_cast<Wire>(b)};
230 assert(
parent_a_.at(0)->GetNumberOfSimdValues() ==
parent_b_.at(0)->GetNumberOfSimdValues());
249 auto w = std::make_shared<arithmetic_gmw::Wire<T>>(
backend_, a->GetNumberOfSimdValues());
255 fmt::format(
"uint{}_t type, gate id {}, parents: {}, {}",
sizeof(T) * 8,
gate_id_,
258 "Created an ConstantArithmeticAdditionGate with following properties: {}", gate_info));
272 parent_a_.at(0)->GetIsReadyCondition().Wait();
273 parent_b_.at(0)->GetIsReadyCondition().Wait();
275 auto non_constant_wire_origin =
parent_a_.at(0);
276 auto constant_wire_origin =
parent_b_.at(0);
278 auto non_constant_wire =
279 std::dynamic_pointer_cast<const arithmetic_gmw::Wire<T>>(non_constant_wire_origin);
281 std::dynamic_pointer_cast<const ConstantArithmeticWire<T>>(constant_wire_origin);
283 assert(non_constant_wire);
284 assert(constant_wire);
286 std::vector<T> output =
289 auto arithmetic_wire = std::dynamic_pointer_cast<arithmetic_gmw::Wire<T>>(
output_wires_.at(0));
290 arithmetic_wire->GetMutableValues() = std::move(output);
293 fmt::format(
"Evaluated arithmetic_gmw::AdditionGate with id#{}",
gate_id_));
301 auto arithmetic_wire = std::dynamic_pointer_cast<arithmetic_gmw::Wire<T>>(
output_wires_.at(0));
302 assert(arithmetic_wire);
303 auto result = std::make_shared<arithmetic_gmw::Share<T>>(arithmetic_wire);
ConstantArithmeticInputGate(const std::vector< T > &v, Backend &backend)
Definition: constant_gate.cpp:71
void LogTrace(const std::string &message)
Definition: logger.cpp:110
Definition: constant_gate.h:79
GateType gate_type_
Definition: gate.h:105
std::vector< T > RestrictMulVectors(const std::vector< T > &a, const std::vector< T > &b)
Mulitiplies each element in a and b and returns the result. It is assumed that the vectors do not ove...
Definition: helpers.h:241
communication::CommunicationLayer & GetCommunicationLayer()
Definition: gate.cpp:92
std::vector< WirePointer > output_wires_
Definition: gate.h:100
Definition: constant_gate.h:218
arithmetic_gmw::SharePointer< T > GetOutputAsArithmeticShare()
Definition: constant_gate.h:205
ConstantBooleanInputGate(const BitVector<> &bv, Backend &backend)
Definition: constant_gate.h:52
std::vector< WirePointer > parent_b_
Definition: gate.h:221
Definition: constant_gate.h:44
ConstantArithmeticMultiplicationGate(const arithmetic_gmw::WirePointer< T > &a, const ConstantArithmeticWirePointer< T > &b)
Definition: constant_gate.h:224
Logger & GetLogger()
Definition: gate.cpp:100
ConstantArithmeticAdditionGate(const arithmetic_gmw::WirePointer< T > &a, const ConstantArithmeticWirePointer< T > &b)
Definition: constant_gate.h:124
void EvaluateSetup() final override
Definition: constant_gate.h:163
ConstantBooleanInputGate(bool b, Backend &backend)
Definition: constant_gate.h:46
ConstantArithmeticAdditionGate(const ConstantArithmeticWirePointer< T > &a, const arithmetic_gmw::WirePointer< T > &b)
Definition: constant_gate.h:120
void EvaluateOnline() final override
Definition: constant_gate.h:268
ConstantArithmeticMultiplicationGate(const ConstantArithmeticWirePointer< T > &a, const arithmetic_gmw::WirePointer< T > &b)
Definition: constant_gate.h:220
motion::SharePointer GetOutputAsShare() const
Definition: constant_gate.cpp:88
std::shared_ptr< Share > SharePointer
Definition: constant_gate.h:41
void EvaluateOnline() final override
Definition: constant_gate.h:68
void LogDebug(const std::string &message)
Definition: logger.cpp:142
void EvaluateOnline() final override
Definition: constant_gate.h:108
std::atomic< bool > requires_online_interaction_
Definition: gate.h:108
Register & GetRegister()
Definition: gate.cpp:96
void InitializationHelper()
Definition: constant_gate.h:87
std::vector< WirePointer > parent_a_
Definition: gate.h:220
void EvaluateOnline() final override
Definition: constant_gate.h:168
void IncrementEvaluatedGatesOnlineCounter()
Definition: register.cpp:125
void RegisterWaitingFor(std::size_t wire_id)
Definition: gate.cpp:36
arithmetic_gmw::SharePointer< T > GetOutputAsArithmeticShare()
Definition: constant_gate.h:300
void SetOnlineIsReady()
Definition: gate.cpp:54
Backend & backend_
Definition: gate.h:101
std::vector< T > RestrictAddVectors(const std::vector< T > &a, const std::vector< T > &b)
Adds each element in a and b and returns the result. It is assumed that the vectors do not overlap.
Definition: helpers.h:197
void SetSetupIsReady()
Definition: gate.cpp:46
void IncrementEvaluatedGatesSetupCounter()
Definition: register.cpp:114
~ConstantBooleanInputGate() final=default
std::shared_ptr< Share > SharePointer
Definition: conversion_gate.h:49
motion::SharePointer GetOutputAsShare() const
Definition: constant_gate.cpp:66
std::int64_t gate_id_
Definition: gate.h:102
~ConstantArithmeticInputGate() final=default
ConstantArithmeticAdditionGate()=delete
std::shared_ptr< Share< T > > SharePointer
Definition: arithmetic_gmw_share.h:156
~ConstantArithmeticMultiplicationGate() final=default
std::atomic< bool > setup_is_ready_
Definition: gate.h:106
constexpr bool kVerboseDebug
Definition: constants.h:50
Definition: constant_gate.h:118
void InitializationHelper()
Definition: constant_gate.cpp:52
std::shared_ptr< ConstantArithmeticWire< T > > ConstantArithmeticWirePointer
Definition: constant_wire.h:67
ConstantArithmeticMultiplicationGate()=delete
void WaitSetup() const
Definition: gate.cpp:68
void RegisterNextWire(WirePointer wire)
Definition: register.h:78
void EvaluateSetup() final override
Definition: constant_gate.h:263
default
Definition: geninput.py:149
~ConstantArithmeticAdditionGate() final=default
ConstantBooleanInputGate(BitVector<> &&bv, Backend &backend)
Definition: constant_gate.h:49
Definition: constant_wire.h:33
std::shared_ptr< Wire< T > > WirePointer
Definition: arithmetic_gmw_wire.h:68
void EvaluateSetup() final override
Definition: constant_gate.h:103
void EvaluateSetup() final override
Definition: constant_gate.h:63
std::size_t NextGateId() noexcept
Definition: register.cpp:53