Why ZKPoK?
A Zero-Knowledge Proof of Knowledge (ZKPoK) lets a user prove they know the plaintext behind an encrypted input, without revealing that plaintext. ZKPoKs protect against potential malicious vectors, including:- Malleability attacks: Without ZKPoK protection, attackers could transform observed ciphertexts into new valid-looking ones without knowing their contents, for example by combining them with encrypted zeros.
- Chosen ciphertext attacks (CCAs): Attackers submit modified ciphertexts and observe the results, potentially exploiting homomorphic operations to infer sensitive information or even recover the secret key.
Sending encrypted inputs
When providing ciphertexts as an input to a smart contract, users have to generate a ZKPoK and get a verification approval first. The Client SDK (@cofhe/sdk) and FHE.sol handle most of this work; the mechanism is described here end to end (also in the diagram below).
- Your app encrypts the inputs through the Client SDK, which generates a ZK proof of knowledge for each one.
- The Client SDK sends the ciphertexts and proofs to the ZK Verifier, as one batch.
- The ZK Verifier verifies each proof. If all are valid, it stores the encrypted values in the CT Server and signs one message approving the whole batch.
- The ZK Verifier returns the handles and the batch approval to your app.
- Your app sends the handles and the approval as inputs to a contract call.
- The TaskManager verifies the batch signature and emits
InputVerifiedper input. The compute pipeline picks those events up and posts a commitment for each input to the CommitmentRegistry, so the input becomes decryptable later. - The contract performs the actual logic.
Trust model
The ZK Verifier runs inside a hardware-attested TEE (Intel TDX). Its signing key is held as Shamir shares by independent partners and released only to the exact attested code image. Neither the operator nor anyone else can sign approvals outside the reviewed program. See Key Management for how shares are created and released. After a successful verification, the component stores the ciphertext bytes in the CT Server. It also archives the inputs and their proofs in a public Google Cloud Storage bucket for independent auditing. The repo ships the checking tool:verify_stored_ct.rs fetches a stored ciphertext and checks it against its commitment. Verify a commitment offline covers the full procedure.
The signed message is verified onchain by the TaskManager using ecrecover; the verifier’s signer address is registered there as verifierSigner.
Signature format
For developers integrating without the SDK, the signature covers a batch digest. Each input is hashed, the hashes are concatenated in input order, and the digest of that concatenation is signed:recid value the component returns (0 or 1) must be adjusted to 27 or 28 for Solidity’s ecrecover.
Verify a batch yourself
The format above is enough to check any verified batch against public data alone. This walkthrough recovers the signer of a real batch on Arbitrum Sepolia and compares it to theverifierSigner registered on the TaskManager.
You need the transaction that consumed the batch, plus the 65-byte approval. The approval is in the SDK’s encrypt result, and in the transaction’s calldata, because your app passed it into the contract call. Everything else comes from the chain:
- Each
InputVerifiedevent’scommitmentfield is thect_hashthe signature covers. The indexedctHashis the handle, which replaces the last two bytes with metadata, and is not signed. - The handle’s byte 30 is the type and byte 31 is the security zone, and both are in the preimage.
- The batch is bound to your contract’s caller and to your contract. When your app calls the contract directly, those are
tx.fromandtx.to.
npm install viem:
verify-batch.mjs
verified. Change any byte of the preimage, including the order of the inputs, and recovery returns a different address. That is the property the TaskManager enforces when it rejects a batch with InvalidSigner.
The onchain half of this check is batchVerifyInputs, inputMessageHash, and extractBatchSigner in TaskManager.sol. The signing half is public too: the component’s source is zee-k-verifier.