fhenix-best-practices
Installation
SKILL.md
Fhenix FHE Best Practices
Security
- Always update permissions. After modifying any encrypted value you'll use later, call
FHE.allowThis(value)(andFHE.allow(value, user)for user-readable values). MissingallowThisis the #1 FHE bug. - Never branch on encrypted data. No
if (ebool),require(ebool), orwhileon encrypted conditions — it leaks via execution path/timing. UseFHE.select(cond, a, b)for constant-time logic. Don't decrypt just to branch.// ❌ FHE.publishDecryptResult(condition, p, sig); if (p > 0) {...} // ✅ result = FHE.select(condition, a, b); - Publish decrypted data carefully. Publishing makes plaintext permanently public. Evaluate information leakage first; minimize what you publish; prefer
FHE.verifyDecryptResult(confirm without storing) overpublishDecryptResult, anddecryptForView(UI-only) when no on-chain proof is needed. - Unchecked arithmetic.
euintmath wraps on overflow (no revert, by design). Size types so wrap-around can't corrupt logic. - Division/remainder by zero returns an encrypted max-value sentinel (no leak) — guard the divisor with
FHE.selectwhen correctness depends on it.