xtrace_sdk.crypto.encryption.paillier_lookup ============================================ .. py:module:: xtrace_sdk.crypto.encryption.paillier_lookup Attributes ---------- .. autoapisummary:: xtrace_sdk.crypto.encryption.paillier_lookup.MSG_BITS xtrace_sdk.crypto.encryption.paillier_lookup.NOISE_TABLE_SIZE xtrace_sdk.crypto.encryption.paillier_lookup.NOISE_MULTIPLES Classes ------- .. autoapisummary:: xtrace_sdk.crypto.encryption.paillier_lookup.Paillier_Lookup Module Contents --------------- .. py:data:: MSG_BITS :value: 8 .. py:data:: NOISE_TABLE_SIZE :value: 256 .. py:data:: NOISE_MULTIPLES :value: 14 .. py:class:: Paillier_Lookup(keys) Bases: :py:obj:`xtrace_sdk.crypto.encryption.homomorphic_base.HomomorphicBase`\ [\ :py:obj:`int`\ , :py:obj:`int`\ , :py:obj:`xtrace_sdk.utils.xtrace_types.PaillierKeyPair`\ , :py:obj:`xtrace_sdk.utils.xtrace_types.PaillierPublicKey`\ ] A self implemented paillier encryption scheme .. py:attribute:: keys .. py:method:: key_gen(key_len, alpha_len) :staticmethod: Key generation routine for the Paillier crypto scheme. :param key_len: the number of bits in PK SK :type key_len: int :return: Paillier PK, SK pair :rtype: PaillierKeyPair .. py:method:: precompute_g_table(g, n, key_len, msg_bits = MSG_BITS) :staticmethod: .. py:method:: precompute_noise_table(g, n, size = NOISE_TABLE_SIZE) :staticmethod: .. py:method:: gen_dsa_params_custom(p_bits, q_bits) :staticmethod: 1024-bit DSA => q is 160-bit (FIPS 186-4). :param p_bits: The number of bits for the keys :type p_bits: int :param q_bits: The number of bits in alpha :type q_bits: int :return: mpz(P), mpz(Q), mpz(G). :rtype: int .. py:method:: generate_random_r(pk) :staticmethod: Helper function for encryption required by Paillier scheme :param pk: the public key :type pk: PaillierPublicKey :return: a random r to be used for encryption. :rtype: int .. py:method:: encrypt(plaintext, pk, g_table = None, noise_table = None, message_chunks = 0) :staticmethod: Encryption with PK :param plaintext: the plaintext to be encrypted. :type plaintext: int :param pk: the public key to be used for encryption :type pk: PaillierPublicKey :return: Paillier cipher :rtype: int .. py:method:: decrypt(ciphertext, keys) :staticmethod: Decrypts a cihpher with paillier key pair and returns the plaintext :param ciphertext: cipher to be decrypted :type ciphertext: int :param keys: pk,sk pair where sk is used to encrypt ct. :type keys: PaillierKeyPair :return: plaintext :rtype: int .. py:method:: add(ciphertext1, ciphertext2, pk) :staticmethod: Homomorphic addition of Paillier crypto system. :param ciphertext1: one the ciphers to be added :type ciphertext1: int :param ciphertext2: one the ciphers to be added :type ciphertext2: int :param pk: Pailier public key :type pk: PaillierPublicKey :return: ciphertext3 such that decrypt(ct3,sk) = decrypt(ct1,sk) + decrypt(ct2,sk) :rtype: int .. py:method:: multiply(ciphertext1, ciphertext2, pk) :staticmethod: :abstractmethod: Not supported for Paillier. .. py:method:: xor(ciphertext1, ciphertext2, pk) :staticmethod: :abstractmethod: Not supported for Paillier. .. py:method:: L(x, n) :staticmethod: Helper method for decryption .. py:method:: bitlen(x) :staticmethod: Helper method to get bit length of gmpy mpz integers .. py:method:: crt_pair(a1, m1, a2, m2) :staticmethod: Helper method for Chinsese Remainder Theorem .. py:method:: lift_to_p2_with_p_component(g_mod_p, p) :staticmethod: Multiply by (1+p) to inject an order-p component in Z_{p^2}*