MOTION  0.01
Framework for mixed-protocol multi-party computation
bmr_data.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 <cstddef>
28 #include <memory>
29 #include <unordered_map>
30 #include <utility>
31 #include "utility/bit_vector.h"
32 #include "utility/block.h"
34 
36 
37 class Condition;
38 
39 enum DataType : unsigned int { kInputStep0 = 0, kInputStep1 = 1, kAndGate = 2 };
40 
41 struct Data {
42  void MessageReceived(const std::uint8_t* message, const DataType type, const std::size_t i);
43  void Reset();
44 
46  std::size_t bitlength);
48  std::size_t number_of_blocks);
50  std::size_t number_of_blocks);
51 
52  // gate_id -> bit size X promise with public values
53  using InputPublicValueType = std::pair<std::size_t, ReusableFiberPromise<BitVector<>>>;
54  std::unordered_map<std::size_t, InputPublicValueType> input_public_value_promises_;
55 
56  // gate_id -> block size X promise with keys
57  using KeysType = std::pair<std::size_t, ReusableFiberPromise<Block128Vector>>;
58  std::unordered_map<std::size_t, KeysType> input_public_key_promises_;
59 
60  // gate_id -> block size X promise with partial garbled rows
61  using GarbledRowsType = std::pair<std::size_t, ReusableFiberPromise<Block128Vector>>;
62  std::unordered_map<std::size_t, GarbledRowsType> garbled_rows_promises_;
63 };
64 
65 } // namespace encrypto::motion::proto::bmr
condition.h
encrypto::motion::proto::bmr::Data::GarbledRowsType
std::pair< std::size_t, ReusableFiberPromise< Block128Vector > > GarbledRowsType
Definition: bmr_data.h:61
encrypto::motion::ReusableFuture
Definition: reusable_future.h:129
encrypto::motion::proto::bmr::Data::KeysType
std::pair< std::size_t, ReusableFiberPromise< Block128Vector > > KeysType
Definition: bmr_data.h:57
encrypto::motion::proto::bmr::Data::input_public_value_promises_
std::unordered_map< std::size_t, InputPublicValueType > input_public_value_promises_
Definition: bmr_data.h:54
reusable_future.h
bit_vector.h
geninput.type
type
Definition: geninput.py:149
encrypto::motion::ReusablePromise::get_future
ReusableFuture< R, MutexType, ConditionVariableType > get_future()
Definition: reusable_future.h:242
encrypto::motion::proto::bmr::Data::InputPublicValueType
std::pair< std::size_t, ReusableFiberPromise< BitVector<> >> InputPublicValueType
Definition: bmr_data.h:53
encrypto::motion::Block128Vector
Vector of 128 bit / 16 B blocks.
Definition: block.h:168
block.h
encrypto::motion::proto::bmr::Data::MessageReceived
void MessageReceived(const std::uint8_t *message, const DataType type, const std::size_t i)
Definition: bmr_data.cpp:30
encrypto::motion::BitVector<>
encrypto::motion::proto::bmr::DataType
DataType
Definition: bmr_data.h:39
encrypto::motion::proto::bmr
Definition: backend.h:50
encrypto::motion::proto::bmr::Data::RegisterForInputPublicKeys
ReusableFiberFuture< Block128Vector > RegisterForInputPublicKeys(std::size_t gate_id, std::size_t number_of_blocks)
Definition: bmr_data.cpp:79
encrypto::motion::proto::bmr::Data::RegisterForInputPublicValues
ReusableFiberFuture< BitVector<> > RegisterForInputPublicValues(std::size_t gate_id, std::size_t bitlength)
Definition: bmr_data.cpp:65
encrypto::motion::proto::bmr::Data::RegisterForGarbledRows
ReusableFiberFuture< Block128Vector > RegisterForGarbledRows(std::size_t gate_id, std::size_t number_of_blocks)
Definition: bmr_data.cpp:93
encrypto::motion::proto::bmr::kInputStep0
@ kInputStep0
Definition: bmr_data.h:39
encrypto::motion::proto::bmr::Data::input_public_key_promises_
std::unordered_map< std::size_t, KeysType > input_public_key_promises_
Definition: bmr_data.h:58
encrypto::motion::proto::bmr::Data::Reset
void Reset()
Definition: bmr_data.cpp:59
encrypto::motion::proto::bmr::Data
Definition: bmr_data.h:41
encrypto::motion::proto::bmr::kAndGate
@ kAndGate
Definition: bmr_data.h:39
encrypto::motion::ReusablePromise
Definition: reusable_future.h:123
encrypto::motion::proto::bmr::kInputStep1
@ kInputStep1
Definition: bmr_data.h:39
encrypto::motion::proto::bmr::Data::garbled_rows_promises_
std::unordered_map< std::size_t, GarbledRowsType > garbled_rows_promises_
Definition: bmr_data.h:62
bmr_data.h