tfhe_libex
integer_core.hpp
[詳解]
1 
5 #ifndef INTEGER_CORE
6 #define INTEGER_CORE
7 #include "../../operations/arithmetic/ternary/mux.hpp"
8 #include "../../operations/arithmetic/utils/full_adder.hpp"
9 #include "../../operations/arithmetic/utils/half_adder.hpp"
10 #include "../../operations/io/io.hpp"
11 #include "../config/config.hpp"
12 #include "../raw/bits.hpp"
13 #include "bool_core.hpp"
14 
18 class TFHEIntegerCore : virtual protected TFHEKeySet, virtual protected TFHEIO {
19  public:
20  TFHEBits bits;
21 
23  TFHEIntegerCore(const TFHEIntegerCore& elm, int nbelems);
24 
25  TFHEIntegerCore(int nbelems);
26 
27  TFHEIntegerCore(int nbelems, int number);
28 
29  TFHEIntegerCore(int nbelems, const char* path, int id);
30 
35  int decrypt();
36 
42  void save(const char* path, int id);
43 
50 
57 
65 
73 
80 
88 
97 
105 
113 
121 
128  TFHEBoolCore operator<(const TFHEIntegerCore& other);
129 
138 
145  TFHEBoolCore operator>(const TFHEIntegerCore& other);
146 
155 
163 
171 
178  TFHEBoolCore operator<(const int& other);
179 
186  TFHEBoolCore operator>(const int& other);
187 
194  TFHEBoolCore operator==(const int& other);
195 
196  protected:
197  TFHEBoolCore overflow_error_flag;
198  TFHEBoolCore division_byZero_error_flag;
199  virtual void save_raw(FILE* fp);
200  virtual void load_raw(FILE* fp);
201  void check_division_byZero(TFHEIntegerCore value);
202  void check_overflow_add(TFHEIntegerCore value1, TFHEIntegerCore value2);
203  void check_overflow_sub(TFHEIntegerCore value1, TFHEIntegerCore value2);
204  void check_overflow_mul();
205  void check_error(TFHEIntegerCore value);
206  void check_decrypt_error();
207  TFHEIntegerCore add(TFHEIntegerCore value1, TFHEIntegerCore value2);
208  TFHEIntegerCore minus(TFHEIntegerCore value);
209  TFHEIntegerCore sub(TFHEIntegerCore value1, TFHEIntegerCore value2);
210  static TFHEIntegerCore shift(TFHEIntegerCore value, int shift);
211  TFHEIntegerCore mul(TFHEIntegerCore value1, TFHEBoolCore value2);
212  TFHEIntegerCore mul(TFHEIntegerCore value1, TFHEIntegerCore value2);
213  TFHEIntegerCore div(TFHEIntegerCore value1, TFHEIntegerCore value2);
214  TFHEIntegerCore mod(TFHEIntegerCore value1, TFHEIntegerCore value2);
215  TFHEBoolCore lt(TFHEIntegerCore value1, TFHEIntegerCore value2);
216  TFHEBoolCore ltoet(TFHEIntegerCore value1, TFHEIntegerCore value2);
217  TFHEBoolCore gt(TFHEIntegerCore value1, TFHEIntegerCore value2);
218  TFHEBoolCore gtoet(TFHEIntegerCore value1, TFHEIntegerCore value2);
219  TFHEBoolCore et(TFHEIntegerCore value1, TFHEIntegerCore value2);
220  TFHEBoolCore net(TFHEIntegerCore value1, TFHEIntegerCore value2);
221 };
222 
223 #endif
TFHEIntegerCore::operator==
TFHEBoolCore operator==(const TFHEIntegerCore &other)
TFHEの整数型で等号(eqaul to)の判定を行うオペレータ.
Definition: integer_core.cpp:563
TFHEIntegerCore::operator/
TFHEIntegerCore operator/(const TFHEIntegerCore &other)
TFHEの整数型で除算を行うオペレータ.
Definition: integer_core.cpp:533
TFHEIntegerCore::save
void save(const char *path, int id)
TFHEの整数型をファイルに保存するメソッド.
Definition: integer_core.cpp:600
TFHEIntegerCore::operator>
TFHEBoolCore operator>(const TFHEIntegerCore &other)
TFHEの整数型で不等号(greater than)の判定を行うオペレータ.
Definition: integer_core.cpp:557
TFHEIntegerCore::sign
TFHEIntegerCore sign()
TFHEの整数型で符号を取得するメソッド.
Definition: integer_core.cpp:86
TFHEIntegerCore::operator=
TFHEIntegerCore & operator=(const TFHEIntegerCore &num)
TFHEの整数型の代入を行うオペレータ.
Definition: integer_core.cpp:487
TFHEIntegerCore::operator*
TFHEIntegerCore operator*(const TFHEBoolCore &other)
TFHEの整数型で真理値がtrueならば現在値をfalseならば0を返すオペレータ.
Definition: integer_core.cpp:521
TFHEIntegerCore
TFHEの整数型のcoreクラス.
Definition: integer_core.hpp:18
TFHEBits
複数のLweSample*をwrapするクラス.
Definition: bits.hpp:12
TFHEIntegerCore::operator<
TFHEBoolCore operator<(const TFHEIntegerCore &other)
TFHEの整数型で不等号(less than)の判定を行うオペレータ.
Definition: integer_core.cpp:551
TFHEIntegerCore::decrypt
int decrypt()
TFHEの整数型を復号するメソッド.
Definition: integer_core.cpp:59
TFHEIntegerCore::operator!=
TFHEBoolCore operator!=(const TFHEIntegerCore &other)
TFHEの整数型で等号否定(not equal to)の判定を行うオペレータ.
Definition: integer_core.cpp:566
TFHEBoolCore
TFHEのBool型のcoreクラス.
Definition: bool_core.hpp:14
TFHEIntegerCore::operator>=
TFHEBoolCore operator>=(const TFHEIntegerCore &other)
TFHEの整数型で等号付き不等号(greater than or equal to)の判定を行うオペレータ.
Definition: integer_core.cpp:560
TFHEIntegerCore::operator-
TFHEIntegerCore operator-()
TFHEの整数型の反数を返すオペレータ.
Definition: integer_core.cpp:504
TFHEIntegerCore::operator%
TFHEIntegerCore operator%(const TFHEIntegerCore &other)
TFHEの整数型で剰余演算を行うオペレータ.
Definition: integer_core.cpp:542
bool_core.hpp
TFHEのBool型のcoreクラス.
TFHEIO
ファイル入出力の共通処理のクラス.
Definition: io.hpp:12
TFHEIntegerCore::operator+
TFHEIntegerCore operator+(const TFHEIntegerCore &other)
TFHEの整数型で加算を行うオペレータ.
Definition: integer_core.cpp:492
TFHEKeySet
TFHEの秘密鍵,クラウド鍵,パラメータをまとめて管理するwrapperクラス.
Definition: keyset.hpp:43
TFHEIntegerCore::abs
TFHEIntegerCore abs()
TFHEの整数型で絶対値を取得するメソッド.
Definition: integer_core.cpp:95
TFHEIntegerCore::operator<=
TFHEBoolCore operator<=(const TFHEIntegerCore &other)
TFHEの整数型で等号付き不等号(less than or equal to)の判定を行うオペレータ.
Definition: integer_core.cpp:554