MOTION  0.01
Framework for mixed-protocol multi-party computation
ot_flavors.h
Go to the documentation of this file.
1 // MIT License
2 //
3 // Copyright (c) 2019 Lennart Braun
4 //
5 // Permission is hereby granted, free of charge, to any person obtaining a copy
6 // of this software and associated documentation files (the "Software"), to deal
7 // in the Software without restriction, including without limitation the rights
8 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 // copies of the Software, and to permit persons to whom the Software is
10 // furnished to do so, subject to the following conditions:
11 //
12 // The above copyright notice and this permission notice shall be included in all
13 // copies or substantial portions of the Software.
14 //
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 // SOFTWARE.
22 
23 #pragma once
24 
25 #include "ot_provider.h"
26 
27 #include <span>
28 
29 #include "utility/bit_vector.h"
30 #include "utility/block.h"
32 #include "utility/type_traits.h"
33 
34 namespace encrypto::motion {
35 
36 // base class capturing the common things among the sender implementations
37 class BasicOtSender : public OtVector {
38  public:
39  // wait that the ot extension setup has finished
40  void WaitSetup() const;
41 
42  protected:
43  BasicOtSender(std::size_t ot_id, std::size_t number_of_ots, std::size_t bitlength, OtProtocol p,
44  const std::function<void(flatbuffers::FlatBufferBuilder&&)>& send_function,
45  OtExtensionSenderData& data);
46 
47  // reference to data storage
49 };
50 
51 // base class capturing the common things among the receiver implementations
52 class BasicOtReceiver : public OtVector {
53  public:
54  // wait that the ot extension setup has finished
55  void WaitSetup() const;
56 
57  // set the receiver's inputs, the choices
58  void SetChoices(BitVector<>&& choices) { choices_ = std::move(choices); }
60 
61  // get the receiver's inputs, the choices
62  const BitVector<>& GetChoices() const { return choices_; }
63 
64  // check if the choices are already set
65  bool AreChoicesSet() const { return !choices_.Empty(); }
66 
67  // send the correction in the online phase
68  void SendCorrections();
69 
70  protected:
71  BasicOtReceiver(std::size_t ot_id, std::size_t number_of_ots, std::size_t bitlength, OtProtocol p,
72  const std::function<void(flatbuffers::FlatBufferBuilder&&)>& Send,
74 
75  // reference to data storage
77 
78  // input of the receiver, the choices
80 
81  // if the corrections have been transmitted
82  bool corrections_sent_ = false;
83 };
84 
85 // sender implementation of batched xor-correlated bit ots
86 class ROtSender : public OtVector {
87  public:
88  ROtSender(std::size_t ot_id, std::size_t number_of_ots, std::size_t bitlength,
90  const std::function<void(flatbuffers::FlatBufferBuilder&&)>& send_function);
91 
92  // wait that the ot extension setup has finished
93  void WaitSetup() const;
94 
95  // compute the sender's outputs
96  void ComputeOutputs();
97 
98  // get the sender's outputs
99  std::span<const BitVector<>> GetOutputs() const {
100  assert(outputs_computed_);
101  return outputs_;
102  }
103 
104  // send the sender's messages
105  void SendMessages() const;
106 
107  private:
108  // reference to data storage
109  OtExtensionSenderData& data_;
110 
111  // both output masks of the sender
112  std::vector<BitVector<>> outputs_;
113 
114  // if the sender outputs have been computed
115  bool outputs_computed_ = false;
116 };
117 
118 // sender implementation of batched xor-correlated 128 bit string OT with a
119 // fixed correlation for all OTs
121  public:
122  FixedXcOt128Sender(std::size_t ot_id, std::size_t number_of_ots, OtExtensionSenderData& data,
123  const std::function<void(flatbuffers::FlatBufferBuilder&&)>& send_function);
124 
125  // set the *single* correlation for all OTs in this batch
126  void SetCorrelation(Block128 correlation) { correlation_ = correlation; }
127 
128  // compute the sender's outputs
129  void ComputeOutputs();
130 
131  // get the sender's outputs
133  assert(outputs_computed_);
134  return outputs_;
135  }
136 
137  // send the sender's messages
138  void SendMessages() const;
139 
140  private:
141  // the correlation function is f(x) = x ^ correlation_ for all OTs
142  Block128 correlation_;
143 
144  // the "0 output" for the sender (the "1 output" can be computed by applying the correlation)
145  Block128Vector outputs_;
146 
147  // if the sender outputs have been computed
148  bool outputs_computed_ = false;
149 };
150 
151 // receiver implementation of batched xor-correlated 128 bit string OT with a
152 // fixed correlation for all OTs
154  public:
155  FixedXcOt128Receiver(std::size_t ot_id, std::size_t number_of_ots, OtExtensionReceiverData& data,
156  const std::function<void(flatbuffers::FlatBufferBuilder&&)>& send_function);
157 
158  // compute the receiver's outputs
159  void ComputeOutputs();
160 
161  // get the receiver's outputs
162  const Block128Vector& GetOutputs() const {
163  assert(outputs_computed_);
164  return outputs_;
165  }
166 
167  private:
168  // future for the sender's message
169  ReusableFiberFuture<Block128Vector> sender_message_future_;
170 
171  // the output for the receiver
172  Block128Vector outputs_;
173 
174  // if the sender outputs have been computed
175  bool outputs_computed_ = false;
176 };
177 
178 // sender implementation of batched xor-correlated bit ots
179 class XcOtBitSender : public BasicOtSender {
180  public:
181  XcOtBitSender(std::size_t ot_id, std::size_t number_of_ots, OtExtensionSenderData& data,
182  const std::function<void(flatbuffers::FlatBufferBuilder&&)>& send_function);
183 
184  // set the correlations for the OTs in this batch
185  void SetCorrelations(BitVector<>&& correlations) {
186  assert(correlations.GetSize() == number_of_ots_);
187  correlations_ = std::move(correlations);
188  }
189  void SetCorrelations(const BitVector<>& correlations) {
190  assert(correlations.GetSize() == number_of_ots_);
191  correlations_ = correlations;
192  }
193 
194  // get the correlations for the OTs in this batch
195  const BitVector<>& GetCorrelations() const { return correlations_; }
196 
197  // compute the sender's outputs
198  void ComputeOutputs();
199 
200  // get the sender's outputs
202  assert(outputs_computed_);
203  return outputs_;
204  }
205 
206  // send the sender's messages
207  void SendMessages() const;
208 
209  private:
210  // the correlation vector
211  BitVector<> correlations_;
212 
213  // the "0 output" for the sender (the "1 output" can be computed by applying the correlation)
214  BitVector<> outputs_;
215 
216  // if the sender outputs have been computed
217  bool outputs_computed_ = false;
218 };
219 
220 // sender implementation of batched xor-correlated bit ots
221 class XcOtSender : public BasicOtSender {
222  public:
223  XcOtSender(std::size_t ot_id, std::size_t number_of_ots, std::size_t bitlength,
224  OtExtensionSenderData& data,
225  const std::function<void(flatbuffers::FlatBufferBuilder&&)>& send_function);
226 
227  // set the correlations for the OTs in this batch
228  void SetCorrelations(std::vector<BitVector<>>&& correlations) {
229  assert(correlations.size() == number_of_ots_);
230  correlations_ = std::move(correlations);
231  }
232  void SetCorrelations(std::span<const BitVector<>> correlations) {
233  assert(correlations.size() == number_of_ots_);
234  correlations_.assign(correlations.begin(), correlations.end());
235  }
236 
237  // get the correlations for the OTs in this batch
238  std::span<const BitVector<>> GetCorrelations() const { return correlations_; }
239 
240  // compute the sender's outputs
241  void ComputeOutputs();
242 
243  // get the sender's outputs
244  std::span<const BitVector<>> GetOutputs() const {
245  assert(outputs_computed_);
246  return outputs_;
247  }
248 
249  // send the sender's messages
250  void SendMessages() const;
251 
252  private:
253  // the correlation vector
254  std::vector<BitVector<>> correlations_;
255 
256  // the "0 output" for the sender (the "1 output" can be computed by applying the correlation)
257  std::vector<BitVector<>> outputs_;
258 
259  // if the sender outputs have been computed
260  bool outputs_computed_ = false;
261 };
262 
263 // receiver implementation of batched random generic ots
265  public:
266  ROtReceiver(std::size_t ot_id, std::size_t number_of_ots, std::size_t bitlength,
268  const std::function<void(flatbuffers::FlatBufferBuilder&&)>& send_function);
269 
270  // wait that the ot extension setup has finished
271  void WaitSetup() const;
272 
273  // compute the receiver's outputs
274  void ComputeOutputs();
275 
276  // get the receiver's outputs
277  std::span<const BitVector<>> GetOutputs() {
278  assert(outputs_computed_);
279  return outputs_;
280  }
281 
283  assert(outputs_computed_);
284  return choices_;
285  }
286 
287  private:
288  // reference to data storage
290 
291  // random message choices
292  BitVector<> choices_;
293 
294  // the output for the receiver
295  std::vector<BitVector<>> outputs_;
296 
297  // if the sender outputs have been computed
298  bool outputs_computed_ = false;
299 };
300 
301 // receiver implementation of batched xor-correlated bit ots
303  public:
304  XcOtBitReceiver(std::size_t ot_id, std::size_t number_of_ots, OtExtensionReceiverData& data,
305  const std::function<void(flatbuffers::FlatBufferBuilder&&)>& send_function);
306 
307  // compute the receiver's outputs
308  void ComputeOutputs();
309 
310  // get the receiver's outputs
312  assert(outputs_computed_);
313  return outputs_;
314  }
315 
316  private:
317  // future for the sender's message
318  ReusableFiberFuture<BitVector<>> sender_message_future_;
319 
320  // the output for the receiver
321  BitVector<> outputs_;
322 
323  // if the sender outputs have been computed
324  bool outputs_computed_ = false;
325 };
326 
327 // receiver implementation of batched xor-correlated generic ots
329  public:
330  XcOtReceiver(std::size_t ot_id, std::size_t number_of_ots, std::size_t bitlength,
332  const std::function<void(flatbuffers::FlatBufferBuilder&&)>& send_function);
333 
334  // compute the receiver's outputs
335  void ComputeOutputs();
336 
337  // get the receiver's outputs
338  std::span<const BitVector<>> GetOutputs() {
339  assert(outputs_computed_);
340  return outputs_;
341  }
342 
343  private:
344  // future for the sender's message
345  ReusableFiberFuture<std::vector<BitVector<>>> sender_message_future_;
346 
347  // the output for the receiver
348  std::vector<BitVector<>> outputs_;
349 
350  // if the sender outputs have been computed
351  bool outputs_computed_ = false;
352 };
353 
354 // sender implementation of batched additive-correlated ots
355 template <typename T> //, typename U = IsUnsignedInt<T>>
356 class AcOtSender : public BasicOtSender {
357  using IsUnsignedEnablerType = IsUnsignedInt<T>;
358 
359  public:
360  AcOtSender(std::size_t ot_id, std::size_t number_of_ots, std::size_t vector_size,
361  OtExtensionSenderData& data,
362  const std::function<void(flatbuffers::FlatBufferBuilder&&)>& send_function);
363 
364  // set the correlations for the OTs in this batch
365  void SetCorrelations(std::vector<T>&& correlations) {
366  assert(correlations.size() == number_of_ots_ * vector_size_);
367  correlations_ = std::move(correlations);
368  }
369  void SetCorrelations(const std::vector<T>& correlations) {
370  assert(correlations.size() == number_of_ots_ * vector_size_);
371  correlations_ = correlations;
372  }
373 
374  // get the correlations for the OTs in this batch
375  const std::vector<T>& GetCorrelations() const { return correlations_; }
376 
377  // compute the sender's outputs
378  void ComputeOutputs();
379 
380  // get the sender's outputs
381  std::vector<T>& GetOutputs() {
382  assert(outputs_computed_);
383  return outputs_;
384  }
385 
386  // send the sender's messages
387  void SendMessages() const;
388 
389  private:
390  // dimension of each sender-input/output
391  const std::size_t vector_size_;
392 
393  // the correlation vector
394  std::vector<T> correlations_;
395 
396  // the "0 output" for the sender (the "1 output" can be computed by applying the correlation)
397  std::vector<T> outputs_;
398 
399  // if the sender outputs have been computed
400  bool outputs_computed_ = false;
401 };
402 
403 // receiver implementation of batched additive-correlated ots
404 template <typename T> //, typename = IsUnsignedInt<T>>
406  using IsUnsignedEnablerType = IsUnsignedInt<T>;
407 
408  public:
409  AcOtReceiver(std::size_t ot_id, std::size_t number_of_ots, std::size_t vector_size,
411  const std::function<void(flatbuffers::FlatBufferBuilder&&)>& send_function);
412 
413  // compute the receiver's outputs
414  void ComputeOutputs();
415 
416  // get the receiver's outputs
417  std::vector<T>& GetOutputs() {
418  assert(outputs_computed_);
419  return outputs_;
420  }
421 
422  private:
423  // dimension of each sender-input/output
424  const std::size_t vector_size_;
425 
426  // future for the sender's message
427  ReusableFiberFuture<std::vector<T>> sender_message_future_;
428 
429  // the output for the receiver
430  std::vector<T> outputs_;
431 
432  // if the sender outputs have been computed
433  bool outputs_computed_ = false;
434 };
435 
436 // sender implementation of batched 128 bit string OT
437 class GOt128Sender : public BasicOtSender {
438  public:
439  GOt128Sender(std::size_t ot_id, std::size_t number_of_ots, OtExtensionSenderData& data,
440  const std::function<void(flatbuffers::FlatBufferBuilder&&)>& send_function);
441 
442  // set the message pairs for all OTs in this batch
443  void SetInputs(Block128Vector&& inputs) { inputs_ = std::move(inputs); }
444  void SetInputs(const Block128Vector& inputs) { inputs_ = inputs; }
445 
446  // send the sender's messages
447  void SendMessages() const;
448 
449  private:
450  // the sender's inputs, 2 * number_of_ots blocks
451  Block128Vector inputs_;
452 };
453 
454 // receiver implementation of batched 128 bit string OT
456  public:
457  GOt128Receiver(std::size_t ot_id, std::size_t number_of_ots, OtExtensionReceiverData& data,
458  const std::function<void(flatbuffers::FlatBufferBuilder&&)>& send_function);
459 
460  // compute the receiver's outputs
461  void ComputeOutputs();
462 
463  // get the receiver's outputs
464  const Block128Vector& GetOutputs() const {
465  assert(outputs_computed_);
466  return outputs_;
467  }
468 
469  private:
470  // future for the sender's message
471  ReusableFiberFuture<Block128Vector> sender_message_future_;
472 
473  // the output for the receiver
474  Block128Vector outputs_;
475 
476  // if the sender outputs have been computed
477  bool outputs_computed_ = false;
478 };
479 
480 // sender implementation of batched 1 bit string OT
481 class GOtBitSender : public BasicOtSender {
482  public:
483  GOtBitSender(std::size_t ot_id, std::size_t number_of_ots, OtExtensionSenderData& data,
484  const std::function<void(flatbuffers::FlatBufferBuilder&&)>& send_function);
485 
486  // set the message pairs for all OTs in this batch
487  void SetInputs(BitVector<>&& inputs) { inputs_ = std::move(inputs); }
488  void SetInputs(const BitVector<>& inputs) { inputs_ = inputs; }
489 
490  // send the sender's messages
491  void SendMessages() const;
492 
493  private:
494  // the sender's inputs, 2 * number_of_ots blocks
495  BitVector<> inputs_;
496 };
497 
498 // sender implementation of batched 1 bit string OT
499 class GOtSender : public BasicOtSender {
500  public:
501  GOtSender(std::size_t ot_id, std::size_t number_of_ots, std::size_t bitlength,
502  OtExtensionSenderData& data,
503  const std::function<void(flatbuffers::FlatBufferBuilder&&)>& send_function);
504 
505  // set the message pairs for all OTs in this batch
506  void SetInputs(std::vector<BitVector<>>&& inputs) { inputs_ = std::move(inputs); }
507  void SetInputs(const std::span<BitVector<>> inputs) {
508  inputs_.assign(inputs.begin(), inputs.end());
509  }
510 
511  // send the sender's messages
512  void SendMessages() const;
513 
514  private:
515  // the sender's inputs, 2 * number_of_ots blocks
516  std::vector<BitVector<>> inputs_;
517 };
518 
519 // receiver implementation of batched 1 bit string OT
521  public:
522  GOtBitReceiver(std::size_t ot_id, std::size_t number_of_ots, OtExtensionReceiverData& data,
523  const std::function<void(flatbuffers::FlatBufferBuilder&&)>& send_function);
524 
525  // compute the receiver's outputs
526  void ComputeOutputs();
527 
528  // get the receiver's outputs
529  const BitVector<>& GetOutputs() const {
530  assert(outputs_computed_);
531  return outputs_;
532  }
533 
534  private:
535  // future for the sender's message
536  ReusableFiberFuture<BitVector<>> sender_message_future_;
537 
538  // the output for the receiver
539  BitVector<> outputs_;
540 
541  // if the sender outputs have been computed
542  bool outputs_computed_ = false;
543 };
544 
545 // receiver implementation of batched arbitrary-size bit string OT
546 class GOtReceiver : public BasicOtReceiver {
547  public:
548  GOtReceiver(std::size_t ot_id, std::size_t number_of_ots, std::size_t bitlength,
550  const std::function<void(flatbuffers::FlatBufferBuilder&&)>& send_function);
551 
552  // compute the receiver's outputs
553  void ComputeOutputs();
554 
555  // get the receiver's outputs
556  const std::span<const BitVector<>> GetOutputs() const {
557  assert(outputs_computed_);
558  return outputs_;
559  }
560 
561  private:
562  // future for the sender's message
563  ReusableFiberFuture<std::vector<BitVector<>>> sender_message_future_;
564 
565  // the output for the receiver
566  std::vector<BitVector<>> outputs_;
567 
568  // if the sender outputs have been computed
569  bool outputs_computed_ = false;
570 };
571 
572 } // namespace encrypto::motion
encrypto::motion::OtExtensionReceiverData::RegisterForBlock128SenderMessage
ReusableFiberFuture< Block128Vector > RegisterForBlock128SenderMessage(std::size_t ot_id, std::size_t size)
Definition: ot_extension_data.cpp:183
encrypto::motion::Block128Vector::resize
void resize(std::size_t new_size)
Resize the Block128Vector to contain new_size elements. New elements are left uninitialized.
Definition: block.h:233
encrypto::motion::XcOtBitSender::SetCorrelations
void SetCorrelations(BitVector<> &&correlations)
Definition: ot_flavors.h:185
encrypto::motion::ROtSender::WaitSetup
void WaitSetup() const
Definition: ot_flavors.cpp:93
encrypto::motion::IsUnsignedInt
std::enable_if_t< std::conjunction_v< std::is_integral< T >, std::is_unsigned< T >, std::negation< std::is_same< T, bool > >> > IsUnsignedInt
Definition: type_traits.h:31
encrypto::motion::BasicOtReceiver::data_
OtExtensionReceiverData & data_
Definition: ot_flavors.h:76
encrypto::motion::XcOtReceiver::XcOtReceiver
XcOtReceiver(std::size_t ot_id, std::size_t number_of_ots, std::size_t bitlength, OtExtensionReceiverData &data, const std::function< void(flatbuffers::FlatBufferBuilder &&)> &send_function)
Definition: ot_flavors.cpp:212
encrypto::motion::FixedXcOt128Sender::FixedXcOt128Sender
FixedXcOt128Sender(std::size_t ot_id, std::size_t number_of_ots, OtExtensionSenderData &data, const std::function< void(flatbuffers::FlatBufferBuilder &&)> &send_function)
Definition: ot_flavors.cpp:246
encrypto::motion::GOtBitSender::SetInputs
void SetInputs(BitVector<> &&inputs)
Definition: ot_flavors.h:487
encrypto::motion::XcOtSender::ComputeOutputs
void ComputeOutputs()
Definition: ot_flavors.cpp:158
encrypto::motion::OtExtensionSenderData::received_correction_offsets_condition
std::unordered_map< std::size_t, std::unique_ptr< FiberCondition > > received_correction_offsets_condition
Definition: ot_extension_data.h:158
encrypto::motion::ROtSender
Definition: ot_flavors.h:86
type_traits.h
encrypto::motion::FixedXcOt128Receiver::ComputeOutputs
void ComputeOutputs()
Definition: ot_flavors.cpp:311
encrypto::motion::OtMessageType::kBit
@ kBit
ot_extension_message.h
encrypto::motion::GOtReceiver::GetOutputs
const std::span< const BitVector<> > GetOutputs() const
Definition: ot_flavors.h:556
encrypto::motion::OtVector::send_function_
std::function< void(flatbuffers::FlatBufferBuilder &&)> send_function_
Definition: ot_provider.h:97
encrypto::motion::ROtSender::GetOutputs
std::span< const BitVector<> > GetOutputs() const
Definition: ot_flavors.h:99
encrypto::motion::XcOtBitSender::SetCorrelations
void SetCorrelations(const BitVector<> &correlations)
Definition: ot_flavors.h:189
encrypto::motion::OtExtensionSenderData::number_of_ots_in_batch
std::unordered_map< std::size_t, std::size_t > number_of_ots_in_batch
Definition: ot_extension_data.h:152
encrypto::motion::GOtBitSender::SendMessages
void SendMessages() const
Definition: ot_flavors.cpp:643
encrypto::motion::BasicOtReceiver::WaitSetup
void WaitSetup() const
Definition: ot_flavors.cpp:65
encrypto::motion::GOt128Receiver
Definition: ot_flavors.h:455
encrypto::motion::GOt128Receiver::GOt128Receiver
GOt128Receiver(std::size_t ot_id, std::size_t number_of_ots, OtExtensionReceiverData &data, const std::function< void(flatbuffers::FlatBufferBuilder &&)> &send_function)
Definition: ot_flavors.cpp:603
encrypto::motion::BitVector::GetData
const auto & GetData() const noexcept
Get const reference to content of BitVector.
Definition: bit_vector.h:152
encrypto::motion::OtExtensionSenderData
Definition: ot_extension_data.h:133
fiber_condition.h
encrypto::motion::XcOtSender::XcOtSender
XcOtSender(std::size_t ot_id, std::size_t number_of_ots, std::size_t bitlength, OtExtensionSenderData &data, const std::function< void(flatbuffers::FlatBufferBuilder &&)> &send_function)
Definition: ot_flavors.cpp:153
encrypto::motion::ReusableFuture
Definition: reusable_future.h:129
encrypto::motion::OtVector
Definition: ot_provider.h:80
encrypto::motion::XcOtSender::SetCorrelations
void SetCorrelations(std::span< const BitVector<>> correlations)
Definition: ot_flavors.h:232
encrypto::motion::ROtSender::ComputeOutputs
void ComputeOutputs()
Definition: ot_flavors.cpp:95
reusable_future.h
encrypto::motion::XcOtSender::GetOutputs
std::span< const BitVector<> > GetOutputs() const
Definition: ot_flavors.h:244
encrypto::motion::AcOtReceiver
Definition: ot_flavors.h:405
encrypto::motion::FixedXcOt128Sender::GetOutputs
Block128Vector & GetOutputs()
Definition: ot_flavors.h:132
encrypto::motion::XcOtBitSender::SendMessages
void SendMessages() const
Definition: ot_flavors.cpp:372
bit_vector.h
encrypto::motion::FixedXcOt128Sender::SetCorrelation
void SetCorrelation(Block128 correlation)
Definition: ot_flavors.h:126
encrypto::motion::XcOtBitReceiver
Definition: ot_flavors.h:302
encrypto::motion::GOtReceiver
Definition: ot_flavors.h:546
encrypto::motion::OtMessageType::kBlock128
@ kBlock128
encrypto::motion::BasicOtReceiver::SetChoices
void SetChoices(BitVector<> &&choices)
Definition: ot_flavors.h:58
encrypto::motion::GOtSender::GOtSender
GOtSender(std::size_t ot_id, std::size_t number_of_ots, std::size_t bitlength, OtExtensionSenderData &data, const std::function< void(flatbuffers::FlatBufferBuilder &&)> &send_function)
Definition: ot_flavors.cpp:704
encrypto::motion::GOtBitReceiver::ComputeOutputs
void ComputeOutputs()
Definition: ot_flavors.cpp:678
encrypto::motion::BitVector::Set
void Set(bool value) noexcept
Sets or unsets all bits in the BitVector.
Definition: bit_vector.cpp:440
encrypto::motion::Block128Vector::ByteSize
std::size_t ByteSize() const
Get size of the Block128Vector content in bytes.
Definition: block.h:228
encrypto::motion::OtExtensionReceiverData::RegisterForBitSenderMessage
ReusableFiberFuture< BitVector<> > RegisterForBitSenderMessage(std::size_t ot_id, std::size_t size)
Definition: ot_extension_data.cpp:196
kAcOt
@ kAcOt
Definition: benchmark_providers.h:36
encrypto::motion::AcOtSender::GetCorrelations
const std::vector< T > & GetCorrelations() const
Definition: ot_flavors.h:375
encrypto::motion::kROt
@ kROt
Definition: ot_provider.h:52
encrypto::motion::XcOtBitSender::XcOtBitSender
XcOtBitSender(std::size_t ot_id, std::size_t number_of_ots, OtExtensionSenderData &data, const std::function< void(flatbuffers::FlatBufferBuilder &&)> &send_function)
Definition: ot_flavors.cpp:333
encrypto::motion::XcOtSender
Definition: ot_flavors.h:221
ot_extension_data.h
encrypto::motion::GOt128Sender::SendMessages
void SendMessages() const
Definition: ot_flavors.cpp:577
encrypto::motion::Block128Vector
Vector of 128 bit / 16 B blocks.
Definition: block.h:168
encrypto::motion::kXcOt
@ kXcOt
Definition: ot_provider.h:53
block.h
encrypto::motion::OtVector::number_of_ots_
const std::size_t number_of_ots_
Definition: ot_provider.h:94
encrypto::motion::FixedXcOt128Sender
Definition: ot_flavors.h:120
encrypto::motion::BitVector::Reserve
void Reserve(std::size_t number_of_bits)
Reserves new space for BitVector, so that it can contain at least number_of_bits bits.
Definition: bit_vector.h:185
encrypto::motion::BitVector<>
encrypto::motion::GOtSender::SetInputs
void SetInputs(const std::span< BitVector<>> inputs)
Definition: ot_flavors.h:507
encrypto::motion::BasicOtReceiver::corrections_sent_
bool corrections_sent_
Definition: ot_flavors.h:82
encrypto::motion::OtExtensionReceiverData::random_choices
std::unique_ptr< AlignedBitVector > random_choices
Definition: ot_extension_data.h:120
encrypto::motion::XcOtBitReceiver::ComputeOutputs
void ComputeOutputs()
Definition: ot_flavors.cpp:395
encrypto::motion::XcOtSender::SetCorrelations
void SetCorrelations(std::vector< BitVector<>> &&correlations)
Definition: ot_flavors.h:228
encrypto::motion::XcOtBitReceiver::XcOtBitReceiver
XcOtBitReceiver(std::size_t ot_id, std::size_t number_of_ots, OtExtensionReceiverData &data, const std::function< void(flatbuffers::FlatBufferBuilder &&)> &send_function)
Definition: ot_flavors.cpp:386
encrypto::motion::BasicOtSender::BasicOtSender
BasicOtSender(std::size_t ot_id, std::size_t number_of_ots, std::size_t bitlength, OtProtocol p, const std::function< void(flatbuffers::FlatBufferBuilder &&)> &send_function, OtExtensionSenderData &data)
Definition: ot_flavors.cpp:33
encrypto::motion::AcOtReceiver::AcOtReceiver
AcOtReceiver(std::size_t ot_id, std::size_t number_of_ots, std::size_t vector_size, OtExtensionReceiverData &data, const std::function< void(flatbuffers::FlatBufferBuilder &&)> &send_function)
Definition: ot_flavors.cpp:499
encrypto::motion::GOt128Sender::GOt128Sender
GOt128Sender(std::size_t ot_id, std::size_t number_of_ots, OtExtensionSenderData &data, const std::function< void(flatbuffers::FlatBufferBuilder &&)> &send_function)
Definition: ot_flavors.cpp:572
encrypto::motion::GOtSender
Definition: ot_flavors.h:499
encrypto::motion::FixedXcOt128Receiver::GetOutputs
const Block128Vector & GetOutputs() const
Definition: ot_flavors.h:162
geninput.choices
choices
Definition: geninput.py:153
encrypto::motion::BasicOtReceiver::GetChoices
const BitVector & GetChoices() const
Definition: ot_flavors.h:62
encrypto::motion::AcOtSender::SetCorrelations
void SetCorrelations(const std::vector< T > &correlations)
Definition: ot_flavors.h:369
encrypto::motion::OtExtensionSenderData::received_correction_offsets
std::unordered_set< std::size_t > received_correction_offsets
Definition: ot_extension_data.h:156
encrypto::motion::kFixedXcOt128
@ kFixedXcOt128
Definition: ot_provider.h:55
encrypto::motion::BasicOtSender::data_
OtExtensionSenderData & data_
Definition: ot_flavors.h:48
encrypto::motion::ROtReceiver::ROtReceiver
ROtReceiver(std::size_t ot_id, std::size_t number_of_ots, std::size_t bitlength, OtExtensionReceiverData &data, const std::function< void(flatbuffers::FlatBufferBuilder &&)> &send_function)
Definition: ot_flavors.cpp:121
ot_provider.h
encrypto::motion::AcOtReceiver::GetOutputs
std::vector< T > & GetOutputs()
Definition: ot_flavors.h:417
encrypto::motion::AcOtSender
Definition: ot_flavors.h:356
encrypto::motion::BasicOtReceiver::choices_
BitVector choices_
Definition: ot_flavors.h:79
encrypto::motion::OtExtensionSenderData::y1
std::vector< BitVector<> > y1
Definition: ot_extension_data.h:164
encrypto::motion::OtMessageType::kGenericBoolean
@ kGenericBoolean
encrypto::motion::communication::BuildOtExtensionMessageSender
flatbuffers::FlatBufferBuilder BuildOtExtensionMessageSender(const std::byte *buffer, const std::size_t size, const std::size_t i)
Definition: ot_extension_message.cpp:31
encrypto::motion::FixedXcOt128Sender::SendMessages
void SendMessages() const
Definition: ot_flavors.cpp:289
encrypto::motion::OtExtensionSenderData::bitlengths
std::vector< std::size_t > bitlengths
Definition: ot_extension_data.h:167
encrypto::motion::GOtBitReceiver::GOtBitReceiver
GOtBitReceiver(std::size_t ot_id, std::size_t number_of_ots, OtExtensionReceiverData &data, const std::function< void(flatbuffers::FlatBufferBuilder &&)> &send_function)
Definition: ot_flavors.cpp:670
encrypto::motion::OtVector::ot_id_
const std::size_t ot_id_
Definition: ot_provider.h:94
encrypto::motion::GOtBitSender
Definition: ot_flavors.h:481
encrypto::motion::GOtSender::SendMessages
void SendMessages() const
Definition: ot_flavors.cpp:709
encrypto::motion::Block128Vector::data
Block128 * data()
Get pointer to the first Block128.
Definition: block.h:219
encrypto::motion::BitVector::Empty
bool Empty() const
Check if BitVector is empty.
Definition: bit_vector.h:146
encrypto::motion::ROtReceiver::WaitSetup
void WaitSetup() const
Definition: ot_flavors.cpp:130
encrypto::motion
Definition: algorithm_description.cpp:35
encrypto::motion::BitVector::GetSize
auto GetSize() const noexcept
Get size of BitVector.
Definition: bit_vector.h:149
encrypto::motion::XcOtBitSender::GetOutputs
BitVector & GetOutputs()
Definition: ot_flavors.h:201
encrypto::motion::GOtBitSender::GOtBitSender
GOtBitSender(std::size_t ot_id, std::size_t number_of_ots, OtExtensionSenderData &data, const std::function< void(flatbuffers::FlatBufferBuilder &&)> &send_function)
Definition: ot_flavors.cpp:638
encrypto::motion::AcOtSender::SendMessages
void SendMessages() const
Definition: ot_flavors.cpp:474
encrypto::motion::kXcOtBit
@ kXcOtBit
Definition: ot_provider.h:56
encrypto::motion::XcOtBitSender
Definition: ot_flavors.h:179
encrypto::motion::GOt128Receiver::GetOutputs
const Block128Vector & GetOutputs() const
Definition: ot_flavors.h:464
encrypto::motion::OtExtensionReceiverData::bitlengths
std::vector< std::size_t > bitlengths
Definition: ot_extension_data.h:91
encrypto::motion::Block128
Block of aligned 128 bit / 16 B.
Definition: block.h:34
encrypto::motion::GOt128Receiver::ComputeOutputs
void ComputeOutputs()
Definition: ot_flavors.cpp:612
encrypto::motion::GOt128Sender
Definition: ot_flavors.h:437
encrypto::motion::OtExtensionReceiverData::RegisterForGenericSenderMessage
ReusableFiberFuture< std::vector< BitVector<> > > RegisterForGenericSenderMessage(std::size_t ot_id, std::size_t size, std::size_t bitlength)
Definition: ot_extension_data.cpp:210
encrypto::motion::BasicOtReceiver
Definition: ot_flavors.h:52
kGOt
@ kGOt
Definition: benchmark_providers.h:34
encrypto::motion::BasicOtReceiver::SetChoices
void SetChoices(const BitVector<> &choices)
Definition: ot_flavors.h:59
encrypto::motion::XcOtReceiver
Definition: ot_flavors.h:328
encrypto::motion::AcOtSender::ComputeOutputs
void ComputeOutputs()
Definition: ot_flavors.cpp:426
encrypto::motion::OtExtensionReceiverData::message_type
std::unordered_map< std::size_t, OtMessageType > message_type
Definition: ot_extension_data.h:94
encrypto::motion::ROtSender::ROtSender
ROtSender(std::size_t ot_id, std::size_t number_of_ots, std::size_t bitlength, OtExtensionSenderData &data, const std::function< void(flatbuffers::FlatBufferBuilder &&)> &send_function)
Definition: ot_flavors.cpp:77
ot_flavors.h
encrypto::motion::kAcOt
@ kAcOt
Definition: ot_provider.h:54
encrypto::motion::GOtSender::SetInputs
void SetInputs(std::vector< BitVector<>> &&inputs)
Definition: ot_flavors.h:506
encrypto::motion::XcOtBitSender::ComputeOutputs
void ComputeOutputs()
Definition: ot_flavors.cpp:338
encrypto::motion::AcOtSender::AcOtSender
AcOtSender(std::size_t ot_id, std::size_t number_of_ots, std::size_t vector_size, OtExtensionSenderData &data, const std::function< void(flatbuffers::FlatBufferBuilder &&)> &send_function)
Definition: ot_flavors.cpp:418
encrypto::motion::BasicOtReceiver::AreChoicesSet
bool AreChoicesSet() const
Definition: ot_flavors.h:65
encrypto::motion::GOtReceiver::GOtReceiver
GOtReceiver(std::size_t ot_id, std::size_t number_of_ots, std::size_t bitlength, OtExtensionReceiverData &data, const std::function< void(flatbuffers::FlatBufferBuilder &&)> &send_function)
Definition: ot_flavors.cpp:742
encrypto::motion::OtProtocol
OtProtocol
Definition: ot_provider.h:50
encrypto::motion::OtVector::bitlen_
const std::size_t bitlen_
Definition: ot_provider.h:94
encrypto::motion::XcOtReceiver::ComputeOutputs
void ComputeOutputs()
Definition: ot_flavors.cpp:222
encrypto::motion::ROtReceiver
Definition: ot_flavors.h:264
encrypto::motion::OtExtensionReceiverData
Definition: ot_extension_data.h:65
encrypto::motion::FixedXcOt128Receiver
Definition: ot_flavors.h:153
encrypto::motion::OtExtensionSenderData::corrections
BitVector corrections
Definition: ot_extension_data.h:159
encrypto::motion::BitSpan
Non-owning non-resizeable BitVector.
Definition: bit_vector.h:578
encrypto::motion::OtExtensionSenderData::setup_finished_condition
std::unique_ptr< FiberCondition > setup_finished_condition
Definition: ot_extension_data.h:170
encrypto::motion::AcOtSender::SetCorrelations
void SetCorrelations(std::vector< T > &&correlations)
Definition: ot_flavors.h:365
encrypto::motion::XcOtSender::GetCorrelations
std::span< const BitVector<> > GetCorrelations() const
Definition: ot_flavors.h:238
encrypto::motion::FixedXcOt128Receiver::FixedXcOt128Receiver
FixedXcOt128Receiver(std::size_t ot_id, std::size_t number_of_ots, OtExtensionReceiverData &data, const std::function< void(flatbuffers::FlatBufferBuilder &&)> &send_function)
Definition: ot_flavors.cpp:302
encrypto::motion::BitVector::Append
void Append(bool bit) noexcept
Appends a bit to BitVector.
Definition: bit_vector.cpp:621
encrypto::motion::OtExtensionReceiverData::setup_finished_condition
std::unique_ptr< FiberCondition > setup_finished_condition
Definition: ot_extension_data.h:126
encrypto::motion::GOtBitSender::SetInputs
void SetInputs(const BitVector<> &inputs)
Definition: ot_flavors.h:488
encrypto::motion::GOtBitReceiver::GetOutputs
const BitVector & GetOutputs() const
Definition: ot_flavors.h:529
encrypto::motion::ROtReceiver::GetOutputs
std::span< const BitVector<> > GetOutputs()
Definition: ot_flavors.h:277
encrypto::motion::AcOtReceiver::ComputeOutputs
void ComputeOutputs()
Definition: ot_flavors.cpp:518
encrypto::motion::BasicOtSender::WaitSetup
void WaitSetup() const
Definition: ot_flavors.cpp:51
d
static const fe d
Definition: mycurve25519_tables.h:30
encrypto::motion::kSetBitMask
constexpr std::byte kSetBitMask[]
Definition: bit_vector.h:43
encrypto::motion::OtExtensionSenderData::y0
std::vector< BitVector<> > y0
Definition: ot_extension_data.h:164
encrypto::motion::AcOtSender::GetOutputs
std::vector< T > & GetOutputs()
Definition: ot_flavors.h:381
encrypto::motion::communication::BuildOtExtensionMessageReceiverCorrections
flatbuffers::FlatBufferBuilder BuildOtExtensionMessageReceiverCorrections(const std::byte *buffer, const std::size_t size, const std::size_t i)
Definition: ot_extension_message.cpp:55
encrypto::motion::XcOtBitReceiver::GetOutputs
BitVector & GetOutputs()
Definition: ot_flavors.h:311
encrypto::motion::GOtBitReceiver
Definition: ot_flavors.h:520
encrypto::motion::OtExtensionReceiverData::number_of_ots_in_batch
std::unordered_map< std::size_t, std::size_t > number_of_ots_in_batch
Definition: ot_extension_data.h:123
encrypto::motion::BasicOtReceiver::SendCorrections
void SendCorrections()
Definition: ot_flavors.cpp:67
encrypto::motion::BasicOtReceiver::BasicOtReceiver
BasicOtReceiver(std::size_t ot_id, std::size_t number_of_ots, std::size_t bitlength, OtProtocol p, const std::function< void(flatbuffers::FlatBufferBuilder &&)> &Send, OtExtensionReceiverData &data)
Definition: ot_flavors.cpp:55
encrypto::motion::GOtReceiver::ComputeOutputs
void ComputeOutputs()
Definition: ot_flavors.cpp:752
encrypto::motion::XcOtReceiver::GetOutputs
std::span< const BitVector<> > GetOutputs()
Definition: ot_flavors.h:338
encrypto::motion::Block128::data
std::byte * data()
Get a pointer to the beginning of this Block128.
Definition: block.h:148
encrypto::motion::OtExtensionReceiverData::outputs
std::vector< BitVector<> > outputs
Definition: ot_extension_data.h:86
encrypto::motion::OtExtensionSenderData::corrections_mutex
std::mutex corrections_mutex
Definition: ot_extension_data.h:160
encrypto::motion::BitVector::Subset
BitVector Subset(std::size_t from, std::size_t to) const
Returns a new BitVector containing the bits of this BitVector between positions from and to.
Definition: bit_vector.cpp:806
encrypto::motion::ROtReceiver::GetChoices
const BitVector & GetChoices()
Definition: ot_flavors.h:282
encrypto::motion::ROtSender::SendMessages
void SendMessages() const
encrypto::motion::kGOt
@ kGOt
Definition: ot_provider.h:51
encrypto::motion::XcOtSender::SendMessages
void SendMessages() const
Definition: ot_flavors.cpp:198
encrypto::motion::GOt128Sender::SetInputs
void SetInputs(const Block128Vector &inputs)
Definition: ot_flavors.h:444
encrypto::motion::BasicOtSender
Definition: ot_flavors.h:37
encrypto::motion::GOt128Sender::SetInputs
void SetInputs(Block128Vector &&inputs)
Definition: ot_flavors.h:443
encrypto::motion::ROtReceiver::ComputeOutputs
void ComputeOutputs()
Definition: ot_flavors.cpp:132
encrypto::motion::Block128Vector::at
Block128 & at(std::size_t index)
Access Block128 at index. Throws an exception if index is out of bounds.
Definition: block.h:215
encrypto::motion::FixedXcOt128Sender::ComputeOutputs
void ComputeOutputs()
Definition: ot_flavors.cpp:251
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::XcOtBitSender::GetCorrelations
const BitVector & GetCorrelations() const
Definition: ot_flavors.h:195