MOTION
0.01
Framework for mixed-protocol multi-party computation
|
Go to the documentation of this file.
27 #include <fmt/format.h>
36 template <
typename T,
typename = std::enable_if_t<std::is_
unsigned_v<T>>>
44 throw(std::runtime_error(
"Something went wrong with creating an arithmetic share"));
49 wires_ = {std::static_pointer_cast<motion::Wire>(wire)};
54 for (
auto i = 0ull; i < wires.size(); ++i) {
55 wires_.emplace_back(wires.at(i));
57 if (wires.size() == 0) {
58 throw(std::runtime_error(
"Trying to create an arithmetic share without wires"));
60 if (wires.size() > 1) {
62 std::runtime_error(fmt::format(
"Cannot create an arithmetic share "
63 "from more than 1 wire; got {} wires",
69 if (wires.size() == 0) {
70 throw(std::runtime_error(
"Trying to create an arithmetic share without wires"));
72 if (wires.size() > 1) {
74 std::runtime_error(fmt::format(
"Cannot create an arithmetic share "
75 "from more than 1 wire; got {} wires",
80 throw(std::runtime_error(
"Something went wrong with creating an arithmetic share"));
85 wires_ = {std::make_shared<arithmetic_gmw::Wire<T>>(input, backend)};
89 wires_ = {std::make_shared<arithmetic_gmw::Wire<T>>(input, backend)};
94 ~Share()
override =
default;
97 return wires_.at(0)->GetNumberOfSimdValues();
102 return wires_.at(0)->GetProtocol();
107 return wires_.at(0)->GetCircuitType();
111 auto wire = std::dynamic_pointer_cast<arithmetic_gmw::Wire<T>>(
wires_.at(0));
116 const std::vector<motion::WirePointer>&
GetWires() const noexcept final {
return wires_; }
123 auto wire = std::dynamic_pointer_cast<arithmetic_gmw::Wire<T>>(
wires_.at(0));
125 return wire->GetRawSharedValues();
128 std::size_t
GetBitLength() const noexcept final {
return sizeof(T) * 8; }
130 std::vector<std::shared_ptr<Base>>
Split() const noexcept final {
131 std::vector<std::shared_ptr<Base>> v;
133 for (
const auto& w :
wires_) {
134 const std::vector<motion::WirePointer> w_v = {std::static_pointer_cast<motion::Wire>(w)};
135 v.emplace_back(std::make_shared<
Share<T>>(w_v));
140 std::shared_ptr<Base>
GetWire(std::size_t i)
const override {
142 throw std::out_of_range(
143 fmt::format(
"Trying to access wire #{} out of {} wires", i,
wires_.size()));
145 std::vector<motion::WirePointer> result = {std::static_pointer_cast<motion::Wire>(
wires_[i])};
146 return std::make_shared<Share<T>>(result);
155 template <
typename T,
typename = std::enable_if_t<std::is_
unsigned_v<T>>>
const bool & Finished()
Definition: arithmetic_gmw_share.h:120
std::vector< motion::WirePointer > & GetMutableWires() noexcept final
Definition: arithmetic_gmw_share.h:118
Definition: arithmetic_gmw_share.h:37
CircuitType
Definition: typedefs.h:165
std::size_t GetBitLength() const noexcept final
Definition: arithmetic_gmw_share.h:128
const std::vector< T > & GetValue() const
Definition: arithmetic_gmw_share.h:122
Backend & GetBackend() const
Definition: share.h:61
std::shared_ptr< Wire > WirePointer
Definition: register.h:40
std::shared_ptr< Base > GetWire(std::size_t i) const override
Definition: arithmetic_gmw_share.h:140
std::size_t GetNumberOfSimdValues() const noexcept final
Definition: arithmetic_gmw_share.h:96
Share(const arithmetic_gmw::WirePointer< T > &wire)
Definition: arithmetic_gmw_share.h:48
Share(const T input, Backend &backend)
Definition: arithmetic_gmw_share.h:88
std::vector< WirePointer > wires_
Definition: share.h:77
CircuitType GetCircuitType() const noexcept final
Definition: arithmetic_gmw_share.h:105
Share(const std::vector< arithmetic_gmw::WirePointer< T >> &wires)
Definition: arithmetic_gmw_share.h:52
MpcProtocol GetProtocol() const noexcept final
Definition: arithmetic_gmw_share.h:100
Share(const motion::WirePointer &wire)
Definition: arithmetic_gmw_share.h:41
std::shared_ptr< Share< T > > SharePointer
Definition: arithmetic_gmw_share.h:156
const arithmetic_gmw::WirePointer< T > GetArithmeticWire()
Definition: arithmetic_gmw_share.h:110
std::vector< std::shared_ptr< Base > > Split() const noexcept final
Definition: arithmetic_gmw_share.h:130
MpcProtocol
Definition: typedefs.h:140
Share(const std::vector< motion::WirePointer > &wires)
Definition: arithmetic_gmw_share.h:68
Share(const std::vector< T > &input, Backend &backend)
Definition: arithmetic_gmw_share.h:84
Definition: arithmetic_gmw_gate.h:45
std::shared_ptr< Wire< T > > WirePointer
Definition: arithmetic_gmw_wire.h:68
const std::vector< motion::WirePointer > & GetWires() const noexcept final
Definition: arithmetic_gmw_share.h:116
~Share() override=default