From 568b8f9d164108d0a3493dfb9edc4b762bfe3687 Mon Sep 17 00:00:00 2001 From: Alexandre Carvalheira Date: Wed, 25 Feb 2026 21:14:15 -0300 Subject: [PATCH 1/3] Update fhe-library/core-concepts/conditions.mdx Co-Authored-By: mintlify[bot] <109931778+mintlify[bot]@users.noreply.github.com> --- fhe-library/core-concepts/conditions.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fhe-library/core-concepts/conditions.mdx b/fhe-library/core-concepts/conditions.mdx index 3d4637c..d067669 100644 --- a/fhe-library/core-concepts/conditions.mdx +++ b/fhe-library/core-concepts/conditions.mdx @@ -1,5 +1,5 @@ --- -title: "Conditions" +title: "Conditions (if .. else)" description: "Understanding why if..else isn't possible with FHE and exploring the alternatives" --- From 2f7b132da384b472ec4e52837b3f35894de31322 Mon Sep 17 00:00:00 2001 From: Alexandre Carvalheira Date: Wed, 25 Feb 2026 21:14:31 -0300 Subject: [PATCH 2/3] Update fhe-library/core-concepts/require.mdx Co-Authored-By: mintlify[bot] <109931778+mintlify[bot]@users.noreply.github.com> --- fhe-library/core-concepts/require.mdx | 54 +++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 fhe-library/core-concepts/require.mdx diff --git a/fhe-library/core-concepts/require.mdx b/fhe-library/core-concepts/require.mdx new file mode 100644 index 0000000..83a445e --- /dev/null +++ b/fhe-library/core-concepts/require.mdx @@ -0,0 +1,54 @@ +--- +title: "Require" +description: "Understanding require statements with encrypted data in FHE" +--- + +## Overview + +The `require` statement in FHE contracts works similarly to [Conditions (if .. else)](/fhe-library/core-concepts/conditions) 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. + + +Traditional `require` statements that check encrypted conditions will leak information about your encrypted values through execution paths. + + +--- + +## Why Require is Like Conditions + +Both `require` and conditional statements face the same fundamental challenge in FHE: + + + +The condition being checked is encrypted, so the contract can't directly evaluate it to decide whether to revert. + + + +If a transaction reverts based on an encrypted condition, observers can infer information about the encrypted data. + + + +--- + +## The Solution + +Instead of using `require` with encrypted conditions, you should: + +1. **Use `FHE.select`** to handle the conditional logic (see [Conditions (if .. else)](/fhe-library/core-concepts/conditions)) +2. **Only use `require` for non-encrypted conditions** like access control checks, address validation, or other plaintext values + +```solidity +// Good - require on plaintext condition +require(msg.sender == owner, "Not authorized"); + +// Good - use select for encrypted logic +euint32 result = FHE.select(encryptedCondition, valueA, valueB); + +// Bad - require on encrypted condition leaks information! +require(FHE.decrypt(encryptedValue.gt(threshold)), "Value too low"); +``` + +--- + +## Learn More + +For detailed guidance on handling conditional logic with encrypted data, see the [Conditions (if .. else)](/fhe-library/core-concepts/conditions) page. From 73758917362877db38dcc4f9292218bcc7e9675c Mon Sep 17 00:00:00 2001 From: Alexandre Carvalheira Date: Wed, 25 Feb 2026 21:14:42 -0300 Subject: [PATCH 3/3] Update docs.json Co-Authored-By: mintlify[bot] <109931778+mintlify[bot]@users.noreply.github.com> --- docs.json | 1 + 1 file changed, 1 insertion(+) diff --git a/docs.json b/docs.json index 7475f23..894fadc 100644 --- a/docs.json +++ b/docs.json @@ -111,6 +111,7 @@ "fhe-library/core-concepts/data-evaluation", "fhe-library/core-concepts/encrypted-operations", "fhe-library/core-concepts/conditions", + "fhe-library/core-concepts/require", "fhe-library/core-concepts/access-control", "fhe-library/core-concepts/decryption-operations", "fhe-library/core-concepts/randomness",