usencrypt.ifelse#
- usencrypt.ifelse(b, x, y)#
Ternary if-else expression for programming with encrypted objects.
- Parameters
b (
usencrypt.cipher.Boolean
) – The control flow boolean expression.x (subclass of
usencrypt.cipher.Ciphertext
) – The value returned whenb
isTrue
.y (subclass of
usencrypt.cipher.Ciphertext
) – The value returned whenb
isFalse
.
- Returns
Returns
x
ifb
isTrue
. Otherwise, it returnsy
.- 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