Skip to main content
This page covers the “decrypt to write tx” flow after you run 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

  1. Run decryptForTx and get a result object with ctHash, decryptedValue, and signature.
  2. 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 onchain

The intended consumer of decryptForTx is an onchain 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.