FHE Operation Request Flow
Overview
This document outlines the complete flow of an FHE (Fully Homomorphic Encryption) operation request in the CoFHE ecosystem through Smart Contracts. Understanding this process is essential for developers integrating private computation capabilities into their smart contracts.Key Components
| Component | Description |
|---|---|
| dApp | The decentralized application that requests FHE operations |
| FHE.sol | The library providing FHE operation functions |
| Task Manager | Verifies and forwards operation requests |
| Slim Listener | Monitors blockchain events and forwards requests to the execution layer |
| Result Processor | Handles operation results and publishes them back to the blockchain |
| fheOS Server | Executes the actual FHE operations |
| Threshold Network | (When applicable) Handles secure decryption operations |
Flow Diagram
The following diagram illustrates the complete flow of an FHE operation request in the CoFHE ecosystem:Step-by-Step Flow
Integration with Cofhejs
The decentralized application (dApp) integrates with CoFHE by utilizing Cofhejs for encryption.See in GitHub 1️⃣Encrypt request using Cofhejs, returns
InEuint structure.This step happens on the client side before blockchain interaction.
Requesting an FHE Operation
When the dApp needs to perform an encrypted operation within the smart contract: 2️⃣Import the FHE library in Solidity:Call the appropriate FHE function from the imported library:FHE.sol forwards the request to the Task Manager contract
Task Manager Processing
The Task Manager serves as the gateway for all FHE operation requests:
- Validate request structure to ensure all inputs are properly formatted
- Verify access permissions by checking if the caller has proper access to the encrypted inputs (using ACL.sol) 3️⃣
- Generate a unique handle that will be used to reference the future ciphertext result
- Return the handle to the calling dApp contract
- Emit an event containing the operation details for the Slim Listener to process 4️⃣
Slim Listener Processing
The Slim Listener monitors and forwards FHE operation requests:
- Listen for events from the Task Manager 5️⃣
- Forward request details to the fheOS server 6️⃣
FheOS server - FHE Operation Execution
The FheOS server handles requests:
- Create execution thread on the fheOS server
- Execute the requested operation on encrypted data
- Generate result ciphertext containing the encrypted result
- Map the handle to the actual ciphertext hash in the private storage
- Make result available for subsequent operations
- Notify the Result Processor of operation completion