- You can’t use an if/else statement with a condition depending on a private value. The flow that the program would take would leak information about the private value.
- For the same reason you can’t revert a transaction based on a condition depending on a private value.
Multiplexer Design Pattern
The inco equivalent of an if/else statement is theselect
statement.
The select
statement takes an encrypted boolean as first argument and two encrypted values as second and third arguments.
The result of the select
statement is the second argument if the first argument is true and the third argument otherwise.
Example usage from the confidential token contract: