3.0 KiB
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
- 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:
ebool - Unsigned Integers:
euint8,euint16,euint32,euint64,euint128,euint256 - Addresses:
eaddress - Input:
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 booleans - Casting to encrypted types:
FHE.asEuintXconverts plaintext values to encrypted types - Casting 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.rem- Note:
divandremoperations are supported only with plaintext divisors
- Note:
- Bitwise:
FHE.and,FHE.or,FHE.xor,FHE.not,FHE.shl,FHE.shr,FHE.rotl,FHE.rotr - Comparison:
FHE.eq,FHE.ne,FHE.lt,FHE.le,FHE.gt,FHE.ge - Advanced:
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. - Persistent public decryption:
FHE.makePubliclyDecryptable,FHE.isPubliclyDecryptablemakes a given ciphertext permanently publicly decryptable.
For more information see ACL.