(self, value, precision=None, random_value=None)
return encryptednumber
Encode and Paillier encrypt a real number value.
Encode and Paillier encrypt a real number value.
Encode and Paillier encrypt a real number value .
def encrypt(self, value, precision=None, random_value=None):
        """Encode and Paillier encrypt a real number value.
        """
        if isinstance(value, FixedPointNumber):
            value = value.decode()
        encoding = FixedPointNumber.encode(value, self.n, self.max_int, precision)
        obfuscator = random_value or 1
        ciphertext = self.raw_encrypt(encoding.encoding, random_value=obfuscator)
        encryptednumber = PaillierEncryptedNumber(self, ciphertext, encoding.exponent)
        if random_value is None:
            encryptednumber.apply_obfuscator()

        return encryptednumber
def encrypt ( self , value , precision = None , random_value = None ) : if isinstance ( value , FixedPointNumber ) : value = value . decode ( ) encoding = FixedPointNumber . encode ( value , self . n , self . max_int , precision ) obfuscator = random_value or 1 ciphertext = self . raw_encrypt ( encoding . encoding , random_value = obfuscator ) encryptednumber = PaillierEncryptedNumber ( self , ciphertext , encoding . exponent ) if random_value is None : encryptednumber . apply_obfuscator ( ) return encryptednumber