| Aspect | Description |
|---|---|
| Type | Off-chain service, used by clients. |
| Function | Verifies the user’s input, ensuring that it is safe to use. |
| Responsibilities | • Receives a user’s ZKPoK of their inputs. • Verifies said ZK proofs. • Generates a signature, allowing the user to use these inputs in a smart contract function call. |
ZKPoK - Why?
Zero-Knowledge Proof of Knowledge (ZKPoK) provides a crucial security mechanism in CoFHE. It allows users to prove they know the plaintext of an encrypted input they’re sending to a smart contract, without revealing the plaintext itself. ZKPoKs protect against potential malicious vectors, including:- Malleability Attacks: Without ZKPoK protection, attackers could manipulate encrypted data by applying transformations to observed ciphertexts, even without knowing what’s inside them. For example, they might combine existing ciphertexts with encrypted zero values to create new valid-looking encrypted data, potentially compromising user’s confidentiality.
- Chosen Ciphertext Attacks (CCAs): Attackers can submit modified ciphertexts to the system and observe the results, potentially exploiting homomorphic operations to infer sensitive information, manipulate data, or even recover the secret key.
Sending encrypted inputs
As mentioned before, when providing ciphertexts as an input to a smart contract, users have to generate a ZKPoK and get a verification approval first. Although most of the work will be handled by Cofhejs and FHE.sol, we will describe this mechanism in high-level (also in the diagram below).- User encrypts an input(s) and generate a ZK proof of knowledge for it.
- User sends the ciphertext(s) and proof(s) to the ZKVerifier.
- ZK-Verifier verifies the proof. If valid, sign a message that approves input(s).
- ZK-Verifier returns the signed approval to User.
- User sends
(ciphertext, signed_approve)(one or more) as input(s) to a contract call. - Contract verifies the signed message, approving the input(s).
- Contract performs actual logic.
ZK-Verifier
The ZK-Verifier is a zk-verification program. It has two purposes:- Verify the ZKPoK’s of ciphertexts that are intended to be inputted to a CoFHE smart contract.
- Sign a verification message, allowing the said contract to ensure that the inputs are safe and were validated.
ecrecover. That means that the ZKVerifier’s public key will be predetermined and well-known.
The ZKVerifier is intended to run in a TEE to reduce trust and ensure the integrity of the inputs and signed verification messages.