Skip to content

Commit afe90ec

Browse files
Added a binding for Encrypt() with private key
1 parent 4b50c70 commit afe90ec

2 files changed

Lines changed: 19 additions & 3 deletions

File tree

src/include/docstrings/cryptocontext_docs.h

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,17 +306,28 @@ const char* cc_EvalAtIndexKeyGen_docs = R"pbdoc(
306306
:return: None
307307
)pbdoc";
308308

309-
const char* cc_Encrypt_docs = R"doc(
309+
const char* cc_EncryptPubkey_docs = R"doc(
310310
Encrypt a plaintext using a given public key
311311
312312
:param plaintext: plaintext
313-
:type plaintext: Plaintext
313+
:type plaintext: ConstPlaintext
314314
:param publicKey: public key
315315
:type publicKey: PublicKey
316316
:return: ciphertext (or null on failure)
317317
:rtype: Ciphertext
318318
)doc";
319319

320+
const char* cc_EncryptPrivkey_docs = R"doc(
321+
Encrypt a plaintext using a given private key
322+
323+
:param plaintext: plaintext
324+
:type plaintext: ConstPlaintext
325+
:param privateKey: private key
326+
:type privateKey: PrivateKey
327+
:return: ciphertext (or null on failure)
328+
:rtype: Ciphertext
329+
)doc";
330+
320331
const char* cc_Decrypt_docs = R"pbdoc(
321332
Decrypt a single ciphertext into the appropriate plaintext
322333

src/lib/bindings.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,12 @@ void bind_crypto_context(py::module &m) {
613613
py::overload_cast<const PublicKey<DCRTPoly>&, ConstPlaintext&>(&CryptoContextImpl<DCRTPoly>::Encrypt, py::const_),
614614
py::arg("publicKey"),
615615
py::arg("plaintext"),
616-
py::doc(cc_Encrypt_docs))
616+
py::doc(cc_EncryptPubkey_docs))
617+
.def("Encrypt",
618+
py::overload_cast<const PrivateKey<DCRTPoly>&, ConstPlaintext&>(&CryptoContextImpl<DCRTPoly>::Encrypt, py::const_),
619+
py::arg("privateKey"),
620+
py::arg("plaintext"),
621+
py::doc(cc_EncryptPrivkey_docs))
617622
.def("Decrypt",
618623
[](CryptoContext<DCRTPoly>& self, const PrivateKey<DCRTPoly> privKey, ConstCiphertext<DCRTPoly> ct) {
619624
Plaintext result;

0 commit comments

Comments
 (0)