Skip to content

Commit 9d2da8a

Browse files
docs(common): move pages on solidity guides (#341)
* docs(common): move pages on solidity guides * docs(common): readd hcu * docs(common): fix links
1 parent ab39ae1 commit 9d2da8a

32 files changed

Lines changed: 841 additions & 630 deletions
File renamed without changes.

docs/solidity-guides/README.md

Whitespace-only changes.

docs/solidity-guides/SUMMARY.md

Lines changed: 28 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,36 @@
1-
## Get Started
2-
31
- [Overview](overview.md)
4-
- [Quick Start - Hardhat](hardhat/README.md)
5-
- [Prerequisites](hardhat/prerequisites.md)
6-
- [1. Setting up Hardhat](hardhat/1.-setting-up-hardhat.md)
7-
- [2. Quick start](hardhat/2.-quickstart.md)
82

9-
## Encrypted Types & Operations
3+
## Getting Started
104

11-
- [Supported types](types.md)
12-
- [Operations on encrypted types](operations.md)
13-
- [AsEbool, asEuintXX, and asEaddress operations](asEXXoperators.md)
5+
- [What is FHEVM Solidity](getting-started/overview.md)
6+
- [Set up Hardhat](hardhat/setup.md)
7+
- [Quick Start - Tutorial](getting-started/README.md)
8+
- [1. Setting up Hardhat](hardhat/setup.md)
9+
- [2. Write a simple contract](getting-started/write_a_simple_contract.md)
10+
- [3. Turn it into FHEVM](getting-started/turn_into_fhevm.md)
1411

15-
## Access & Inputs
12+
## Smart Contract
1613

14+
- [Configuration](configure.md)
15+
- [Contract addresses](contract_addresses.md)
16+
- [Supported types](types.md)
17+
- [Operations on encrypted types](operations/README.md)
18+
- [AsEbool, asEuintXX, and asEaddress operations](operations/asEXXoperators.md)
19+
- [Generate random numbers](operations/random.md)
1720
- [Encrypted Inputs](inputs.md)
1821
- [Access Control List](acl/README.md)
1922
- [ACL examples](acl/acl_examples.md)
20-
21-
## Public Decryption & User Decryption
22-
23-
- [User Decryption](decryption/user-decryption.md)
24-
- [Public Decryption](decryption/public-decryption.md)
25-
- [Decryption in depth](decryption/decrypt_details.md)
26-
27-
## Control Flow & Logic
28-
29-
- [Branching in FHE](conditions.md)
30-
- [Dealing with branches and conditions](loop.md)
31-
- [Generate random numbers](random.md)
32-
33-
## Configuration & Contracts
34-
35-
- [Key features](key_concepts.md)
36-
- [Configuration](configure.md)
37-
- [fhevm contracts](contracts.md)
38-
39-
## Tooling & Debugging
40-
41-
- [Using Foundry](foundry.md)
42-
- [Mocked mode](mocked.md)
43-
- [HCU estimation](hcu.md)
44-
- [Debug decrypt](debug_decrypt.md)
45-
- [Error handling](error_handling.md)
46-
47-
## API
48-
49-
- [fhevm API](functions.md)
23+
- [Logics](logics/README.md)
24+
- [Branching](logics/conditions.md)
25+
- [Dealing with branches and conditions](logics/loop.md)
26+
- [Error handling](logics/error_handling.md)
27+
- [Decryption](decryption/oracle.md) -[Debugging](decryption/debugging.md)
28+
29+
## Development Guide
30+
31+
- [Hardhat module](hardhat/README.md)
32+
- [Setup Hardhat](hardhat/setup.md)
33+
- [Test](hardhat/test.md)
34+
- [Deployment](hardhat/deploy.md)
35+
- [Foundry](foundry.md)
36+
- [HCU Estimator](hcu.md)

docs/solidity-guides/acl/README.md

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
# Access Control List
22

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.
47

58
## What is the ACL?
69

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.
813

914
## Why is the ACL important?
1015

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:
1218

1319
- **Granular permissions**: Define specific access rules for individual accounts or contracts.
1420
- **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
3440

3541
**Syntactic sugar**:
3642

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.
3845

3946
### Transient vs. permanent allowance
4047

@@ -62,10 +69,13 @@ To check if an entity has permission to access a ciphertext, use functions like
6269

6370
## Practical uses of the ACL
6471

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.
6674
- **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.
6877

6978
---
7079

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
81+
[ACL examples](acl_examples.md).

docs/solidity-guides/acl/acl_examples.md

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# ACL examples
22

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](./).
45

56
---
67

@@ -58,7 +59,8 @@ ciphertext.allowThis();
5859

5960
#### Make publicly decryptable
6061

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.
6264

6365
```solidity
6466
// Grant public decryption right to a ciphertext
@@ -72,9 +74,11 @@ ciphertext.makePubliclyDecryptable();
7274
- **Purpose**: Makes the ciphertext decryptable by anyone.
7375
- **Use Case**: When you want to publish encrypted results or data.
7476

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+
>
7780
> **Example**
81+
>
7882
> ```solidity
7983
> // Grant transient access to one address and permanent access to another address
8084
> ciphertext.allowTransient(address1).allow(address2);
@@ -87,11 +91,14 @@ ciphertext.makePubliclyDecryptable();
8791
8892
### Verifying sender access
8993
90-
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.
9197
9298
#### Example scenario: Confidential ERC20 attack
9399
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:
95102
96103
1. The attacker attempts to send the target user's encrypted balance from **Account A** to **Account B**.
97104
2. Observing the transaction outcome, the attacker gains information:
@@ -100,7 +107,8 @@ Consider an **Confidential ERC20 token**. An attacker controlling two accounts,
100107
101108
This type of attack allows the attacker to infer private balances without explicit access.
102109
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.
104112
105113
---
106114
@@ -117,13 +125,17 @@ function transfer(address to, euint64 encryptedAmount, bytes calldata inputProof
117125
}
118126
```
119127
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.
121130

122131
## ACL for user decryption
123132

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.
125136

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.
127139

128140
### Example: Secure Transfer in ConfidentialERC20
129141

@@ -149,4 +161,5 @@ function transfer(address to, euint64 encryptedAmount) public {
149161

150162
---
151163

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](./).

docs/solidity-guides/configure.md

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
# Configuration
22

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.
46

57
## Core configuration setup
68

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.
812

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.
1017

1118
## Key components configured automatically
1219

@@ -18,13 +25,20 @@ By inheriting these configuration contracts, you ensure seamless initialization
1825

1926
## ZamaConfig.sol
2027

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).
2230

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`).
2433

2534
## SepoliaConfig
2635

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.
2842

2943
**Example: using Sepolia configuration**
3044

@@ -41,10 +55,10 @@ contract MyERC20 is SepoliaConfig {
4155
}
4256
```
4357

44-
4558
## Using `isInitialized`
4659

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.
4862

4963
**Function signature**
5064

@@ -65,4 +79,6 @@ require(FHE.isInitialized(counter), "Counter not initialized!");
6579

6680
## Summary
6781

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.

docs/solidity-guides/table_of_addresses.md renamed to docs/solidity-guides/contract_addresses.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Save this in your `.env` file.
55
These are Sepolia addresses.
66

77
| Contract/Service | Address/Value |
8-
|----------------------------|------------------------------------------------|
8+
| -------------------------- | ---------------------------------------------- |
99
| FHEVM_EXECUTOR_CONTRACT | 0x848B0066793BcC60346Da1F49049357399B8D595 |
1010
| ACL_CONTRACT | 0x687820221192C5B662b25367F70076A37bc79b6c |
1111
| HCU_LIMIT_CONTRACT | 0x594BB474275918AF9609814E68C61B1587c5F838 |

0 commit comments

Comments
 (0)