fhenix-on-chain-decryption
Installation
SKILL.md
Fhenix On-Chain Decryption
Overview
Decryption is a two-phase, multi-step process — there is no synchronous on-chain FHE.decrypt. The Threshold Network (MPC) decrypts off-chain and signs the result (ECDSA, via its Dispatcher); the contract verifies that signature on-chain.
The 3 steps:
- On-chain: grant decrypt permission on the handle —
FHE.allowPublic(ct)(anyone) /FHE.allow(ct, addr)/FHE.allowSender(ct). - Off-chain: client calls
decryptForTx(ctHash)(seefhenix-client-sdk-decryption-tx) →{ ctHash, decryptedValue (bigint), signature }. - On-chain: submit the result via publish or verify.
Publish vs verify (step 3)
| Function | Behavior | Use when |
|---|---|---|
FHE.publishDecryptResult(ct, plaintext, sig) |
Verifies sig, stores result on-chain (readable via getDecryptResult). Reverts on bad sig. |
Result should be globally reusable |
FHE.verifyDecryptResult(ct, plaintext, sig) → bool |
Verifies sig without storing. Reverts on bad sig. | Only need to confirm authenticity in-tx |
FHE.verifyDecryptResultSafe(...) → bool |
Returns false instead of reverting |
Branch on validity without revert |