Back to Hub
Gateway Decryption
Two-phase gateway decryption pattern for public revelation
Encryption
Documentation
Gateway Decryption - Public Revelation
Two-phase gateway decryption pattern for revealing encrypted values publicly - essential for auctions, voting results, and game outcomes.
What You'll Learn
- Two-phase decryption flow (request → callback)
- Using
FHE.makePubliclyDecryptable() - Gateway callback pattern
- Event-driven architecture for decryption
- Production security considerations
Two-Phase Pattern
Phase 1: Request Decryption
Loading...
Phase 2: Gateway Callback
Loading...
Use Cases
- Auctions: Reveal winning bid after bidding ends
- Voting: Publish results after voting period
- Gaming: Determine outcomes (dice rolls, card draws)
- Lotteries: Reveal random winner publicly
Complete Flow
Loading...
Production Security
⚠️ This simplified example lacks production security!
Real implementations MUST:
- Verify
msg.senderis authorized gateway - Check cryptographic proofs (
FHE.checkSignatures) - Prevent replay attacks
- Handle callback failures
Loading...
Quick Start
Loading...
Important Notes
- Decryption is async (two separate transactions)
- Gateway must be running and monitoring events
- This is one-way (encrypted → public, cannot go back)
- Use for revealing information, not for computation
Loading...
