cryptocontext_docs.h 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985
  1. #ifndef CRYPTOCONTEXT_DOCSTRINGS_H
  2. #define CRYPTOCONTEXT_DOCSTRINGS_H
  3. #include "pybind11/pybind11.h"
  4. #include "pybind11/attr.h"
  5. namespace py = pybind11;
  6. // const char* cc_docs = R"doc(
  7. // test
  8. // )doc";
  9. // auto cc_docs2 = py::doc(cc_docs);
  10. const char* cc_SetKeyGenLevel_docs = R"pbdoc(
  11. Set the level used for key generation
  12. :param level: the level to set the key generation to
  13. :type level: int
  14. )pbdoc";
  15. const char* cc_GetKeyGenLevel_docs = R"pbdoc(
  16. Get the level used for key generation
  17. :return: The level used for key generation
  18. :rtype: int
  19. )pbdoc";
  20. const char* cc_GetRingDimension_docs = R"pbdoc(
  21. Get the ring dimension used for this context
  22. :return: The ring dimension
  23. :rtype: int
  24. )pbdoc";
  25. const char* cc_Enable_docs = R"pbdoc(
  26. Enable a particular feature for use with this CryptoContext
  27. :param feature: the feature that should be enabled.
  28. The list of available features is defined in the PKESchemeFeature enum.
  29. :type feature: PKESchemeFeature
  30. )pbdoc";
  31. const char* cc_KeyGen_docs = R"pbdoc(
  32. Generate a public and private key pair
  33. :return: a public/secret key pair
  34. :rtype: KeyPair
  35. )pbdoc";
  36. const char* cc_EvalMultKeyGen_docs = R"pbdoc(
  37. EvalMultKeyGen creates a key that can be used with the OpenFHE EvalMult operator.
  38. The new evaluation key is stored in cryptocontext.
  39. :param privateKey: the private key
  40. :type privateKey: PrivateKey
  41. )pbdoc";
  42. const char* cc_EvalMultKeysGen_docs = R"pbdoc(
  43. EvalMultsKeyGen creates a vector evalmult keys that can be used with the OpenFHE EvalMult operator.
  44. The 1st key (for s^2) is used for multiplication of ciphertexts of depth 1.
  45. The 2nd key (for s^3) is used for multiplication of ciphertexts of depth 2, etc.
  46. A vector of new evaluation keys is stored in cryptocontext.
  47. :param privateKey: the private key
  48. :type privateKey: PrivateKey
  49. )pbdoc";
  50. const char* cc_EvalRotateKeyGen_docs = R"pbdoc(
  51. EvalRotateKeyGen generates evaluation keys for a list of indices
  52. :param privateKey: private key
  53. :type privateKey: PrivateKey
  54. :param indexList: list of integers representing the indices
  55. :type indexList: list
  56. :param publicKey: public key (used in NTRU schemes)
  57. :type publicKey: PublicKey
  58. )pbdoc";
  59. // MakeStringPlaintext
  60. const char* cc_MakeStringPlaintext_docs = R"pbdoc(
  61. MakeStringPlaintext constructs a StringEncoding in this context.
  62. :param str: the string to convert
  63. :type str: str
  64. :return: plaintext
  65. )pbdoc";
  66. const char* cc_MakePackedPlaintext_docs = R"pbdoc(
  67. MakePackedPlaintext constructs a PackedEncoding in this context
  68. :param value: the vector (of integers) to convert
  69. :type value: list
  70. :param depth: is the multiplicative depth to encode the plaintext at
  71. :type depth: int
  72. :param level: is the level to encode the plaintext at
  73. :type level: int
  74. :return: plaintext
  75. :rtype: Plaintext
  76. )pbdoc";
  77. const char* cc_MakeCoefPackedPlaintext_docs = R"pbdoc(
  78. MakeCoefPackedPlaintext constructs a CoefPackedEncoding in this context
  79. :param value: the vector (of integers) to convert
  80. :type value: list
  81. :param depth: is the multiplicative depth to encode the plaintext at
  82. :type depth: int
  83. :param level: is the level to encode the plaintext at
  84. :type level: int
  85. :return: plaintext
  86. :rtype: Plaintext
  87. )pbdoc";
  88. const char* cc_MakeCKKSPackedPlaintextComplex_docs = R"pbdoc(
  89. COMPLEX ARITHMETIC IS NOT AVAILABLE STARTING WITH OPENFHE 1.10.6, AND THIS METHOD BE DEPRECATED. USE THE REAL-NUMBER METHOD INSTEAD. MakeCKKSPackedPlaintext constructs a CKKSPackedEncoding in this context from a vector of complex numbers
  90. :param value: input vector (of complex numbers)
  91. :type value: list
  92. :param depth: depth used to encode the vector
  93. :type depth: int
  94. :param level: level at each the vector will get encrypted
  95. :type level: int
  96. :param params: parameters to be used for the ciphertext (Only accepting params = None in this version)
  97. :type params: openfhe.ParmType
  98. :param slots: number of slots
  99. :type slots: int
  100. :return: plaintext
  101. :rtype: Plaintext
  102. )pbdoc";
  103. const char* cc_MakeCKKSPlaintextReal_docs = R"pbdoc(
  104. MakeCKKSPlaintext constructs a CKKSPackedEncoding in this context from a vector of real numbers
  105. :param value: input vector (of floats)
  106. :type value: list
  107. :param depth: depth used to encode the vector
  108. :type depth: int
  109. :param level: level at each the vector will get encrypted
  110. :type level: int
  111. :param params: parameters to be used for the ciphertext (Only accepting params = None in this version)
  112. :type params: openfhe.ParmType
  113. :param slots: number of slots
  114. :type slots: int
  115. :return: plaintext
  116. :rtype: Plaintext
  117. )pbdoc";
  118. const char* cc_EvalRotate_docs = R"pbdoc(
  119. EvalRotate rotates a ciphertext by a given index
  120. :param ciphertext: the ciphertext to rotate
  121. :type ciphertext: Ciphertext
  122. :param index: the index of the rotation. Positive indices correspond to left rotations and negative indices correspond to right rotations.
  123. :type index: int
  124. :return: the rotated ciphertext
  125. :rtype: Ciphertext
  126. )pbdoc";
  127. const char* cc_EvalFastRotationPreCompute_docs = R"pbdoc(
  128. EvalFastRotationPrecompute implements the precomputation step of hoisted automorphisms.
  129. Please refer to Section 5 of Halevi and Shoup, "Faster Homomorphic
  130. linear transformations in HELib." for more details, link:
  131. https://eprint.iacr.org/2018/244.
  132. Generally, automorphisms are performed with three steps:
  133. (1) The automorphism is applied to the ciphertext.
  134. (2) The automorphed values are decomposed into digits.
  135. (3) Key switching is applied to enable further computations on the ciphertext.
  136. Hoisted automorphisms are a technique that performs the digit decomposition for the original ciphertext first,
  137. and then performs the automorphism and the key switching on the decomposed digits.
  138. The benefit of this is that the digit decomposition is independent of the automorphism rotation index,
  139. so it can be reused for multiple different indices.
  140. This can greatly improve performance when we have to compute many automorphisms on the same ciphertext.
  141. This routinely happens when we do permutations (EvalPermute).
  142. EvalFastRotationPrecompute implements the digit decomposition step of hoisted automorphisms.
  143. :param ciphertext: the input ciphertext on which to do the precomputation (digit decomposition)
  144. :type ciphertext: Ciphertext
  145. :return: the precomputed ciphertext created using the digit decomposition
  146. :rtype: Ciphertext
  147. )pbdoc";
  148. const char* cc_EvalFastRotation_docs = R"pbdoc(
  149. EvalFastRotation implements the automorphism and key switching step of hoisted automorphisms.
  150. Please refer to Section 5 of Halevi and Shoup, "Faster Homomorphic
  151. linear transformations in HELib." for more details, link:
  152. https://eprint.iacr.org/2018/244.
  153. Generally, automorphisms are performed with three steps:
  154. (1) The automorphism is applied to the ciphertext.
  155. (2) The automorphed values are decomposed into digits.
  156. (3) Key switching is applied to enable further computations on the ciphertext.
  157. Hoisted automorphisms are a technique that performs the digit decomposition for the original ciphertext first,
  158. and then performs the automorphism and the key switching on the decomposed digits.
  159. The benefit of this is that the digit decomposition is independent of the automorphism rotation index,
  160. so it can be reused for multiple different indices.
  161. This can greatly improve performance when we have to compute many automorphisms on the same ciphertext.
  162. This routinely happens when we do permutations (EvalPermute).
  163. EvalFastRotation implements the automorphism and key switching step of hoisted automorphisms.
  164. This method assumes that all required rotation keys exist.
  165. This may not be true if we are using baby-step/giant-step key switching.
  166. Please refer to Section 5.1 of the above reference and EvalPermuteBGStepHoisted to see how to deal with this issue.
  167. :param ciphertext: the input ciphertext to perform the automorphism on
  168. :type ciphertext: Ciphertext
  169. :param index: the index of the rotation. Positive indices correspond to left rotations and negative indices correspond to right rotations.
  170. :type index: int
  171. :param m: is the cyclotomic order
  172. :type m: int
  173. :param digits: the precomputed ciphertext created by EvalFastRotationPrecompute using the digit decomposition at the precomputation step
  174. :type digits: Ciphertext
  175. :return: the rotated ciphertext
  176. :rtype: Ciphertext
  177. )pbdoc";
  178. const char* cc_EvalFastRotationExt_docs = R"pbdoc(
  179. Only supported for hybrid key switching. Performs fast (hoisted) rotation and returns the results in the extended CRT basis P*Q
  180. :param ciphertext: input ciphertext
  181. :type ciphertext: Ciphertext
  182. :param index: the rotation index
  183. :type index: int
  184. :param digits: the precomputed ciphertext created by EvalFastRotationPrecompute
  185. :type digits: Ciphertext
  186. :param addFirst: if true, the first element c0 is also computed (otherwise ignored)
  187. :type addFirst: bool
  188. :return: resulting ciphertext
  189. :rtype: Ciphertext
  190. )pbdoc";
  191. const char* cc_EvalAtIndex_docs = R"pbdoc(
  192. Moves i-th slot to slot 0
  193. :param ciphertext: the ciphertext
  194. :type ciphertext: Ciphertext
  195. :param i: the index
  196. :type i: int
  197. :return: resulting ciphertext
  198. :rtype: Ciphertext
  199. )pbdoc";
  200. const char* cc_EvalAtIndexKeyGen_docs = R"pbdoc(
  201. EvalAtIndexKeyGen generates evaluation keys for a list of indices
  202. :param privateKey: the private key
  203. :type privateKey: PrivateKey
  204. :param indexList: list of indices
  205. :type indexList: list
  206. :param publicKey: the public key (used in NTRU schemes)
  207. :type publicKey: PublicKey
  208. :return: None
  209. )pbdoc";
  210. const char* cc_Encrypt_docs = R"doc(
  211. Encrypt a plaintext using a given public key
  212. :param plaintext: the plaintext to encrypt
  213. :type plaintext: Plaintext
  214. :param publicKey: the public key
  215. :type publicKey: PublicKey
  216. :return: ciphertext (or null on failure)
  217. :rtype: Ciphertext
  218. )doc";
  219. const char* cc_Decrypt_docs = R"pbdoc(
  220. Decrypt a single ciphertext into the appropriate plaintext
  221. :param ciphertext: ciphertext to decrypt
  222. :type ciphertext: Ciphertext
  223. :param privateKey: decryption key
  224. :type privateKey: PrivateKey
  225. :return: decrypted plaintext
  226. :rtype: Plaintext
  227. )pbdoc";
  228. const char* cc_EvalAdd_docs = R"pbdoc(
  229. Add two ciphertexts
  230. :param ct1: first ciphertext
  231. :type ct1: Ciphertext
  232. :param ct2: second ciphertext
  233. :type ct2: Ciphertext
  234. :return: resulting ciphertext
  235. :rtype: Ciphertext
  236. )pbdoc";
  237. const char* cc_EvalAddfloat_docs = R"pbdoc(
  238. EvalAdd - OpenFHE EvalAdd method for a ciphertext and constant
  239. :param ct: ciphertext
  240. :type ct: Ciphertext
  241. :param constant: constant to add
  242. :type constant: float
  243. :return: new ciphertext for ciphertext + constant
  244. :rtype: Ciphertext
  245. )pbdoc";
  246. const char* cc_EvalAddInPlace_docs = R"pbdoc(
  247. EvalAdd - OpenFHE EvalAddInPlace method for a pair of ciphertexts
  248. :param ct1: Input/output ciphertext
  249. :type ct1: Ciphertext
  250. :param ct2: Input ciphertext
  251. :type ct2: Ciphertext
  252. :return: ct1 contains ct1 + ct2
  253. )pbdoc";
  254. const char* cc_EvalAddInPlacePlaintext_docs = R"pbdoc(
  255. EvalAdd - OpenFHE EvalAddInPlace method for a ciphertext and plaintext
  256. :param ct: Input/output ciphertext
  257. :type ct: Ciphertext
  258. :param pt: Input plaintext
  259. :type pt: Plaintext
  260. :return: ct contains ct + pt
  261. )pbdoc";
  262. const char* cc_EvalAddMutable_docs = R"pbdoc(
  263. EvalAdd - OpenFHE EvalAddMutable method for a pair of ciphertexts. This is a mutable version - input ciphertexts may get automatically rescaled, or level-reduced.
  264. :param ct1: first ciphertext
  265. :type ct1: Ciphertext
  266. :param ct2: second ciphertext
  267. :type ct2: Ciphertext
  268. :return: new ciphertext for ct1 + ct2
  269. :rtype: Ciphertext
  270. )pbdoc";
  271. const char* cc_EvalAddMutablePlaintext_docs = R"pbdoc(
  272. EvalAdd - OpenFHE EvalAddMutable method for a ciphertext and plaintext. This is a mutable version - input ciphertexts may get automatically rescaled, or level-reduced.
  273. :param ciphertext: ciphertext
  274. :type ciphertext: Ciphertext
  275. :param plaintext: plaintext
  276. :type plaintext: Plaintext
  277. :return: new ciphertext for ciphertext + plaintext
  278. :rtype: Ciphertext
  279. )pbdoc";
  280. const char* cc_EvalAddMutableInPlace_docs = R"pbdoc(
  281. EvalAdd - Inplace version of EvalAddMutable
  282. :param ct1: Input/output ciphertext
  283. :type ct1: Ciphertext
  284. :param ct2: Input ciphertext
  285. :type ct2: Ciphertext
  286. :return: ct1 contains ct1 + ct2
  287. )pbdoc";
  288. const char* cc_EvalSub_docs = R"pbdoc(
  289. EvalSub - OpenFHE EvalSub method for a pair of ciphertexts
  290. :param ct1: first ciphertext
  291. :type ct1: Ciphertext
  292. :param ct2: second ciphertext
  293. :type ct2: Ciphertext
  294. :return: new ciphertext for ct1 - ct2
  295. :rtype: Ciphertext
  296. )pbdoc";
  297. const char* cc_EvalSubfloat_docs = R"pbdoc(
  298. EvalSub - OpenFHE EvalSub method for a ciphertext and constant
  299. :param ciphertext: ciphertext
  300. :type ciphertext: Ciphertext
  301. :param constant: constant to subtract
  302. :type constant: float
  303. :return: new ciphertext for ciphertext - constant
  304. :rtype: Ciphertext
  305. )pbdoc";
  306. const char* cc_EvalSubPlaintext_docs = R"pbdoc(
  307. EvalSub - OpenFHE EvalSub method for a ciphertext and plaintext
  308. :param ciphertext: ciphertext
  309. :type ciphertext: Ciphertext
  310. :param plaintext: plaintext
  311. :type plaintext: Plaintext
  312. :return: new ciphertext for ciphertext - plaintext
  313. :rtype: Ciphertext
  314. )pbdoc";
  315. const char* cc_EvalSubInPlace_docs = R"pbdoc(
  316. Inplace version of EvalSub for a pair of ciphertexts
  317. :param ct1: Input/output ciphertext
  318. :type ct1: Ciphertext
  319. :param ct2: Input ciphertext
  320. :type ct2: Ciphertext
  321. :return: ct1 contains ct1 - ct2
  322. )pbdoc";
  323. const char* cc_EvalSubInPlacefloat_docs = R"pbdoc(
  324. Inplace version of EvalSub for a ciphertext and constant
  325. :param ciphertext: Input/output ciphertext
  326. :type ciphertext: Ciphertext
  327. :param constant: constant to subtract
  328. :type constant: float
  329. :return: ciphertext contains ciphertext - constant
  330. )pbdoc";
  331. // EvalSubMutable
  332. const char* cc_EvalSubMutable_docs = R"pbdoc(
  333. EvalSub - OpenFHE EvalSubMutable method for a pair of ciphertexts. This is a mutable version - input ciphertexts may get automatically rescaled, or level-reduced.
  334. :param ct1: first ciphertext
  335. :type ct1: Ciphertext
  336. :param ct2: second ciphertext
  337. :type ct2: Ciphertext
  338. :return: new ciphertext for ct1 - ct2
  339. )pbdoc";
  340. // EvalSubMutableInPlace
  341. const char* cc_EvalSubMutableInPlace_docs = R"pbdoc(
  342. EvalSub - Inplace variant for EvalSubMutable.
  343. :param ct1: Input/output ciphertext
  344. :type ct1: Ciphertext
  345. :param ct2: Input ciphertext
  346. :type ct2: Ciphertext
  347. :return: ct1 contains ct1 - ct2
  348. )pbdoc";
  349. // EvalSubMutablePlaintext
  350. const char* cc_EvalSubMutablePlaintext_docs = R"pbdoc(
  351. EvalSub - OpenFHE EvalSubMutable method for a ciphertext and plaintext. This is a mutable version - input ciphertexts may get automatically rescaled, or level-reduced.
  352. :param ciphertext: ciphertext
  353. :type ciphertext: Ciphertext
  354. :param plaintext: plaintext
  355. :type plaintext: Plaintext
  356. :return: new ciphertext for ciphertext - plaintext
  357. )pbdoc";
  358. const char* cc_EvalMult_docs = R"pbdoc(
  359. EvalMult - OpenFHE EvalMult method for a pair of ciphertexts - with key switching
  360. :param ct1: first ciphertext
  361. :type ct1: Ciphertext
  362. :param ct2: second ciphertext
  363. :type ct2: Ciphertext
  364. :return: new ciphertext for ct1 * ct2
  365. :rtype: Ciphertext
  366. )pbdoc";
  367. const char* cc_EvalMultfloat_docs = R"pbdoc(
  368. EvalMult - OpenFHE EvalMult method for a ciphertext and constant
  369. :param ciphertext: the ciphertext
  370. :type ciphertext: Ciphertext
  371. :param constant: constant to multiply
  372. :type constant: float
  373. :return: new ciphertext for ciphertext * constant
  374. :rtype: Ciphertext
  375. )pbdoc";
  376. const char* cc_EvalMultPlaintext_docs = R"pbdoc(
  377. EvalMult - OpenFHE EvalMult method for a ciphertext and plaintext
  378. :param ciphertext: the ciphertext
  379. :type ciphertext: Ciphertext
  380. :param plaintext: the plaintext
  381. :type plaintext: Plaintext
  382. :return: new ciphertext for ciphertext * plaintext
  383. :rtype: Ciphertext
  384. )pbdoc";
  385. const char* cc_EvalMultMutable_docs = R"pbdoc(
  386. EvalMult - OpenFHE EvalMultMutable method for a pair of ciphertexts. This is a mutable version - input ciphertexts may get automatically rescaled, or level-reduced.
  387. :param ct1: first ciphertext
  388. :type ct1: Ciphertext
  389. :param ct2: second ciphertext
  390. :type ct2: Ciphertext
  391. :return: new ciphertext for ct1 * ct2
  392. :rtype: Ciphertext
  393. )pbdoc";
  394. const char* cc_EvalMultMutablePlaintext_docs = R"pbdoc(
  395. EvalMult - OpenFHE EvalMultMutable method for a ciphertext and plaintext. This is a mutable version - input ciphertexts may get automatically rescaled, or level-reduced.
  396. :param ciphertext: the ciphertext
  397. :type ciphertext: Ciphertext
  398. :param plaintext: the plaintext
  399. :type plaintext: Plaintext
  400. :return: new ciphertext for ciphertext * plaintext
  401. :rtype: Ciphertext
  402. )pbdoc";
  403. const char* cc_EvalMultMutableInPlace_docs = R"pbdoc(
  404. EvalMult - OpenFHE EvalMult method for a pair of ciphertexts - with key switching. This is a mutable version - input ciphertexts may get automatically rescaled, or level-reduced.
  405. :param ct1: Input/output ciphertext
  406. :type ct1: Ciphertext
  407. :param ct2: Input cipherext
  408. :type ct2: Ciphertext
  409. :return: ct1 contains ct1 * ct2
  410. )pbdoc";
  411. const char* cc_EvalSquare_docs = R"pbdoc(
  412. EvalSquare - OpenFHE EvalSquare method for a ciphertext
  413. :param ct: the ciphertext to square
  414. :type ct: Ciphertext
  415. :return: new ciphertext for ct^2 = ct * ct
  416. :rtype: Ciphertext
  417. )pbdoc";
  418. const char* cc_EvalSquareMutable_docs = R"pbdoc(
  419. EvalSquare - OpenFHE EvalSquareMutable method for a ciphertext. This is a mutable version - input ciphertexts may get automatically rescaled, or level-reduced.
  420. :param ct: the ciphertext to square
  421. :type ct: Ciphertext
  422. :return: new ciphertext for ct^2 = ct * ct
  423. :rtype: Ciphertext
  424. )pbdoc";
  425. const char* cc_EvalSquareInPlace_docs = R"pbdoc(
  426. EvalSquare - OpenFHE EvalSquare method for a ciphertext. This is a mutable version - input ciphertexts may get automatically rescaled, or level-reduced.
  427. :param ct: Input/output ciphertext
  428. :type ct: Ciphertext
  429. :return: ct contains ct^2 = ct * ct
  430. )pbdoc";
  431. const char* cc_EvalMultNoRelin_docs = R"pbdoc(
  432. EvalMultNoRelin - OpenFHE EvalMult method for a pair of ciphertexts - no key switching (relinearization)
  433. :param ct1: first ciphertext
  434. :type ct1: Ciphertext
  435. :param ct2: second ciphertext
  436. :type ct2: Ciphertext
  437. :return: new ciphertext for ct1 * ct2
  438. :rtype: Ciphertext
  439. )pbdoc";
  440. const char* cc_Relinearize_docs = R"pbdoc(
  441. Function for relinearization of a ciphertext.
  442. :param ct: input ciphertext
  443. :type ct: Ciphertext
  444. :return: relienarized ciphertext
  445. :rtype: Ciphertext
  446. )pbdoc";
  447. const char* cc_RelinearizeInPlace_docs = R"pbdoc(
  448. Function for inplace relinearization of a ciphertext.
  449. :param ct: input/output ciphertext
  450. :type ct: Ciphertext
  451. :return: ct contains relienarized ciphertext
  452. )pbdoc";
  453. const char* cc_EvalMultAndRelinearize_docs = R"pbdoc(
  454. Function for evaluating multiplication on ciphertext followed by relinearization operation. Currently it assumes that the input arguments have total depth smaller than the supported depth. Otherwise, it throws an error
  455. :param ct1: first input ciphertext
  456. :type ct1: Ciphertext
  457. :param ct2: second input ciphertext
  458. :type ct2: Ciphertext
  459. :return: new ciphertext
  460. :rtype: Ciphertext
  461. )pbdoc";
  462. const char* cc_EvalNegate_docs = R"pbdoc(
  463. EvalSub - OpenFHE Negate method for a ciphertext
  464. :param ct: input ciphertext
  465. :type ct: Ciphertext
  466. :return: new ciphertext -ct
  467. :rtype: Ciphertext
  468. )pbdoc";
  469. const char* cc_EvalNegateInPlace_docs = R"pbdoc(
  470. EvalSub - Inplace OpenFHE Negate method for a ciphertext
  471. :param ct: input/output ciphertext
  472. :type ct: Ciphertext
  473. :return: ct contains -ct
  474. )pbdoc";
  475. const char* cc_EvalChebyshevSeries_docs = R"pbdoc(
  476. Method for evaluating Chebyshev polynomial interpolation; first the range [a,b] is mapped to [-1,1] using linear transformation 1 + 2 (x-a)/(b-a) If the degree of the polynomial is less than 5, use EvalChebyshevSeriesLinear, otherwise, use EvalChebyshevSeriesPS.
  477. :param ciphertext: input ciphertext
  478. :type ciphertext: Ciphertext
  479. :param coefficients: list of coefficients in Chebyshev expansion
  480. :type coefficients: list
  481. :param a: lower bound of argument for which the coefficients were found
  482. :type a: float
  483. :param b: upper bound of argument for which the coefficients were found
  484. :type b: float
  485. :return: the result of polynomial evaluation
  486. :rtype: Ciphertext
  487. )pbdoc";
  488. const char* cc_EvalChebyshevSeriesLinear_docs = R"pbdoc(
  489. Evaluate Chebyshev polynomial of degree less than 5.
  490. :param ciphertext: input ciphertext
  491. :type ciphertext: Ciphertext
  492. :param coefficients: list of coefficients in Chebyshev expansion
  493. :type coefficients: list
  494. :param a: lower bound of argument for which the coefficients were found
  495. :type a: float
  496. :param b: upper bound of argument for which the coefficients were found
  497. :type b: float
  498. :return: the result of polynomial evaluation
  499. :rtype: Ciphertext
  500. )pbdoc";
  501. const char* cc_EvalChebyshevSeriesPS_docs = R"pbdoc(
  502. Evaluate Chebyshev polynomial of degree greater or equal to 5.
  503. :param ciphertext: input ciphertext
  504. :type ciphertext: Ciphertext
  505. :param coefficients: list of coefficients in Chebyshev expansion
  506. :type coefficients: list
  507. :param a: lower bound of argument for which the coefficients were found
  508. :type a: float
  509. :param b: upper bound of argument for which the coefficients were found
  510. :type b: float
  511. :return: the result of polynomial evaluation
  512. :rtype: Ciphertext
  513. )pbdoc";
  514. const char* cc_EvalChebyshevFunction_docs = R"pbdoc(
  515. Method for calculating Chebyshev evaluation on a ciphertext for a smooth input function over the range [a,b].
  516. :param func: the function to be approximated
  517. :type func: function
  518. :param ciphertext: input ciphertext
  519. :type ciphertext: Ciphertext
  520. :param a: lower bound of argument for which the coefficients were found
  521. :type a: float
  522. :param b: upper bound of argument for which the coefficients were found
  523. :type b: float
  524. :param degree: Desired degree of approximation
  525. :type degree: int
  526. :return: the coefficients of the Chebyshev approximation.
  527. :rtype: Ciphertext
  528. )pbdoc";
  529. const char* cc_EvalSin_docs = R"pbdoc(
  530. Evaluate approximate sine function on a ciphertext using the Chebyshev approximation.
  531. :param ciphertext: input ciphertext
  532. :type ciphertext: Ciphertext
  533. :param a: lower bound of argument for which the coefficients were found
  534. :type a: float
  535. :param b: upper bound of argument for which the coefficients were found
  536. :type b: float
  537. :param degree: Desired degree of approximation
  538. :type degree: int
  539. :return: the result of polynomial evaluation.
  540. :rtype: Ciphertext
  541. )pbdoc";
  542. const char* cc_EvalCos_docs = R"pbdoc(
  543. Evaluate approximate cosine function on a ciphertext using the Chebyshev approximation.
  544. :param ciphertext: input ciphertext
  545. :type ciphertext: Ciphertext
  546. :param a: lower bound of argument for which the coefficients were found
  547. :type a: float
  548. :param b: upper bound of argument for which the coefficients were found
  549. :type b: float
  550. :param degree: Desired degree of approximation
  551. :type degree: int
  552. :return: the result of polynomial evaluation.
  553. :rtype: Ciphertext
  554. )pbdoc";
  555. const char* cc_EvalLogistic_docs = R"pbdoc(
  556. Evaluate approximate logistic function 1/(1 + exp(-x)) on a ciphertext using the Chebyshev approximation.
  557. :param ciphertext: input ciphertext
  558. :type ciphertext: Ciphertext
  559. :param a: lower bound of argument for which the coefficients were found
  560. :type a: float
  561. :param b: upper bound of argument for which the coefficients were found
  562. :type b: float
  563. :param degree: Desired degree of approximation
  564. :type degree: int
  565. :return: the result of polynomial evaluation.
  566. :rtype: Ciphertext
  567. )pbdoc";
  568. const char* cc_EvalDivide_docs = R"pbdoc(
  569. Evaluate approximate division function 1/x where x >= 1 on a ciphertext using the Chebyshev approximation.
  570. :param ciphertext: input ciphertext
  571. :type ciphertext: Ciphertext
  572. :param a: lower bound of argument for which the coefficients were found
  573. :type a: float
  574. :param b: upper bound of argument for which the coefficients were found
  575. :type b: float
  576. :param degree: Desired degree of approximation
  577. :type degree: int
  578. :return: the result of polynomial evaluation.
  579. :rtype: Ciphertext
  580. )pbdoc";
  581. const char* cc_EvalSumKeyGen_docs = R"pbdoc(
  582. EvalSumKeyGen generates the key map to be used by evalsum
  583. :param privateKey: private key
  584. :type privateKey: PrivateKey
  585. :param publicKey: public key (used in NTRU schemes)
  586. :type publicKey: PublicKey
  587. :return: None
  588. )pbdoc";
  589. const char* cc_EvalSumRowsKeyGen_docs = R"pbdoc(
  590. EvalSumRowsKeyGen generates the key map to be used by EvalSumRows
  591. :param privateKey: private key
  592. :type privateKey: PrivateKey
  593. :param publicKey: public key (used in NTRU schemes)
  594. :type publicKey: PublicKey
  595. :param rowSize: number of rows
  596. :type rowSize: int
  597. :param subringDim: dimension of the subring
  598. :type subringDim: int
  599. :return: dict: Evaluation key map, where the keys being integer indexes and values being EvalKey objects
  600. )pbdoc";
  601. const char* cc_EvalSumColsKeyGen_docs = R"pbdoc(
  602. EvalSumColsKeyGen generates the key map to be used by EvalSumCols
  603. :param privateKey: private key
  604. :type privateKey: PrivateKey
  605. :param publicKey: public key (used in NTRU schemes)
  606. :type publicKey: PublicKey
  607. :return: dict: Evaluation key map, where the keys being integer indexes and values being EvalKey objects
  608. )pbdoc";
  609. const char* cc_EvalSumRows_docs = R"pbdoc(
  610. :param ciphertext: input ciphertext
  611. :type ciphertext: Ciphertext
  612. :param rowSize: number of rows
  613. :type rowSize: int
  614. :param evalSumKeyMap: evaluation key map, where the keys being integer indexes and values being EvalKey objects
  615. :type evalSumKeyMap: dict
  616. :param subringDim: dimension of the subring
  617. :type subringDim: int
  618. :return: Ciphertext: resulting ciphertext
  619. :rtype: Ciphertext
  620. )pbdoc";
  621. const char* cc_EvalSumCols_docs = R"pbdoc(
  622. :param ciphertext: input ciphertext
  623. :type ciphertext: Ciphertext
  624. :param rowSize: number of rows
  625. :type rowSize: int
  626. :param evalSumKeyMap: evaluation key map, where the keys being integer indexes and values being EvalKey objects
  627. :type evalSumKeyMap: dict
  628. :return: Ciphertext: resulting ciphertext
  629. :rtype: Ciphertext
  630. )pbdoc";
  631. const char* cc_EvalInnerProduct_docs = R"pbdoc(
  632. Evaluates inner product in batched encoding
  633. :param ciphertext1: first vector
  634. :type ciphertext1: Ciphertext
  635. :param ciphertext2: second vector
  636. :type ciphertext2: Ciphertext
  637. :param batchSize: size of the batch to be summed up
  638. :type batchSize: int
  639. :return: Ciphertext: resulting ciphertext
  640. :rtype: Ciphertext
  641. )pbdoc";
  642. const char* cc_EvalInnerProductPlaintext_docs = R"pbdoc(
  643. Evaluates inner product in batched encoding
  644. :param ciphertext: first vector - ciphertext
  645. :type ciphertext: Ciphertext
  646. :param plaintext: second vector - plaintext
  647. :type plaintext: Plaintext
  648. :param batchSize: size of the batch to be summed up
  649. :type batchSize: int
  650. :return: Ciphertext: resulting ciphertext
  651. :rtype: Ciphertext
  652. )pbdoc";
  653. const char* cc_EvalMerge_docs = R"pbdoc(
  654. Merges multiple ciphertexts with encrypted results in slot 0 into a single ciphertext The slot assignment is done based on the order of ciphertexts in the vector
  655. :param ciphertextVec: vector of ciphertexts to be merged.
  656. :type ciphertextVec: list
  657. :return: Ciphertext: resulting ciphertext
  658. :rtype: Ciphertext
  659. )pbdoc";
  660. const char* cc_EvalPoly_docs = R"pbdoc(
  661. Method for polynomial evaluation for polynomials represented as power series.
  662. :param ciphertext: input ciphertext
  663. :type ciphertext: Ciphertext
  664. :param coefficients: vector of coefficients in the polynomial; the size of the vector is the degree of the polynomial + 1
  665. :type coefficients: list
  666. :return: Ciphertext: the result of polynomial evaluation.
  667. :rtype: Ciphertext
  668. )pbdoc";
  669. const char* cc_EvalPolyLinear_docs = R"pbdoc(
  670. Method for polynomial evaluation for polynomials represented in the power series. This uses EvalPolyLinear, which uses a binary tree computation of the polynomial powers.
  671. :param ciphertext: input ciphertext
  672. :type ciphertext: Ciphertext
  673. :param coefficients: vector of coefficients in the polynomial; the size of the vector is the degree of the polynomial
  674. :type coefficients: list
  675. :return: Ciphertext: the result of polynomial evaluation.
  676. :rtype: Ciphertext
  677. )pbdoc";
  678. const char* cc_EvalPolyPS_docs = R"pbdoc(
  679. :param ciphertext: input ciphertext
  680. :type ciphertext: Ciphertext
  681. :param coefficients: vector of coefficients in the polynomial; the size of the vector is the degree of the polynomial
  682. :type coefficients: list
  683. :return: Ciphertext: the result of polynomial evaluation.
  684. :rtype: Ciphertext
  685. )pbdoc";
  686. const char* cc_Rescale_docs = R"pbdoc(
  687. Rescale - An alias for OpenFHE ModReduce method. This is because ModReduce is called Rescale in CKKS.
  688. :param ciphertext: ciphertext
  689. :type ciphertext: Ciphertext
  690. :return: Ciphertext: mod reduced ciphertext
  691. :rtype: Ciphertext
  692. )pbdoc";
  693. const char* cc_EvalBootstrapSetup_docs = R"pbdoc(
  694. Bootstrap functionality: There are three methods that have to be called in this specific order:
  695. 1. EvalBootstrapSetup: computes and encodes the coefficients for encoding and decoding and stores the necessary parameters
  696. 2. EvalBootstrapKeyGen: computes and stores the keys for rotations and conjugation
  697. 3. EvalBootstrap: refreshes the given ciphertext Sets all parameters for the linear method for the FFT-like method
  698. :param levelBudget: vector of budgets for the amount of levels in encoding and decoding
  699. :type levelBudget: list
  700. :param dim1: vector of inner dimension in the baby-step giant-step routine for encoding and decodingl
  701. :type dim1: list
  702. :param slots: number of slots to be bootstraped
  703. :type slots: int
  704. :param correctionFactor: alue to rescale message by to improve precision. If set to 0, we use the default logic. This value is only used when get_native_int()=64
  705. :type correctionFactor: int
  706. :return: None
  707. )pbdoc";
  708. const char* cc_EvalBootstrapKeyGen_docs = R"pbdoc(
  709. Generates all automorphism keys for EvalBT. EvalBootstrapKeyGen uses the baby-step/giant-step strategy.
  710. :param privateKey: private key.
  711. :type privateKey: PrivateKey
  712. :param slots: number of slots to support permutations on.
  713. :type slots: int
  714. :return: None
  715. )pbdoc";
  716. const char* cc_EvalBootstrap_docs = R"pbdoc(
  717. Defines the bootstrapping evaluation of ciphertext using either the FFT-like method or the linear method
  718. :param ciphertext: the input ciphertext
  719. :type ciphertext: Ciphertext
  720. :param numIterations: number of iterations to run iterative bootstrapping (Meta-BTS). Increasing the iterations increases the precision of bootstrapping
  721. :type numIterations: int
  722. :param precision: precision of initial bootstrapping algorithm. This value is determined by the user experimentally by first running EvalBootstrap with numIterations = 1 and precision = 0 (unused).
  723. :type precision: int
  724. :return: Ciphertext: the refreshed ciphertext
  725. :rtype: Ciphertext
  726. )pbdoc";
  727. const char* cc_EvalAutomorphismKeyGen_docs = R"pbdoc(
  728. Generate automophism keys for a given private key; Uses the private key for encryption
  729. :param privateKey: private key.
  730. :type privateKey: PrivateKey
  731. :param indexList: list of automorphism indices to be computed.
  732. :type indexList: list
  733. :return: dict: returns the evaluation key
  734. )pbdoc";
  735. const char* cc_EvalAutomorphismKeyGenPublic_docs = R"pbdoc(
  736. Generate automophism keys for a given private key.
  737. :param publicKey: original public key.
  738. :type publicKey: PublicKey
  739. :param privateKey: original private key.
  740. :type privateKey: PrivateKey
  741. :param indexList: list of automorphism indices to be computed.
  742. :type indexList: list
  743. :return: dict: returns the evaluation keys; index 0 of the vector corresponds to plaintext index 2, index 1 to plaintex index 3, etc.
  744. )pbdoc";
  745. const char* cc_FindAutomorphismIndex_docs = R"pbdoc(
  746. Find the automorphism index for a given plaintext index
  747. :param idx: plaintext index
  748. :type idx: int
  749. :return: int: automorphism index
  750. )pbdoc";
  751. const char* cc_FindAutomorphismIndices_docs = R"pbdoc(
  752. Find the automorphism indices for a given list of plaintext indices
  753. :param idxList: list of plaintext indices
  754. :type idxList: list
  755. :return: list: list of automorphism indices
  756. )pbdoc";
  757. const char* cc_ClearEvalMultKeys_docs = R"pbdoc(
  758. ClearEvalMultKeys - flush EvalMultKey cache
  759. )pbdoc";
  760. const char* cc_ClearEvalAutomorphismKeys_docs = R"pbdoc(
  761. ClearEvalAutomorphismKeys - flush EvalAutomorphismKey cache
  762. )pbdoc";
  763. const char* cc_SerializeEvalAutomorphismKey_docs = R"pbdoc(
  764. SerializeEvalAutomorphismKey for a single EvalAuto key or all of the EvalAuto keys
  765. :param filename: output file
  766. :type filename: str
  767. :param sertype: serialization type
  768. :type sertype: SERJSON, SERBINARY
  769. :param id: key to serialize; empty string means all keys
  770. :type id: str
  771. :return: bool: true on success
  772. )pbdoc";
  773. const char* cc_SerializeEvalMultKey_docs = R"pbdoc(
  774. SerializeEvalMultKey for a single EvalMult key or all of the EvalMult keys
  775. :param filename: output file
  776. :type filename: str
  777. :param sertype: type of serialization
  778. :type sertype: SERJSON, SERBINARY
  779. :param id: for key to serialize - if empty string, serialize them all
  780. :type id: str
  781. :return: bool: true on success
  782. )pbdoc";
  783. const char* cc_DeserializeEvalAutomorphismKey_docs = R"pbdoc(
  784. DeserializeEvalAutomorphismKey deserialize all keys in the serialization deserialized keys silently replace any existing matching keys deserialization will create CryptoContext if necessary
  785. :param filename: path for the file to deserialize from
  786. :type filename: str
  787. :param sertype: type of serialization
  788. :type sertype: SERJSON, SERBINARY
  789. :return: bool: true on success
  790. )pbdoc";
  791. const char* cc_DeserializeEvalMultKey_docs = R"pbdoc(
  792. DeserializeEvalMultKey deserialize all keys in the serialization deserialized keys silently replace any existing matching keys deserialization will create CryptoContext if necessary
  793. :param filename: path for the file to deserialize from
  794. :type filename: str
  795. :param sertype: type of serialization
  796. :type sertype: SERJSON, SERBINARY
  797. :return: bool: true on success
  798. )pbdoc";
  799. #endif //CRYPTOCONTEXT_DOCSTRINGS_H