fhEVM
WebsiteLibrariesProduct & ServicesDevelopersSupport
0.3
0.3
  • <- Home
  • What is Zama's fhEVM
    • Overview
    • Whitepaper
  • Getting Started
    • Connecting to Zama Devnet
    • Using Zama Faucet
    • Local dev node
  • How to
    • Write contract
      • Using Hardhat
      • Using Remix
      • Other development environment
    • Use encrypted types
    • Operations on encrypted types
    • Generate random number
    • Write conditions
    • Decrypt and reencrypt
    • Estimate gas
    • Common pitfalls and best practises
  • API
    • Function specifications
  • Client SDK
    • Getting started
      • Using Node
      • Using a template
      • Other frontend tooling
      • Using CLI
    • Setup an instance
    • Encrypt an input
    • Get a reencryption
    • Examples
      • Transfer tokens (node)
      • Get balance (node)
  • Resources
    • Examples
    • Tutorials
    • Repositories
  • Future Developments
    • Development Roadmap
  • 🔗Support
    • Community forum
    • Telegram
    • FHE.org discord
    • Twitter
Powered by GitBook

Libraries

  • TFHE-rs
  • Concrete
  • Concrete ML
  • fhEVM

Developers

  • Blog
  • Documentation
  • Github
  • FHE resources

Company

  • About
  • Introduction to FHE
  • Media
  • Careers
On this page

Was this helpful?

Export as PDF
  1. How to

Generate random number

Random encrypted integers can be generated fully on-chain.

That can only be done during transactions and not on an eth_call RPC method, because PRNG state needs to be mutated on-chain during generation.

WARNING: Not for use in production! Currently, integers are generated in the plain via a PRNG whose seed and state are public, with the state being on-chain. An FHE-based PRNG is coming soon, where the seed and state will be encrypted.

Example

euint8 r8 = TFHE.randEuint8();
euint16 r16 = TFHE.randEuint16();
euint32 r32 = TFHE.randEuint32();
PreviousOperations on encrypted typesNextWrite conditions

Last updated 1 year ago

Was this helpful?