Skip to content

[FEAT] Add on-chain signature verification for decrypt results#42

Merged
roeezolantz merged 16 commits intomasterfrom
feat/tn-chain-sig-verification
Feb 25, 2026
Merged

[FEAT] Add on-chain signature verification for decrypt results#42
roeezolantz merged 16 commits intomasterfrom
feat/tn-chain-sig-verification

Conversation

@roeezolantz
Copy link
Contributor

@roeezolantz roeezolantz commented Feb 3, 2026

Summary

Enables SDK/JS users to publish decryption results directly to the TaskManager contract with cryptographic signature verification from the threshold decryption network.

Main Changes

TaskManager.sol:

  • Added publishDecryptResult() - publish signed decrypt result to chain
  • Added publishDecryptResultBatch() - batch publish for gas efficiency
  • Added verifyDecryptResult() - verify signature without publishing (view, reverts on invalid)
  • Added verifyDecryptResultSafe() - verify signature without publishing (view, returns false on invalid)
  • Added decryptResultSigner state variable and setDecryptResultSigner() admin function, triggering DecryptResultSignerChanged event upon change

ICofhe.sol / FHE.sol:

  • Added interface definitions and wrapper functions
  • Typed overloads for all encrypted types (ebool, euint8, euint16, euint32, euint64, euint128, eaddress)
  • Impl layer uses bytes32 for ctHash, matching the existing pattern (e.g. getDecryptResult(bytes32))

Message Format: result (32 bytes), enc_type (4), chain_id (8), ct_hash (32) = 76 bytes total

Examples

taskManager.publishDecryptResult(0x123..., 42, 0xsig...)
FHE.publishDecryptResult(ctHash, result, signature)

taskManager.publishDecryptResultBatch([hash1, hash2], [42, 100], [sig1, sig2])

bool valid = taskManager.verifyDecryptResult(0x123..., 42, 0xsig...)
bool valid = FHE.verifyDecryptResult(ctHash, result, signature)

// Non-reverting version (returns false instead of reverting)
bool valid = taskManager.verifyDecryptResultSafe(0x123..., 42, 0xsig...)
bool valid = FHE.verifyDecryptResultSafe(ctHash, result, signature)

taskManager.setDecryptResultSigner(0xDispatcherAddress)

address signer = taskManager.decryptResultSigner()

@roeezolantz roeezolantz marked this pull request as ready for review February 8, 2026 13:53
@roeezolantz
Copy link
Contributor Author

@liorbond didn't rebase on the CTA PR yet, but fixed everything else, please re-review :)

@roeezolantz roeezolantz requested a review from liorbond February 9, 2026 18:24
@roeezolantz roeezolantz force-pushed the feat/tn-chain-sig-verification branch from b949fe9 to 4694f33 Compare February 23, 2026 12:41
@roeezolantz
Copy link
Contributor Author

roeezolantz commented Feb 23, 2026

@liorbond I've added some fixes :

  • C-1: Use ECDSA.tryRecover instead of recover so verifyDecryptResultSafe returns false on malformed signatures instead of reverting
  • H-2: Added onlyIfEnabled modifier to publishDecryptResult and publishDecryptResultBatch
  • Replaced require string with LengthMismatch custom error in batch function
  • Added safety comment in assembly and advance free memory pointer to be on the safe side if this function ever get changed in the future and the data is needed
  • Changed Impl functions to accept bytes32 for ctHash (matching getDecryptResult pattern) - based on the CTA rebase
  • Added verifyDecryptResultSafe typed overloads for all encrypted types
  • Added EADDRESS_TFHE to encryption types test coverage

@roeezolantz roeezolantz requested a review from liorbond February 23, 2026 14:25
* Add `allowPublic` alias for `allowGlobal`

* Add isPubliclyAllowed and isGloballyAllowed to TaskManager

* Add tests for isPubliclyAllowed and isGloballyAllowed

* update changelog

* add FHE.isPubliclyAllowed, remove from DeterministicTM

* remove isGloballyAllowed, keep only isPubliclyAllowed

* update changelog

---------

Co-authored-by: Roee Zolantz <zolantz.roee@gmail.com>
@roeezolantz roeezolantz merged commit c6ad9ab into master Feb 25, 2026
2 checks passed
@roeezolantz roeezolantz deleted the feat/tn-chain-sig-verification branch February 25, 2026 09:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants