decryptForTx: you take { ctHash, decryptedValue, signature } and submit a transaction that your contract can verify.
There are two common patterns:
- Publish: call
FHE.publishDecryptResult(ctHash, plaintext, signature)so other contracts/users can reference the published result. - Verify-only: call
FHE.verifyDecryptResult(ctHash, plaintext, signature)inside your contract without publishing globally.
Prerequisites
- Run
decryptForTxand get a result object withctHash,decryptedValue, andsignature. - Ensure the Solidity parameter type matches your encrypted type.
decryptedValue is a bigint. If your Solidity function expects a smaller integer type (e.g. uint32), make sure the value is within range.Publish the decrypt result on-chain
The intended consumer ofdecryptForTx is an on-chain verifier such as FHE.publishDecryptResult(...). In practice, you publish the result by calling a function on your contract that invokes FHE.publishDecryptResult internally.
Verify a decrypt result signature (without publishing)
Some protocols don’t need (or don’t want) to publish the decrypt result globally — they only need to verify that the provided plaintext and signature match a specific handle (ctHash).
For example, an “unshield” flow can accept (ctHash, plaintext, signature) and only proceed if the signature is valid:
If you prefer to publish the result (so it can be reused elsewhere), use
FHE.publishDecryptResult(...) instead.