MOTION
0.01
Framework for mixed-protocol multi-party computation
|
Go to the documentation of this file.
36 template <
typename T,
typename = std::enable_if_t<std::is_
unsigned_v<T>>>
42 throw(std::runtime_error(
"Something went wrong with creating a constant arithmetic share"));
45 if constexpr (
kDebug) ConstructorConsistencyCheck();
50 wires_ = {std::static_pointer_cast<Wire>(wire)};
52 if constexpr (
kDebug) ConstructorConsistencyCheck();
57 for (
auto i = 0ull; i < wires.size(); ++i) {
58 wires_.emplace_back(wires.at(i));
62 throw(std::runtime_error(
"Trying to create a constant arithmetic share without wires"));
63 }
else if (wires.size() > 1) {
65 std::runtime_error(fmt::format(
"Cannot create a constant arithmetic share "
66 "from more than 1 wire; got {} wires",
70 if constexpr (
kDebug) ConstructorConsistencyCheck();
75 if (wires.size() == 0) {
76 throw(std::runtime_error(
"Trying to create an arithmetic share without wires"));
78 if (wires.size() > 1) {
80 std::runtime_error(fmt::format(
"Cannot create an arithmetic share "
81 "from more than 1 wire; got {} wires",
86 throw(std::runtime_error(
"Something went wrong with creating an arithmetic share"));
91 wires_ = {std::make_shared<ConstantArithmeticWirePointer<T>>(input, backend)};
95 wires_ = {std::make_shared<ConstantArithmeticWirePointer<T>>(input, backend)};
101 return wires_.at(0)->GetNumberOfSimdValues();
106 return wires_.at(0)->GetProtocol();
111 return wires_.at(0)->GetCircuitType();
115 auto wire = std::dynamic_pointer_cast<ConstantArithmeticWirePointer<T>>(
wires_.at(0));
120 const std::vector<WirePointer>&
GetWires() const noexcept final {
return wires_; }
127 auto wire = std::dynamic_pointer_cast<ConstantArithmeticWirePointer<T>>(
wires_.at(0));
129 return wire->GetRawSharedValues();
132 std::size_t
GetBitLength() const noexcept final {
return sizeof(T) * 8; }
134 std::vector<std::shared_ptr<motion::Share>>
Split() const noexcept final {
135 std::vector<std::shared_ptr<motion::Share>> v;
137 for (
const auto& w :
wires_) {
138 const std::vector<WirePointer> w_v = {std::static_pointer_cast<Wire>(w)};
144 std::shared_ptr<motion::Share>
GetWire(std::size_t i)
const override {
146 throw std::out_of_range(
147 fmt::format(
"Trying to access wire #{} out of {} wires", i,
wires_.size()));
149 std::vector<motion::WirePointer> result = {std::static_pointer_cast<motion::Wire>(
wires_[i])};
150 return std::make_shared<ConstantArithmeticShare<T>>(result);
158 void ConstructorConsistencyCheck()
const {
159 assert(
wires_.size() == 1);
160 auto arithmetic_wire =
161 std::dynamic_pointer_cast<ConstantArithmeticWirePointer<T>>(
wires_.at(0));
162 assert(arithmetic_wire);
163 assert(arithmetic_wire->IsConstant());
169 template <
typename T,
typename = std::enable_if_t<std::is_
unsigned_v<T>>>
178 const std::vector<WirePointer>&
GetWires() const noexcept final {
return wires_; }
190 std::vector<std::shared_ptr<motion::Share>>
Split() const noexcept final;
192 std::shared_ptr<motion::
Share>
GetWire(std::
size_t i) const final;
std::vector< std::shared_ptr< motion::Share > > Split() const noexcept final
Definition: constant_share.cpp:88
std::shared_ptr< motion::Share > GetWire(std::size_t i) const override
Definition: constant_share.h:144
std::vector< WirePointer > & GetMutableWires() noexcept final
Definition: constant_share.h:180
Definition: constant_share.h:172
ConstantArithmeticShare(const T input, Backend &backend)
Definition: constant_share.h:94
MpcProtocol GetProtocol() const noexcept final
Definition: constant_share.cpp:29
CircuitType
Definition: typedefs.h:165
std::vector< std::shared_ptr< motion::Share > > Split() const noexcept final
Definition: constant_share.h:134
CircuitType GetCircuitType() const noexcept final
Definition: constant_share.cpp:37
Backend & GetBackend() const
Definition: share.h:61
std::shared_ptr< Wire > WirePointer
Definition: register.h:40
std::size_t GetNumberOfSimdValues() const noexcept final
Definition: constant_share.cpp:81
std::vector< WirePointer > & GetMutableWires() noexcept final
Definition: constant_share.h:122
const std::vector< WirePointer > & GetWires() const noexcept final
Definition: constant_share.h:120
std::size_t GetBitLength() const noexcept final
Definition: constant_share.h:188
ConstantArithmeticShare(const std::vector< T > &input, Backend &backend)
Definition: constant_share.h:90
ConstantArithmeticShare(const WirePointer &wire)
Definition: constant_share.h:39
const bool & Finished()
Definition: constant_share.h:124
std::shared_ptr< ConstantArithmeticShare< T > > ConstantArithmeticSharePointer
Definition: constant_share.h:170
std::vector< WirePointer > wires_
Definition: share.h:77
std::shared_ptr< ConstantBooleanShare > ConstantBooleanSharePointer
Definition: constant_share.h:195
CircuitType GetCircuitType() const noexcept final
Definition: constant_share.h:109
ConstantArithmeticShare(const std::vector< WirePointer > &wires)
Definition: constant_share.h:73
const ConstantArithmeticWirePointer< T > GetConstantArithmeticWire() const
Definition: constant_share.h:114
MpcProtocol GetProtocol() const noexcept final
Definition: constant_share.h:104
Definition: constant_share.h:37
MpcProtocol
Definition: typedefs.h:140
ConstantArithmeticShare(const std::vector< ConstantArithmeticWirePointer< T >> &wires)
Definition: constant_share.h:55
const std::vector< T > & GetValue() const
Definition: constant_share.h:126
std::shared_ptr< ConstantArithmeticWire< T > > ConstantArithmeticWirePointer
Definition: constant_wire.h:67
~ConstantArithmeticShare() override=default
ConstantArithmeticShare(const ConstantArithmeticWirePointer< T > &wire)
Definition: constant_share.h:48
std::size_t GetNumberOfSimdValues() const noexcept final
Definition: constant_share.h:100
constexpr bool kDebug
Definition: config.h:36
std::size_t GetBitLength() const noexcept final
Definition: constant_share.h:132
const std::vector< WirePointer > & GetWires() const noexcept final
Definition: constant_share.h:178
ConstantBooleanShare(const std::vector< WirePointer > &wires)
Definition: constant_share.cpp:45
std::shared_ptr< motion::Share > GetWire(std::size_t i) const final
Definition: constant_share.cpp:98