Skip to main content

Control Flow

The e_select function enables conditional logic on encrypted values without revealing the condition.

e_select

Returns if_true when condition is encrypted true, if_false otherwise.

Example: Confidential Transfer with Balance Check

How e_select Works

Conditional Transfer Flow


Why Use e_select?

This pattern ensures:
  • No information leakage: Balance check happens on encrypted values
  • Atomic transfers: Either full amount transfers or nothing
  • No negative balances: Impossible to overdraw
Never branch on decrypted values in your program. Use e_select to keep logic encrypted:
The last parameter in operation calls identifies whether the left-hand side operand is ciphertext (0) or plaintext (1). Always pass 0 when working with encrypted handles.