usencrypt.ifelse#

usencrypt.ifelse(b, x, y)#

Ternary if-else expression for programming with encrypted objects.

Parameters
Returns

Returns x if b is True. Otherwise, it returns y.

Return type

A subclass of usencrypt.cipher.Ciphertext.

Note

Short-circuiting is not supported in order to maintain the security of the method. Therefore, this function is strict in all its three arguments.

Examples
>>> import usencrypt as ue
>>> a = ue.encrypt(0.25)
>>> b = ue.encrypt(0.5)
>>> c = ue.ifelse(a > b, a, b)
>>> ue.decrypt(c)
0.5