emp-toolkit
bit.h
Go to the documentation of this file.
1 #ifndef BIT_H__
2 #define BIT_H__
3 #include "backend.h"
4 #include "utils.h"
5 #include "block.h"
6 #include "swappable.h"
7 
8 class Bit : public Swappable<Bit>{ public:
10 
11  Bit(bool _b = false, int party = PUBLIC);
12  Bit(const block& a) {
13  memcpy(&bit, &a, sizeof(block));
14  }
15 
16  template<typename O = bool>
17  O reveal(int party = PUBLIC) const;
18 
19  Bit operator!=(const Bit& rhs) const;
20  Bit operator==(const Bit& rhs) const;
21  Bit operator &(const Bit& rhs) const;
22  Bit operator |(const Bit& rhs) const;
23  Bit operator !() const;
24 
25  //swappable
26  Bit select(const Bit & select, const Bit & new_v)const ;
27  Bit operator ^(const Bit& rhs) const;
28 
29  //batcher
30  template<typename... Args>
31  static size_t bool_size(Args&&... args) {
32  return 1;
33  }
34 
35  static void bool_data(bool *b, bool data) {
36  b[0] = data;
37  }
38 
39  Bit(size_t size, const block* a) {
40  memcpy(&bit, a, sizeof(block));
41  }
42 };
43 #include "bit.hpp"
44 #endif
static void bool_data(bool *b, bool data)
Definition: bit.h:35
Bit(bool _b=false, int party=PUBLIC)
Definition: bit.hpp:1
O reveal(int party=PUBLIC) const
Definition: bit.hpp:15
static size_t bool_size(Args &&... args)
Definition: bit.h:31
Bit(size_t size, const block *a)
Definition: bit.h:39
__m128i block
Definition: block.h:8
Bit operator==(const Bit &rhs) const
Definition: bit.hpp:30
Bit operator!() const
Definition: bit.hpp:53
#define PUBLIC
Definition: utils.h:14
Bit(const block &a)
Definition: bit.h:12
Bit operator!=(const Bit &rhs) const
Definition: bit.hpp:34
Definition: swappable.h:7
Definition: bit.h:8
Bit operator^(const Bit &rhs) const
Definition: bit.hpp:43
Bit select(const Bit &select, const Bit &new_v) const
Definition: bit.hpp:7
int party
Definition: input-check-malicious.cpp:12
block bit
Definition: bit.h:9
Bit operator|(const Bit &rhs) const
Definition: bit.hpp:49
Bit operator&(const Bit &rhs) const