Просмотр исходного кода

Merge pull request #37 from openfheorg/dev

Merging documentation style fixes
Rener Oliveira 1 год назад
Родитель
Сommit
935f2932b1

+ 21 - 0
docs/binfhe.rst

@@ -0,0 +1,21 @@
+BinFHEContext
+----------------
+
+.. autoclass:: openfhe.BinFHEContext
+    :members:
+    :undoc-members:
+    :show-inheritance:
+
+LWECiphertext
+----------------
+.. autoclass:: openfhe.LWECiphertext
+    :members:
+    :undoc-members:
+    :show-inheritance:
+    
+LWEPrivateKey
+----------------
+.. autoclass:: openfhe.LWEPrivateKey
+    :members:
+    :undoc-members:
+    :show-inheritance:

+ 31 - 0
docs/binfhe_enums.rst

@@ -0,0 +1,31 @@
+BinFHE enums
+=============
+
+Parameter Set
+#############
+
+.. autoclass:: openfhe.BINFHE_PARAMSET
+    :members:
+    :undoc-members:
+    :show-inheritance:
+
+BINFHE_METHOD
+#############
+.. autoclass:: openfhe.BINFHE_METHOD
+    :members:
+    :undoc-members:
+    :show-inheritance:
+
+BinFHE Output
+#############
+.. autoclass:: openfhe.BINFHE_OUTPUT
+    :members:
+    :undoc-members:
+    :show-inheritance:
+
+Binary Gates
+#############
+.. autoclass:: openfhe.BINGATE
+    :members:
+    :undoc-members:
+    :show-inheritance:

+ 7 - 0
docs/ciphertext.rst

@@ -0,0 +1,7 @@
+Ciphertext
+==========
+
+.. autoclass:: openfhe.Ciphertext
+    :members:
+    :undoc-members:
+    :show-inheritance:

+ 2 - 1
docs/conf.py

@@ -42,6 +42,7 @@ extensions = [
     'sphinx.ext.autodoc',
     'sphinx.ext.autosummary',
     'sphinx.ext.intersphinx',
+    'sphinx.ext.napoleon'
 ]
 
 # Add any paths that contain templates here, relative to this directory.
@@ -61,7 +62,7 @@ master_doc = 'index'
 #
 # This is also used if you do content translation via gettext catalogs.
 # Usually you set "language" from the command line for these cases.
-language = None
+language = 'en'
 
 # List of patterns, relative to source directory, that match files and
 # directories to ignore when looking for source files.

+ 1 - 3
docs/cryptocontext.rst

@@ -5,6 +5,4 @@ CryptoContext
     :members:
     :undoc-members:
     :show-inheritance:
-
-.. autofunction:: openfhe.CryptoContext.Encrypt
-.. autofunction:: openfhe.CryptoContext.Decrypt
+    :noindex:

+ 16 - 10
docs/index.rst

@@ -6,16 +6,22 @@
 Welcome to OpenFHE - Python's documentation!
 ============================================
 
-.. toctree::
-   :maxdepth: 2
-   :caption: Contents:
-      
-   cryptocontext
+OpenFHE - Python
+----------------
+Fully Homomorphic Encryption (FHE) is a powerful cryptographic primitive that enables performing computations over encrypted data without having access to the secret key. `OpenFHE <https://openfhe.org/>`_ is an open-source FHE library that includes efficient implementations of all common FHE schemes: BFV, BGV, CKKS, DM and CGGI.
 
+``openfhe-python`` is a Python library built as a wrapper for the main capabilities of OpenFHE C++ library. It provides a more user-friendly interface for Python developers, 
+while keeping the efficiency of C++ FHE operations.
 
-Indices and tables
-==================
+.. toctree::
+   :maxdepth: 1
+   :caption: API Reference:
+   
+   cryptocontext
+   ciphertext
+   plaintext
+   keys
+   pke_enums
+   binfhe
+   binfhe_enums
 
-* :ref:`genindex`
-* :ref:`modindex`
-* :ref:`search`

+ 22 - 0
docs/keys.rst

@@ -0,0 +1,22 @@
+Public Key
+===========
+
+.. autoclass:: openfhe.PublicKey
+    :members:
+    :undoc-members:
+    :show-inheritance:
+
+Private Key
+===========
+.. autoclass:: openfhe.PrivateKey
+    :members:
+    :undoc-members:
+    :show-inheritance:
+
+KeyPair
+=======
+.. autoclass:: openfhe.KeyPair
+    :members:
+    :undoc-members:
+    :show-inheritance:
+

+ 89 - 0
docs/pke_enums.rst

@@ -0,0 +1,89 @@
+PKE enums
+=============
+
+Scheme Types 
+#############
+
+.. autoclass:: openfhe.SCHEME
+    :members:
+    :undoc-members:
+    :show-inheritance:
+
+PKE Scheme Features
+####################
+.. autoclass:: openfhe.PKESchemeFeature
+    :members:
+    :undoc-members:
+    :show-inheritance:
+
+Scaling Techniques
+####################
+.. autoclass:: openfhe.ScalingTechnique
+    :members:
+    :undoc-members:
+    :show-inheritance:
+
+Key Switching Techniques
+########################
+.. autoclass:: openfhe.KeySwitchTechnique
+    :members:
+    :undoc-members:
+    :show-inheritance:
+
+Secret Key Dist
+################
+.. autoclass:: openfhe.SecretKeyDist
+    :members:
+    :undoc-members:
+    :show-inheritance:
+
+Proxy Reencryption Mode
+#######################
+.. autoclass:: openfhe.ProxyReEncryptionMode
+    :members:
+    :undoc-members:
+    :show-inheritance:
+
+Multiparty Mode
+###############
+.. autoclass:: openfhe.MultipartyMode
+    :members:
+    :undoc-members:
+    :show-inheritance:
+
+Execution Mode
+###############
+.. autoclass:: openfhe.ExecutionMode
+    :members:
+    :undoc-members:
+    :show-inheritance:
+
+Decryption Noise Mode
+######################
+.. autoclass:: openfhe.DecryptionNoiseMode
+    :members:
+    :undoc-members:
+    :show-inheritance:
+
+Encryption Technique
+#####################
+.. autoclass:: openfhe.EncryptionTechnique
+    :members:
+    :undoc-members:
+    :show-inheritance:
+
+Multiplication Technique
+#########################
+.. autoclass:: openfhe.MultiplicationTechnique
+    :members:
+    :undoc-members:
+    :show-inheritance:
+
+Security Level
+###############
+.. autoclass:: openfhe.SecurityLevel
+    :members:
+    :undoc-members:
+    :show-inheritance:
+
+"""

+ 7 - 0
docs/plaintext.rst

@@ -0,0 +1,7 @@
+Plaintext
+=============
+
+.. autoclass:: openfhe.Plaintext
+    :members:
+    :undoc-members:
+    :show-inheritance:

+ 36 - 0
docs/requirements.txt

@@ -0,0 +1,36 @@
+alabaster==0.7.12
+Babel==2.9.1
+breathe==4.33.1
+certifi==2021.10.8
+charset-normalizer==2.0.12
+docutils==0.17.1
+exhale>=0.3.0
+idna==3.3
+imagesize==1.3.0
+importlib-metadata>=4.0.0
+Jinja2==3.0.3
+MarkupSafe>=2.0.0
+packaging==21.3
+pybind11=2.10.3
+pybind11-global=2.10.3
+Pygments==2.11.2
+pyparsing==3.0.7
+pytz==2021.3
+requests==2.27.1
+snowballstemmer==2.2.0
+Sphinx==4.4.0
+sphinx-rtd-theme==1.0.0
+sphinxcontrib-applehelp==1.0.2
+sphinxcontrib-devhelp==1.0.2
+sphinxcontrib-htmlhelp==2.0.0
+sphinxcontrib-jsmath==1.0.1
+sphinxcontrib-mermaid==0.7.1
+sphinxcontrib-qthelp==1.0.3
+sphinxcontrib-serializinghtml==1.1.5
+tk=8.6.12
+tomli=1.2.2
+typing-extensions=4.7.1
+urllib3=2.0.4
+wheel=0.38.4
+xz=5.2.6
+zipp=3.16.2

+ 83 - 85
include/docstrings/binfhecontext_docs.h

@@ -1,91 +1,89 @@
 #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";
+// GenerateBinFHEContext
+const char* binfhe_GenerateBinFHEContext_parset_docs = R"pbdoc(
+    Creates a crypto context using predefined parameter sets. Recommended for most users.
+
+    :param set: The parameter set: TOY, MEDIUM, STD128, STD192, STD256.
+    :type set: BINFHE_PARAMSET
+    :param method: The bootstrapping method (DM or CGGI).
+    :type method: BINFHE_METHOD
+    :return: The created crypto context.
+    :rtype: BinFHEContext
+)pbdoc";
+
+// KeyGen
+const char* binfhe_KeyGen_docs = R"pbdoc(
+    Generates a secret key for the main LWE scheme.
+
+    :return: The secret key.
+    :rtype: LWEPrivateKey
+)pbdoc";
+
+// BTKeyGen
+const char* binfhe_BTKeyGen_docs = R"pbdoc(
+    Generates bootstrapping keys.
+
+    :param sk: The secret key.
+    :type sk: LWEPrivateKey
+)pbdoc";
+
+// Encrypt
+const char* binfhe_Encrypt_docs = R"pbdoc(
+    Encrypts a bit using a secret key (symmetric key encryption).
+
+    :param sk: The secret key.
+    :type sk: LWEPrivateKey
+    :param m: The plaintext.
+    :type m: int
+    :param output: FRESH to generate a fresh ciphertext, BOOTSTRAPPED to generate a refreshed ciphertext (default).
+    :type output: BINFHE_OUTPUT
+    :param p: Plaintext modulus (default 4).
+    :type p: int
+    :param mod: Encrypt according to mod instead of m_q if mod != 0.
+    :type mod: int
+    :return: The ciphertext.
+    :rtype: LWECiphertext
+)pbdoc";
+
+// Decrypt
+const char* binfhe_Decrypt_docs = R"pbdoc(
+    Decrypts a ciphertext using a secret key.
+
+    :param sk: The secret key.
+    :type sk: LWEPrivateKey
+    :param ct: The ciphertext.
+    :type ct: LWECiphertext
+    :param p: Plaintext modulus (default 4).
+    :type p: int
+    :return: The plaintext.
+    :rtype: int
+)pbdoc";
+
+// EvalBinGate
+const char* binfhe_EvalBinGate_docs = R"pbdoc(
+    Evaluates a binary gate (calls bootstrapping as a subroutine).
+
+    :param gate: The gate; can be AND, OR, NAND, NOR, XOR, or XNOR.
+    :type gate: BINGATE
+    :param ct1: First ciphertext.
+    :type ct1: LWECiphertext
+    :param ct2: Second ciphertext.
+    :type ct2: LWECiphertext
+    :return: The resulting ciphertext.
+    :rtype: LWECiphertext
+)pbdoc";
+
+// EvalNOT
+const char* binfhe_EvalNOT_docs = R"pbdoc(
+    Evaluates the NOT gate.
+
+    :param ct: The input ciphertext.
+    :type ct: LWECiphertext
+    :return: The resulting ciphertext.
+    :rtype: LWECiphertext
+)pbdoc";
 
 
 #endif // BINFHECONTEXT_DOCSTRINGS_H

+ 13 - 12
include/docstrings/ciphertext_docs.h

@@ -1,19 +1,20 @@
 #ifndef CIPHERTEXT_DOCSTRINGS_H
 #define CIPHERTEXT_DOCSTRINGS_H
 
-const char* ctx_GetLevel_docs = R"doc(
-    Get the number of scalings performed
+// GetLevel
+const char* ctx_GetLevel_docs = R"pbdoc(
+    Get the number of scalings performed.
 
-    Returns
-    -------
-        int: The level of the ciphertext.
-)doc";
+    :return: The level of the ciphertext.
+    :rtype: int
+)pbdoc";
 
-const char* ctx_SetLevel_docs = R"doc(
-    Set the number of scalings
+// SetLevel
+const char* ctx_SetLevel_docs = R"pbdoc(
+    Set the number of scalings.
+
+    :param level: The level to set.
+    :type level: int
+)pbdoc";
 
-    Parameters
-    ----------
-        level (int): The level to set.
-)doc";
 #endif // CIPHERTEXT_DOCSTRINGS_H

Разница между файлами не показана из-за своего большого размера
+ 690 - 849
include/docstrings/cryptocontext_docs.h


+ 49 - 54
include/docstrings/plaintext_docs.h

@@ -1,84 +1,79 @@
 #ifndef PLAINTEXT_DOCSTRINGS_H
 #define PLAINTEXT_DOCSTRINGS_H
 
+// GetScalingFactor
 const char* ptx_GetScalingFactor_docs = R"doc(
     Get the scaling factor of the plaintext for CKKS-based plaintexts.
 
-    Returns
-    -------
-        float: The scaling factor of the plaintext.
+    :return: The scaling factor of the plaintext.
+    :rtype: float
 )doc";
 
-const char* ptx_SetScalingFactor_docs = R"doc(
+// SetScalingFactor
+const char* ptx_SetScalingFactor_docs = R"pbdoc(
     Set the scaling factor of the plaintext for CKKS-based plaintexts.
 
-    Parameters
-    ----------
-        sf (float): The scaling factor to set.
-)doc";
+    :param sf: The scaling factor to set.
+    :type sf: float
+)pbdoc";
 
-const char* ptx_GetLength_docs = R"doc(
+// GetLength
+const char* ptx_GetLength_docs = R"pbdoc(
     Get method to return the length of the plaintext.
 
-    Returns
-    -------
-        int: The length of the plaintext in terms of the number of bits.
-)doc";
+    :return: The length of the plaintext in terms of the number of bits.
+    :rtype: int
+)pbdoc";
 
-const char* ptx_GetSchemeID_docs = R"doc(
+// GetSchemeID
+const char* ptx_GetSchemeID_docs = R"pbdoc(
     Get the encryption technique of the plaintext for BFV-based plaintexts.
 
-    Returns
-    -------
-        SCHEME: The scheme ID of the plaintext.
-)doc";
+    :return: The scheme ID of the plaintext.
+    :rtype: SCHEME
+)pbdoc";
 
-const char* ptx_SetLength_docs = R"doc(
-    resize the plaintext; only works for plaintexts that support a resizable vector (coefpacked)
+// SetLength
+const char* ptx_SetLength_docs = R"pbdoc(
+    Resize the plaintext; only works for plaintexts that support a resizable vector (coefpacked).
+    
+    :param newSize: The new size of the plaintext.
+    :type newSize: int
+)pbdoc";
 
-    Parameters
-    ----------
-        newSize (int): -
-)doc";
-
-const char* ptx_IsEncoded_docs = R"doc(
+// IsEncoded
+const char* ptx_IsEncoded_docs = R"pbdoc(
     Check if the plaintext is encoded.
 
-    Returns
-    -------
-        bool: True if the plaintext is encoded, False otherwise.
-)doc";
+    :return: True if the plaintext is encoded, False otherwise.
+    :rtype: bool
+)pbdoc";
 
-const char* ptx_GetLogPrecision_docs = R"doc(
+// GetLogPrecision
+const char* ptx_GetLogPrecision_docs = R"pbdoc(
     Get the log of the plaintext precision.
 
-    Returns
-    -------
-        float: The log of the plaintext precision.
-)doc";
+    :return: The log of the plaintext precision.
+    :rtype: float
+)pbdoc";
 
-const char* ptx_Encode_docs = R"doc(
-    Encode the plaintext into a polynomial
+// Encode
+const char* ptx_Encode_docs = R"pbdoc(
+    Encode the plaintext into a polynomial.
+)pbdoc";
 
-    Returns
-    -------
-        None
-)doc";
-
-const char* ptx_Decode_docs = R"doc(
-    Decode the polynomial into a plaintext
-
-    Returns
-    -------
-        None
-)doc";
+// Decode
+const char* ptx_Decode_docs = R"pbdoc(
+    Decode the polynomial into a plaintext.
+)pbdoc";
 
-const char* ptx_GetCKKSPackedValue_docs = R"doc(
+// GetCKKSPackedValue
+const char* ptx_GetCKKSPackedValue_docs = R"pbdoc(
     Get the packed value of the plaintext for CKKS-based plaintexts.
 
-    Returns
-    -------
-        List[complex]: The packed value of the plaintext.
-)doc";
+    :return: The packed value of the plaintext.
+    :rtype: List[complex]
+)pbdoc";
+
 
 #endif // PLAINTEXT_DOCSTRINGS_H

Некоторые файлы не были показаны из-за большого количества измененных файлов