xtrace_sdk.crypto.encryption.paillier ===================================== .. py:module:: xtrace_sdk.crypto.encryption.paillier Classes ------- .. autoapisummary:: xtrace_sdk.crypto.encryption.paillier.Paillier Module Contents --------------- .. py:class:: Paillier(keys) Bases: :py:obj:`xtrace_sdk.crypto.encryption.homomorphic_base.HomomorphicBase`\ [\ :py:obj:`gmpy2.mpz`\ , :py:obj:`gmpy2.mpz`\ , :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) :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:: 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: gmpy2.mpz .. py:method:: encrypt(plaintext, pk) :staticmethod: Encryption with PK :param plaintext: the plaintext to be encrypted. :type plaintext: gmpy2.mpz :param pk: the public key to be used for encryption :type pk: PaillierPublicKey :return: Paillier cipher :rtype: gmpy2.mpz .. 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: gmpy2.mpz :param keys: pk,sk pair where sk is used to encrypt ct. :type keys: PaillierKeyPair :return: plaintext :rtype: gmpy2.mpz .. 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: gmpy2.mpz .. py:method:: multiply(ciphertext1, ciphertext2, pk) :staticmethod: :abstractmethod: Not supported for Paillier. .. py:method:: xor(ciphertext1, ciphertext2, pk) :staticmethod: :abstractmethod: Not supported for Paillier.