Skip to content

Commit a732a6e

Browse files
committed
docs(common): updates FHEVM and other suggestions
1 parent b1d99f0 commit a732a6e

28 files changed

Lines changed: 62 additions & 59 deletions

docs/solidity-guides/acl/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ The ACL is a permission management system designed to control who can access, co
88

99
## Why is the ACL important?
1010

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

1313
- **Granular permissions**: Define specific access rules for individual accounts or contracts.
1414
- **Secure computations**: Ensure that only authorized entities can manipulate or decrypt encrypted data.

docs/solidity-guides/acl/acl_examples.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ The ACL system allows you to define two types of permissions for accessing ciphe
1919
You can also use method-chaining syntax for granting allowances:
2020

2121
```solidity
22+
use FHE for *;
2223
ciphertext.allow(address1).allow(address2);
2324
```
2425

@@ -36,6 +37,7 @@ This is equivalent to calling `FHE.allow(ciphertext, address1)` followed by `FHE
3637
Method chaining is also available for transient allowances:
3738

3839
```solidity
40+
use FHE for *;
3941
ciphertext.allowTransient(address1).allowTransient(address2);
4042
```
4143

@@ -48,6 +50,7 @@ ciphertext.allowTransient(address1).allowTransient(address2);
4850
#### Alternative Solidity syntax
4951

5052
```solidity
53+
use FHE for *;
5154
ciphertext.allowThis();
5255
```
5356

@@ -145,4 +148,4 @@ function transfer(address to, euint64 encryptedAmount) public {
145148

146149
---
147150

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

docs/solidity-guides/asEXXoperators.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# asEbool, asEuintXX, and asEaddress operations
22

3-
This documentation covers the `asEbool`, `asEuintXX`, and `asEaddress` operations provided by the FHE library for working with encrypted data in the fhevm. These operations are essential for converting between plaintext and encrypted types, as well as handling encrypted inputs.
3+
This documentation covers the `asEbool`, `asEuintXX`, and `asEaddress` operations provided by the FHE library for working with encrypted data in the FHEVM. These operations are essential for converting between plaintext and encrypted types, as well as handling encrypted inputs.
44

55
The operations can be categorized into three main use cases:
66

docs/solidity-guides/conditions.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# Branching in FHE
22

3-
This document explains how to implement conditional logic (if/else branching) when working with encrypted values in fhevm. Unlike typical Solidity programming, working with Fully Homomorphic Encryption (FHE) requires specialized methods to handle conditions on encrypted data.
3+
This document explains how to implement conditional logic (if/else branching) when working with encrypted values in FHEVM. Unlike typical Solidity programming, working with Fully Homomorphic Encryption (FHE) requires specialized methods to handle conditions on encrypted data.
44

55
## **Overview**
66

7-
In fhevm, when you perform [comparison operations](../references/functions.md#comparison-operation-eq-ne-ge-gt-le-lt), the result is an encrypted boolean (`ebool`). Since encrypted booleans do not support standard boolean operations like `if` statements or logical operators, conditional logic must be implemented using specialized methods.
7+
In FHEVM, when you perform [comparison operations](../references/functions.md#comparison-operation-eq-ne-ge-gt-le-lt), the result is an encrypted boolean (`ebool`). Since encrypted booleans do not support standard boolean operations like `if` statements or logical operators, conditional logic must be implemented using specialized methods.
88

9-
To facilitate conditional assignments, fhevm provides the `FHE.select` function, which acts as a ternary operator for encrypted values.
9+
To facilitate conditional assignments, FHEVM provides the `FHE.select` function, which acts as a ternary operator for encrypted values.
1010

1111
## **Using `FHE.select` for conditional logic**
1212

docs/solidity-guides/configure.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import { SepoliaZamaFHEVMConfig } from "fhevm/config/ZamaFHEVMConfig.sol";
2828
**Purpose:**
2929

3030
- Sets encryption parameters such as cryptographic keys and supported ciphertext types.
31-
- Ensures proper initialization of the fhevm environment.
31+
- Ensures proper initialization of the FHEVM environment.
3232

3333
**Example: using Sepolia configuration**
3434

@@ -71,7 +71,7 @@ import "fhevm/gateway/GatewayCaller.sol";
7171
7272
contract Test is SepoliaZamaFHEVMConfig, SepoliaZamaGatewayConfig, GatewayCaller {
7373
constructor() {
74-
// Gateway and fhevm environment initialized automatically
74+
// Gateway and FHEVM environment initialized automatically
7575
}
7676
}
7777
```

docs/solidity-guides/contracts.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# fhevm-contracts
22

3-
This guide explains how to use the [fhevm Contracts standard library](https://github.com/zama-ai/fhevm-contracts/tree/main). This library provides secure, extensible, and pre-tested Solidity templates designed for developing smart contracts on fhevm using the FHE library.
3+
This guide explains how to use the [fhevm Contracts standard library](https://github.com/zama-ai/fhevm-contracts/tree/main). This library provides secure, extensible, and pre-tested Solidity templates designed for developing smart contracts on FHEVM using the FHE library.
44

55
## Overview
66

docs/solidity-guides/decryption/decrypt.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ To learn how decryption works see [Encryption, Decryption, Re-encryption, and Co
1515

1616
## Overview
1717

18-
Decryption in fhevm is an asynchronous process that involves the Gateway and Key Management System (KMS). Contracts requiring decryption must extend the GatewayCaller contract, which imports the necessary libraries and provides access to the Gateway.
18+
Decryption in FHEVM is an asynchronous process that involves the Gateway and Key Management System (KMS). Contracts requiring decryption must extend the GatewayCaller contract, which imports the necessary libraries and provides access to the Gateway.
1919

2020
Here’s an example of how to request decryption in a contract:
2121

@@ -52,7 +52,7 @@ contract TestAsyncDecrypt is SepoliaZamaFHEVMConfig, SepoliaZamaGatewayConfig, G
5252

5353
#### Key additions to the code
5454

55-
1. **Configuration imports**: The configuration contracts are imported to set up the fhevm environment and Gateway.
55+
1. **Configuration imports**: The configuration contracts are imported to set up the FHEVM environment and Gateway.
5656

5757
```solidity
5858
import { SepoliaZamaFHEVMConfig } from "fhevm/config/ZamaFHEVMConfig.sol";

docs/solidity-guides/decryption/decrypt_details.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
# Decryption in depth
22

3-
This document provides a detailed guide on implementing decryption in your smart contracts using the `GatewayContract` in fhevm. It covers the setup, usage of the `Gateway.requestDecryption` function, and testing with Hardhat.
3+
This document provides a detailed guide on implementing decryption in your smart contracts using the `DecryptionOracle` in fhevm. It covers the setup, usage of the `FHE.requestDecryption` function, and testing with Hardhat.
44

5-
## `GatewayContract` set up
5+
## `DecryptionOracle` set up
66

7-
The `GatewayContract` is pre-deployed on the fhevm testnet. It uses a default relayer account specified in the `PRIVATE_KEY_GATEWAY_RELAYER` or `ADDRESS_GATEWAY_RELAYER` environment variable in the `.env` file.
7+
The `DecryptionOracle` is pre-deployed on the FHEVM testnet. It uses a default relayer account specified in the `PRIVATE_KEY_GATEWAY_RELAYER` or `ADDRESS_GATEWAY_RELAYER` environment variable in the `.env` file.
88

99
Relayers are the only accounts authorized to fulfill decryption requests. The role of the `DecryptionORacle`, however, is to independently verify the KMS signature during execution. This ensures that the relayers cannot manipulate or send fraudulent decryption results, even if compromised. However, the relayers are still trusted to forward decryption requests on time.
1010

11-
## `IDecryptionOracle.requestDecryption` function
11+
## `FHE.requestDecryption` function
1212

13-
The interface of the `IDecryptionOracle.requestDecryption` function from previous snippet is the following:
13+
You can call the function `FHE.requestDecryption` as such:
1414

1515
```solidity
1616
function requestDecryption(uint256 requestID, bytes32[] calldata ctsHandles, bytes4 callbackSelector) external payable;
@@ -144,7 +144,7 @@ event ResultCallback(uint256 indexed requestID, bool success, bytes result);
144144

145145
The first argument is the `requestID` of the corresponding decryption request, `success` is a boolean assessing if the call to the callback succeeded, and `result` is the bytes array corresponding to the return data from the callback.
146146

147-
In your hardhat tests, if you sent some transactions which are requesting one or several decryptions and you wish to await the fulfillment of those decryptions, you should import the two helper methods `initGateway` and `awaitAllDecryptionResults` from the `asyncDecrypt.ts` utility file. This would work both when testing on a fhevm node or in mocked mode. Here is a simple hardhat test for the previous `TestAsyncDecrypt` contract (more examples can be seen [here](https://github.com/zama-ai/fhevm-solidity/tree/v0.6.2/test/gatewayDecrypt/testAsyncDecrypt.ts)):
147+
In your hardhat tests, if you sent some transactions which are requesting one or several decryptions and you wish to await the fulfillment of those decryptions, you should import the two helper methods `initGateway` and `awaitAllDecryptionResults` from the `asyncDecrypt.ts` utility file. This would work both when testing on a FHEVM node or in mocked mode. Here is a simple hardhat test for the previous `TestAsyncDecrypt` contract (more examples can be seen [here](https://github.com/zama-ai/fhevm-solidity/tree/v0.6.2/test/gatewayDecrypt/testAsyncDecrypt.ts)):
148148

149149
```js
150150
import { initGateway, awaitAllDecryptionResults } from "../asyncDecrypt";
@@ -165,7 +165,7 @@ describe("TestAsyncDecrypt", function () {
165165
});
166166

167167
it("test async decrypt uint32", async function () {
168-
const tx2 = await this.contract.connect(this.signers.carol).requestUint32(5, 15, { gasLimit: 500_000 }); // custom gasLimit to avoid gas estimation error in fhevm mode
168+
const tx2 = await this.contract.connect(this.signers.carol).requestUint32(5, 15, { gasLimit: 500_000 }); // custom gasLimit to avoid gas estimation error in FHEVM mode
169169
await tx2.wait();
170170
await awaitAllDecryptionResults();
171171
const y = await this.contract.yUint32();

docs/solidity-guides/decryption/reencryption.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
This document explains how to perform user decryption. User decryption required when you want a user to access their private data without it being exposed to the blockchain.
44

5-
Re-encryption in fhevm enables the secure sharing or reuse of encrypted data under a new public key without exposing the plaintext. This feature is essential for scenarios where encrypted data must be transferred between contracts, dApps, or users while maintaining its confidentiality.
5+
Re-encryption in FHEVM enables the secure sharing or reuse of encrypted data under a new public key without exposing the plaintext. This feature is essential for scenarios where encrypted data must be transferred between contracts, dApps, or users while maintaining its confidentiality.
66

77
{% hint style="info" %}
88
Before implementing re-encryption, ensure you are familiar with the foundational concepts of encryption, re-encryption and computation. Refer to [Encryption, Decryption, Re-encryption, and Computation](../d_re_ecrypt_compute.md).

docs/solidity-guides/error_handling.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Error handling
22

3-
This document explains how to handle errors effectively in fhevm smart contracts. Since transactions involving encrypted data do not automatically revert when conditions are not met, developers need alternative mechanisms to communicate errors to users.
3+
This document explains how to handle errors effectively in FHEVM smart contracts. Since transactions involving encrypted data do not automatically revert when conditions are not met, developers need alternative mechanisms to communicate errors to users.
44

55
## **Challenges in error handling**
66

0 commit comments

Comments
 (0)