Skip to main content
@cofhe/sdk is the TypeScript client SDK for CoFHE. It handles the client-side work of interacting with FHE-enabled smart contracts: encrypting inputs with ZK proofs, and decrypting ciphertext handles via the Threshold Network. It also manages the EIP-712 Access Control Permissions (ACPs) that authorize those decryptions. Onchain, contracts use FHE.sol to operate on encrypted data. Offchain, this SDK prepares the inputs and reads the outputs.

What the SDK does

Encrypt Inputs

Packs plaintext values, generates a ZKPoK, and submits them to the CoFHE verifier’s batch endpoint. Returns one ciphertext handle per input plus a single shared signature, for use in contract calls.

Decrypt for View

Requests decryption of a ciphertext handle via the Threshold Network using an ACP. Returns the plaintext locally, not published onchain.

Decrypt for Tx

Requests decryption and returns the plaintext with a Threshold Network signature for onchain verification.

Manage ACPs

Creates, stores, and manages EIP-712 ACPs that authorize decryption of specific ciphertext handles.

Entrypoints

Client lifecycle

The SDK follows a three-step lifecycle: config to client to connect.

Key concepts

Quick Start

Install the SDK, write a contract, and run your first encrypt to store to decrypt test in minutes.

Encrypting Inputs

Encrypt plaintext values with ZK proofs before passing them to your smart contract.

Access Control Permissions

Create and manage the EIP-712 ACPs that authorize decryption of confidential data.

Decrypt to View

Reveal encrypted values locally for UI display using ACPs.

Decrypt to Transact

Decrypt with a verifiable Threshold Network signature for onchain use.