cryptocontext_docs.h 59 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594
  1. //==================================================================================
  2. // BSD 2-Clause License
  3. //
  4. // Copyright (c) 2023-2025, Duality Technologies Inc. and other contributors
  5. //
  6. // All rights reserved.
  7. //
  8. // Author TPOC: contact@openfhe.org
  9. //
  10. // Redistribution and use in source and binary forms, with or without
  11. // modification, are permitted provided that the following conditions are met:
  12. //
  13. // 1. Redistributions of source code must retain the above copyright notice, this
  14. // list of conditions and the following disclaimer.
  15. //
  16. // 2. Redistributions in binary form must reproduce the above copyright notice,
  17. // this list of conditions and the following disclaimer in the documentation
  18. // and/or other materials provided with the distribution.
  19. //
  20. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  21. // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  22. // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  23. // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  24. // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  25. // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  26. // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  27. // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  28. // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  29. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  30. //==================================================================================
  31. #ifndef __CRYPTOCONTEXT_DOCS_H__
  32. #define __CRYPTOCONTEXT_DOCS_H__
  33. #include "pybind11/pybind11.h"
  34. #include "pybind11/attr.h"
  35. namespace py = pybind11;
  36. // const char* cc_docs = R"doc(
  37. // test
  38. // )doc";
  39. // auto cc_docs2 = py::doc(cc_docs);
  40. const char* cc_SetKeyGenLevel_docs = R"pbdoc(
  41. For future use: setter for the level at which evaluation keys should be generated
  42. :param level: the level to set the key generation to
  43. :type level: int
  44. )pbdoc";
  45. const char* cc_GetKeyGenLevel_docs = R"pbdoc(
  46. For future use: getter for the level at which evaluation keys should be generated
  47. :return: The level used for key generation
  48. :rtype: int
  49. )pbdoc";
  50. const char* cc_GetRingDimension_docs = R"pbdoc(
  51. Getter for ring dimension
  52. :return: The ring dimension
  53. :rtype: int
  54. )pbdoc";
  55. const char* cc_GetPlaintextModulus_docs = R"pbdoc(
  56. Get the plaintext modulus used for this context
  57. :return: The plaintext modulus
  58. :rtype: int
  59. )pbdoc";
  60. const char* cc_GetCyclotomicOrder_docs = R"pbdoc(
  61. Getter for cyclotomic order
  62. :return: cyclotomic order
  63. :rtype: int
  64. )pbdoc";
  65. const char* cc_GetModulus_docs = R"pbdoc(
  66. Getter for ciphertext modulus
  67. :return: modulus
  68. :rtype: int
  69. )pbdoc";
  70. const char* cc_Enable_docs = R"pbdoc(
  71. Enable a particular feature for use with this CryptoContext
  72. :param feature: the feature that should be enabled.
  73. The list of available features is defined in the PKESchemeFeature enum.
  74. :type feature: PKESchemeFeature
  75. )pbdoc";
  76. const char* cc_KeyGen_docs = R"pbdoc(
  77. Generates a standard public/secret key pair.
  78. :return: a public/secret key pair
  79. :rtype: KeyPair
  80. )pbdoc";
  81. const char* cc_EvalMultKeyGen_docs = R"pbdoc(
  82. EvalMultKeyGen creates a key that can be used with the OpenFHE EvalMult operator.
  83. The new evaluation key is stored in cryptocontext.
  84. :param privateKey: the private key
  85. :type privateKey: PrivateKey
  86. )pbdoc";
  87. const char* cc_EvalMultKeysGen_docs = R"pbdoc(
  88. EvalMultsKeyGen creates a vector evalmult keys that can be used with the OpenFHE EvalMult operator.
  89. The 1st key (for s^2) is used for multiplication of ciphertexts of depth 1.
  90. The 2nd key (for s^3) is used for multiplication of ciphertexts of depth 2, etc.
  91. A vector of new evaluation keys is stored in cryptocontext.
  92. :param privateKey: the private key
  93. :type privateKey: PrivateKey
  94. )pbdoc";
  95. const char* cc_EvalRotateKeyGen_docs = R"pbdoc(
  96. EvalRotateKeyGen generates evaluation keys for a list of indices. Calls EvalAtIndexKeyGen under the hood.
  97. :param privateKey: private key
  98. :type privateKey: PrivateKey
  99. :param indexList: list of integers representing the indices
  100. :type indexList: list
  101. :param publicKey: public key (used in NTRU schemes)
  102. :type publicKey: PublicKey
  103. )pbdoc";
  104. const char* cc_MakeStringPlaintext_docs = R"pbdoc(
  105. MakeStringPlaintext constructs a StringEncoding in this context.
  106. :param str: string to be encoded
  107. :type str: str
  108. :return: plaintext
  109. )pbdoc";
  110. const char* cc_MakePackedPlaintext_docs = R"pbdoc(
  111. MakePackedPlaintext constructs a PackedEncoding in this context
  112. :param value: vector of signed integers mod t
  113. :type value: List[int]
  114. :param noiseScaleDeg: is degree of the scaling factor to encode the plaintext at
  115. :type noiseScaleDeg: int
  116. :param level: is the level to encode the plaintext at
  117. :type level: int
  118. :return: plaintext
  119. :rtype: Plaintext
  120. )pbdoc";
  121. const char* cc_MakeCoefPackedPlaintext_docs = R"pbdoc(
  122. MakeCoefPackedPlaintext constructs a CoefPackedEncoding in this context
  123. :param value: vector of signed integers mod t
  124. :type value: List[int]
  125. :param noiseScaleDeg : is degree of the scaling factor to encode the plaintext at
  126. :type noiseScaleDeg : int
  127. :param level: is the level to encode the plaintext at
  128. :type level: int
  129. :return: plaintext
  130. :rtype: Plaintext
  131. )pbdoc";
  132. const char* cc_MakeCKKSPackedPlaintextComplex_docs = R"pbdoc(
  133. COMPLEX ARITHMETIC IS NOT AVAILABLE, AND THIS METHOD BE DEPRECATED. USE THE REAL-NUMBER METHOD INSTEAD. MakeCKKSPackedPlaintext constructs a CKKSPackedEncoding in this context from a vector of complex numbers
  134. :param value: input vector of complex numbers
  135. :type value: List[complex]
  136. :param scaleDeg: degree of scaling factor used to encode the vector
  137. :type scaleDeg: int
  138. :param level: level at each the vector will get encrypted
  139. :type level: int
  140. :param params: parameters to be used for the ciphertext (Only accepting params = None in this version)
  141. :type params: openfhe.ParmType
  142. :param slots: number of slots
  143. :type slots: int
  144. :return: plaintext
  145. :rtype: Plaintext
  146. )pbdoc";
  147. const char* cc_MakeCKKSPlaintextReal_docs = R"pbdoc(
  148. MakeCKKSPlaintext constructs a CKKSPackedEncoding in this context from a vector of real numbers
  149. :param value: input vector (of floats)
  150. :type value: list
  151. :param scaleDeg: degree of scaling factor used to encode the vector
  152. :type scaleDeg: int
  153. :param level: level at each the vector will get encrypted
  154. :type level: int
  155. :param params: parameters to be used for the ciphertext (Only accepting params = None in this version)
  156. :type params: openfhe.ParmType
  157. :param slots: number of slots
  158. :type slots: int
  159. :return: plaintext
  160. :rtype: Plaintext
  161. )pbdoc";
  162. const char* cc_EvalRotate_docs = R"pbdoc(
  163. Rotates a ciphertext by an index (positive index is a left shift, negative index is a right shift). Uses a rotation key stored in a crypto context. Calls EvalAtIndex under the hood.
  164. :param ciphertext: input ciphertext
  165. :type ciphertext: Ciphertext
  166. :param index: rotation index
  167. :type index: int
  168. :return: a rotated ciphertext
  169. :rtype: Ciphertext
  170. )pbdoc";
  171. const char* cc_EvalFastRotationPreCompute_docs = R"pbdoc(
  172. EvalFastRotationPrecompute implements the precomputation step of hoisted automorphisms.
  173. Please refer to Section 5 of Halevi and Shoup, "Faster Homomorphic
  174. linear transformations in HELib." for more details, link:
  175. https://eprint.iacr.org/2018/244.
  176. Generally, automorphisms are performed with three steps:
  177. (1) The automorphism is applied to the ciphertext.
  178. (2) The automorphed values are decomposed into digits.
  179. (3) Key switching is applied to enable further computations on the ciphertext.
  180. Hoisted automorphisms are a technique that performs the digit decomposition for the original ciphertext first,
  181. and then performs the automorphism and the key switching on the decomposed digits.
  182. The benefit of this is that the digit decomposition is independent of the automorphism rotation index,
  183. so it can be reused for multiple different indices.
  184. This can greatly improve performance when we have to compute many automorphisms on the same ciphertext.
  185. This routinely happens when we do permutations (EvalPermute).
  186. EvalFastRotationPrecompute implements the digit decomposition step of hoisted automorphisms.
  187. :param ciphertext: the input ciphertext on which to do the precomputation (digit decomposition)
  188. :type ciphertext: Ciphertext
  189. :return: the precomputed ciphertext created using the digit decomposition
  190. :rtype: Ciphertext
  191. )pbdoc";
  192. const char* cc_EvalFastRotation_docs = R"pbdoc(
  193. EvalFastRotation implements the automorphism and key switching step of hoisted automorphisms.
  194. Please refer to Section 5 of Halevi and Shoup, "Faster Homomorphic
  195. linear transformations in HELib." for more details, link:
  196. https://eprint.iacr.org/2018/244.
  197. Generally, automorphisms are performed with three steps:
  198. (1) The automorphism is applied to the ciphertext.
  199. (2) The automorphed values are decomposed into digits.
  200. (3) Key switching is applied to enable further computations on the ciphertext.
  201. Hoisted automorphisms are a technique that performs the digit decomposition for the original ciphertext first,
  202. and then performs the automorphism and the key switching on the decomposed digits.
  203. The benefit of this is that the digit decomposition is independent of the automorphism rotation index,
  204. so it can be reused for multiple different indices.
  205. This can greatly improve performance when we have to compute many automorphisms on the same ciphertext.
  206. This routinely happens when we do permutations (EvalPermute).
  207. EvalFastRotation implements the automorphism and key switching step of hoisted automorphisms.
  208. This method assumes that all required rotation keys exist.
  209. This may not be true if we are using baby-step/giant-step key switching.
  210. Please refer to Section 5.1 of the above reference and EvalPermuteBGStepHoisted to see how to deal with this issue.
  211. :param ciphertext: the input ciphertext to perform the automorphism on
  212. :type ciphertext: Ciphertext
  213. :param index: the index of the rotation. Positive indices correspond to left rotations and negative indices correspond to right rotations.
  214. :type index: int
  215. :param m: is the cyclotomic order
  216. :type m: int
  217. :param digits: the precomputed ciphertext created by EvalFastRotationPrecompute using the digit decomposition at the precomputation step
  218. :type digits: Ciphertext
  219. :return: the rotated ciphertext
  220. :rtype: Ciphertext
  221. )pbdoc";
  222. const char* cc_EvalFastRotationExt_docs = R"pbdoc(
  223. Only supported for hybrid key switching. Performs fast (hoisted) rotation and returns the results in the extended CRT basis P*Q
  224. :param ciphertext: input ciphertext
  225. :type ciphertext: Ciphertext
  226. :param index: the rotation index
  227. :type index: int
  228. :param digits: the precomputed ciphertext created by EvalFastRotationPrecompute
  229. :type digits: Ciphertext
  230. :param addFirst: if true, the first element c0 is also computed (otherwise ignored)
  231. :type addFirst: bool
  232. :return: resulting ciphertext
  233. :rtype: Ciphertext
  234. )pbdoc";
  235. const char* cc_EvalAtIndex_docs = R"pbdoc(
  236. Rotates a ciphertext by an index (positive index is a left shift, negative index is a right shift). Uses a rotation key stored in a crypto context.
  237. :param ciphertext: input ciphertext
  238. :type ciphertext: Ciphertext
  239. :param i: rotation index
  240. :type i: int
  241. :return: a rotated ciphertext
  242. :rtype: Ciphertext
  243. )pbdoc";
  244. const char* cc_EvalAtIndexKeyGen_docs = R"pbdoc(
  245. EvalAtIndexKeyGen generates evaluation keys for a list of rotation indices
  246. :param privateKey: the private key
  247. :type privateKey: PrivateKey
  248. :param indexList: list of indices
  249. :type indexList: list
  250. :param publicKey: the public key (used in NTRU schemes). Not used anymore.
  251. :type publicKey: PublicKey
  252. :return: None
  253. )pbdoc";
  254. const char* cc_Encrypt_docs = R"doc(
  255. Encrypt a plaintext using a given public key
  256. :param plaintext: plaintext
  257. :type plaintext: Plaintext
  258. :param publicKey: public key
  259. :type publicKey: PublicKey
  260. :return: ciphertext (or null on failure)
  261. :rtype: Ciphertext
  262. )doc";
  263. const char* cc_Decrypt_docs = R"pbdoc(
  264. Decrypt a single ciphertext into the appropriate plaintext
  265. :param ciphertext: ciphertext to decrypt
  266. :type ciphertext: Ciphertext
  267. :param privateKey: decryption key
  268. :type privateKey: PrivateKey
  269. :return: decrypted plaintext
  270. :rtype: Plaintext
  271. )pbdoc";
  272. const char* cc_KeySwitchGen_docs = R"pbdoc(
  273. Generates a key switching key from one secret key to another.
  274. :param oldPrivateKey: Original secret key.
  275. :type oldPrivateKey: PrivateKey
  276. :param newPrivateKey: Target secret key.
  277. :type newPrivateKey: PrivateKey
  278. :return: New evaluation key for key switching.
  279. :rtype: EvalKey
  280. )pbdoc";
  281. const char* cc_EvalAdd_docs = R"pbdoc(
  282. Homomorphic addition of two ciphertexts
  283. :param ciphertext1: first addend
  284. :type ciphertext1: Ciphertext
  285. :param ciphertext2: second addend
  286. :type ciphertext2: Ciphertext
  287. :return: the result as a new ciphertext
  288. :rtype: Ciphertext
  289. )pbdoc";
  290. const char* cc_EvalAddfloat_docs = R"pbdoc(
  291. EvalAdd - OpenFHE EvalAdd method for a ciphertext and a real number. Supported only in CKKS.
  292. :param ciphertext: input ciphertext
  293. :type ciphertext: Ciphertext
  294. :param constant: a real number
  295. :type constant: float
  296. :return: new ciphertext for ciphertext + constant
  297. :rtype: Ciphertext
  298. )pbdoc";
  299. const char* cc_EvalAddPlaintext_docs = R"pbdoc(
  300. EvalAdd - OpenFHE EvalAdd method for a ciphertext and plaintext
  301. :param ciphertext: input ciphertext
  302. :type ciphertext: Ciphertext
  303. :param plaintex: input plaintext
  304. :type plaintext: Plaintext
  305. :return: new ciphertext for ciphertext + constant
  306. :rtype: Ciphertext
  307. )pbdoc";
  308. const char* cc_EvalAddInPlace_docs = R"pbdoc(
  309. In-place homomorphic addition of two ciphertexts
  310. :param ciphertext1: ciphertext1
  311. :type ciphertext1: Ciphertext
  312. :param ciphertext2: second addend
  313. :type ciphertext2: Ciphertext
  314. :return: ciphertext1 contains ciphertext1 + ciphertext2
  315. )pbdoc";
  316. const char* cc_EvalAddInPlacePlaintext_docs = R"pbdoc(
  317. In-place addition for a ciphertext and plaintext
  318. :param ciphertext: Input/output ciphertext
  319. :type ciphertext: Ciphertext
  320. :param plaintext: Input plaintext
  321. :type plaintext: Plaintext
  322. :return: ciphertext contains ciphertext + plaintext
  323. )pbdoc";
  324. const char* cc_EvalAddMutable_docs = R"pbdoc(
  325. Homomorphic addition of two mutable ciphertexts (they can be changed during the operation)
  326. :param ciphertext1: first addend
  327. :type ciphertext1: Ciphertext
  328. :param ciphertext2: second addend
  329. :type ciphertext2: Ciphertext
  330. :return: the result as a new ciphertext
  331. :rtype: Ciphertext
  332. )pbdoc";
  333. const char* cc_EvalAddMutablePlaintext_docs = R"pbdoc(
  334. Homomorphic addition a mutable ciphertext and plaintext
  335. :param ciphertext: ciphertext
  336. :type ciphertext: Ciphertext
  337. :param plaintext: plaintext
  338. :type plaintext: Plaintext
  339. :return: new ciphertext for ciphertext + plaintext
  340. :rtype: Ciphertext
  341. )pbdoc";
  342. const char* cc_EvalAddMutableInPlace_docs = R"pbdoc(
  343. Homomorphic addition a mutable ciphertext and plaintext
  344. :param ciphertext1: first addend
  345. :type ciphertext1: Ciphertext
  346. :param ciphertext2: second addend
  347. :type ciphertext2: Ciphertext
  348. :return: ciphertext1 contains ciphertext1 + ciphertext2
  349. )pbdoc";
  350. const char* cc_EvalSub_docs = R"pbdoc(
  351. Homomorphic subtraction of two ciphertexts
  352. :param ciphertext1: minuend
  353. :type ciphertext1: Ciphertext
  354. :param ciphertext2: subtrahend
  355. :type ciphertext2: Ciphertext
  356. :return: the result as a new ciphertext
  357. :rtype: Ciphertext
  358. )pbdoc";
  359. const char* cc_EvalSubfloat_docs = R"pbdoc(
  360. Subtraction of a ciphertext and a real number. Supported only in CKKS.
  361. :param ciphertext: input ciphertext
  362. :type ciphertext: Ciphertext
  363. :param constant: a real number
  364. :type constant: float
  365. :return: new ciphertext for ciphertext - constant
  366. :rtype: Ciphertext
  367. )pbdoc";
  368. const char* cc_EvalSubPlaintext_docs = R"pbdoc(
  369. Subtraction of a ciphertext and a real number. Supported only in CKKS.
  370. :param ciphertext: minuend
  371. :type ciphertext: Ciphertext
  372. :param plaintext: subtrahend
  373. :type plaintext: Plaintext
  374. :return: new ciphertext for ciphertext - plaintext
  375. :rtype: Ciphertext
  376. )pbdoc";
  377. const char* cc_EvalSubInPlace_docs = R"pbdoc(
  378. In-place homomorphic subtraction of two ciphertexts
  379. :param ciphertext1: minuend
  380. :type ciphertext1: Ciphertext
  381. :param ciphertext2: subtrahend
  382. :type ciphertext2: Ciphertext
  383. :return: the result as a new ciphertext
  384. )pbdoc";
  385. const char* cc_EvalSubInPlacefloat_docs = R"pbdoc(
  386. In-place subtraction of a ciphertext and a real number. Supported only in CKKS.
  387. :param ciphertext: input ciphertext
  388. :type ciphertext: Ciphertext
  389. :param constant: a real number
  390. :type constant: float
  391. )pbdoc";
  392. // EvalSubMutable
  393. const char* cc_EvalSubMutable_docs = R"pbdoc(
  394. Homomorphic subtraction of two mutable ciphertexts
  395. :param ciphertext1: minuend
  396. :type ciphertext1: Ciphertext
  397. :param ciphertext2: subtrahend
  398. :type ciphertext2: Ciphertext
  399. :return: the result as a new ciphertext
  400. )pbdoc";
  401. // EvalSubMutableInPlace
  402. const char* cc_EvalSubMutableInPlace_docs = R"pbdoc(
  403. In-place homomorphic subtraction of two mutable ciphertexts
  404. :param ciphertext1: minuend
  405. :type ciphertext1: Ciphertext
  406. :param ciphertext2: subtrahend
  407. :type ciphertext2: Ciphertext
  408. :return: the updated minuend
  409. )pbdoc";
  410. // EvalSubMutablePlaintext
  411. const char* cc_EvalSubMutablePlaintext_docs = R"pbdoc(
  412. Homomorphic subtraction of mutable ciphertext and plaintext
  413. :param ciphertext: minuend
  414. :type ciphertext: Ciphertext
  415. :param plaintext: subtrahend
  416. :type plaintext: Plaintext
  417. :return: new ciphertext for ciphertext - plaintext
  418. )pbdoc";
  419. const char* cc_EvalMult_docs = R"pbdoc(
  420. EvalMult - OpenFHE EvalMult method for a pair of ciphertexts (uses a relinearization key from the crypto context)
  421. :param ciphertext1: multiplier
  422. :type ciphertext1: Ciphertext
  423. :param ciphertext2: multiplicand
  424. :type ciphertext2: Ciphertext
  425. :return: new ciphertext for ciphertext1 * ciphertext2
  426. :rtype: Ciphertext
  427. )pbdoc";
  428. const char* cc_EvalMultfloat_docs = R"pbdoc(
  429. Multiplication of a ciphertext by a real number. Supported only in CKKS.
  430. :param ciphertext: multiplier
  431. :type ciphertext: Ciphertext
  432. :param constant: multiplicand
  433. :type constant: float
  434. :return: the result of multiplication
  435. :rtype: Ciphertext
  436. )pbdoc";
  437. const char* cc_EvalMultPlaintext_docs = R"pbdoc(
  438. Multiplication of a ciphertext by a plaintext
  439. :param ciphertext: multiplier
  440. :type ciphertext: Ciphertext
  441. :param plaintext: multiplicand
  442. :type plaintext: Plaintext
  443. :return: the result of multiplication
  444. :rtype: Ciphertext
  445. )pbdoc";
  446. const char* cc_EvalMultMutable_docs = R"pbdoc(
  447. EvalMult - OpenFHE EvalMult method for a pair of mutable ciphertexts (uses a relinearization key from the crypto context)
  448. :param ciphertext1: multiplier
  449. :type ciphertext1: Ciphertext
  450. :param ciphertext2: multiplicand
  451. :type ciphertext2: Ciphertext
  452. :return: new ciphertext for ciphertext1 * ciphertext2
  453. :rtype: Ciphertext
  454. )pbdoc";
  455. const char* cc_EvalMultMutablePlaintext_docs = R"pbdoc(
  456. Multiplication of mutable ciphertext and plaintext
  457. :param ciphertext: multiplier
  458. :type ciphertext: Ciphertext
  459. :param plaintext: multiplicand
  460. :type plaintext: Plaintext
  461. :return: the result of multiplication
  462. :rtype: Ciphertext
  463. )pbdoc";
  464. const char* cc_EvalMultMutableInPlace_docs = R"pbdoc(
  465. In-place EvalMult method for a pair of mutable ciphertexts (uses a relinearization key from the crypto context)
  466. :param ciphertext1: multiplier
  467. :type ciphertext1: Ciphertext
  468. :param ciphertext2: multiplicand
  469. :type ciphertext2: Ciphertext
  470. )pbdoc";
  471. const char* cc_EvalSquare_docs = R"pbdoc(
  472. Efficient homomorphic squaring of a ciphertext - uses a relinearization key stored in the crypto context
  473. :param ciphertext: input ciphertext
  474. :type ciphertext: Ciphertext
  475. :return: squared ciphertext
  476. :rtype: Ciphertext
  477. )pbdoc";
  478. const char* cc_EvalSquareMutable_docs = R"pbdoc(
  479. Efficient homomorphic squaring of a mutable ciphertext - uses a relinearization key stored in the crypto context
  480. :param ciphertext: input ciphertext
  481. :type ciphertext: Ciphertext
  482. :return: squared ciphertext
  483. :rtype: Ciphertext
  484. )pbdoc";
  485. const char* cc_EvalSquareInPlace_docs = R"pbdoc(
  486. In-place homomorphic squaring of a mutable ciphertext - uses a relinearization key stored in the crypto context
  487. :param ciphertext: input ciphertext
  488. :type ciphertext: Ciphertext
  489. :return: squared ciphertext
  490. )pbdoc";
  491. const char* cc_EvalMultNoRelin_docs = R"pbdoc(
  492. Homomorphic multiplication of two ciphertexts without relinearization
  493. :param ciphertext1: multiplier
  494. :type ciphertext1: Ciphertext
  495. :param ciphertext2: multiplicand
  496. :type ciphertext2: Ciphertext
  497. :return: new ciphertext for ciphertext1 * ciphertext2
  498. :rtype: Ciphertext
  499. )pbdoc";
  500. const char* cc_Relinearize_docs = R"pbdoc(
  501. Homomorphic multiplication of two ciphertexts withour relinearization
  502. :param ciphertext: input ciphertext
  503. :type ciphertext: Ciphertext
  504. :return: relinearized ciphertext
  505. :rtype: Ciphertext
  506. )pbdoc";
  507. const char* cc_RelinearizeInPlace_docs = R"pbdoc(
  508. In-place relinearization of a ciphertext to the lowest level (with 2 polynomials per ciphertext).
  509. :param ciphertext: input ciphertext
  510. :type ciphertext: Ciphertext
  511. )pbdoc";
  512. const char* cc_EvalMultAndRelinearize_docs = R"pbdoc(
  513. Homomorphic multiplication of two ciphertexts followed by relinearization to the lowest level
  514. :param ciphertext1: first input ciphertext
  515. :type ciphertext1: Ciphertext
  516. :param ciphertext2: second input ciphertext
  517. :type ciphertext2: Ciphertext
  518. :return: new ciphertext
  519. :rtype: Ciphertext
  520. )pbdoc";
  521. const char* cc_EvalNegate_docs = R"pbdoc(
  522. Negates a ciphertext
  523. :param ciphertext: input ciphertext
  524. :type ciphertext: Ciphertext
  525. :return: new ciphertext: -ciphertext
  526. :rtype: Ciphertext
  527. )pbdoc";
  528. const char* cc_EvalNegateInPlace_docs = R"pbdoc(
  529. In-place negation of a ciphertext
  530. :param ciphertext: input ciphertext
  531. :type ciphertext: Ciphertext
  532. )pbdoc";
  533. const char* cc_EvalChebyshevSeries_docs = R"pbdoc(
  534. 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 (naive linear method), otherwise, use EvalChebyshevSeriesPS (Paterson-Stockmeyer method). Supported only in CKKS.
  535. :param ciphertext: input ciphertext
  536. :type ciphertext: Ciphertext
  537. :param coefficients: is the vector of coefficients in Chebyshev expansion
  538. :type coefficients: list
  539. :param a: lower bound of argument for which the coefficients were found
  540. :type a: float
  541. :param b: upper bound of argument for which the coefficients were found
  542. :type b: float
  543. :return: the result of polynomial evaluation
  544. :rtype: Ciphertext
  545. )pbdoc";
  546. const char* cc_EvalChebyshevSeriesLinear_docs = R"pbdoc(
  547. Naive linear 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). Supported only in CKKS.
  548. :param ciphertext: input ciphertext
  549. :type ciphertext: Ciphertext
  550. :param coefficients: is the vector of coefficients in Chebyshev expansion
  551. :type coefficients: list
  552. :param a: lower bound of argument for which the coefficients were found
  553. :type a: float
  554. :param b: upper bound of argument for which the coefficients were found
  555. :type b: float
  556. :return: the result of polynomial evaluation
  557. :rtype: Ciphertext
  558. )pbdoc";
  559. const char* cc_EvalChebyshevSeriesPS_docs = R"pbdoc(
  560. Paterson-Stockmeyer 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). Supported only in CKKS.
  561. :param ciphertext: input ciphertext
  562. :type ciphertext: Ciphertext
  563. :param coefficients: is the vector of coefficients in Chebyshev expansion
  564. :type coefficients: list
  565. :param a: lower bound of argument for which the coefficients were found
  566. :type a: float
  567. :param b: upper bound of argument for which the coefficients were found
  568. :type b: float
  569. :return: the result of polynomial evaluation
  570. :rtype: Ciphertext
  571. )pbdoc";
  572. const char* cc_EvalChebyshevFunction_docs = R"pbdoc(
  573. Method for calculating Chebyshev evaluation on a ciphertext for a smooth input function over the range [a,b]. Supported only in CKKS.
  574. :param func: the function to be approximated
  575. :type func: function
  576. :param ciphertext: input ciphertext
  577. :type ciphertext: Ciphertext
  578. :param a: lower bound of argument for which the coefficients were found
  579. :type a: float
  580. :param b: upper bound of argument for which the coefficients were found
  581. :type b: float
  582. :param degree: Desired degree of approximation
  583. :type degree: int
  584. :return: the coefficients of the Chebyshev approximation.
  585. :rtype: Ciphertext
  586. )pbdoc";
  587. const char* cc_EvalSin_docs = R"pbdoc(
  588. Evaluate approximate sine function on a ciphertext using the Chebyshev approximation. Supported only in CKKS.
  589. :param ciphertext: input ciphertext
  590. :type ciphertext: Ciphertext
  591. :param a: lower bound of argument for which the coefficients were found
  592. :type a: float
  593. :param b: upper bound of argument for which the coefficients were found
  594. :type b: float
  595. :param degree: Desired degree of approximation
  596. :type degree: int
  597. :return: the result of polynomial evaluation.
  598. :rtype: Ciphertext
  599. )pbdoc";
  600. const char* cc_EvalCos_docs = R"pbdoc(
  601. Evaluate approximate cosine function on a ciphertext using the Chebyshev approximation. Supported only in CKKS.
  602. :param ciphertext: input ciphertext
  603. :type ciphertext: Ciphertext
  604. :param a: lower bound of argument for which the coefficients were found
  605. :type a: float
  606. :param b: upper bound of argument for which the coefficients were found
  607. :type b: float
  608. :param degree: Desired degree of approximation
  609. :type degree: int
  610. :return: the result of polynomial evaluation.
  611. :rtype: Ciphertext
  612. )pbdoc";
  613. const char* cc_EvalLogistic_docs = R"pbdoc(
  614. Evaluate approximate logistic function 1/(1 + exp(-x)) on a ciphertext using the Chebyshev approximation. Supported only in CKKS.
  615. :param ciphertext: input ciphertext
  616. :type ciphertext: Ciphertext
  617. :param a: lower bound of argument for which the coefficients were found
  618. :type a: float
  619. :param b: upper bound of argument for which the coefficients were found
  620. :type b: float
  621. :param degree: Desired degree of approximation
  622. :type degree: int
  623. :return: the result of polynomial evaluation.
  624. :rtype: Ciphertext
  625. )pbdoc";
  626. const char* cc_EvalDivide_docs = R"pbdoc(
  627. Evaluate approximate division function 1/x where x >= 1 on a ciphertext using the Chebyshev approximation. Supported only in CKKS.
  628. :param ciphertext: input ciphertext
  629. :type ciphertext: Ciphertext
  630. :param a: lower bound of argument for which the coefficients were found
  631. :type a: float
  632. :param b: upper bound of argument for which the coefficients were found
  633. :type b: float
  634. :param degree: Desired degree of approximation
  635. :type degree: int
  636. :return: the result of polynomial evaluation.
  637. :rtype: Ciphertext
  638. )pbdoc";
  639. const char* cc_EvalSumKeyGen_docs = R"pbdoc(
  640. EvalSumKeyGen Generates the key map to be used by EvalSum
  641. :param privateKey: private key
  642. :type privateKey: PrivateKey
  643. :param publicKey: public key (used in NTRU schemes)
  644. :type publicKey: PublicKey
  645. :return: None
  646. )pbdoc";
  647. const char* cc_EvalSumRowsKeyGen_docs = R"pbdoc(
  648. Generates automorphism keys for EvalSumRows (only for packed encoding).
  649. :param privateKey: Private key used for key generation.
  650. :type privateKey: PrivateKey
  651. :param publicKey: Public key (used in NTRU schemes; unused now).
  652. :type publicKey: PublicKey
  653. :param rowSize: Number of slots per row in the packed matrix.
  654. :type rowSize: int
  655. :param subringDim: Subring dimension (use cyclotomic order if 0).
  656. :type subringDim: int
  657. :return: Map of generated evaluation keys.
  658. :rtype: EvalKeyMap
  659. )pbdoc";
  660. const char* cc_EvalSumColsKeyGen_docs = R"pbdoc(
  661. Generates automorphism keys for EvalSumCols (only for packed encoding).
  662. :param privateKey: Private key used for key generation.
  663. :type privateKey: PrivateKey
  664. :param publicKey: Public key (used in NTRU schemes; unused now).
  665. :type publicKey: PublicKey
  666. :return: Map of generated evaluation keys.
  667. :rtype: EvalKeyMap
  668. )pbdoc";
  669. const char* cc_EvalSumRows_docs = R"pbdoc(
  670. Sums all elements across each row in a packed-encoded matrix ciphertext.
  671. :param ciphertext: Input ciphertext.
  672. :type ciphertext: Ciphertext
  673. :param numRows: Number of rows in the matrix.
  674. :type numRows: int
  675. :param evalSumKeyMap: Map of evaluation keys generated for row summation.
  676. :type evalSumKeyMap: EvalKeyMap
  677. :param subringDim: Subring dimension (use full cyclotomic order if 0).
  678. :type subringDim: int
  679. :return: Ciphertext: Ciphertext containing row-wise sums.
  680. :rtype: Ciphertext
  681. )pbdoc";
  682. const char* cc_EvalSumCols_docs = R"pbdoc(
  683. Sums all elements across each column in a packed-encoded matrix ciphertext.
  684. :param ciphertext: Input ciphertext.
  685. :type ciphertext: Ciphertext
  686. :param numCols: Number of columns in the matrix.
  687. :type numCols: int
  688. :param evalSumKeyMap: Map of evaluation keys generated for column summation.
  689. :type evalSumKeyMap: EvalKeyMap
  690. :return: Ciphertext: Ciphertext containing column-wise sums.
  691. :rtype: Ciphertext
  692. )pbdoc";
  693. const char* cc_EvalInnerProduct_docs = R"pbdoc(
  694. Evaluates inner product in packed encoding (uses EvalSum)
  695. :param ciphertext1: first vector
  696. :type ciphertext1: Ciphertext
  697. :param ciphertext2: second vector
  698. :type ciphertext2: Ciphertext
  699. :param batchSize: size of the batch to be summed up
  700. :type batchSize: int
  701. :return: Ciphertext: resulting ciphertext
  702. :rtype: Ciphertext
  703. )pbdoc";
  704. const char* cc_EvalInnerProductPlaintext_docs = R"pbdoc(
  705. Evaluates inner product in packed encoding (uses EvalSum)
  706. :param ciphertext: first vector - ciphertext
  707. :type ciphertext: Ciphertext
  708. :param plaintext: second vector - plaintext
  709. :type plaintext: Plaintext
  710. :param batchSize: size of the batch to be summed up
  711. :type batchSize: int
  712. :return: Ciphertext: resulting ciphertext
  713. :rtype: Ciphertext
  714. )pbdoc";
  715. const char* cc_MultipartyKeyGen_docs = R"pbdoc(
  716. Threshold FHE: Generation of a public key derived from a previous joined public key (for prior secret shares) and the secret key share of the current party.
  717. :param publicKey: joined public key from prior parties.
  718. :type publicKey: PublicKey
  719. :param makeSparse: set to true if ring reduce by a factor of 2 is to be used. NOT SUPPORTED BY ANY SCHEME ANYMORE.
  720. :type makeSparse: bool
  721. :param fresh: set to true if proxy re-encryption is used in the multi-party protocol or star topology is used
  722. :type fresh: bool
  723. :return: KeyPair: key pair including the secret share for the current party and joined public key
  724. :rtype: KeyPair
  725. )pbdoc";
  726. const char* cc_MultipartyKeyGen_vector_docs = R"pbdoc(
  727. Threshold FHE: Generates a public key from a vector of secret shares. ONLY FOR DEBUGGIN PURPOSES. SHOULD NOT BE USED IN PRODUCTION.
  728. :param privateKeyVec: secret key shares.
  729. :type privateKeyVec: List[PrivateKey]
  730. :return KeyPair: key pair including the private for the current party and joined public key
  731. :rtype: KeyPair
  732. )pbdoc";
  733. const char* cc_MultipartyDecryptLead_docs = R"pbdoc(
  734. Threshold FHE: Method for decryption operation run by the lead decryption client
  735. :param ciphertextVec: a list of ciphertexts
  736. :type ciphertextVec: list
  737. :param privateKey: secret key share used for decryption.
  738. :type privateKey: PrivateKey
  739. :return: list of partially decrypted ciphertexts.
  740. :rtype: List[Ciphertext]
  741. )pbdoc";
  742. const char* cc_MultipartyDecryptMain_docs = R"pbdoc(
  743. Threshold FHE: "Partial" decryption computed by all parties except for the lead one
  744. :param ciphertextVec: a list of ciphertexts
  745. :type ciphertextVec: list
  746. :param privateKey: secret key share used for decryption.
  747. :type privateKey: PrivateKey
  748. :return: list of partially decrypted ciphertexts.
  749. :rtype: List[Ciphertext]
  750. )pbdoc";
  751. const char* cc_MultipartyDecryptFusion_docs = R"pbdoc(
  752. Threshold FHE: Method for combining the partially decrypted ciphertexts and getting the final decryption in the clear.
  753. :param partialCiphertextVec: list of "partial" decryptions
  754. :type partialCiphertextVec: list
  755. :return: Plaintext: resulting plaintext
  756. :rtype: Plaintext
  757. )pbdoc";
  758. const char* cc_MultiKeySwitchGen_docs = R"pbdoc(
  759. Threshold FHE: Generates a joined evaluation key from the current secret share and a prior joined evaluation key
  760. :param originalPrivateKey: secret key transformed from.
  761. :type originalPrivateKey: PrivateKey
  762. :param newPrivateKey: secret key transformed from.
  763. :type newPrivateKey: PrivateKey
  764. :param evalKey: the prior joined evaluation key.
  765. :type evalKey: EvalKey
  766. :return: EvalKey: the new joined evaluation key.
  767. :rtype: EvalKey
  768. )pbdoc";
  769. const char* cc_GetEvalMultKeyVector_docs = R"pbdoc(
  770. Get relinearization keys for a specific secret key tag
  771. :param keyId: key identifier used for private key
  772. :type keyId: str
  773. :return: EvalKeyVector: vector with all relinearization keys.
  774. :rtype: EvalKeyVector
  775. )pbdoc";
  776. const char* cc_GetEvalAutomorphismKeyMap_docs = R"pbdoc(
  777. Get automorphism keys for a specific secret key tag
  778. :param keyId: key identifier used for private key
  779. :type keyId: str
  780. :return: EvalKeyMap: map with all automorphism keys.
  781. :rtype: EvalKeyMap
  782. )pbdoc";
  783. const char* cc_GetEvalSumKeyMap_docs = R"pbdoc(
  784. Get a map of summation keys (each is composed of several automorphism keys) for a specific secret key tag
  785. :return: EvalKeyMap: key map
  786. :rtype: EvalKeyMap
  787. )pbdoc";
  788. const char* cc_InsertEvalSumKey_docs = R"pbdoc(
  789. InsertEvalSumKey - add the given map of keys to the map, replacing the existing map if there
  790. :param evalKeyMap: key map
  791. :type evalKeyMap: EvalKeyMap
  792. )pbdoc";
  793. const char* cc_MultiEvalAtIndexKeyGen_docs = R"pbdoc(
  794. Threshold FHE: Generates joined rotation keys from the current secret key and prior joined rotation keys
  795. :param privateKey: secret key share
  796. :type privateKey: PrivateKey
  797. :param evalKeyMap: a map with prior joined rotation keys
  798. :type evalKeyMap: EvalKeyMap
  799. :param indexList: a vector of rotation indices
  800. :type indexList: List[int32]
  801. :param keyId: new key identifier used for resulting evaluation key
  802. :type keyId: str
  803. :return: EvalKeyMap: a map with new joined rotation keys
  804. :rtype: EvalKeyMap
  805. )pbdoc";
  806. const char* cc_MultiEvalSumKeyGen_docs = R"pbdoc(
  807. Threshold FHE: Generates joined summation evaluation keys from the current secret share and prior joined summation keys
  808. :param privateKey: secret key share
  809. :type privateKey: PrivateKey
  810. :param evalKeyMap: a map with prior joined summation keys
  811. :type evalKeyMap: EvalKeyMap
  812. :param keyId: new key identifier used for resulting evaluation key
  813. :type keyId: str
  814. :return: EvalKeyMap: new joined summation keys
  815. :rtype: EvalKeyMap
  816. )pbdoc";
  817. const char* cc_MultiAddEvalAutomorphismKeys_docs = R"pbdoc(
  818. Threshold FHE: Adds two prior evaluation key sets for automorphisms
  819. :param evalKeyMap1: first automorphism key set
  820. :type evalKeyMap1: EvalKeyMap
  821. :param evalKeyMap2: second automorphism key set
  822. :type evalKeyMap2: EvalKeyMap
  823. :param keyId: new key identifier used for resulting evaluation key
  824. :type keyId: str
  825. :return: the new joined key set for summation
  826. :rtype: evalKeyMap
  827. )pbdoc";
  828. const char* cc_MultiAddPubKeys_docs = R"pbdoc(
  829. Threshold FHE: Adds two prior public keys
  830. :param publicKey1: first public key
  831. :type publicKey1: PublicKey
  832. :param publicKey2: second public key
  833. :type publicKey2: PublicKey
  834. :param keyId: new key identifier used for the resulting key
  835. :type keyId: str
  836. :return: the new combined key
  837. :rtype: PublicKey
  838. )pbdoc";
  839. const char* cc_MultiAddEvalKeys_docs = R"pbdoc(
  840. Threshold FHE: Adds two prior evaluation keys
  841. :param evalKey1: first evaluation key
  842. :type evalKey1: EvalKey
  843. :param evalKey2: second evaluation key
  844. :type evalKey2: EvalKey
  845. :param keyId: new key identifier used for resulting evaluation key
  846. :type keyId: str
  847. :return: the new joined key
  848. :rtype: EvalKey
  849. )pbdoc";
  850. const char* cc_MultiMultEvalKey_docs = R"pbdoc(
  851. Threshold FHE: Generates a partial evaluation key for homomorphic multiplication based on the current secret share and an existing partial evaluation key
  852. :param privateKey: current secret share
  853. :type privateKey: PrivateKey
  854. :param evalKey: prior evaluation key
  855. :type evalKey: EvalKey
  856. :param keyId: new key identifier used for resulting evaluation key
  857. :type keyId: str
  858. :return: the new joined key
  859. :rtype: EvalKey
  860. )pbdoc";
  861. const char* cc_MultiAddEvalSumKeys_docs = R"pbdoc(
  862. Threshold FHE: Adds two prior evaluation key sets for summation
  863. :param evalKeyMap1: first summation key set
  864. :type evalKeyMap1: EvalKeyMap
  865. :param evalKeyMap2: second summation key set
  866. :type evalKeyMap2: EvalKeyMap
  867. :param keyId: new key identifier used for resulting evaluation key
  868. :type keyId: str
  869. :return: the neew joined key set for summation
  870. :rtype: EvalKeyMap
  871. )pbdoc";
  872. const char* cc_MultiAddEvalMultKeys_docs = R"pbdoc(
  873. Threshold FHE: Adds two prior evaluation key sets for summation
  874. :param evalKey1: first evaluation key
  875. :type evalKey1: EvalKey
  876. :param evalKey2: second evaluation key
  877. :type evalKey2: EvalKey
  878. :param keyId: new key identifier used for resulting evaluation key
  879. :type keyId: str
  880. :return: the new joined key
  881. :rtype: EvalKey
  882. )pbdoc";
  883. const char* cc_IntMPBootAdjustScale_docs = R"pbdoc(
  884. Threshold FHE: Prepare a ciphertext for Multi-Party Interactive Bootstrapping.
  885. :param ciphertext: Input Ciphertext
  886. :type ciphertext: Ciphertext
  887. :return: Resulting Ciphertext
  888. :rtype: Ciphertext
  889. )pbdoc";
  890. const char* cc_IntMPBootRandomElementGen_docs = R"pbdoc(
  891. Threshold FHE: Generate a common random polynomial for Multi-Party Interactive Bootstrapping
  892. :param publicKey: the scheme public key (you can also provide the lead party's public-key)
  893. :type publicKey: PublicKey
  894. :return: Resulting ring element
  895. :rtype: Ciphertext
  896. )pbdoc";
  897. const char* cc_IntMPBootDecrypt_docs = R"pbdoc(
  898. Threshold FHE: Does masked decryption as part of Multi-Party Interactive Bootstrapping. Each party calls this function as part of the protocol
  899. :param privateKey: secret key share for party i
  900. :type privateKey: PrivateKey
  901. :param ciphertext: input ciphertext
  902. :type ciphertext: Ciphertext
  903. :param a: input common random polynomial
  904. :type a: Ciphertext
  905. :return: Resulting masked decryption
  906. :rtype: Ciphertext
  907. )pbdoc";
  908. const char* cc_IntMPBootAdd_docs = R"pbdoc(
  909. Threshold FHE: Aggregates a vector of masked decryptions and re-encryotion shares, which is the second step of the interactive multiparty bootstrapping procedure.
  910. :param sharesPairVec: vector of pair of ciphertexts, each element of this vector contains (h_0i, h_1i) - the masked-decryption and encryption shares ofparty i
  911. :type sharesPairVec: List[List[Ciphertext]]
  912. :return: aggregated pair of shares ((h_0, h_1)
  913. :rtype: List[Ciphertext]
  914. )pbdoc";
  915. const char* cc_IntMPBootEncrypt_docs = R"pbdoc(
  916. Threshold FHE: Does public key encryption of lead party's masked decryption as part of interactive multi-party bootstrapping, which increases the ciphertext modulus and enables future computations. This operation is done by the lead party as the final step of interactive multi-party bootstrapping.
  917. :param publicKey: the lead party's public key
  918. :type publicKey: PublicKey
  919. :param sharesPair: aggregated decryption and re-encryption shares
  920. :type sharesPair: List[Ciphertext]
  921. :param a: common random ring element
  922. :type a: Ciphertext
  923. :param ciphertext: input ciphertext
  924. :type ciphertext: Ciphertext
  925. :return: Resulting encryption
  926. :rtype: Ciphertext
  927. )pbdoc";
  928. const char* cc_InsertEvalMultKey_docs = R"pbdoc(
  929. Adds the given vector of keys to the map, replacing the existing vector if there
  930. :param evalKeyVec: vector of keys
  931. :type evalKeyVec: List[EvalKey]
  932. )pbdoc";
  933. const char* cc_InsertEvalAutomorphismKey_docs = R"pbdoc(
  934. Add the given map of keys to the map, replacing the existing map if there is one
  935. :param evalKeyMap: map of keys to be inserted
  936. :type EvalKeyMap
  937. :param keyTag: key identifier for the given key map
  938. :type keyTag: str
  939. )pbdoc";
  940. const char* cc_EvalSum_docs = R"pbdoc(
  941. Function for evaluating a sum of all components in a vector.
  942. :param ciphertext: the input ciphertext
  943. :type ciphertext: Ciphertext
  944. :param batchSize: size of the batch
  945. :type batchSize: int
  946. :return: resulting ciphertext
  947. :rtype: Ciphertext
  948. )pbdoc";
  949. const char* cc_EvalMerge_docs = R"pbdoc(
  950. 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. Requires the generation of rotation keys for the indices that are needed.
  951. :param ciphertextVec: vector of ciphertexts to be merged.
  952. :type ciphertextVec: list
  953. :return: resulting ciphertext
  954. :rtype: Ciphertext
  955. )pbdoc";
  956. const char* cc_ReKeyGen_docs = R"pbdoc(
  957. ReKeyGen produces an Eval Key that OpenFHE can use for Proxy Re-Encryption
  958. :param oldPrivateKey: original private key
  959. :type privateKey: PrivateKey
  960. :param newPublicKey: public key
  961. :type publicKey: PublicKey
  962. :return: new evaluation key
  963. :rtype: EvalKey
  964. )pbdoc";
  965. const char* cc_ReEncrypt_docs = R"pbdoc(
  966. ReEncrypt - Proxy Re-Encryption mechanism for OpenFHE
  967. :param ciphertext: input ciphertext
  968. :type ciphertext: Ciphertext
  969. :param evalKey: evaluation key for PRE keygen method
  970. :type evalKey: EvalKey
  971. :param publicKey: the public key of the recipient of the reencrypted ciphertext
  972. :type publicKey: PublicKey
  973. :return: the resulting ciphertext
  974. :rtype: Ciphertext
  975. )pbdoc";
  976. const char* cc_EvalPoly_docs = R"pbdoc(
  977. Evaluates a polynomial (given as a power series) on a ciphertext (CKKS only). Use EvalPolyLinear() for low polynomial degrees (degree < 5), or EvalPolyPS() for higher degrees.
  978. :param ciphertext: Input ciphertext.
  979. :type ciphertext: Ciphertext
  980. :param coefficients: Polynomial coefficients (vector's size = (degree + 1)).
  981. :type coefficients: list
  982. :return: Ciphertext: Resulting ciphertext.
  983. :rtype: Ciphertext
  984. )pbdoc";
  985. const char* cc_EvalPolyLinear_docs = R"pbdoc(
  986. Naive method for polynomial evaluation for polynomials represented in the power series (fast only for small-degree polynomials; less than 10). Uses a binary tree computation of the polynomial powers. Supported only in CKKS.
  987. :param ciphertext: input ciphertext
  988. :type ciphertext: Ciphertext
  989. :param coefficients: is the vector of coefficients in the polynomial; the size of the vector is the degree of the polynomial
  990. :type coefficients: list
  991. :return: Ciphertext: the result of polynomial evaluation.
  992. :rtype: Ciphertext
  993. )pbdoc";
  994. const char* cc_EvalPolyPS_docs = R"pbdoc(
  995. Paterson-Stockmeyer method for evaluation for polynomials represented in the power series. Supported only in CKKS.
  996. :param ciphertext: input ciphertext
  997. :type ciphertext: Ciphertext
  998. :param coefficients: is the vector of coefficients in the polynomial; the size of the vector is the degree of the polynomial
  999. :type coefficients: list
  1000. :return: Ciphertext: the result of polynomial evaluation.
  1001. :rtype: Ciphertext
  1002. )pbdoc";
  1003. const char* cc_Rescale_docs = R"pbdoc(
  1004. Rescale - An alias for OpenFHE ModReduce method. This is because ModReduce is called Rescale in CKKS.
  1005. :param ciphertext: ciphertext
  1006. :type ciphertext: Ciphertext
  1007. :return: Ciphertext: rescaled ciphertext
  1008. :rtype: Ciphertext
  1009. )pbdoc";
  1010. const char* cc_RescaleInPlace_docs = R"pbdoc(
  1011. Rescale - An alias for OpenFHE ModReduceInPlace method. This is because ModReduceInPlace is called RescaleInPlace in CKKS.
  1012. :param ciphertext: ciphertext to be rescaled in-place
  1013. :type ciphertext: Ciphertext
  1014. )pbdoc";
  1015. const char* cc_ModReduce_docs = R"pbdoc(
  1016. ModReduce - OpenFHE ModReduce method used only for BGV/CKKS.
  1017. :param ciphertext: ciphertext
  1018. :type ciphertext: Ciphertext
  1019. :return: Ciphertext: mod reduced ciphertext
  1020. :rtype: Ciphertext
  1021. )pbdoc";
  1022. const char* cc_ModReduceInPlace_docs = R"pbdoc(
  1023. ModReduce - OpenFHE ModReduceInPlace method used only for BGV/CKKS.
  1024. :param ciphertext: ciphertext to be mod-reduced in-place
  1025. :type ciphertext: Ciphertext
  1026. )pbdoc";
  1027. const char* cc_EvalBootstrapSetup_docs = R"pbdoc(
  1028. Bootstrap functionality: There are three methods that have to be called in this specific order:
  1029. 1. EvalBootstrapSetup: computes and encodes the coefficients for encoding and decoding and stores the necessary parameters
  1030. 2. EvalBootstrapKeyGen: computes and stores the keys for rotations and conjugation
  1031. 3. EvalBootstrap: refreshes the given ciphertext Sets all parameters for both linear and FTT-like methods. Supported in CKKS only.
  1032. :param levelBudget: vector of budgets for the amount of levels in encoding and decoding
  1033. :type levelBudget: list
  1034. :param dim1: vector of inner dimension in the baby-step giant-step routine for encoding and decodingl
  1035. :type dim1: list
  1036. :param slots: number of slots to be bootstraped
  1037. :type slots: int
  1038. :param correctionFactor: value to internally rescale message by to improve precision of bootstrapping. If set to 0, we use the default logic. This value is only used when NATIVE_SIZE=64.
  1039. :type correctionFactor: int
  1040. :return: None
  1041. )pbdoc";
  1042. const char* cc_EvalBootstrapKeyGen_docs = R"pbdoc(
  1043. Generates all automorphism keys for EvalBootstrap. Supported in CKKS only. EvalBootstrapKeyGen uses the baby-step/giant-step strategy.
  1044. :param privateKey: private key.
  1045. :type privateKey: PrivateKey
  1046. :param slots: number of slots to support permutations on.
  1047. :type slots: int
  1048. :return: None
  1049. )pbdoc";
  1050. const char* cc_EvalBootstrap_docs = R"pbdoc(
  1051. Defines the bootstrapping evaluation of ciphertext using either the FFT-like method or the linear method
  1052. :param ciphertext: the input ciphertext
  1053. :type ciphertext: Ciphertext
  1054. :param numIterations: number of iterations to run iterative bootstrapping (Meta-BTS). Increasing the iterations increases the precision of bootstrapping
  1055. :type numIterations: int
  1056. :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).
  1057. :type precision: int
  1058. :return: Ciphertext: the refreshed ciphertext
  1059. :rtype: Ciphertext
  1060. )pbdoc";
  1061. const char* cc_EvalCKKStoFHEWSetup_docs = R"pbdoc(
  1062. Sets all parameters for switching from CKKS to FHEW.
  1063. :param schswchparams: Parameters for CKKS-to-FHEW scheme switching.
  1064. :type schswchparams: SchSwchParams
  1065. :return: FHEW secret key.
  1066. :rtype: LWEPrivateKey
  1067. )pbdoc";
  1068. const char* cc_EvalCKKStoFHEWKeyGen_docs = R"pbdoc(
  1069. Sets all parameters for switching from CKKS to FHEW.
  1070. :param keyPair: CKKS key pair.
  1071. :type keyPair: KeyPair
  1072. :param lwesk: FHEW secret key.
  1073. :type lwesk: LWEPrivateKey
  1074. )pbdoc";
  1075. const char* cc_EvalCKKStoFHEWPrecompute_docs = R"pbdoc(
  1076. Performs precomputations for CKKS homomorphic decoding. Allows setting a custom scale factor. Given as a separate method than EvalCKKStoFHEWSetup to allow the user to specify a scale that depends on the CKKS and FHEW cryptocontexts
  1077. :param scale: Scaling factor for the linear transform matrix.
  1078. :type scale: float
  1079. )pbdoc";
  1080. const char* cc_EvalCKKStoFHEW_docs = R"pbdoc(
  1081. Switches a CKKS ciphertext to a vector of FHEW ciphertexts.
  1082. :param ciphertext: Input CKKS ciphertext.
  1083. :type ciphertext: Ciphertext
  1084. :param numCtxts: Number of coefficients to extract (defaults to number of slots if 0).
  1085. :type numCtxts: int
  1086. )pbdoc";
  1087. const char* cc_EvalFHEWtoCKKSSetup_docs = R"pbdoc(
  1088. Sets parameters for switching from FHEW to CKKS. Requires existing CKKS context.
  1089. :param ccLWE: Source FHEW crypto context.
  1090. :type ccLWE: BinFHEContext
  1091. :param numSlotsCKKS Number of slots in resulting CKKS ciphertext.
  1092. :type numSlotsCKKS: int
  1093. :param logQ: Ciphertext modulus size in FHEW (for high precision).
  1094. :type logQ: int
  1095. )pbdoc";
  1096. const char* cc_EvalFHEWtoCKKSKeyGen_docs = R"pbdoc(
  1097. Generates keys for switching from FHEW to CKKS.
  1098. :param keyPair: CKKS key pair.
  1099. :type keyPair: KeyPair
  1100. :param lwesk: FHEW secret key.
  1101. :type lwesk: LWEPrivateKey
  1102. :param numSlots: Number of slots for CKKS encryption.
  1103. :type numSlots: int
  1104. :param numCtxts: Number of LWE ciphertext values to encrypt.
  1105. :type numCtxts: int
  1106. :param dim1: Baby-step parameter for linear transform.
  1107. :type dim1: int
  1108. :param L: Target level for homomorphic decoding matrix.
  1109. :type L: int
  1110. )pbdoc";
  1111. const char* cc_EvalFHEWtoCKKS_docs = R"pbdoc(
  1112. Switches a vector of FHEW ciphertexts to a single CKKS ciphertext.
  1113. :param LWECiphertexts: Input vector of FHEW ciphertexts.
  1114. :type LWECiphertexts: list of LWECiphertext.
  1115. :param numCtxts: Number of values to encode.
  1116. :type numCtxts: int
  1117. :param numSlots: Number of CKKS slots to use.
  1118. :type numSlots: int
  1119. :param p: Plaintext modulus (default = 4).
  1120. :type p: int.
  1121. :param pmin: Minimum expected plaintext value (default = 0.0).
  1122. :type pmin: float.
  1123. :param pmax: Maximum expected plaintext value (default = 2.0).
  1124. :type pmax: float.
  1125. :param dim1: Baby-step parameter (used in argmin).
  1126. :type dim1: int.
  1127. :return: CKKS ciphertext encoding the input LWE messages.
  1128. :rtype: Ciphertext
  1129. )pbdoc";
  1130. const char* cc_EvalSchemeSwitchingSetup_docs = R"pbdoc(
  1131. Sets parameters for switching between CKKS and FHEW.
  1132. :param schswchparams: Scheme switching parameter object.
  1133. :type schswchparams: SchSwchParams.
  1134. :return: FHEW secret key.
  1135. :rtype: LWEPrivateKey.
  1136. )pbdoc";
  1137. const char* cc_EvalSchemeSwitchingKeyGen_docs = R"pbdoc(
  1138. Generates keys for switching between CKKS and FHEW.
  1139. :param keyPair: CKKS key pair.
  1140. :type keyPair: KeyPair.
  1141. :param lwesk: FHEW secret key.
  1142. :type lwesk: LWEPrivateKey.
  1143. )pbdoc";
  1144. const char* cc_EvalCompareSwitchPrecompute_docs = R"pbdoc(
  1145. Performs precomputations for scheme switching in CKKS-to-FHEW comparison. Given as a separate method than EvalSchemeSwitchingSetup to allow the user to specify a scale.
  1146. :param pLWE: Target plaintext modulus for FHEW ciphertexts.
  1147. :type pLWE: int.
  1148. :param scaleSign: Scaling factor for CKKS ciphertexts before switching.
  1149. :type scaleSign: float.
  1150. :param unit: Indicates if input messages are normalized to unit circle.
  1151. :type unit: bool.
  1152. )pbdoc";
  1153. const char* cc_EvalCompareSchemeSwitching_docs = R"pbdoc(
  1154. Compares two CKKS ciphertexts using FHEW-based scheme switching and returns CKKS result.
  1155. :param ciphertext1: First input CKKS ciphertext.
  1156. :type ciphertext1: Ciphertext.
  1157. :param ciphertext2: Second input CKKS ciphertext.
  1158. :type ciphertext2: Ciphertext.
  1159. :param numCtxts: Number of coefficients to extract.
  1160. :type numCtxts: int.
  1161. :param numSlots: Number of slots to encode in the result.
  1162. :type numSlots: int.
  1163. :param pLWE: Target plaintext modulus for FHEW ciphertexts.
  1164. :type pLWE: int.
  1165. :param scaleSign: Scaling factor for CKKS ciphertexts before switching.
  1166. :type scaleSign: float.
  1167. :param unit: Indicates if input messages are normalized to unit circle.
  1168. :type unit: bool.
  1169. :return: CKKS ciphertext encoding sign comparison result.
  1170. :rtype: Ciphertext
  1171. )pbdoc";
  1172. const char* cc_EvalMinSchemeSwitching_docs = R"pbdoc(
  1173. Computes minimum and index of the first packed values using scheme switching.
  1174. :param ciphertext: Input CKKS ciphertext.
  1175. :type ciphertext: Ciphertext.
  1176. :param publicKey: CKKS public key.
  1177. :type publicKey: PublicKey.
  1178. :param numValues: Number of values to compare (we assume that numValues is a power of two).
  1179. :type numValues: int.
  1180. :param numSlots: Number of output slots.
  1181. :type numSlots: int.
  1182. :param pLWE: Target plaintext modulus for FHEW.
  1183. :type pLWE: int.
  1184. :param scaleSign: Scaling factor before switching to FHEW. The resulting FHEW ciphertexts will encrypt values modulo pLWE, so scaleSign should account for this pLWE and is given here only if the homomorphic decoding matrix is not scaled with the desired values
  1185. :type scaleSign: float.
  1186. :return: A vector of two CKKS ciphertexts: [min, argmin]. The ciphertexts have junk after the first slot in the first ciphertext
  1187. and after numValues in the second ciphertext if oneHot=true and after the first slot if oneHot=false.
  1188. :rtype: list of Ciphertext.
  1189. )pbdoc";
  1190. const char* cc_EvalMinSchemeSwitchingAlt_docs = R"pbdoc(
  1191. Computes minimum and index using more FHEW operations than CKKS with higher precision, but slower than EvalMinSchemeSwitching.
  1192. :param ciphertext: Input CKKS ciphertext.
  1193. :type ciphertext: Ciphertext.
  1194. :param publicKey: CKKS public key.
  1195. :type publicKey: PublicKey.
  1196. :param numValues: Number of packed values to compare.
  1197. :type numValues: int.
  1198. :param numSlots: Number of slots in the output ciphertexts.
  1199. :type numSlots: int.
  1200. :param pLWE: Target plaintext modulus for FHEW ciphertexts.
  1201. :type pLWE: int.
  1202. :param scaleSign: Scaling factor before switching to FHEW.
  1203. :type scaleSign: float.
  1204. :return: A vector with two CKKS ciphertexts: [min, argmin].
  1205. :rtype: list of Ciphertext.
  1206. )pbdoc";
  1207. const char* cc_EvalMaxSchemeSwitching_docs = R"pbdoc(
  1208. Computes maximum and index from the first packed values using scheme switching.
  1209. :param ciphertext: Input CKKS ciphertext.
  1210. :type ciphertext: Ciphertext.
  1211. :param publicKey: CKKS public key.
  1212. :type publicKey: PublicKey.
  1213. :param numValues: Number of values to compare (we assume that numValues is a power of two).
  1214. :type numValues: int.
  1215. :param numSlots: Number of output slots.
  1216. :type numSlots: int.
  1217. :param pLWE: Target plaintext modulus for FHEW.
  1218. :type pLWE: int.
  1219. :param scaleSign: Scaling factor before switching to FHEW.
  1220. :type scaleSign: float.
  1221. :return: A vector of two CKKS ciphertexts: [max, argmax]. The ciphertexts have junk after the first slot in the first ciphertext and after numValues in the second ciphertext if oneHot=true and after the first slot if oneHot=false.
  1222. :rtype: list of Ciphertext.
  1223. )pbdoc";
  1224. const char* cc_EvalMaxSchemeSwitchingAlt_docs = R"pbdoc(
  1225. Computes max and index via scheme switching, with more FHEW operations for better precision than EvalMaxSchemeSwitching.
  1226. :param ciphertext: Input CKKS ciphertext.
  1227. :type ciphertext: Ciphertext.
  1228. :param publicKey: CKKS public key.
  1229. :type publicKey: PublicKey.
  1230. :param numValues: Number of values to compare.
  1231. :type numValues: int.
  1232. :param numSlots: Number of output slots.
  1233. :type numSlots: int.
  1234. :param pLWE: Target plaintext modulus for FHEW.
  1235. :type pLWE: int.
  1236. :param scaleSign: Scaling factor before switching to FHEW.
  1237. :type scaleSign: float.
  1238. :return: A vector of two CKKS ciphertexts: [max, argmax].
  1239. :rtype: list of Ciphertext.
  1240. )pbdoc";
  1241. const char* cc_EvalAutomorphismKeyGen_docs = R"pbdoc(
  1242. Generate automophism keys for a given private key; Uses the private key for encryption
  1243. :param privateKey: private key.
  1244. :type privateKey: PrivateKey
  1245. :param indexList: list of automorphism indices to be computed.
  1246. :type indexList: list
  1247. :return: returns the evaluation key
  1248. :rtype: EvalKeyMap
  1249. )pbdoc";
  1250. const char* cc_FindAutomorphismIndex_docs = R"pbdoc(
  1251. Finds an automorphism index for a given vector index using a scheme-specific algorithm
  1252. :param idx: regular vector index
  1253. :type idx: int
  1254. :return: the automorphism index
  1255. :rtype: int
  1256. )pbdoc";
  1257. const char* cc_FindAutomorphismIndices_docs = R"pbdoc(
  1258. Finds automorphism indices for a given list of vector indices using a scheme-specific algorithm
  1259. :param idxList: list of indices
  1260. :type idxList: List[int]
  1261. :return: a list of automorphism indices
  1262. :rtype: List[int]
  1263. )pbdoc";
  1264. const char* cc_ClearEvalMultKeys_docs = R"pbdoc(
  1265. ClearEvalMultKeys - flush EvalMultKey cache for a given id
  1266. :param id: the corresponding key id
  1267. :type id: str
  1268. )pbdoc";
  1269. const char* cc_ClearEvalAutomorphismKeys_docs = R"pbdoc(
  1270. Flush EvalAutomorphismKey cache
  1271. )pbdoc";
  1272. const char* cc_SerializeEvalAutomorphismKey_docs = R"pbdoc(
  1273. SerializeEvalAutomorphismKey for a single EvalAuto key or all of the EvalAuto keys
  1274. :param filename: output file
  1275. :type filename: str
  1276. :param sertype: serialization type
  1277. :type sertype: SERJSON, SERBINARY
  1278. :param id: key to serialize; empty string means all keys
  1279. :type id: str
  1280. :return: bool: true on success
  1281. )pbdoc";
  1282. const char* cc_SerializeEvalMultKey_docs = R"pbdoc(
  1283. SerializeEvalMultKey for a single EvalMult key or all of the EvalMult keys
  1284. :param filename: output file to serialize to
  1285. :type filename: str
  1286. :param sertype: type of serialization
  1287. :type sertype: SERJSON, SERBINARY
  1288. :param id: for key to serialize - if empty string, serialize them all
  1289. :type id: str
  1290. :return: bool: true on success (false on failure or no keys found)
  1291. )pbdoc";
  1292. const char* cc_DeserializeEvalAutomorphismKey_docs = R"pbdoc(
  1293. DeserializeEvalAutomorphismKey deserialize all keys in the serialization deserialized keys silently replace any existing matching keys deserialization will create CryptoContext if necessary
  1294. :param filename: path for the file to deserialize from
  1295. :type filename: str
  1296. :param sertype: type of serialization
  1297. :type sertype: SERJSON, SERBINARY
  1298. :return: bool: true on success
  1299. )pbdoc";
  1300. const char* cc_DeserializeEvalMultKey_docs = R"pbdoc(
  1301. DeserializeEvalMultKey deserialize all keys in the serialization deserialized keys silently replace any existing matching keys deserialization will create CryptoContext if necessary
  1302. :param filename: path for the file to deserialize from
  1303. :type filename: str
  1304. :param sertype: type of serialization
  1305. :type sertype: SERJSON, SERBINARY
  1306. :return: bool: true on success
  1307. )pbdoc";
  1308. #endif // __CRYPTOCONTEXT_DOCS_H__