docs/protocol/architecture/coprocessor.md
This document explains one of the key components of the Zama Protocol - Coprocessor, the Zama Protocol’s off-chain computation engine.
Coprocessor performs the heavy cryptographic operations—specifically, fully homomorphic encryption (FHE) computations—on behalf of smart contracts that operate on encrypted data. Acting as a decentralized compute layer, the coprocessor bridges symbolic on-chain logic with real-world encrypted execution.
Coprocessor works together with the Gateway, verifying encrypted inputs, executing FHE instructions, and maintaining synchronization of access permissions, in particular:
add, mul, div, cmp, etc.) on ciphertexts.Each coprocessor independently executes tasks and publishes verifiable results, enabling a publicly auditable and horizontally scalable confidential compute infrastructure .
When users submit encrypted values to the Gateway, each coprocessor:
This ensures only valid, well-formed encrypted values enter the system .
When a smart contract executes a function over encrypted values, the on-chain logic emits symbolic computation events.
Each coprocessor:
This offloads expensive computation from the host chain while maintaining full determinism and auditability .
Coprocessors replicate the Access Control List (ACL) logic from host contracts. They:
This ensures decentralized enforcement of access rights, enabling proper handling of decryptions, bridges, and contract interactions .
To ensure verifiability and mitigate misbehavior, each coprocessor:
This is essential for fraud-proof mechanisms and eventual slashing of malicious or faulty operators .
Coprocessors assist in:
These roles help maintain cross-chain interoperability and enable privacy-preserving data access for users and smart contracts .
Coprocessors are designed to be minimally trusted and publicly verifiable. Every FHE computation or input verification they perform is accompanied by a cryptographic commitment (hash digest) and a signature, allowing anyone to independently verify correctness.
The protocol relies on a majority-honest assumption: as long as more than 50% of coprocessors are honest, results are valid. The Gateway aggregates responses and accepts outputs only when a majority consensus is reached.
To enforce honest behavior, coprocessors must stake $ZAMA tokens and are subject to slashing if caught misbehaving—either through automated checks or governance-based fraud proofs.
This model ensures correctness through transparency, resilience through decentralization, and integrity through economic incentives.
Coprocessors can optionally run drift auto-reversal (automatic drift recovery): when a coprocessor detects that its locally computed ciphertext digest disagrees with the digest the Gateway reached consensus on, it treats itself as the drifted node and automatically reverts its own state to before the offending computation.
Because this action trusts the Gateway consensus as the source of truth, it is only safe when that consensus reflects a genuine honest majority — that is, when the coprocessor consensus threshold is high enough that a faulty minority cannot reach consensus on its own. Under the majority-honest model above, this requires at least 3 registered coprocessors with the threshold set to a strict majority. Drift auto-reversal must not be enabled with 2 or fewer coprocessors, or with a non-majority threshold: with such a set there is no threshold at which a drifted node can be safely told apart from an honest majority — a two-node set either blocks recovery entirely or lets a single node dictate the result, so a correct coprocessor could end up reverting its own valid state.
This is an operational requirement, not an on-chain invariant: the Gateway only enforces that the threshold is between 1 and the number of registered coprocessors. Operators and the DAO must ensure a proper majority quorum before enabling drift auto-reversal.
The coprocessor architecture includes:
This modular setup supports horizontal scaling: adding more workers or machines increases throughput. Symbolic computation and delayed execution also ensure low gas costs on-chain .