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/acl/README.md
+17-7Lines changed: 17 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,14 +1,20 @@
1
1
# Access Control List
2
2
3
-
This document describes the Access Control List (ACL) system in FHEVM, a core feature that governs access to encrypted data. The ACL ensures that only authorized accounts or contracts can interact with specific ciphertexts, preserving confidentiality while enabling composable smart contracts. This overview provides a high-level understanding of what the ACL is, why it's essential, and how it works.
3
+
This document describes the Access Control List (ACL) system in FHEVM, a core feature that governs access to encrypted
4
+
data. The ACL ensures that only authorized accounts or contracts can interact with specific ciphertexts, preserving
5
+
confidentiality while enabling composable smart contracts. This overview provides a high-level understanding of what the
6
+
ACL is, why it's essential, and how it works.
4
7
5
8
## What is the ACL?
6
9
7
-
The ACL is a permission management system designed to control who can access, compute on, or decrypt encrypted values in fhevm. By defining and enforcing these permissions, the ACL ensures that encrypted data remains secure while still being usable within authorized contexts.
10
+
The ACL is a permission management system designed to control who can access, compute on, or decrypt encrypted values in
11
+
fhevm. By defining and enforcing these permissions, the ACL ensures that encrypted data remains secure while still being
12
+
usable within authorized contexts.
8
13
9
14
## Why is the ACL important?
10
15
11
-
Encrypted data in FHEVM is entirely confidential, meaning that without proper access control, even the contract holding the ciphertext cannot interact with it. The ACL enables:
16
+
Encrypted data in FHEVM is entirely confidential, meaning that without proper access control, even the contract holding
17
+
the ciphertext cannot interact with it. The ACL enables:
12
18
13
19
-**Granular permissions**: Define specific access rules for individual accounts or contracts.
14
20
-**Secure computations**: Ensure that only authorized entities can manipulate or decrypt encrypted data.
@@ -34,7 +40,8 @@ Encrypted data in FHEVM is entirely confidential, meaning that without proper ac
34
40
35
41
**Syntactic sugar**:
36
42
37
-
-`FHE.allowThis(ciphertext)` is shorthand for `FHE.allow(ciphertext, address(this))`. It authorizes the current contract to reuse a ciphertext handle in future transactions.
43
+
-`FHE.allowThis(ciphertext)` is shorthand for `FHE.allow(ciphertext, address(this))`. It authorizes the current
44
+
contract to reuse a ciphertext handle in future transactions.
38
45
39
46
### Transient vs. permanent allowance
40
47
@@ -62,10 +69,13 @@ To check if an entity has permission to access a ciphertext, use functions like
62
69
63
70
## Practical uses of the ACL
64
71
65
-
-**Confidential parameters**: Pass encrypted values securely between contracts, ensuring only authorized entities can access them.
72
+
-**Confidential parameters**: Pass encrypted values securely between contracts, ensuring only authorized entities can
73
+
access them.
66
74
-**Secure state management**: Store encrypted state variables while controlling who can modify or read them.
67
-
-**Privacy-preserving computations**: Enable computations on encrypted data with confidence that permissions are enforced.
75
+
-**Privacy-preserving computations**: Enable computations on encrypted data with confidence that permissions are
76
+
enforced.
68
77
69
78
---
70
79
71
-
For a detailed explanation of the ACL's functionality, including code examples and advanced configurations, see [ACL examples](acl_examples.md).
80
+
For a detailed explanation of the ACL's functionality, including code examples and advanced configurations, see
Copy file name to clipboardExpand all lines: docs/solidity-guides/acl/acl_examples.md
+24-11Lines changed: 24 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,7 @@
1
1
# ACL examples
2
2
3
-
This page provides detailed instructions and examples on how to use and implement the ACL (Access Control List) in fhevm. For an overview of ACL concepts and their importance, refer to the [access control list (ACL) overview](./).
3
+
This page provides detailed instructions and examples on how to use and implement the ACL (Access Control List) in
4
+
fhevm. For an overview of ACL concepts and their importance, refer to the [access control list (ACL) overview](./).
4
5
5
6
---
6
7
@@ -58,7 +59,8 @@ ciphertext.allowThis();
58
59
59
60
#### Make publicly decryptable
60
61
61
-
To make a ciphertext publicly decryptable, you can use the `FHE.makePubliclyDecryptable(ciphertext)` function. This grants decryption rights to anyone, which is useful for scenarios where the encrypted value should be accessible by all.
62
+
To make a ciphertext publicly decryptable, you can use the `FHE.makePubliclyDecryptable(ciphertext)` function. This
63
+
grants decryption rights to anyone, which is useful for scenarios where the encrypted value should be accessible by all.
-**Purpose**: Makes the ciphertext decryptable by anyone.
73
75
-**Use Case**: When you want to publish encrypted results or data.
74
76
75
-
> You can combine multiple allowance methods (such as `.allow()`, `.allowThis()`, `.allowTransient()`) directly on ciphertext objects to grant access to several addresses or contracts in a single, fluent statement.
76
-
>
77
+
> You can combine multiple allowance methods (such as `.allow()`, `.allowThis()`, `.allowTransient()`) directly on
78
+
> ciphertext objects to grant access to several addresses or contracts in a single, fluent statement.
79
+
>
77
80
> **Example**
81
+
>
78
82
> ```solidity
79
83
> // Grant transient access to one address and permanent access to another address
When processing ciphertexts as input, it’s essential to validate that the sender is authorized to interact with the provided encrypted data. Failing to perform this verification can expose the system to inference attacks where malicious actors attempt to deduce private information.
94
+
When processing ciphertexts as input, it’s essential to validate that the sender is authorized to interact with the
95
+
provided encrypted data. Failing to perform this verification can expose the system to inference attacks where malicious
96
+
actors attempt to deduce private information.
91
97
92
98
#### Example scenario: Confidential ERC20 attack
93
99
94
-
Consider an **Confidential ERC20 token**. An attacker controlling two accounts, **Account A** and **Account B**, with 100 tokens in Account A, could exploit the system as follows:
100
+
Consider an **Confidential ERC20 token**. An attacker controlling two accounts, **Account A** and **Account B**, with
101
+
100 tokens in Account A, could exploit the system as follows:
95
102
96
103
1. The attacker attempts to send the target user's encrypted balance from **Account A** to **Account B**.
97
104
2. Observing the transaction outcome, the attacker gains information:
@@ -100,7 +107,8 @@ Consider an **Confidential ERC20 token**. An attacker controlling two accounts,
100
107
101
108
This type of attack allows the attacker to infer private balances without explicit access.
102
109
103
-
To prevent this, always use the `FHE.isSenderAllowed()` function to verify that the sender has legitimate access to the encrypted amount being transferred.
110
+
To prevent this, always use the `FHE.isSenderAllowed()` function to verify that the sender has legitimate access to the
111
+
encrypted amount being transferred.
104
112
105
113
---
106
114
@@ -117,13 +125,17 @@ function transfer(address to, euint64 encryptedAmount, bytes calldata inputProof
117
125
}
118
126
```
119
127
120
-
By enforcing this check, you can safeguard against inference attacks and ensure that encrypted values are only manipulated by authorized entities.
128
+
By enforcing this check, you can safeguard against inference attacks and ensure that encrypted values are only
129
+
manipulated by authorized entities.
121
130
122
131
## ACL for user decryption
123
132
124
-
If a ciphertext can be decrypt by a user, explicit access must be granted to them. Additionally, the user decryption mechanism requires the signature of a public key associated with the contract address. Therefore, a value that needs to be decrypted must be explicitly authorized for both the user and the contract.
133
+
If a ciphertext can be decrypt by a user, explicit access must be granted to them. Additionally, the user decryption
134
+
mechanism requires the signature of a public key associated with the contract address. Therefore, a value that needs to
135
+
be decrypted must be explicitly authorized for both the user and the contract.
125
136
126
-
Due to the user decryption mechanism, a user signs a public key associated with a specific contract; therefore, the ciphertext also needs to be allowed for the contract.
137
+
Due to the user decryption mechanism, a user signs a public key associated with a specific contract; therefore, the
138
+
ciphertext also needs to be allowed for the contract.
127
139
128
140
### Example: Secure Transfer in ConfidentialERC20
129
141
@@ -149,4 +161,5 @@ function transfer(address to, euint64 encryptedAmount) public {
149
161
150
162
---
151
163
152
-
By understanding how to grant and verify permissions, you can effectively manage access to encrypted data in your FHEVM smart contracts. For additional context, see the [ACL overview](./).
164
+
By understanding how to grant and verify permissions, you can effectively manage access to encrypted data in your FHEVM
165
+
smart contracts. For additional context, see the [ACL overview](./).
Copy file name to clipboardExpand all lines: docs/solidity-guides/configure.md
+25-9Lines changed: 25 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,19 @@
1
1
# Configuration
2
2
3
-
This document explains how to enable encrypted computations in your smart contract by setting up the `fhevm` environment. Learn how to integrate essential libraries, configure encryption, and add secure computation logic to your contracts.
3
+
This document explains how to enable encrypted computations in your smart contract by setting up the `fhevm`
4
+
environment. Learn how to integrate essential libraries, configure encryption, and add secure computation logic to your
5
+
contracts.
4
6
5
7
## Core configuration setup
6
8
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.
9
+
To utilize encrypted computations in Solidity contracts, you must configure the **FHE library** and **Oracle
10
+
addresses**. The `fhevm` package simplifies this process with prebuilt configuration contracts, allowing you to focus on
11
+
developing your contract’s logic without handling the underlying cryptographic setup.
8
12
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.
13
+
This library and its associated contracts provide a standardized way to configure and interact with Zama's FHEVM (Fully
14
+
Homomorphic Encryption Virtual Machine) infrastructure on different Ethereum networks. It supplies the necessary
15
+
contract addresses for Zama's FHEVM components (`ACL`, `FHEVMExecutor`, `KMSVerifier`, `InputVerifier`) and the
16
+
decryption oracle, enabling seamless integration for Solidity contracts that require FHEVM support.
10
17
11
18
## Key components configured automatically
12
19
@@ -18,13 +25,20 @@ By inheriting these configuration contracts, you ensure seamless initialization
18
25
19
26
## ZamaConfig.sol
20
27
21
-
The `ZamaConfig` library exposes functions to retrieve FHEVM configuration structs and oracle addresses for supported networks (currently only the Sepolia testnet).
28
+
The `ZamaConfig` library exposes functions to retrieve FHEVM configuration structs and oracle addresses for supported
29
+
networks (currently only the Sepolia testnet).
22
30
23
-
Under the hood, this library encapsulates the network-specific addresses of Zama's FHEVM infrastructure into a single struct (`FHEVMConfigStruct`).
31
+
Under the hood, this library encapsulates the network-specific addresses of Zama's FHEVM infrastructure into a single
32
+
struct (`FHEVMConfigStruct`).
24
33
25
34
## SepoliaConfig
26
35
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.
36
+
The `SepoliaConfig` contract is designed to be inherited by a user contract. The constructor automatically sets up the
37
+
FHEVM coprocessor and decryption oracle using the configuration provided by the library for the respective network. When
38
+
a contract inherits from `SepoliaConfig`, the constructor calls `FHE.setCoprocessor` and `FHE.setDecryptionOracle` with
39
+
the appropriate addresses. This ensures that the inheriting contract is automatically wired to the correct FHEVM
40
+
contracts and oracle for the target network, abstracting away manual address management and reducing the risk of
41
+
misconfiguration.
28
42
29
43
**Example: using Sepolia configuration**
30
44
@@ -41,10 +55,10 @@ contract MyERC20 is SepoliaConfig {
41
55
}
42
56
```
43
57
44
-
45
58
## Using `isInitialized`
46
59
47
-
The `isInitialized` utility function checks whether an encrypted variable has been properly initialized, preventing unexpected behavior due to uninitialized values.
60
+
The `isInitialized` utility function checks whether an encrypted variable has been properly initialized, preventing
61
+
unexpected behavior due to uninitialized values.
48
62
49
63
**Function signature**
50
64
@@ -65,4 +79,6 @@ require(FHE.isInitialized(counter), "Counter not initialized!");
65
79
66
80
## Summary
67
81
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.
82
+
By leveraging prebuilt a configuration contract like `SepoliaConfig` in `ZamaConfig.sol`, you can efficiently set up
83
+
your smart contract for encrypted computations. These tools abstract the complexity of cryptographic initialization,
84
+
allowing you to focus on building secure, confidential smart contracts.
0 commit comments