fhenix-encrypted-comparisons
Encrypted comparisons returning ebool — eq/ne (all types incl. eaddress), lt/lte/gt/gte and min/max (euint8..128). Comparisons can't branch directly; pair the ebool with FHE.select. Covers operand-type rules and the bid/threshold pattern.
Works with
Agent Skills format with YAML frontmatter. Claude Code reads it as-is.
---
name: "fhenix-encrypted-comparisons"
description: "Encrypted comparisons returning ebool — eq/ne (all types incl. eaddress), lt/lte/gt/gte and min/max (euint8..128). Comparisons can't branch directly; pair the ebool with FHE.select. Covers operand-type rules and the bid/threshold pattern."
license: "MIT"
---
# Fhenix Encrypted Comparisons
## Overview
Comparisons evaluate homomorphically and return an **`ebool`** (encrypted boolean) — you can't read the result directly. To act on it, feed the `ebool` into `FHE.select` (see `fhenix-encrypted-conditionals`).
| Function | Result | Operand types |
| --- | --- | --- |
| `eq` / `ne` | `ebool` | all encrypted types **including `eaddress`** |
| `lt` / `lte` / `gt` / `gte` | `ebool` | `euint8…128` |
| `min` / `max` | `euintXX` | `euint8…128` |
```solidity
ebool isHigher = FHE.gt(newBid, highestBid);
ebool sameAddr = FHE.eq(owner, candidate); // eaddress equality
euint32 higher = FHE.max(newBid, highestBid);
```
## Comparisons + select (the core pattern)
```solidity
// Keep the larger bid without revealing either value
ebool isHigher = bid.gt(highestBid);
euint32 newHigh = FHE.select(isHigher, bid, highestBid);
FHE.allowThis(newHigh);
highestBid = newHigh;
```
## Eligibility / threshold example
```solidity
function isEligible(euint32 reputation) public returns (ebool) {
ebool ok = FHE.gte(reputation, FHE.asEuint32(MIN_REP));
FHE.allowThis(ok);
return ok; // reveal later via decrypt flow if needed
}
```
## Common pitfalls
- **Trying to `if`/`require` on an `ebool`** — impossible; it's encrypted. Use `FHE.select` and resolve true/false off-chain via decryption when you must branch.
- Ordering ops (`lt`/`gt`/`min`/`max`) on `ebool`/`eaddress` — unsupported; only `eq`/`ne` apply there.
- Mismatched widths — convert first.
## Source docs
- [`fhe-library/core-concepts/encrypted-operations.mdx`](../fhenix-docs/fhe-library/core-concepts/encrypted-operations.mdx)
- [`fhe-library/reference/fhe-sol/comparison.mdx`](../fhenix-docs/fhe-library/reference/fhe-sol/comparison.mdx)
- [`fhe-library/core-concepts/conditions.mdx`](../fhenix-docs/fhe-library/core-concepts/conditions.mdx)
## AI Agent Prompt
> "Implement a private auction `placeBid(InEuint32)` that compares the new bid to the stored highest with `FHE.gt`, updates via `FHE.select`, and re-grants ACL — never branching on the encrypted comparison."More General & Other skills
find-skills
vercel-labs/skills
Helps users discover and install agent skills when they ask questions like "how do I do X", "find a skill for X", "is there a skill that can...", or express interest in extending capabilities. This skill should be used when the user is looking for functionality that might exist as an installable skill.
grill-me
mattpocock/skills
A relentless interview to sharpen a plan or design.
grill-with-docs
mattpocock/skills
A relentless interview to sharpen a plan or design, which also creates docs (ADR's and glossary) as we go.

