Skip to main content

Overview of FHE Library

The CoFHE library is a Solidity framework that enables secure, private computation on encrypted data within smart contracts. This library allows developers to perform operations on encrypted values without revealing the underlying plaintext data, preserving privacy while maintaining the transparency and trustlessness of blockchain technology.


Core Components​

The FHE library consists of the following key components:

1. Encrypted Data Types​

The library supports multiple encrypted data types, each representing an encrypted version of a standard Solidity type:

TypeDescriptionPlaintext Equivalent
eboolEncrypted boolean valuebool
euint8Encrypted 8-bit unsigned integeruint8
euint16Encrypted 16-bit unsigned integeruint16
euint32Encrypted 32-bit unsigned integeruint32
euint64Encrypted 64-bit unsigned integeruint64
euint128Encrypted 128-bit unsigned integeruint128
euint256Encrypted 256-bit unsigned integeruint256
eaddressEncrypted Ethereum addressaddress

2. Encrypted Input Structures​

ICofhe.sol defines various input structures that enable secure data submission:

  • EncryptedInput: The core structure containing:

    • πŸ” Ciphertext hash β€” A unique hash representing the encrypted data, used to reference it across the system.
    • πŸ›‘οΈ Security zone parameter β€” Defines the trust context or boundary in which the encrypted data is valid and accessible.
    • πŸ“‹ Type indicator β€” Specifies the data type of the encrypted value (e.g. euint8, euint16) to ensure correct handling.
    • βœ… Cryptographic signature β€” A signature proving that the data and its metadata were generated and verified by an authorized entity.
  • Type-specific input structures:

    • InEuint8, InEuint16, InEuint32
    • InEuint64, InEuint128, InEuint256
    • InEbool, InEaddress

3. Core Functionality (FHE.sol)​

The FHE library provides a comprehensive set of operations for encrypted data manipulation:

1. Arithmetic Operations​

Enables basic math (FHE.add) directly on encrypted integers.

2. Bitwise Operations​

Supports bitwise logic (AND, OR, XOR, shifts) on encrypted data.

3. Comparison Operations​

Performs encrypted comparisons (eq, gt, lt, etc.) that return an eboolβ€”an encrypted boolean value that contains the result of the comparison.

4. Control Flow​

Includes conditionals like select to allowing encrypted branching without revealing decision paths.

4. Data and Access Management​

Provides functions for sealing outputs, decrypting values securely, and managing user access via permits, ensuring only authorized parties can access decrypted data.


4. Task Management​

The library interacts with a TaskManager contract that coordinates:

  • βš™οΈ Execution of FHE operations
  • πŸ”’ Access control for encrypted data
  • πŸ”‘ Decryption request processing

The complete CoFHE-Contracts repository is available at:

Additional Resources​