emp-toolkit
semihonest_eva.h
Go to the documentation of this file.
1 #ifndef SEMIHONEST_EVA_H__
2 #define SEMIHONEST_EVA_H__
3 #include <emp-tool/emp-tool.h>
4 #include <emp-ot/emp-ot.h>
5 #include <iostream>
6 
7 template<typename T>
8 void eval_feed(Backend* be, int party, block * label, const bool*, int length);
9 template<typename T>
10 void eval_reveal(Backend* be, bool* clear, int party, const block * label, int length);
11 
12 template<typename T>
13 class SemiHonestEva: public Backend { public:
18  this->io = io;
19  ot = new SHOTIterated(io, false);
20  this->gc = gc;
21  Feed_internal = eval_feed<T>;
22  Reveal_internal = eval_reveal<T>;
23  }
25  delete ot;
26  }
27 };
28 
29 
30 template<typename T>
31 void eval_feed(Backend* be, int party, block * label, const bool* b, int length) {
32  SemiHonestEva<T> * backend = (SemiHonestEva<T>*)(be);
33  if(party == ALICE) {
34  backend->io->recv_block(label, length);
35  } else {
36  backend->ot->recv_cot(label, b, length);
37  }
38 }
39 
40 template<typename T>
41 void eval_reveal(Backend* be, bool * b, int party, const block * label, int length) {
42  SemiHonestEva<T> * backend = (SemiHonestEva<T>*)(be);
43  block tmp;
44  for (int i = 0; i < length; ++i) {
45  if(isOne(&label[i]))
46  b[i] = true;
47  else if (isZero(&label[i]))
48  b[i] = false;
49  else {
50  if (party == BOB or party == PUBLIC) {
51  backend->io->recv_block(&tmp, 1);
52  b[i] = !(block_cmp(&tmp, &label[i], 1));
53  } else if (party == ALICE) {
54  backend->io->send_block(&label[i], 1);
55  b[i] = false;
56  }
57  }
58  }
59  if(party == PUBLIC)
60  backend->io->send_data(b, length);
61 }
62 #endif// GARBLE_CIRCUIT_SEMIHONEST_H__
void send_data(const void *data, int nbyte)
Definition: io_channel.h:14
NetIO * io
Definition: semihonest_eva.h:14
__m128i block
Definition: block.h:8
bool isZero(const block *b)
Definition: block.h:71
#define BOB
Definition: utils.h:16
~SemiHonestEva()
Definition: semihonest_eva.h:24
Definition: net_io_channel.h:22
bool isOne(const block *b)
Definition: block.h:75
#define PUBLIC
Definition: utils.h:14
OTIterated< SHOTExtension > SHOTIterated
Definition: iterated.h:96
SemiHonestEva(NetIO *io, HalfGateEva< T > *gc)
Definition: semihonest_eva.h:17
HalfGateEva< T > * gc
Definition: semihonest_eva.h:16
void eval_reveal(Backend *be, bool *clear, int party, const block *label, int length)
Definition: semihonest_eva.h:41
void eval_feed(Backend *be, int party, block *label, const bool *, int length)
Definition: semihonest_eva.h:31
void(* Reveal_internal)(Backend *be, bool *, int, const block *label, int length)
Definition: backend.h:11
Definition: backend.h:8
#define ALICE
Definition: utils.h:15
void(* Feed_internal)(Backend *be, int, block *label, const bool *, int length)
Definition: backend.h:10
SHOTIterated * ot
Definition: semihonest_eva.h:15
bool block_cmp(const block *x, const block *y, int nblocks)
Definition: block.h:56
void send_block(const block *data, int nblock)
Definition: io_channel.h:132
void recv_block(block *data, int nblock)
Definition: io_channel.h:136
int party
Definition: input-check-malicious.cpp:12
Definition: semihonest_eva.h:13
Definition: iterated.h:9
void recv_cot(block *data, const bool *b, int length)
Definition: iterated.h:74