Overview
Therequire statement in FHE contracts works similarly to Conditions (if .. else) because both involve conditional logic on encrypted data. Just like you can’t use traditional if...else statements with encrypted values, you also can’t use standard require statements that depend on encrypted conditions.
Why Require is Like Conditions
Bothrequire and conditional statements face the same fundamental challenge in FHE:
Encrypted Evaluation
The condition being checked is encrypted, so the contract can’t directly evaluate it to decide whether to revert.
Information Leakage
If a transaction reverts based on an encrypted condition, observers can infer information about the encrypted data.
The Solution
Instead of usingrequire with encrypted conditions, you should:
- Use
FHE.selectto handle the conditional logic (see Conditions (if .. else)) - Only use
requirefor non-encrypted conditions like access control checks, address validation, or other plaintext values