fhEVM
WebsiteLibrariesProduct & ServicesDevelopersSupport
0.5
0.5
  • Welcome to fhEVM
  • Getting Started
    • What is fhEVM
    • Deploy on fhEVM native
      • Using Zama Faucet
      • Local dev node
    • Deploy on Ethereum
    • Whitepaper
  • Fundamentals
    • Write contract
      • Using Hardhat
      • Using Remix
      • Other development environment
    • Encrypted types
      • Operations on encrypted types
      • Branching in FHE
      • Generate random number
    • Encrypted inputs
    • Access Control List
    • Decrypt and reencrypt
    • Contracts standard library
  • Guides
    • Decryption
    • Reencryption
    • Build a web application
    • Build with Node
    • Common pitfalls and best practises
    • How can I break a loop ?
    • Gas estimation on devnet
    • Use the CLI
    • Common webpack errors
  • Tutorials
    • See all tutorials
    • Write confidential smart contract with fhEVM
  • References
    • API function specifications
    • fhevmjs function specifications
    • Repositories
  • Developer
    • Contributing
    • Development roadmap
    • Release note
    • Feature request
    • Bug report
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
  • How it's working
  • Decryption
  • Reencrypt

Was this helpful?

Export as PDF
  1. Fundamentals

Decrypt and reencrypt

PreviousAccess Control ListNextContracts standard library

Last updated 9 months ago

Was this helpful?

How it's working

Validators of the blockchain do not own the blockchain's private key. Instead, the private key is owned by a Key Management Service (KMS). If the plaintext value is needed at some point, there are two ways to obtain it. Both methods are handled by a service called the Gateway.

  • If the plaintext is needed for some logic in a contract, the Gateway acts as an oracle service: it will listen to decryption request events and return the decrypted value through a callback function.

  • If the plaintext is needed by a dApp, the Gateway provides an API to reencrypt a ciphertext with the dApp's public key.

Decryption

We allow explicit decryption requests for any encrypted type. The values are decrypted with the network private key.

Reencrypt

  1. The dApp retrieves the handle from the view function (e.g., balanceOf).

  2. The dApp generates a keypair for the user and requests the user to sign the public key.

  3. The dApp calls the gateway, providing the handle, public key, user address, contract address, and the user's signature.

  4. The dApp decrypts the received value with the private key.

You can read about an actual implemention in .

Reencryption is performed on the client side by calling the gateway service using the library. To do this, you need to provide a view function that returns the ciphertext to be reencrypted.

You can read .

our decryption guide
fhevmjs
our guide explaining how to use it