Key features

This document provides an overview of key features of the fhEVM smart contract library.

Configuration and initialization

Smart contracts using fhEVM require proper configuration and initialization:

  • Environment setup: Import and inherit from environment-specific configuration contracts

  • Gateway configuration: Configure secure gateway access for cryptographic operations

  • Initialization checks: Validate encrypted variables are properly initialized before use

For more information see Configuration.

Encrypted data types

fhEVM introduces encrypted data types compatible with Solidity:

  • Booleans: ebool

  • Unsigned Integers: euint4, euint8, euint16, euint32, euint64, euint128, euint256

  • Addresses: eaddress

  • Bytes: ebytes64, ebytes128, ebytes256

  • Input: einput for handling encrypted input data

Encrypted data is represented as ciphertext handles, ensuring secure computation and interaction.

For more information see use of encrypted types.

Casting types

fhEVM provides functions to cast between encrypted types:

  • Casting between encrypted types: TFHE.asEbool converts encrypted integers to encrypted booleans

  • Casting to encrypted types: TFHE.asEuintX converts plaintext values to encrypted types

  • Casting to encrypted addresses: TFHE.asEaddress converts plaintext addresses to encrypted addresses

  • Casting to encrypted bytes: TFHE.asEbytesX converts plaintext bytes to encrypted bytes

For more information see use of encrypted types.

Confidential computation

fhEVM enables symbolic execution of encrypted operations, supporting:

  • Arithmetic: TFHE.add, TFHE.sub, TFHE.mul, TFHE.min, TFHE.max, TFHE.neg, TFHE.div, TFHE.rem

    • Note: div and rem operations are supported only with plaintext divisors

  • Bitwise: TFHE.and, TFHE.or, TFHE.xor, TFHE.not, TFHE.shl, TFHE.shr, TFHE.rotl, TFHE.rotr

  • Comparison: TFHE.eq, TFHE.ne, TFHE.lt, TFHE.le, TFHE.gt, TFHE.ge

  • Advanced: TFHE.select for branching on encrypted conditions, TFHE.randEuintX for on-chain randomness.

For more information on operations, see Operations on encrypted types.

For more information on conditional branching, see Conditional logic in FHE.

For more information on random number generation, see Generate Random Encrypted Numbers.

Access control mechanism

fhEVM enforces access control with a blockchain-based Access Control List (ACL):

  • Persistent access: TFHE.allow, TFHE.allowThis grants permanent permissions for ciphertexts.

  • Transient access: TFHE.allowTransient provides temporary access for specific transactions.

  • Validation: TFHE.isSenderAllowed ensures that only authorized entities can interact with ciphertexts.

For more information see ACL.

Last updated

Was this helpful?