MOTION  0.01
Framework for mixed-protocol multi-party computation
conversion_gate.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/gate.h"
28 #include "utility/bit_vector.h"
29 #include "utility/block.h"
31 
33 
34 class Share;
35 using SharePointer = std::shared_ptr<Share>;
36 
37 } // namespace encrypto::motion::proto::bmr
38 
40 
41 class Share;
42 using SharePointer = std::shared_ptr<Share>;
43 
44 } // namespace encrypto::motion::proto::boolean_gmw
45 
46 namespace encrypto::motion {
47 
48 class Share;
49 using SharePointer = std::shared_ptr<Share>;
50 
51 class ShareWrapper;
52 
53 class BmrToBooleanGmwGate final : public OneGate {
54  public:
55  BmrToBooleanGmwGate(const SharePointer& parent);
56 
57  ~BmrToBooleanGmwGate() final = default;
58 
59  void EvaluateSetup() final override;
60 
61  void EvaluateOnline() final override;
62 
64 
65  const SharePointer GetOutputAsShare() const;
66 
67  BmrToBooleanGmwGate() = delete;
68 
69  BmrToBooleanGmwGate(const Gate&) = delete;
70 };
71 
72 class BooleanGmwToBmrGate final : public OneGate {
73  public:
74  BooleanGmwToBmrGate(const SharePointer& parent);
75 
76  ~BooleanGmwToBmrGate() final = default;
77 
78  void EvaluateSetup() final override;
79 
80  void EvaluateOnline() final override;
81 
83 
84  const SharePointer GetOutputAsShare() const;
85 
86  BooleanGmwToBmrGate() = delete;
87 
88  BooleanGmwToBmrGate(const Gate&) = delete;
89 
90  private:
91  std::vector<ReusableFiberFuture<BitVector<>>> received_public_values_;
92  std::vector<ReusableFiberFuture<Block128Vector>> received_public_keys_;
93 };
94 
95 class ArithmeticGmwToBmrGate final : public OneGate {
96  public:
97  ArithmeticGmwToBmrGate(const SharePointer& parent);
98 
99  ~ArithmeticGmwToBmrGate() final = default;
100 
101  void EvaluateSetup() final override;
102 
103  void EvaluateOnline() final override;
104 
106 
107  const SharePointer GetOutputAsShare() const;
108 
109  ArithmeticGmwToBmrGate() = delete;
110 
111  ArithmeticGmwToBmrGate(const Gate&) = delete;
112 
113  private:
115 };
116 
117 } // namespace encrypto::motion
encrypto::motion::proto::bmr::Provider::GetGlobalOffset
const Block128 & GetGlobalOffset() const
Definition: bmr_provider.h:46
encrypto::motion::BmrToBooleanGmwGate::EvaluateSetup
void EvaluateSetup() final override
Definition: conversion_gate.cpp:84
encrypto::motion::proto::bmr::SharePointer
std::shared_ptr< Share > SharePointer
Definition: bmr_share.h:52
encrypto::motion::ArithmeticGmwToBmrGate::GetOutputAsBmrShare
const proto::bmr::SharePointer GetOutputAsBmrShare() const
Definition: conversion_gate.cpp:445
encrypto::motion::ShareWrapper
Definition: share_wrapper.h:44
encrypto::motion::Gate::gate_type_
GateType gate_type_
Definition: gate.h:105
encrypto::motion::Register::RegisterNextInputGate
void RegisterNextInputGate(GatePointer gate)
Definition: register.cpp:82
encrypto::motion::ArithmeticGmwToBmrGate::EvaluateSetup
void EvaluateSetup() final override
Definition: conversion_gate.cpp:388
encrypto::motion::BmrToBooleanGmwGate::GetOutputAsShare
const SharePointer GetOutputAsShare() const
Definition: conversion_gate.cpp:131
encrypto::motion::Gate::GetCommunicationLayer
communication::CommunicationLayer & GetCommunicationLayer()
Definition: gate.cpp:92
encrypto::motion::Gate::output_wires_
std::vector< WirePointer > output_wires_
Definition: gate.h:100
encrypto::motion::BitVector::GetData
const auto & GetData() const noexcept
Get const reference to content of BitVector.
Definition: bit_vector.h:152
encrypto::motion::BmrToBooleanGmwGate::~BmrToBooleanGmwGate
~BmrToBooleanGmwGate() final=default
fiber_condition.h
encrypto::motion::Gate::GetLogger
Logger & GetLogger()
Definition: gate.cpp:100
encrypto::motion::ArithmeticGmwToBmrGate::~ArithmeticGmwToBmrGate
~ArithmeticGmwToBmrGate() final=default
encrypto::motion::MpcProtocol::kBmr
@ kBmr
encrypto::motion::BooleanGmwToBmrGate::BooleanGmwToBmrGate
BooleanGmwToBmrGate()=delete
reusable_future.h
encrypto::motion::proto::boolean_gmw
Definition: backend.h:43
bit_vector.h
bmr_wire.h
encrypto::motion::communication::BuildBmrInput0Message
flatbuffers::FlatBufferBuilder BuildBmrInput0Message(const std::size_t id, const std::vector< std::uint8_t > &payload)
Definition: bmr_message.cpp:45
encrypto::motion::OneGate::parent_
std::vector< WirePointer > parent_
Definition: gate.h:155
encrypto::motion::Block128Vector::ByteSize
std::size_t ByteSize() const
Get size of the Block128Vector content in bytes.
Definition: block.h:228
backend.h
encrypto::motion::GateType::kNonInteractive
@ kNonInteractive
encrypto::motion::Block128Vector
Vector of 128 bit / 16 B blocks.
Definition: block.h:168
block.h
encrypto::motion::BitVector<>
encrypto::motion::BmrToBooleanGmwGate
Definition: conversion_gate.h:53
encrypto::motion::Logger::LogDebug
void LogDebug(const std::string &message)
Definition: logger.cpp:142
encrypto::motion::Gate::requires_online_interaction_
std::atomic< bool > requires_online_interaction_
Definition: gate.h:108
encrypto::motion::Gate::GetRegister
Register & GetRegister()
Definition: gate.cpp:96
encrypto::motion::proto::boolean_gmw::SharePointer
std::shared_ptr< Share > SharePointer
Definition: backend.h:46
encrypto::motion::MpcProtocol::kBooleanGmw
@ kBooleanGmw
bmr_share.h
encrypto::motion::Register::IncrementEvaluatedGatesOnlineCounter
void IncrementEvaluatedGatesOnlineCounter()
Definition: register.cpp:125
encrypto::motion::Backend::GetBmrProvider
proto::bmr::Provider & GetBmrProvider()
Definition: backend.h:293
encrypto::motion::proto::bmr
Definition: backend.h:50
encrypto::motion::Gate::RegisterWaitingFor
void RegisterWaitingFor(std::size_t wire_id)
Definition: gate.cpp:36
communication_layer.h
boolean_gmw_wire.h
encrypto::motion::Gate::SetOnlineIsReady
void SetOnlineIsReady()
Definition: gate.cpp:54
bmr_provider.h
encrypto::motion::Gate::backend_
Backend & backend_
Definition: gate.h:101
encrypto::motion::Gate::SetSetupIsReady
void SetSetupIsReady()
Definition: gate.cpp:46
encrypto::motion::Register::IncrementEvaluatedGatesSetupCounter
void IncrementEvaluatedGatesSetupCounter()
Definition: register.cpp:114
encrypto::motion::OneGate
Definition: gate.h:148
secure_unsigned_integer.h
encrypto::motion::Block128Vector::data
Block128 * data()
Get pointer to the first Block128.
Definition: block.h:219
encrypto::motion
Definition: algorithm_description.cpp:35
encrypto::motion::BooleanGmwToBmrGate::GetOutputAsBmrShare
const proto::bmr::SharePointer GetOutputAsBmrShare() const
Definition: conversion_gate.cpp:313
encrypto::motion::SharePointer
std::shared_ptr< Share > SharePointer
Definition: conversion_gate.h:49
encrypto::motion::Gate::gate_id_
std::int64_t gate_id_
Definition: gate.h:102
bmr_message.h
encrypto::motion::ArithmeticGmwToBmrGate::EvaluateOnline
void EvaluateOnline() final override
Definition: conversion_gate.cpp:398
encrypto::motion::BooleanGmwToBmrGate::GetOutputAsShare
const SharePointer GetOutputAsShare() const
Definition: conversion_gate.cpp:319
encrypto::motion::ArithmeticGmwToBmrGate
Definition: conversion_gate.h:95
encrypto::motion::communication::BuildBmrInput1Message
flatbuffers::FlatBufferBuilder BuildBmrInput1Message(const std::size_t id, const std::vector< std::uint8_t > &payload)
Definition: bmr_message.cpp:55
encrypto::motion::Gate
Definition: gate.h:67
encrypto::motion::ArithmeticGmwToBmrGate::ArithmeticGmwToBmrGate
ArithmeticGmwToBmrGate()=delete
encrypto::motion::BooleanGmwToBmrGate::~BooleanGmwToBmrGate
~BooleanGmwToBmrGate() final=default
conversion_gate.h
encrypto::motion::Gate::own_output_wires_
bool own_output_wires_
Definition: gate.h:128
encrypto::motion::ArithmeticGmwToBmrGate::GetOutputAsShare
const SharePointer GetOutputAsShare() const
Definition: conversion_gate.cpp:451
encrypto::motion::BooleanGmwToBmrGate
Definition: conversion_gate.h:72
encrypto::motion::ReusablePromise
Definition: reusable_future.h:123
encrypto::motion::BitVector::Append
void Append(bool bit) noexcept
Appends a bit to BitVector.
Definition: bit_vector.cpp:621
bmr_gate.h
encrypto::motion::BmrToBooleanGmwGate::GetOutputAsGmwShare
const proto::boolean_gmw::SharePointer GetOutputAsGmwShare() const
Definition: conversion_gate.cpp:125
encrypto::motion::BooleanGmwToBmrGate::EvaluateOnline
void EvaluateOnline() final override
Definition: conversion_gate.cpp:201
gate.h
encrypto::motion::MpcProtocol::kArithmeticGmw
@ kArithmeticGmw
encrypto::motion::BmrToBooleanGmwGate::EvaluateOnline
void EvaluateOnline() final override
Definition: conversion_gate.cpp:89
encrypto::motion::Gate::WaitSetup
void WaitSetup() const
Definition: gate.cpp:68
encrypto::motion::Register::RegisterNextWire
void RegisterNextWire(WirePointer wire)
Definition: register.h:78
constants.h
encrypto::motion::GateType::kInteractive
@ kInteractive
encrypto::motion::kDebug
constexpr bool kDebug
Definition: config.h:36
encrypto::motion::BitVector::Subset
BitVector Subset(std::size_t from, std::size_t to) const
Returns a new BitVector containing the bits of this BitVector between positions from and to.
Definition: bit_vector.cpp:806
bmr_data.h
boolean_gmw_share.h
encrypto::motion::BooleanGmwToBmrGate::EvaluateSetup
void EvaluateSetup() final override
Definition: conversion_gate.cpp:180
encrypto::motion::ToInput
std::vector< BitVector< Allocator > > ToInput(IntegralType integral_value)
Definition: bit_vector.cpp:1189
encrypto::motion::Block128Vector::at
Block128 & at(std::size_t index)
Access Block128 at index. Throws an exception if index is out of bounds.
Definition: block.h:215
encrypto::motion::Register::NextGateId
std::size_t NextGateId() noexcept
Definition: register.cpp:53
encrypto::motion::BmrToBooleanGmwGate::BmrToBooleanGmwGate
BmrToBooleanGmwGate()=delete