Browse Source

binfhecontext docs

Rener Oliveira (Ubuntu WSL) 2 years ago
parent
commit
cd5d7232fd
2 changed files with 101 additions and 2 deletions
  1. 91 0
      include/docstrings/binfhecontext_docs.h
  2. 10 2
      src/binfhe_bindings.cpp

+ 91 - 0
include/docstrings/binfhecontext_docs.h

@@ -0,0 +1,91 @@
+#ifndef BINFHECONTEXT_DOCSTRINGS_H
+#define BINFHECONTEXT_DOCSTRINGS_H
+
+// BinFHEContext Docs:
+const char* binfhe_GenerateBinFHEContext_parset_docs = R"doc(
+    Creates a crypto context using predefined parameters sets. Recommended for most users.
+
+    Parameters:
+    ----------
+        set (BINFHE_PARAMSET): the parameter set: TOY, MEDIUM, STD128, STD192, STD256.
+        method (BINFHE_METHOD):  the bootstrapping method (DM or CGGI).
+
+    Returns:
+    --------
+        create the crypto context
+)doc";
+
+const char* binfhe_KeyGen_docs = R"doc(
+    Generates a secret key for the main LWE scheme
+
+    Returns:
+    --------
+        LWEPrivateKey: the secret key
+)doc";
+
+const char* binfhe_BTKeyGen_docs = R"doc(
+    Generates bootstrapping keys
+
+    Psrameters:
+    -----------
+        sk (LWEPrivateKey): secret key
+)doc";
+
+const char* binfhe_Encrypt_docs = R"doc(
+    Encrypts a bit using a secret key (symmetric key encryption)
+
+    Parameters:
+    -----------
+        sk (LWEPrivateKey): the secret key
+        m (int): the plaintext
+        output (BINFHE_OUTPUT):  FRESH to generate fresh ciphertext, BOOTSTRAPPED to generate a refreshed ciphertext (default)
+        p (int): plaintext modulus (default 4)
+        mod (int): Encrypt according to mod instead of m_q if mod != 0
+
+    Returns:
+    --------
+        LWECiphertext: the ciphertext
+)doc";
+
+const char* binfhe_Decrypt_docs = R"doc(
+    Encrypt according to mod instead of m_q if mod != 0
+
+    Parameters:
+    -----------
+        sk (LWEPrivateKey): the secret key
+        ct (LWECiphertext): the ciphertext
+        p (int): plaintext modulus (default 4)
+
+    Returns:
+    --------
+       int: the plaintext
+)doc";
+
+const char* binfhe_EvalBinGate_docs = R"doc(
+    Evaluates a binary gate (calls bootstrapping as a subroutine)
+
+    Parameters:
+    -----------
+        gate (BINGATE): the gate; can be AND, OR, NAND, NOR, XOR, or XNOR
+        ct1 (LWECiphertext): first ciphertext
+        ct2 (LWECiphertext): second ciphertext
+
+    Returns:
+    --------
+        LWECiphertext: the resulting ciphertext
+)doc";
+
+const char* binfhe_EvalNOT_docs = R"doc(
+    Evaluates NOT gate
+
+    Parameters:
+    -----------
+        ct (LWECiphertext): the input ciphertext
+
+    Returns:
+    --------
+        LWECiphertext: the resulting ciphertext
+)doc";
+
+
+#endif // BINFHECONTEXT_DOCSTRINGS_H

+ 10 - 2
src/binfhe_bindings.cpp

@@ -5,6 +5,7 @@
 #include "binfhe_bindings.h"
 #include "binfhecontext.h"
 #include "binfhecontext_wrapper.h"
+#include "binfhecontext_docs.h"
 
 using namespace lbcrypto;
 namespace py = pybind11;
@@ -105,25 +106,32 @@ void bind_binfhe_context(py::module &m)
     py::class_<BinFHEContext>(m, "BinFHEContext")
         .def(py::init<>())
         .def("GenerateBinFHEContext", static_cast<void (BinFHEContext::*)(BINFHE_PARAMSET, BINFHE_METHOD)>(&BinFHEContext::GenerateBinFHEContext),
+             binfhe_GenerateBinFHEContext_parset_docs,
              py::arg("set"), 
              py::arg("method") = GINX)
-        .def("KeyGen", &BinFHEContext::KeyGen)
-        .def("BTKeyGen", &BinFHEContext::BTKeyGen)
+        .def("KeyGen", &BinFHEContext::KeyGen,
+            binfhe_KeyGen_docs)
+        .def("BTKeyGen", &BinFHEContext::BTKeyGen,
+            binfhe_BTKeyGen_docs)
         .def("Encrypt", &binfhe_EncryptWrapper,
+             binfhe_Encrypt_docs,
              py::arg("sk"),
              py::arg("m"),
              py::arg("output") = BOOTSTRAPPED,
              py::arg("p") = 4, 
              py::arg("mod") = 0)
         .def("Decrypt",&binfhe_DecryptWrapper,
+             binfhe_Decrypt_docs,
              py::arg("sk"),
              py::arg("ct"),
              py::arg("p") = 4)
         .def("EvalBinGate",&BinFHEContext::EvalBinGate,
+             binfhe_EvalBinGate_docs,
              py::arg("gate"),
              py::arg("ct1"),
              py::arg("ct2"))
         .def("EvalNOT",&BinFHEContext::EvalNOT,
+             binfhe_EvalNOT_docs,
              py::arg("ct"));
             
 }