This page summarizes the public surface of
@cofhe/foundry-plugin. For task-oriented walkthroughs, see Getting Started and Testing.CofheTest
Abstract test base. Inherit it instead of forge-std/Test (it inherits Test for you).
Setup
| Function | Description |
|---|---|
deployMocks() | Deploy MockTaskManager, MockACL, MockZkVerifier, MockZkVerifierSigner, MockThresholdNetwork, MockThresholdNetworkSigner. Wires them via setACLContract / setVerifierSigner / setDecryptResultSigner. Funds the ZK signer with 10 ether. Call once in setUp(). |
createCofheClient() | Returns a fresh CofheClient. Follow with client.connect(pkey). |
Plaintext reads
| Function | Description |
|---|---|
getPlaintext(bytes32 handle) | Returns the raw bytes32 plaintext from MockTaskManager.mockStorage. |
getPlaintext(ebool) / (euint8) / (euint16) / (euint32) / (euint64) / (euint128) / (eaddress) | Typed overloads returning bool / uint8–uint128 / address. |
expectPlaintext(handle, value) | Assertion variant — typed overloads for the same set. |
expectPlaintext(handle, value, "msg") | With assertion message. |
Logging
| Function | Description |
|---|---|
enableLogs() | Calls mockTaskManager.setLogOps(true). |
disableLogs() | Calls mockTaskManager.setLogOps(false). |
Public state
| Field | Type |
|---|---|
mockTaskManager | MockTaskManager |
mockAcl | MockACL |
mockZkVerifier | MockZkVerifier |
mockZkVerifierSigner | MockZkVerifierSigner |
mockThresholdNetwork | MockThresholdNetwork |
mockThresholdNetworkSigner | MockThresholdNetworkSigner |
CofheClient
Per-user shim. One client per scenario address.
Connection
| Function | Description |
|---|---|
connect(uint256 pkey) | Set the connected account to vm.addr(pkey). Required before any createIn* or permit_* call. |
account() | Returns the connected address. |
Encrypt inputs
| Function | Returns |
|---|---|
createInEbool(bool) | InEbool |
createInEuint8(uint8) | InEuint8 |
createInEuint16(uint16) | InEuint16 |
createInEuint32(uint32) | InEuint32 |
createInEuint64(uint64) | InEuint64 |
createInEuint128(uint128) | InEuint128 |
createInEaddress(address) | InEaddress |
EncryptedInput shapes signed for account().
Decrypt
| Function | Returns | Notes |
|---|---|---|
decryptForTx_withoutPermit(bytes32 ctHash) | (bytes32, uint256, bytes) | (ctHash, plaintext, signature). Signature consumable by FHE.publishDecryptResult. Requires FHE.allowPublic(handle) to have been called. |
decryptForTx_withPermit(bytes32 ctHash, Permission permit) | (bytes32, uint256, bytes) | ACL-gated decryptForTx. |
decryptForView(bytes32 ctHash, Permission permit) | uint256 | Off-chain seal/unseal. Reverts on deny — to assert deny use mockThresholdNetwork.querySealOutput(...). |
Permits
| Function | Description |
|---|---|
permit_createSelf() | Self-permit for the connected account; sealing key auto-derived. |
permit_createShared(address recipient) | Issuer-side shared permit. |
permit_exportShared(Permission perm) | Strip sensitive fields → SharedPermitExport. |
permit_importShared(SharedPermitExport export) | Recipient-side completion. Reverts unless export.recipient == account(). |
createSealingKey(bytes32 seed) | Custom sealing key (rarely needed). |
Mock storage layout
MockTaskManager.mockStorage is the on-chain plaintext storage that backs getPlaintext / expectPlaintext. It only exists in the mock environment — getPlaintext reverts on real CoFHE networks.
foundry.toml requirements
remappings.txt (canonical shape)
@cofhe/mock-contracts/points at the package root, not…/contracts/. The plugin’s imports include thecontracts/segment themselves.hardhat/=node_modules/forge-std/src/is required so thatMockCoFHE.sol’simport "hardhat/console.sol"resolves to forge-std’s compatible console.
Version pinning
@cofhe/foundry-plugin and @cofhe/mock-contracts pin @fhenixprotocol/cofhe-contracts exactly — keep all three CoFHE packages aligned. Known-good tuple as of the latest release:
| Package | Version |
|---|---|
@cofhe/foundry-plugin | 0.5.1 |
@cofhe/mock-contracts | 0.5.1 |
@fhenixprotocol/cofhe-contracts | 0.1.3 |