What is FHEVM Solidity
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
Relayer configuration: Configure secure relayer 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:
eboolUnsigned Integers:
euint8,euint16,euint32,euint64,euint128,euint256Addresses:
eaddressInput:
externalEbool,externalEaddress,externalEuintXXfor 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:
FHE.asEboolconverts encrypted integers to encrypted booleansCasting to encrypted types:
FHE.asEuintXconverts plaintext values to encrypted typesCasting to encrypted addresses:
FHE.asEaddressconverts plaintext addresses to encrypted addresses
For more information see use of encrypted types.
Confidential computation
fhevm enables symbolic execution of encrypted operations, supporting:
Arithmetic:
FHE.add,FHE.sub,FHE.mul,FHE.min,FHE.max,FHE.neg,FHE.div,FHE.remNote:
divandremoperations are supported only with plaintext divisors
Bitwise:
FHE.and,FHE.or,FHE.xor,FHE.not,FHE.shl,FHE.shr,FHE.rotl,FHE.rotrComparison:
FHE.eq,FHE.ne,FHE.lt,FHE.le,FHE.gt,FHE.geAdvanced:
FHE.selectfor branching on encrypted conditions,FHE.randEuintXfor 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:
FHE.allow,FHE.allowThisgrants permanent permissions for ciphertexts.Transient access:
FHE.allowTransientprovides temporary access for specific transactions.Validation:
FHE.isSenderAllowedensures that only authorized entities can interact with ciphertexts.
For more information see ACL.
Last updated