MOTION  0.01
Framework for mixed-protocol multi-party computation
share.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 <memory>
28 #include <vector>
29 #include "utility/typedefs.h"
30 
31 namespace encrypto::motion {
32 
33 class Wire; // forward declaration
34 using WirePointer = std::shared_ptr<Wire>;
35 
36 class Backend; // forward declaration
37 using BackendPointer = std::shared_ptr<Backend>;
38 
39 class Register;
40 
41 class Share : public std::enable_shared_from_this<Share> {
42  public:
43  virtual ~Share() = default;
44 
45  virtual std::size_t GetNumberOfSimdValues() const noexcept = 0;
46 
47  virtual MpcProtocol GetProtocol() const noexcept = 0;
48 
49  virtual CircuitType GetCircuitType() const noexcept = 0;
50 
51  virtual std::size_t GetBitLength() const noexcept = 0;
52 
53  virtual const std::vector<WirePointer>& GetWires() const noexcept = 0;
54 
55  virtual std::vector<WirePointer>& GetMutableWires() noexcept = 0;
56 
57  virtual std::vector<std::shared_ptr<Share>> Split() const noexcept = 0;
58 
59  virtual std::shared_ptr<Share> GetWire(std::size_t i) const = 0;
60 
61  Backend& GetBackend() const { return backend_; }
62 
63  std::shared_ptr<Register> GetRegister();
64 
65  Share(Share&) = delete;
66 
67  Share(const Share&) = delete;
68 
69  static std::shared_ptr<Share> Concatenate(const std::vector<std::shared_ptr<Share>>& v);
70 
71  bool IsConstant() const noexcept;
72 
73  protected:
74  Share(Backend& backend) : backend_(backend) {}
75 
77  std::vector<WirePointer> wires_;
78 };
79 
80 using SharePointer = std::shared_ptr<Share>;
81 
82 class BooleanShare : public Share {
83  public:
84  ~BooleanShare() override = default;
85 
86  BooleanShare(BooleanShare&) = delete;
87 
88  protected:
89  BooleanShare(Backend& backend) : Share(backend) {}
90 };
91 
92 using BooleanSharePointer = std::shared_ptr<BooleanShare>;
93 
94 } // namespace encrypto::motion
CheckPartyArgumentSyntax
bool CheckPartyArgumentSyntax(const std::string &party_argument)
Definition: sha256_main.cpp:95
encrypto::motion::AccumulatedCommunicationStatistics::Add
void Add(const communication::TransportStatistics &statistics)
Definition: analysis.cpp:125
analysis.h
party.h
encrypto::motion::AccumulatedRunTimeStatistics
Definition: analysis.h:43
encrypto::motion::CircuitType
CircuitType
Definition: typedefs.h:165
encrypto::motion::MpcProtocol::kBmr
@ kBmr
encrypto::motion::Share::Share
Share(Share &)=delete
encrypto::motion::PartyPointer
std::unique_ptr< Party > PartyPointer
Definition: party.h:387
encrypto::motion::Share::GetBackend
Backend & GetBackend() const
Definition: share.h:61
encrypto::motion::BooleanShare::~BooleanShare
~BooleanShare() override=default
encrypto::motion::WirePointer
std::shared_ptr< Wire > WirePointer
Definition: register.h:40
encrypto::motion::BooleanShare
Definition: share.h:82
sha256.h
CreateParty
encrypto::motion::PartyPointer CreateParty(const program_options::variables_map &user_options)
Definition: sha256_main.cpp:180
encrypto::motion::Share::GetProtocol
virtual MpcProtocol GetProtocol() const noexcept=0
backend.h
encrypto::motion::Share::GetMutableWires
virtual std::vector< WirePointer > & GetMutableWires() noexcept=0
encrypto::motion::BooleanSharePointer
std::shared_ptr< BooleanShare > BooleanSharePointer
Definition: share.h:92
encrypto::motion::Share::IsConstant
bool IsConstant() const noexcept
Definition: share.cpp:33
encrypto::motion::MpcProtocol::kBooleanGmw
@ kBooleanGmw
encrypto::motion::Share::wires_
std::vector< WirePointer > wires_
Definition: share.h:77
ParseProgramOptions
std::pair< program_options::variables_map, bool > ParseProgramOptions(int ac, char *av[])
Definition: sha256_main.cpp:111
encrypto::motion::BackendPointer
std::shared_ptr< Backend > BackendPointer
Definition: backend.h:333
encrypto::motion::communication::TcpSetupHelper
Definition: tcp_transport.h:69
encrypto::motion::Backend
Definition: backend.h:88
main
int main(int ac, char *av[])
Definition: sha256_main.cpp:49
encrypto::motion::Share::Split
virtual std::vector< std::shared_ptr< Share > > Split() const noexcept=0
communication_layer.h
encrypto::motion::Share::Concatenate
static std::shared_ptr< Share > Concatenate(const std::vector< std::shared_ptr< Share >> &v)
encrypto::motion::Backend::GetRegister
const RegisterPointer & GetRegister() const noexcept
Definition: backend.h:101
encrypto::motion::communication::TcpPartiesConfiguration
std::vector< TcpConnectionConfiguration > TcpPartiesConfiguration
Definition: tcp_transport.h:62
encrypto::motion
Definition: algorithm_description.cpp:35
encrypto::motion::SharePointer
std::shared_ptr< Share > SharePointer
Definition: conversion_gate.h:49
geninput.help
help
Definition: geninput.py:150
encrypto::motion::Share::backend_
Backend & backend_
Definition: share.h:76
encrypto::motion::Share::GetCircuitType
virtual CircuitType GetCircuitType() const noexcept=0
encrypto::motion::BooleanShare::BooleanShare
BooleanShare(Backend &backend)
Definition: share.h:89
encrypto::motion::Share::GetRegister
std::shared_ptr< Register > GetRegister()
Definition: share.cpp:31
encrypto::motion::PrintStatistics
std::string PrintStatistics(const std::string &experiment_name, const AccumulatedRunTimeStatistics &execution_statistics, const AccumulatedCommunicationStatistics &communication_statistics)
Definition: analysis.cpp:176
EvaluateProtocol
encrypto::motion::RunTimeStatistics EvaluateProtocol(encrypto::motion::PartyPointer &party, std::size_t number_of_simd, encrypto::motion::MpcProtocol protocol, bool check)
Definition: aes128.cpp:56
typedefs.h
encrypto::motion::MpcProtocol
MpcProtocol
Definition: typedefs.h:140
encrypto::motion::BooleanShare::BooleanShare
BooleanShare(BooleanShare &)=delete
share.h
encrypto::motion::Share::GetWire
virtual std::shared_ptr< Share > GetWire(std::size_t i) const =0
encrypto::motion::Share::GetWires
virtual const std::vector< WirePointer > & GetWires() const noexcept=0
encrypto::motion::Share::~Share
virtual ~Share()=default
encrypto::motion::Share::GetNumberOfSimdValues
virtual std::size_t GetNumberOfSimdValues() const noexcept=0
encrypto::motion::Share
Definition: share.h:41
tcp_transport.h
encrypto::motion::Share::GetBitLength
virtual std::size_t GetBitLength() const noexcept=0
encrypto::motion::AccumulatedCommunicationStatistics
Definition: analysis.h:65
kPartyArgumentRegex
const std::regex kPartyArgumentRegex("(\\d+),(\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}),(\\d{1,5})")
encrypto::motion::AccumulatedRunTimeStatistics::Add
void Add(const RunTimeStatistics &statistics)
Definition: analysis.cpp:43
encrypto::motion::communication::TcpSetupHelper::SetupConnections
std::vector< std::unique_ptr< Transport > > SetupConnections()
Definition: tcp_transport.cpp:203
ParsePartyArgument
std::tuple< std::size_t, std::string, std::uint16_t > ParsePartyArgument(const std::string &party_argument)
Definition: sha256_main.cpp:100