Random Number Generation
Inco Lightning provides on-chain encrypted random number generation through thee_rand function. This enables use cases like lotteries, games, fair distribution, and any application requiring unpredictable values.
Overview
| Function | Description | Signature |
|---|---|---|
e_rand | Generate encrypted random number | (CpiContext, u8) -> Result<Euint128> |
Basic Usage
The second parameter identifies whether the operand is ciphertext (
0) or plaintext (1). Always pass 0 when working with encrypted handles.Account Structure
Use Cases
Fair Lottery Selection
Random Game Outcomes
Security Properties
- Unpredictable: Random values cannot be predicted before generation
- Encrypted: Results are encrypted and only visible to authorized parties
- Verifiable: Decryption requires attestation from the covalidator network