cryptocontext_docs.h 39 KB

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