You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/solidity-guides/configure.md
+9-41Lines changed: 9 additions & 41 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,31 +4,27 @@ This document explains how to enable encrypted computations in your smart contra
4
4
5
5
## Core configuration setup
6
6
7
-
To utilize encrypted computations in Solidity contracts, you must configure the **FHE library** and **Relayer addresses**. The `fhevm` package simplifies this process with prebuilt configuration contracts, allowing you to focus on developing your contract’s logic without handling the underlying cryptographic setup.
7
+
To utilize encrypted computations in Solidity contracts, you must configure the **FHE library** and **Oracle addresses**. The `fhevm` package simplifies this process with prebuilt configuration contracts, allowing you to focus on developing your contract’s logic without handling the underlying cryptographic setup.
8
+
9
+
This library and its associated contracts provide a standardized way to configure and interact with Zama's FHEVM (Fully Homomorphic Encryption Virtual Machine) infrastructure on different Ethereum networks. It supplies the necessary contract addresses for Zama's FHEVM components (`ACL`, `FHEVMExecutor`, `KMSVerifier`, `InputVerifier`) and the decryption oracle, enabling seamless integration for Solidity contracts that require FHEVM support.
8
10
9
11
## Key components configured automatically
10
12
11
13
1.**FHE library**: Sets up encryption parameters and cryptographic keys.
12
-
2.**Relayer**: Manages secure cryptographic operations, including user decryption and public decryption.
14
+
2.**Oracle**: Manages secure cryptographic operations such as public decryption.
13
15
3.**Network-specific settings**: Adapts to local testing, testnets (Sepolia for example), or mainnet deployment.
14
16
15
17
By inheriting these configuration contracts, you ensure seamless initialization and functionality across environments.
16
18
17
19
## ZamaConfig.sol
18
20
19
-
This configuration contract initializes the **fhevm environment** with required encryption parameters.
20
-
21
-
**Import based on your environment:**
21
+
The `ZamaConfig` library exposes functions to retrieve FHEVM configuration structs and oracle addresses for supported networks (currently only the Sepolia testnet).
22
22
23
-
```solidity
24
-
// For Ethereum Sepolia
25
-
import { SepoliaConfig } from "@fhevm/solidity/config/ZamaConfig.sol";
26
-
```
23
+
Under the hood, this library encapsulates the network-specific addresses of Zama's FHEVM infrastructure into a single struct (`FHEVMConfigStruct`).
27
24
28
-
**Purpose:**
25
+
## SepoliaConfig
29
26
30
-
- Sets encryption parameters such as cryptographic keys and supported ciphertext types.
31
-
- Ensures proper initialization of the FHEVM environment.
27
+
The `SepoliaConfig` contract is designed to be inherited by a user contract. The constructor automatically sets up the FHEVM coprocessor and decryption oracle using the configuration provided by the library for the respective network. When a contract inherits from `SepoliaConfig`, the constructor calls `FHE.setCoprocessor` and `FHE.setDecryptionOracle` with the appropriate addresses. This ensures that the inheriting contract is automatically wired to the correct FHEVM contracts and oracle for the target network, abstracting away manual address management and reducing the risk of misconfiguration.
32
28
33
29
**Example: using Sepolia configuration**
34
30
@@ -45,34 +41,6 @@ contract MyERC20 is SepoliaConfig {
45
41
}
46
42
```
47
43
48
-
## ZamaConfig.sol
49
-
50
-
To perform public decryption or user decryption, your contract must interact with the **Relayer**, which acts as a secure bridge between the blockchain, coprocessor, and Key Management System (KMS).
51
-
52
-
**Import based on your environment**
53
-
54
-
```solidity
55
-
// For Sepolia
56
-
import { SepoliaConfig } from "@fhevm/solidity/config/ZamaConfig.sol";
57
-
```
58
-
59
-
**Purpose**
60
-
61
-
- Configures the relayer for secure cryptographic operations.
62
-
- Facilitates public and user decryption requests.
63
-
64
-
**Example: Configuring the relayer with Sepolia settings**
65
-
66
-
```solidity
67
-
import "@fhevm/solidity/lib/FHE.sol";
68
-
import { SepoliaConfig } from "@fhevm/solidity/config/ZamaConfig.sol";
69
-
70
-
contract Test is SepoliaConfig {
71
-
constructor() {
72
-
// Relayer and FHEVM environment initialized automatically
73
-
}
74
-
}
75
-
```
76
44
77
45
## Using `isInitialized`
78
46
@@ -97,4 +65,4 @@ require(FHE.isInitialized(counter), "Counter not initialized!");
97
65
98
66
## Summary
99
67
100
-
By leveraging prebuilt a configuration contract like `ZamaConfig.sol`, you can efficiently set up your smart contract for encrypted computations. These tools abstract the complexity of cryptographic initialization, allowing you to focus on building secure, confidential smart contracts.
68
+
By leveraging prebuilt a configuration contract like `SepoliaConfig` in `ZamaConfig.sol`, you can efficiently set up your smart contract for encrypted computations. These tools abstract the complexity of cryptographic initialization, allowing you to focus on building secure, confidential smart contracts.
0 commit comments