MOTION  0.01
Framework for mixed-protocol multi-party computation
constants.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 <iostream>
28 #include <limits>
29 #include <string>
30 
31 #include "config.h"
32 #include "typedefs.h"
33 
34 namespace encrypto::motion {
35 
36 // just in case if we all of a sudden will decide to change the name
37 constexpr std::string_view kFrameworkName{"MOTION"};
38 
39 // abbreviation for megabytes
40 constexpr std::size_t kMb{1024 * 1024};
41 
42 // Verbose debug flag. If kDebug equals false, this flag will always be interpreted as false.
43 // Verbose means here that MOTION will log virtually everything: not only the performed actions but
44 // also the sent and received messages. One may need this, e.g., for debugging correctness of the
45 // protocols to better understand what went wrong. This may be _very_ slow and need a lot of storage
46 // for logs! So try to keep the code small if you need this flag for debugging.
47 constexpr bool kVerboseDebugWish{false};
48 
49 // Don't compile unnecessary code if verbose debugging is not needed
51 
52 constexpr std::size_t kAesKeySize{16};
53 
54 constexpr std::size_t kAesBlockSize{16};
55 
56 constexpr std::size_t kAesIvSize{kAesBlockSize / 2};
57 
58 constexpr std::size_t kMessageSizeBytelen{sizeof(std::uint32_t)};
59 
60 // the maximum allowed message size in flatbuffers
61 // 2^31, approx. 2 GB
62 constexpr std::uint32_t kMaxMessageSize{std::numeric_limits<std::uint32_t>::max() / 2};
63 
64 // symmetric security parameter
65 constexpr std::size_t kKappa{128};
66 
67 // stack size for fibers
68 // Increase the fiber stack size when in debug mode because it requires storing additional debugging
69 // information, which, however, would be an unnecessary memory overhead when built in release mode,
70 // thus increase the fiber stack size only in debug mode
71 constexpr std::size_t kFiberStackSize = kDebug ? 32 * 1024 : 14 * 1024;
72 
73 enum class FiberStackAllocator {
74  // standard allocator
75  kFixedSize,
76  // allocate the stacks from a memory pool
78  // use an allocator for fiber stacks that inserts a guard page at the end of
79  // the stack space resulting in a SIGSEGV if a stack overflow happens
81 };
82 
83 // standard allocator for fiber stacks
85 
86 } // namespace encrypto::motion
encrypto::motion::kMaxMessageSize
constexpr std::uint32_t kMaxMessageSize
Definition: constants.h:62
encrypto::motion::kAesBlockSize
constexpr std::size_t kAesBlockSize
Definition: constants.h:54
encrypto::motion::kAesIvSize
constexpr std::size_t kAesIvSize
Definition: constants.h:56
encrypto::motion::kAesKeySize
constexpr std::size_t kAesKeySize
Definition: constants.h:52
encrypto::motion::kVerboseDebugWish
constexpr bool kVerboseDebugWish
Definition: constants.h:47
encrypto::motion::FiberStackAllocator
FiberStackAllocator
Definition: constants.h:73
encrypto::motion::kFiberStackAllocator
constexpr FiberStackAllocator kFiberStackAllocator
Definition: constants.h:84
encrypto::motion::FiberStackAllocator::kFixedSize
@ kFixedSize
config.h
encrypto::motion::kKappa
constexpr std::size_t kKappa
Definition: constants.h:65
encrypto::motion::kFrameworkName
constexpr std::string_view kFrameworkName
Definition: constants.h:37
encrypto::motion
Definition: algorithm_description.cpp:35
encrypto::motion::FiberStackAllocator::kPooledFixedSize
@ kPooledFixedSize
typedefs.h
encrypto::motion::FiberStackAllocator::kProtectedFixedSize
@ kProtectedFixedSize
encrypto::motion::kFiberStackSize
constexpr std::size_t kFiberStackSize
Definition: constants.h:71
encrypto::motion::kVerboseDebug
constexpr bool kVerboseDebug
Definition: constants.h:50
encrypto::motion::kDebug
constexpr bool kDebug
Definition: config.h:36
encrypto::motion::kMb
constexpr std::size_t kMb
Definition: constants.h:40
encrypto::motion::kMessageSizeBytelen
constexpr std::size_t kMessageSizeBytelen
Definition: constants.h:58