Explorar el Código

refactor style - plain and ciphertext

Rener Oliveira (Ubuntu WSL) hace 1 año
padre
commit
61938e48a1
Se han modificado 2 ficheros con 106 adiciones y 84 borrados
  1. 57 30
      include/docstrings/binfhecontext_docs.h
  2. 49 54
      include/docstrings/plaintext_docs.h

+ 57 - 30
include/docstrings/binfhecontext_docs.h

@@ -1,90 +1,117 @@
 #ifndef BINFHECONTEXT_DOCSTRINGS_H
 #define BINFHECONTEXT_DOCSTRINGS_H
 
-// BinFHEContext Docs:
+// GenerateBinFHEContext
 const char* binfhe_GenerateBinFHEContext_parset_docs = R"doc(
-    Creates a crypto context using predefined parameters sets. Recommended for most users.
+    Creates a crypto context using predefined parameter 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).
+    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
+    CryptoContext
+        The created crypto context.
 )doc";
 
+// KeyGen
 const char* binfhe_KeyGen_docs = R"doc(
-    Generates a secret key for the main LWE scheme
+    Generates a secret key for the main LWE scheme.
 
     Returns:
     --------
-        LWEPrivateKey: the secret key
+    LWEPrivateKey
+        The secret key.
 )doc";
 
+// BTKeyGen
 const char* binfhe_BTKeyGen_docs = R"doc(
-    Generates bootstrapping keys
+    Generates bootstrapping keys.
 
-    Psrameters:
+    Parameters:
     -----------
-        sk (LWEPrivateKey): secret key
+    sk : LWEPrivateKey
+        The secret key.
 )doc";
 
+// Encrypt
 const char* binfhe_Encrypt_docs = R"doc(
-    Encrypts a bit using a secret key (symmetric key encryption)
+    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
+    sk : LWEPrivateKey
+        The secret key.
+    m : int
+        The plaintext.
+    output : BINFHE_OUTPUT
+        FRESH to generate a 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
+    LWECiphertext
+        The ciphertext.
 )doc";
 
+// Decrypt
 const char* binfhe_Decrypt_docs = R"doc(
-    Encrypt according to mod instead of m_q if mod != 0
+    Decrypts a ciphertext using a secret key.
 
     Parameters:
     -----------
-        sk (LWEPrivateKey): the secret key
-        ct (LWECiphertext): the ciphertext
-        p (int): plaintext modulus (default 4)
+    sk : LWEPrivateKey
+        The secret key.
+    ct : LWECiphertext
+        The ciphertext.
+    p : int
+        Plaintext modulus (default 4).
 
     Returns:
     --------
-       int: the plaintext
+    int
+        The plaintext.
 )doc";
 
+// EvalBinGate
 const char* binfhe_EvalBinGate_docs = R"doc(
-    Evaluates a binary gate (calls bootstrapping as a subroutine)
+    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
+    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
+    LWECiphertext
+        The resulting ciphertext.
 )doc";
 
+// EvalNOT
 const char* binfhe_EvalNOT_docs = R"doc(
-    Evaluates NOT gate
+    Evaluates the NOT gate.
 
     Parameters:
     -----------
-        ct (LWECiphertext): the input ciphertext
+    ct : LWECiphertext
+        The input ciphertext.
 
     Returns:
     --------
-        LWECiphertext: the resulting ciphertext
+    LWECiphertext
+        The resulting ciphertext.
 )doc";
 
 

+ 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