/bn-fhevm:fhevm-overviewfrom bn-fhevm
Used when an AI coding agent needs a mental model of the Zama Confidential Blockchain Protocol — FHEVM architecture, the four off-chain components (coprocessor, KMS threshold network, gateway, relayer), the on-chain contracts (ACL, FHEVMExecutor, KMSVerifier, InputVerifier), the ZKPoK-bound encrypted-input flow, and the v0.9+ async decryption pattern. Triggers on prompts mentioning FHEVM, confidential smart contracts, FHE on-chain, Zama protocol, coprocessor, KMS, relayer, gateway, input proofs, ciphertext handles, or how confidential transactions flow end-to-end.
Ships in bn-fhevm. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
A structured mental model of the Zama Confidential Blockchain Protocol. Read this before writing any contract, test, or client that touches FHEVM. Other skills assume the agent knows what the pieces are and when each one runs — this skill provides that baseline.
The host chain never sees plaintext. The off-chain coprocessor executes TFHE operations on ciphertext handles that live in its own store. The chain carries only opaque 32-byte handles and symbolic compute requests. There is no "decrypt on-chain" primitive.
But that's only half of the FHE-vs-ZK distinction — and the half that matters for product design is the half about what privacy property each provides.
FHE hides the values inside ciphertexts. It does NOT hide:
Set-membership privacy — mixers, shielded transfers, anonymous credentials,
"which one of N inputs am I spending" — requires ZK primitives FHEVM does not
provide. A confidential ERC-7984 transfer leaks (from, to) to anyone
watching the chain; the amount is hidden, the relationship is not. A
sealed-bid auction can hide the winning bid amount via FHE, but the list of
bidder addresses is structurally on-chain. Product designs that assume
otherwise will ship a privacy bug, not a privacy feature.
If your product needs to hide who is interacting (not just how much they're moving), FHEVM is the wrong primitive. Look at zk-rollups (Aztec, Railgun) or zkSNARK-based mixers (Tornado-style protocols) for those use cases. FHEVM gives you confidential amounts and confidential predicates; it does not give you anonymity sets or transaction-graph privacy.
Every encrypted value is addressed by a bytes32 handle. Reading or reusing a handle requires an ACL grant. New handles produced by FHE.* operations inherit no permissions from their inputs — the contract must call FHE.allowThis(newHandle) and, if a user needs to decrypt, FHE.allow(newHandle, user). Forgetting this is the single most common production bug.
Clients encrypt inputs under a chain-specific public key and attach a ZKPoK that proves the ciphertext was produced correctly and is bound to (contract_address, user_address). The on-chain InputVerifier validates the proof before FHE.fromExternal(handle, proof) hands the contract a usable euint*. A proof bound to the wrong contract is rejected on-chain — this is not a validation you can skip.
There is no synchronous decrypt(). The flow is:
FHE.makePubliclyDecryptable(handle) (public) or FHE.allow(handle, user) (user-scoped) grants the KMS permission to reveal.publicDecrypt([handles]) or userDecrypt([{ handle, contract }]) via @zama-fhe/sdk (v3, provider-agnostic — works with viem, ethers, or any EVM library). The KMS threshold network produces a signed cleartext payload.FHE.checkSignatures(handles, encoded, signatures) verifies the KMS threshold signatures before the revealed value is trusted by the contract.Settlement, reveal, claim, and auction-close are always multi-transaction.
An FHEVM transaction touches three independent actors beyond the user:
The relayer is the HTTPS edge that brokers client ↔ coprocessor and client ↔ KMS traffic. The gateway coordinates the off-chain services. Agents that model FHEVM as "a contract call that returns a plaintext" will write broken code every time.
flowchart LR
U[Client / Browser<br/>@zama-fhe/sdk]
subgraph HC[Host Chain — EVM]
UC[User Contract<br/>inherits ZamaEthereumConfig]
ACL[ACL]
FEX[FHEVMExecutor]
IV[InputVerifier]
KV[KMSVerifier]
end
subgraph OFF[Off-chain services]
R[Relayer<br/>HTTPS edge]
G[Gateway<br/>coordinator]
CP[Coprocessor<br/>TFHE compute + ciphertext store]
KMS[KMS threshold network<br/>holds FHE key shares]
end
U -- "tx: handle + ZKPoK" --> UC
UC -- "fromExternal(h, proof)" --> IV
UC -- "FHE.add/select/..." --> FEX
FEX -- "symbolic event" --> CP
UC -- "allow / allowThis / makePubliclyDecryptable" --> ACL
U -- "publicDecrypt / userDecrypt" --> R
R --> G
G --> CP
G --> KMS
KMS -- "threshold signature" --> U
U -- "revealed value + sig" --> UC
UC -- "checkSignatures" --> KV
(contract_address, user_address), and submits the resulting 32-byte handle plus proof bytes in the transaction calldata.FHE.fromExternal(externalEuint64 handle, bytes inputProof). InputVerifier validates the ZKPoK on-chain; FHEVMExecutor records the handle as belonging to the contract.FHE.add(a, b), FHE.select(cond, t, f), etc., the EVM emits a symbolic event to FHEVMExecutor and returns a new handle — no compute happens on-chain.FHE.allowThis(newHandle) to keep using it in future txs, and FHE.allow(newHandle, user) if a user later needs to decrypt it.Public decryption (value is world-readable):
// On-chain: authorize the reveal
FHE.makePubliclyDecryptable(resultHandle);
// Off-chain: fetch cleartext + KMS threshold signature
const { [handle]: value, signatures } = await instance.publicDecrypt([handle]);
// On-chain: verify the signature before using the cleartext
FHE.checkSignatures(handles, abi.encode(value), signatures);
User decryption (value is scoped to a single address):
// On-chain: pre-grant ACL to the user
FHE.allow(handle, user);
// Off-chain: EIP-712 permit authorizes the relayer to re-encrypt under
// the user's ephemeral ML-KEM key. Nothing is revealed on-chain.
// The signer is bound to the SDK at `new ZamaSDK({ relayer, signer, storage })`;
// userDecrypt takes an array of (handle, contractAddress) pairs.
const { [handle]: value } = await sdk.userDecrypt([{ handle, contractAddress }]);
User decryption returns a plaintext the client holds; the chain only knows the user was authorized. Public decryption returns a plaintext + signature any party can verify.
| Contract | Role |
|---|---|
ACL | Stores per-handle permissions (allow, allowThis, allowTransient, makePubliclyDecryptable). Every contract read of a handle checks the ACL. |
FHEVMExecutor | Emits symbolic events that the coprocessor listens to. Records which handles exist, which contract produced them, and which operation produced them. |
InputVerifier | On-chain verifier for client-side ZKPoK input proofs. Gates FHE.fromExternal. |
KMSVerifier | On-chain verifier for KMS threshold signatures returned by publicDecrypt. Gates FHE.checkSignatures. |
All four are deployed per host chain. Their addresses are wired into your contract when it inherits ZamaEthereumConfig from @fhevm/solidity/config/ZamaConfig.sol — do not hard-code them.
| Service | Role |
|---|---|
| Coprocessor | Verifies ZK input proofs server-side, runs TFHE operations, persists result ciphertexts indexed by handle. Stateful. |
| KMS threshold network | Holds shares of the FHE secret key. Signs reveals under a threshold of signers. Stateless w.r.t. ciphertexts. |
| Gateway | Coordinator between the coprocessor, the KMS, and the relayer. Handles retries and ordering. |
| Relayer | HTTPS edge clients talk to. Proxies encrypt / decrypt / reencrypt traffic between browser and coprocessor / KMS. The SDK's relayerUrl points here — it is not the JSON-RPC URL. |
fhevm-contracts.fhevm-setup.ACLNotAllowed or TFHE.* → FHE.* migrations → fhevm-antipatterns.publicDecrypt / userDecrypt flows → fhevm-decryption.fhevm-testing.fhevm-frontend.FHEVM is great when you need confidential values with public computation rules. It is the wrong primitive when the privacy requirement is one of:
If a product spec uses words like "anonymous," "unlinkable," "hidden sender," or "untraceable," the answer is almost never "use FHEVM." Push back at design time, not at audit time.
Conversely, FHEVM is exactly right for: confidential balances on a known
account (ERC-7984), encrypted bid amounts in a known auction with known
participants (BlindAuction), confidential predicates over plaintext metadata
(KYC-gated transfers via canTransact), and any design where the values are
private but the participants are not.
If the prompt is about writing, testing, or debugging code, this skill is the wrong entry point — route via When NOT to Use.
| Package | Version | Role |
|---|---|---|
@fhevm/solidity | 0.11.1 | FHE.* library, euint*, ebool, eaddress, ZamaEthereumConfig |
@fhevm/hardhat-plugin | 0.4.2 | Injects the mock coprocessor on the hardhat network |
@fhevm/mock-utils | 0.4.2 | EIP-712 + KMS mocking helpers for unit tests |
@openzeppelin/confidential-contracts | 0.4.x | ERC-7984 confidential token standard + extensions |
@zama-fhe/sdk | 3.0.0 | Primary client SDK. Provider-agnostic (viem, ethers, or any EVM lib). new ZamaSDK({ relayer, signer, storage }) returns an instance whose publicDecrypt / userDecrypt / encrypt / allow methods drive the off-chain flows. |
@zama-fhe/react-sdk | 3.0.x | React hooks over @zama-fhe/sdk (powered by @tanstack/query-core) |
@zama-fhe/relayer-sdk | ~0.4.2 | Transitive — low-level relayer transport. Pulled in by @zama-fhe/sdk; do not install directly for new code |
Do not use fhevmjs — it is the deprecated SDK name and is superseded by @zama-fhe/*.
@fhevm/solidity source — https://github.com/zama-ai/fhevm-solidity@zama-fhe/sdk source — https://github.com/zama-ai/sdk (v3.0.0 release: https://github.com/zama-ai/sdk/releases/tag/v3.0.0)@zama-fhe/relayer-sdk source (low-level, transitive) — https://github.com/zama-ai/relayer-sdkWhat SKILL.md sets; muted values are Claude Code's defaults
Generated from the plugin's indexed repository (bootnodedev/zama-s2-bounty-skills) — no native marketplace selected
npx claudepluginhub p/bootnodedev-bn-fhevm10 skills in this plugin
/create-templateUse when scaffolding a new FHEVM workspace -- contracts, Next.js frontend, or Vite frontend. Copies the canonical bundled template (project/ or templates/frontend-{next,vite}/) into a target directory and customizes package metadata, env-var defaults, and the Sepolia RPC URL via an interactive AskUserQuestion wizard./fhevm-antipatternsUsed when reviewing, debugging, auditing, or pre-commit-checking FHEVM Solidity or client code. Catalogues the v0.11-era breaking renames (TFHE→FHE, SepoliaZamaFHEVMConfig→ZamaEthereumConfig, ConfidentialFungibleToken→ERC7984, TFHESafeMath→FHESafeMath, tokenURI→contractURI, isUserAllowed→canTransact), the removed FHE.requestDecryption API, deprecated fhevmjs, and high-frequency footguns (missing FHE.allowThis after state writes, view functions returning encrypted types, .env-based Hardhat secrets). Triggers on FHEVM code review, anti-pattern, audit, migration from pre-v0.9/v0.11, pre-commit check, ACLNotAllowed, EmptyDecryptionProof, or DeclarationError./fhevm-contractsUsed when writing, refactoring, or reviewing FHEVM Solidity contracts against the @fhevm/[email protected] API. Covers encrypted types (ebool, euint8..256, eaddress), FHE operations (arithmetic, comparison, FHE.select), the ACL lifecycle (FHE.allow, allowThis, allowTransient, isSenderAllowed, makePubliclyDecryptable), and the input-proof flow (externalEuint* + FHE.fromExternal). Triggers on FHEVM contract patterns, encrypted types, FHE.* library calls, ACL permissions, input proofs, ciphertext handles, ZamaEthereumConfig, or writing a confidential counter / voting / auction / vault contract.Other plugins' skills for the same job