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 type, used when receiving encrypted data from the client SDK. An input arrives as a handle plus abytes proof, and FHE.asEuintXX(handle, proof) converts the pair into the encrypted type:
Shared Types
A value handed over by another contract arrives as a shared type instead.FHE.shareEuintXX(value, receiver) produces one, and the receiver unwraps it with FHE.receiveEuintXXParam or FHE.receiveEuintXXFromCall:
See inputs for when to use each.
Security Considerations
- Initialization: All FHE functions check if their inputs are initialized and set them to 0 if not.
-
Decryption: Decryption is a two-phase process. Mark values with
allowPubliconchain, decrypt offchain via the Client SDK, then publish/verify the result withpublishDecryptResultorverifyDecryptResult. Only reveal values when absolutely necessary. -
Security Zones: Some functions accept a
securityZoneparameter to isolate different encrypted computations. FHE operations can only be performed between ciphertexts that share the same security zone. -
Access Control: The library provides fine-grained access control through the
allow*functions. Always set proper permissions before accessing encrypted values. - Type Safety: Ensure encrypted values use compatible types when performing operations. Type mismatches will cause errors.