Skip to main content
The FHE library provides functions for working with Fully Homomorphic Encryption (FHE) in Solidity smart contracts. It enables computations on encrypted data without decrypting it, ensuring privacy throughout your contract’s execution.

Import

All functions are prefixed with FHE. when called. For example: FHE.add(a, b) or FHE.allowPublic(value).

Encrypted Data Types

Input Types

Each encrypted type has a corresponding input struct used when receiving encrypted data from the client SDK:

Security Considerations

  1. Initialization: All FHE functions check if their inputs are initialized and set them to 0 if not.
  2. Decryption: Decryption is a two-phase process — mark values with allowPublic on-chain, decrypt off-chain via the Client SDK, then publish/verify the result with publishDecryptResult or verifyDecryptResult. Only reveal values when absolutely necessary.
  3. Security Zones: Some functions accept a securityZone parameter to isolate different encrypted computations. FHE operations can only be performed between ciphertexts that share the same security zone.
  4. Access Control: The library provides fine-grained access control through the allow* functions. Always set proper permissions before accessing encrypted values.
  5. Type Safety: Ensure encrypted values use compatible types when performing operations. Type mismatches will cause errors.