> ## Documentation Index
> Fetch the complete documentation index at: https://cofhe-docs.fhenix.zone/llms.txt
> Use this file to discover all available pages before exploring further.

# CoFHE Architecture Overview

> Comprehensive overview of the CoFHE architecture, components, and data flows for privacy-preserving blockchain computations

# CoFHE Architecture

<Frame>
  <img src="https://mintcdn.com/fhenix/QsDx0SV0x2gd-xtZ/images/Architecture.svg?fit=max&auto=format&n=QsDx0SV0x2gd-xtZ&q=85&s=7e8a9197b4c183b376868b7971706412" alt="CoFHE Architecture Diagram" width="4275" height="1321" data-path="images/Architecture.svg" />
</Frame>

*Click on the image to view in full size*

## System Overview

CoFHE (Co-processor for Fully Homomorphic Encryption) is designed as a modular, layered architecture that enables privacy-preserving computations on blockchain networks. The system combines on-chain smart contracts with off-chain processing capabilities to deliver secure, efficient fully homomorphic encryption operations.

### Key Components

#### User-Facing Utilities

* **Client SDK** (`@cofhe/sdk`): A TypeScript library that provides client-side functionality for encrypting inputs, managing permits, and decrypting outputs. Serves as the primary interface between applications and the CoFHE ecosystem.

* **FHE.sol**: The Solidity library that enables smart contracts to perform operations on encrypted data. It exposes a comprehensive API for arithmetic, comparison, and logical operations on encrypted values.

#### Internal Utilities

* **Task Manager**: Acts as the gateway for all FHE operation requests, validating requests and managing permissions through the Access Control Layer (ACL).

* **Slim Listener**: Monitors blockchain events and forwards FHE operation requests to the off-chain execution environment.

* **Result Processor**: Handles FHE operation results from the computation layer and publishes them back to the blockchain.

* **FHEOS Server**: Executes the actual FHE operations on encrypted data and maintains the encrypted state.

* **Threshold Network**: A distributed system that securely handles decryption requests through multi-party computation, ensuring no single entity can access the decryption key.

* **Ciphertext Registry**: Maintains references to encrypted values and handles access control.

### Data Flows

CoFHE implements several critical data flows that maintain privacy throughout the computation lifecycle:

1. **Encryption Request**: Manages the secure encryption of input data via ZK proofs before it enters the blockchain.

2. **FHE Operation Flow**: Handles the process of requesting and executing computations on encrypted data.

3. **Decryption Request**: Processes requests to decrypt data using the Threshold Network.

4. **Decrypt/Seal Output**: Enables users to access encrypted results while maintaining privacy.

This architecture ensures that data remains encrypted throughout its entire lifecycle while still enabling complex computations, providing a foundation for privacy-preserving blockchain applications.
