MOTION  0.01
Framework for mixed-protocol multi-party computation
algorithm_description.h
Go to the documentation of this file.
1 // MIT License
2 //
3 // Copyright (c) 2019 Oleksandr Tkachenko, Lennart Braun
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 <cassert>
28 #include <optional>
29 #include <vector>
30 
31 #include "utility/typedefs.h"
32 
33 namespace encrypto::motion {
34 
37  std::size_t parent_a{0};
38  std::optional<std::size_t> parent_b{std::nullopt};
39  std::optional<std::size_t> selection_bit{std::nullopt};
40  std::size_t output_wire{0};
41 };
42 
44  AlgorithmDescription() = default;
45 
46  static AlgorithmDescription FromBristol(const std::string& path);
47 
48  static AlgorithmDescription FromBristol(std::string&& path);
49 
50  static AlgorithmDescription FromBristol(std::ifstream& stream);
51 
52  static AlgorithmDescription FromBristolFashion(const std::string& path);
53 
54  static AlgorithmDescription FromBristolFashion(std::string&& path);
55 
56  static AlgorithmDescription FromBristolFashion(std::ifstream& stream);
57 
58  static AlgorithmDescription FromAby(const std::string& path);
59 
60  static AlgorithmDescription FromAby(std::string&& path);
61 
62  static AlgorithmDescription FromAby(std::ifstream& stream);
63 
66  std::optional<std::size_t> number_of_input_wires_parent_b{std::nullopt};
67  std::vector<PrimitiveOperation> gates;
68 };
69 
70 } // namespace encrypto::motion
to_string
std::string to_string(Provider p)
Definition: benchmark_providers.h:44
encrypto::motion::PrimitiveOperationType::kOr
@ kOr
encrypto::motion::AlgorithmDescription::number_of_wires
std::size_t number_of_wires
Definition: algorithm_description.h:64
encrypto::motion::PrimitiveOperationType::kMux
@ kMux
encrypto::motion::AlgorithmDescription::FromBristolFashion
static AlgorithmDescription FromBristolFashion(const std::string &path)
Definition: algorithm_description.cpp:149
encrypto::motion::PrimitiveOperation
Definition: algorithm_description.h:35
encrypto::motion::PrimitiveOperation::output_wire
std::size_t output_wire
Definition: algorithm_description.h:40
encrypto::motion::PrimitiveOperation::selection_bit
std::optional< std::size_t > selection_bit
Definition: algorithm_description.h:39
geninput.type
type
Definition: geninput.py:149
encrypto::motion::AlgorithmDescription::AlgorithmDescription
AlgorithmDescription()=default
algorithm_description.h
encrypto::motion::PrimitiveOperationType::kInv
@ kInv
encrypto::motion::PrimitiveOperationType::kXor
@ kXor
encrypto::motion::PrimitiveOperationType::kAnd
@ kAnd
encrypto::motion::AlgorithmDescription::gates
std::vector< PrimitiveOperation > gates
Definition: algorithm_description.h:67
encrypto::motion::PrimitiveOperation::type
PrimitiveOperationType type
Definition: algorithm_description.h:36
encrypto::motion::AlgorithmDescription::number_of_output_wires
std::size_t number_of_output_wires
Definition: algorithm_description.h:64
encrypto::motion::PrimitiveOperationType::kAdd
@ kAdd
encrypto::motion::AlgorithmDescription::number_of_gates
std::size_t number_of_gates
Definition: algorithm_description.h:65
encrypto::motion::AlgorithmDescription
Definition: algorithm_description.h:43
encrypto::motion
Definition: algorithm_description.cpp:35
encrypto::motion::PrimitiveOperationType
PrimitiveOperationType
Definition: typedefs.h:37
encrypto::motion::PrimitiveOperationType::kInvalid
@ kInvalid
encrypto::motion::AlgorithmDescription::FromAby
static AlgorithmDescription FromAby(const std::string &path)
Definition: algorithm_description.cpp:274
typedefs.h
encrypto::motion::AlgorithmDescription::FromBristol
static AlgorithmDescription FromBristol(const std::string &path)
Definition: algorithm_description.cpp:37
encrypto::motion::AlgorithmDescription::number_of_input_wires_parent_b
std::optional< std::size_t > number_of_input_wires_parent_b
Definition: algorithm_description.h:66
encrypto::motion::PrimitiveOperationType::kMul
@ kMul
encrypto::motion::PrimitiveOperation::parent_a
std::size_t parent_a
Definition: algorithm_description.h:37
encrypto::motion::PrimitiveOperation::parent_b
std::optional< std::size_t > parent_b
Definition: algorithm_description.h:38
encrypto::motion::AlgorithmDescription::number_of_input_wires_parent_a
std::size_t number_of_input_wires_parent_a
Definition: algorithm_description.h:64