$ show zama-ai/fhevm
fhevm is a production-grade, full-stack confidential smart contract platform that brings Fully Homomorphic Encryption (FHE) to EVM-compatible blockchains. The system is a distributed microservices architecture: on-chain Solidity contracts (host-contracts for ACL, FHEVMExecutor, KMSVerifier, InputVerifier, ProtocolConfig, and gateway-contracts for decryption/input verification) handle encrypted state and access control, while a suite of Rust services (coprocessor/fhevm-engine with host-listener, gw-listener, tfhe-worker, sns-worker, transaction-sender, zkproof-worker, scheduler) perform off-chain FHE computation, ZK proof verification, and transaction submission. A relayer service exposes HTTP v2/v3 endpoints for public/user/delegated decryption with EIP-712 typed-data attestations, and a KMS connector manages threshold key generation and decryption. The TypeScript SDK (ethers and viem adapters) provides client-side encryption, decryption, and proof generation with WASM-based TFHE/TKMS modules, plus a CLI and load-testing toolkit. Cross-chain bridging via LayerZero V2 is included for confidential token transfers.
The LLM identified 7 files worth highlighting for reuse:
A LIFO resource management scope for tracking and freeing WASM objects. Demonstrates a clean, self-contained pattern for deterministic cleanup of native memory in a JS/TS environment. Extractable into any WASM-based project needing explicit object lifecycle management.
An opaque, tamper-proof container pattern that brands values with a private token to prevent cross-adapter leaks (e.g., preventing a viem client from being passed where an ethers client is expected). A reusable TypeScript pattern for enforcing type-level isolation between similar-but-distinct client abstractions.
A generic async cache with TTL, force-refresh, and in-flight request deduplication. Solves the recurring problem of caching RPC/API calls with stale-while-revalidate semantics. Self-contained and directly reusable in any TypeScript project needing fetch-level caching.
A PostgreSQL advisory lock wrapper for distributed mutual exclusion across multiple worker instances. Demonstrates a clean, safe abstraction over pg_advisory_lock with proper error handling. Reusable in any Rust service needing cross-process coordination backed by Postgres.
A complete SemVer parsing, comparison, and range/interval checking utility with implication logic. Used to gate feature compatibility across protocol versions. Self-contained and directly reusable in any project needing robust semantic version handling beyond simple string comparison.
A builder-pattern configuration for message broker consumers with per-pipeline tuning (prefetch, retries, circuit breaker threshold/cooldown, Redis claim settings). Demonstrates clean, testable configuration design with sensible defaults. Reusable for any event-driven consumer needing robust failure handling.
A pool store for pre-generated single-use resources (ZK-proof payloads, FHE handles) with cursor-based claiming to avoid deduplication issues. A reusable pattern for any load-testing or QA system that needs to distribute finite, single-use resources across concurrent workers.