MOTION  0.01
Framework for mixed-protocol multi-party computation
boolean_gmw_wire.h
Go to the documentation of this file.
1 // MIT License
2 //
3 // Copyright (c) 2019 Oleksandr Tkachenko
4 // Cryptography and Privacy Engineering Group (ENCRYPTO)
5 // TU Darmstadt, Germany
6 //
7 // Permission is hereby granted, free of charge, to any person obtaining a copy
8 // of this software and associated documentation files (the "Software"), to deal
9 // in the Software without restriction, including without limitation the rights
10 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 // copies of the Software, and to permit persons to whom the Software is
12 // furnished to do so, subject to the following conditions:
13 //
14 // The above copyright notice and this permission notice shall be included in all
15 // copies or substantial portions of the Software.
16 //
17 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 // SOFTWARE.
24 
25 #pragma once
26 
27 #include "protocols/wire.h"
28 #include "utility/bit_vector.h"
29 
30 namespace encrypto::motion {
31 
32 class Backend;
33 
34 } // namespace encrypto::motion
35 
37 
38 class Wire final : public BooleanWire {
39  public:
40  Wire(Backend& backend, size_t number_of_simd);
41 
42  explicit Wire(BitVector<>&& values, Backend& backend);
43 
44  explicit Wire(const BitVector<>& values, Backend& backend);
45 
46  explicit Wire(bool value, Backend& backend);
47 
48  ~Wire() final = default;
49 
51 
52  Wire() = delete;
53 
54  Wire(Wire&) = delete;
55 
56  std::size_t GetBitLength() const final { return 1; }
57 
58  const BitVector<>& GetValues() const { return values_; }
59 
60  BitVector<>& GetMutableValues() { return values_; }
61 
62  bool IsConstant() const noexcept final { return false; }
63 
64  private:
65  BitVector<> values_;
66 };
67 
68 using WirePointer = std::shared_ptr<Wire>;
69 
70 } // namespace encrypto::motion::proto::boolean_gmw
encrypto::motion::BooleanWire
Definition: wire.h:112
encrypto::motion::proto::boolean_gmw::Wire::IsConstant
bool IsConstant() const noexcept final
Definition: boolean_gmw_wire.h:62
encrypto::motion::proto::boolean_gmw
Definition: backend.h:43
bit_vector.h
encrypto::motion::proto::boolean_gmw::Wire::GetMutableValues
BitVector & GetMutableValues()
Definition: boolean_gmw_wire.h:60
wire.h
encrypto::motion::proto::boolean_gmw::WirePointer
std::shared_ptr< Wire > WirePointer
Definition: boolean_gmw_wire.h:68
encrypto::motion::proto::boolean_gmw::Wire::GetBitLength
std::size_t GetBitLength() const final
Definition: boolean_gmw_wire.h:56
encrypto::motion::BitVector<>
encrypto::motion::proto::boolean_gmw::Wire::~Wire
~Wire() final=default
encrypto::motion::MpcProtocol::kBooleanGmw
@ kBooleanGmw
encrypto::motion::Backend
Definition: backend.h:88
boolean_gmw_wire.h
encrypto::motion::Wire::Wire
Wire(const Wire &)=delete
encrypto::motion
Definition: algorithm_description.cpp:35
encrypto::motion::proto::boolean_gmw::Wire::Wire
Wire()=delete
encrypto::motion::MpcProtocol
MpcProtocol
Definition: typedefs.h:140
encrypto::motion::proto::boolean_gmw::Wire
Definition: boolean_gmw_wire.h:38
encrypto::motion::proto::boolean_gmw::Wire::GetProtocol
MpcProtocol GetProtocol() const final
Definition: boolean_gmw_wire.h:50
encrypto::motion::BitVector::Append
void Append(bool bit) noexcept
Appends a bit to BitVector.
Definition: bit_vector.cpp:621
encrypto::motion::proto::boolean_gmw::Wire::GetValues
const BitVector & GetValues() const
Definition: boolean_gmw_wire.h:58