MOTION  0.01
Framework for mixed-protocol multi-party computation
subset_gate.h
Go to the documentation of this file.
1 // MIT License
2 //
3 // Copyright (c) 2021 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 <span>
28 #include <vector>
29 
30 #include "protocols/gate.h"
31 
32 namespace encrypto::motion {
33 
34 class Share;
35 using SharePointer = std::shared_ptr<Share>;
36 
37 class ShareWrapper;
38 
43 class SubsetGate final : public OneGate {
44  public:
45  SubsetGate(const SharePointer& parent, std::span<const std::size_t> position_ids);
46 
47  SubsetGate(const SharePointer& parent, std::vector<std::size_t>&& position_ids);
48 
49  ~SubsetGate() = default;
50 
51  void EvaluateSetup() override;
52 
53  void EvaluateOnline() override;
54 
56 
57  SubsetGate() = delete;
58 
59  SubsetGate(const Gate&) = delete;
60 
61  private:
62  const std::vector<std::size_t> position_ids_;
63 };
64 
65 } // namespace encrypto::motion
encrypto::motion::BitVectorSubsetImplementation
void BitVectorSubsetImplementation(const BitVector< Allocator > &in, BitVector< Allocator > &out, std::span< const std::size_t > position_ids)
Definition: subset_gate.cpp:207
encrypto::motion::Gate::gate_type_
GateType gate_type_
Definition: gate.h:105
encrypto::motion::SubsetGate::GetOutputAsShare
const SharePointer GetOutputAsShare()
Definition: subset_gate.cpp:397
encrypto::motion::MpcProtocol::kArithmeticConstant
@ kArithmeticConstant
encrypto::motion::SubsetGate::SubsetGate
SubsetGate()=delete
encrypto::motion::Gate::output_wires_
std::vector< WirePointer > output_wires_
Definition: gate.h:100
encrypto::motion::Gate::GetLogger
Logger & GetLogger()
Definition: gate.cpp:100
encrypto::motion::MpcProtocol::kBmr
@ kBmr
encrypto::motion::WirePointer
std::shared_ptr< Wire > WirePointer
Definition: register.h:40
configuration.h
bmr_wire.h
encrypto::motion::OneGate::parent_
std::vector< WirePointer > parent_
Definition: gate.h:155
encrypto::motion::BitVector::Set
void Set(bool value) noexcept
Sets or unsets all bits in the BitVector.
Definition: bit_vector.cpp:440
encrypto::motion::SubsetGate::~SubsetGate
~SubsetGate()=default
encrypto::motion::MpcProtocol::kBooleanConstant
@ kBooleanConstant
encrypto::motion::GateType::kNonInteractive
@ kNonInteractive
encrypto::motion::SubsetGate::EvaluateSetup
void EvaluateSetup() override
Definition: subset_gate.cpp:222
encrypto::motion::BitVector
Class representing a series of bits and providing single bit access.
Definition: bit_vector.h:64
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::CircuitType::kArithmetic
@ kArithmetic
constant_wire.h
encrypto::motion::MpcProtocol::kBooleanGmw
@ kBooleanGmw
bmr_share.h
encrypto::motion::Gate::GetId
std::int64_t GetId() const
Definition: gate.h:95
encrypto::motion::Register::IncrementEvaluatedGatesOnlineCounter
void IncrementEvaluatedGatesOnlineCounter()
Definition: register.cpp:125
constant_share.h
encrypto::motion::SubsetGate::EvaluateOnline
void EvaluateOnline() override
Definition: subset_gate.cpp:286
encrypto::motion::Gate::RegisterWaitingFor
void RegisterWaitingFor(std::size_t wire_id)
Definition: gate.cpp:36
boolean_gmw_wire.h
encrypto::motion::Gate::SetOnlineIsReady
void SetOnlineIsReady()
Definition: gate.cpp:54
encrypto::motion::Gate::backend_
Backend & backend_
Definition: gate.h:101
encrypto::motion::ArithmeticConstantSubsetOnline
void ArithmeticConstantSubsetOnline(WirePointer parent_wire, WirePointer output_wire, std::span< const std::size_t > position_ids)
Definition: subset_gate.cpp:280
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
register.h
logger.h
encrypto::motion
Definition: algorithm_description.cpp:35
arithmetic_gmw_share.h
encrypto::motion::BitVector::GetSize
auto GetSize() const noexcept
Get size of BitVector.
Definition: bit_vector.h:149
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
encrypto::motion::Configuration::GetNumOfParties
std::size_t GetNumOfParties() const
Definition: configuration.h:56
encrypto::motion::Gate
Definition: gate.h:67
encrypto::motion::MpcProtocol
MpcProtocol
Definition: typedefs.h:140
share.h
encrypto::motion::SubsetGate
obtains a subset of SIMD values of a share at provided position ids. Repeated position ids are allowe...
Definition: subset_gate.h:43
gate.h
subset_gate.h
encrypto::motion::MpcProtocol::kArithmeticGmw
@ kArithmeticGmw
encrypto::motion::Gate::WaitSetup
void WaitSetup() const
Definition: gate.cpp:68
encrypto::motion::ArithmeticGmwSubsetOnline
void ArithmeticGmwSubsetOnline(WirePointer parent_wire, WirePointer output_wire, std::span< const std::size_t > position_ids)
Definition: subset_gate.cpp:273
encrypto::motion::Register::RegisterNextWire
void RegisterNextWire(WirePointer wire)
Definition: register.h:78
constants.h
encrypto::motion::kDebug
constexpr bool kDebug
Definition: config.h:36
encrypto::motion::ArithmeticSubsetOnlineImplementation
void ArithmeticSubsetOnlineImplementation(WirePointer parent_wire, WirePointer output_wire, std::span< const std::size_t > position_ids)
Definition: subset_gate.cpp:252
encrypto::motion::proto::ConstantArithmeticWire
Definition: constant_wire.h:33
encrypto::motion::proto::arithmetic_gmw::Wire
Definition: arithmetic_gmw_wire.h:33
boolean_gmw_share.h
encrypto::motion::Gate::GetConfiguration
Configuration & GetConfiguration()
Definition: gate.cpp:98
encrypto::motion::BitVector::Resize
void Resize(std::size_t number_of_bits, bool zero_fill=false) noexcept
Resize BitVector to size number_of_bits. New bits are uninitialized by default.
Definition: bit_vector.cpp:602
encrypto::motion::Register::NextGateId
std::size_t NextGateId() noexcept
Definition: register.cpp:53
arithmetic_gmw_wire.h