Float#

class usencrypt.cipher.Float(value=None, *args, **kwargs)#

Ciphertext real number, stored in 32.32 fixed-point format.

Parameters
  • value (float) – The real number to be encrypted. Defaults to None.

  • hexstr (str) – The hexadecimal representation of the encrypted float object. Defaults to None.

Examples

To create an encrypted real number object from a non-encrypted real number, we can do the following:

>>> import usencrypt as ue
>>> ue_x = ue.cipher.Float(value=0.75)
>>> ue_x
(0x7f078085fee0) Float: 0x96c525b7cab46206f7966ae4d42bc78d10a7b6405422ee643973a472575a87ab

Similarly, we can encrypt a non-encrypted real number directly using the usencrypt.encrypt() function:

>>> import usencrypt as ue
>>> ue_x = ue.encrypt(0.75, dtype=float)
>>> ue_x
(0x7f078085fee0) Float: 0x96c525b7cab46206f7966ae4d42bc78d10a7b6405422ee643973a472575a87ab

Finally, we can also create an encrypted real number object directly from a hexadecimal string:

>>> import usencrypt as ue
>>> ue_x = ue.cipher.Float(hexstr='0x96c525b7cab46206f7966ae4d42bc78d10a7b6405422ee643973a472575a87ab')
>>> ue_x
(0x7f078085fee0) Float: 0x96c525b7cab46206f7966ae4d42bc78d10a7b6405422ee643973a472575a87ab

METHODS

Float.conjugate

Returns the conjugate of the encrypted real number \(E(x)\).

Float.cos

Computes the cosine of the encrypted real number \(E(x)\) using \(n\) iterations of the Taylor series approximation method.

Float.decrypt

Decrypts the encrypted object \(E(x)\), returning the original non-encrypted \(x\).

Float.encrypt_other

Encrypts \(x\) dynamically with the same dtype as the encrypted object \(E(x)\).

Float.exp

Computes the exponential of the encrypted real number \(E(x)\) using \(n\) iterations of the Taylor series approximation method.

Float.log

Computes the natural logarithm of the encrypted real number \(E(x)\) using the Newton-Raphson method.

Float.sin

Computes the sine of the encrypted real number \(E(x)\) using the cosine series approximation method.

Float.sqrt

Computes the non-negative square-root of the encrypted real number \(E(x)\).