Skip to content

Commit bbec527

Browse files
committed
chore(protocol-contracts): take review into account
1 parent bebfdce commit bbec527

File tree

1 file changed

+22
-20
lines changed
  • protocol-contracts/confidential-wrapper-upgradeable/docs

1 file changed

+22
-20
lines changed

protocol-contracts/confidential-wrapper-upgradeable/docs/README.md

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ Zama provides a registry contract that maps ERC-20 tokens to their corresponding
3131
**Important:** Prior to wrapping, the confidential wrapper contract must be approved by the `msg.sender` on the underlying token.
3232

3333
```solidity
34-
wrapper.wrap(recipientAddress, amount);
34+
wrapper.wrap(to, amount);
3535
```
3636

37-
The wrapper will mint the corresponding confidential token to the `recipientAddress` and refund the excess tokens to the `msg.sender` (due to decimal conversion). Considerations:
37+
The wrapper will mint the corresponding confidential token to the `to` address and refund the excess tokens to the `msg.sender` (due to decimal conversion). Considerations:
3838
- `amount` must be a value using the same decimal precision as the underlying token.
39-
- `recipientAddress` must not be the zero address.
39+
- `to` must not be the zero address.
4040

4141
> ℹ️ **Low amount handling:** If the amount is less than the rate, the wrapping will succeed but the recipient will receive 0 confidential tokens and the excess tokens will be refunded to the `msg.sender`.
4242
@@ -47,19 +47,21 @@ Unwrapping is a **two-step asynchronous process**: an `unwrap` must be first mad
4747

4848
#### 1) Unwrap request
4949

50+
> ⚠️ **Unsupported `from`:** Accounts with a zero balance that have never held tokens cannot be the `from` address in unwrap requests.
51+
5052
##### With input proof
5153

52-
> ℹ️ **Input proof:** To unwrap any amount of confidential tokens, the `fromAddress` must first create an encrypted input to generate an `encryptedAmount` (`externalEuint64`) along its `inputProof`. The amount to be encrypted must use the same decimal precision as the confidential wrapper. More information in the [`relayer-sdk` documentation](https://docs.zama.org/protocol/relayer-sdk-guides/fhevm-relayer/input).
54+
> ℹ️ **Input proof:** To unwrap any amount of confidential tokens, the `from` address must first create an encrypted input to generate an `encryptedAmount` (`externalEuint64`) along its `inputProof`. The amount to be encrypted must use the same decimal precision as the confidential wrapper. More information in the [`relayer-sdk` documentation](https://docs.zama.org/protocol/relayer-sdk-guides/fhevm-relayer/input).
5355
5456
```solidity
55-
wrapper.unwrap(fromAddress, recipientAddress, encryptedAmount, inputProof);
57+
wrapper.unwrap(from, to, encryptedAmount, inputProof);
5658
```
5759

58-
Alternatively, an unwrap request can be made without an input proof if the encrypted amount (`euint64`) is known to `fromAddress`. For example, this can be the confidential balance of `fromAddress`.
60+
Alternatively, an unwrap request can be made without an input proof if the encrypted amount (`euint64`) is known to `from`. For example, this can be the confidential balance of `from`.
5961

60-
This requests an unwrap request of `encryptedAmount` confidential tokens from `fromAddress`. Considerations:
61-
- `msg.sender` must be `fromAddress` or an approved operator for `fromAddress`.
62-
- `fromAddress` mut not be the zero address.
62+
This requests an unwrap request of `encryptedAmount` confidential tokens from `from`. Considerations:
63+
- `msg.sender` must be `from` or an approved operator for `from`.
64+
- `from` mut not be the zero address.
6365
- `encryptedAmount` will be burned in the request.
6466
- **NO** transfer of underlying tokens is made in this request.
6567

@@ -71,10 +73,10 @@ event UnwrapRequested(address indexed receiver, euint64 amount);
7173

7274
###### Without input proof
7375

74-
Alternatively, an unwrap request can be made without an input proof if the encrypted amount (`euint64`) is known to `fromAddress`. For example, this can be the confidential balance of `fromAddress`.
76+
Alternatively, an unwrap request can be made without an input proof if the encrypted amount (`euint64`) is known to `from`. For example, this can be the confidential balance of `from`.
7577

7678
```solidity
77-
wrapper.unwrap(fromAddress, recipientAddress, encryptedAmount);
79+
wrapper.unwrap(from, to, encryptedAmount);
7880
```
7981

8082
On top of the above unwrap request considerations:
@@ -83,18 +85,20 @@ On top of the above unwrap request considerations:
8385

8486
#### 2) Finalize unwrap
8587

86-
> ℹ️ **Public decryption:** The encrypted burned amount emitted by the `UnwrapRequested` event must be publicly decrypted to get the `cleartextAmount` along its `decryptionProof`. More information in the [`relayer-sdk` documentation](https://docs.zama.org/protocol/relayer-sdk-guides/fhevm-relayer/decryption/public-decryption).
88+
> ℹ️ **Public decryption:** The encrypted burned amount `burntAmount` emitted by the `UnwrapRequested` event must be publicly decrypted to get the `cleartextAmount` along its `decryptionProof`. More information in the [`relayer-sdk` documentation](https://docs.zama.org/protocol/relayer-sdk-guides/fhevm-relayer/decryption/public-decryption).
8789
8890
```solidity
8991
wrapper.finalizeUnwrap(burntAmount, cleartextAmount, decryptionProof);
9092
```
9193

92-
This finalizes the unwrap request by sending the corresponding amount of underlying tokens to the `recipientAddress` defined in the `unwrap` request.
94+
This finalizes the unwrap request by sending the corresponding amount of underlying tokens to the `to` defined in the `unwrap` request.
9395

9496
### Transfer confidential tokens
9597

9698
> ℹ️ **Transfer with input proof:** Similarly to the unwrap process, transfers can be made with or without an input proof and the encrypted amount must be approved by the ACL for the `msg.sender`.
9799
100+
> ⚠️ **Unsupported `from`:** Accounts with a zero balance that have never held tokens cannot be the `from` address in confidential transfers.
101+
98102
#### Direct transfer
99103

100104
```solidity
@@ -112,7 +116,7 @@ token.confidentialTransferFrom(from, to, encryptedAmount);
112116
```
113117

114118
Considerations:
115-
- `msg.sender` must be `fromAddress` or an approved operator for `fromAddress`.
119+
- `msg.sender` must be `from` or an approved operator for `from`.
116120

117121
#### Transfer with callback
118122

@@ -135,7 +139,7 @@ token.confidentialTransferFromAndCall(from, to, encryptedAmount, callbackData);
135139
```
136140

137141
Considerations:
138-
- `msg.sender` must be `fromAddress` or an approved operator for `fromAddress`.
142+
- `msg.sender` must be `from` or an approved operator for `from`.
139143

140144
### Check the conversion rate and decimals
141145

@@ -157,6 +161,8 @@ uint8 wrapperDecimals = wrapper.decimals();
157161

158162
The wrapper exposes a non-confidential view of the total supply, computed from the underlying ERC20 balance held by the wrapper contract. This value may be higher than `confidentialTotalSupply()` if tokens are sent directly to the wrapper outside of the wrapping process.
159163

164+
> ℹ️ **Total Value Shielded (TVS):** This view function is useful for getting a good approximation of the wrapper's Total Value Shielded (TVS).
165+
160166
```solidity
161167
uint256 nonConfidentialSupply = wrapper.totalSupply();
162168
```
@@ -267,13 +273,9 @@ Transfer functions with `euint64` (not `externalEuint64`) require the caller to
267273

268274
## Important Considerations
269275

270-
### Zero balance requirement
271-
272-
Accounts with a zero balance that have never held tokens cannot be the `from` address in transfers. This will revert with `ERC7984ZeroBalance`.
273-
274276
### Ciphertext uniqueness assumption
275277

276-
The unwrap mechanism stores requests in a mapping keyed by ciphertext. The current implementation assumes ciphertexts are unique. This holds in practice but be aware of this architectural decision as it is not true in the general case.
278+
The unwrap mechanism stores requests in a mapping keyed by ciphertext and the current implementation assumes these ciphertexts are unique. This holds in this very specific case but be aware of this architectural decision as it is **NOT** true in the general case.
277279

278280
---
279281

0 commit comments

Comments
 (0)