@openzeppelin/confidential-contracts 0.3.1 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/README.md +36 -7
  2. package/build/contracts/BatcherConfidential.json +544 -0
  3. package/build/contracts/CheckpointsConfidential.json +2 -2
  4. package/build/contracts/ERC7984.json +16 -0
  5. package/build/contracts/ERC7984ERC20Wrapper.json +93 -9
  6. package/build/contracts/ERC7984Freezable.json +16 -0
  7. package/build/contracts/ERC7984ObserverAccess.json +16 -0
  8. package/build/contracts/ERC7984Omnibus.json +16 -0
  9. package/build/contracts/ERC7984Restricted.json +35 -19
  10. package/build/contracts/ERC7984Rwa.json +35 -19
  11. package/build/contracts/ERC7984Utils.json +2 -2
  12. package/build/contracts/ERC7984Votes.json +32 -0
  13. package/build/contracts/FHESafeMath.json +2 -2
  14. package/build/contracts/HandleAccessManager.json +16 -0
  15. package/build/contracts/IERC7984ERC20Wrapper.json +659 -0
  16. package/build/contracts/IERC7984Rwa.json +19 -19
  17. package/build/contracts/VestingWalletConfidentialFactory.json +16 -0
  18. package/build/contracts/VotesConfidential.json +16 -0
  19. package/finance/BatcherConfidential.sol +450 -0
  20. package/finance/VestingWalletConfidential.sol +3 -3
  21. package/governance/utils/VotesConfidential.sol +5 -4
  22. package/interfaces/IERC7984ERC20Wrapper.sol +62 -0
  23. package/interfaces/IERC7984Receiver.sol +4 -2
  24. package/interfaces/IERC7984Rwa.sol +2 -2
  25. package/package.json +4 -4
  26. package/token/ERC7984/extensions/ERC7984ERC20Wrapper.sol +81 -55
  27. package/token/ERC7984/extensions/ERC7984Freezable.sol +4 -5
  28. package/token/ERC7984/extensions/ERC7984ObserverAccess.sol +3 -3
  29. package/token/ERC7984/extensions/ERC7984Restricted.sol +8 -8
  30. package/token/ERC7984/extensions/ERC7984Rwa.sol +5 -7
  31. package/token/ERC7984/extensions/ERC7984Votes.sol +2 -2
  32. package/utils/FHESafeMath.sol +2 -2
  33. package/utils/HandleAccessManager.sol +8 -7
  34. package/utils/structs/CheckpointsConfidential.sol +2 -2
  35. package/build/contracts/Checkpoints.json +0 -16
  36. package/utils/structs/temporary-Checkpoints.sol +0 -835
package/README.md CHANGED
@@ -1,15 +1,44 @@
1
- # <img src="logo.svg" alt="OpenZeppelin" height="40px">
1
+ # OpenZeppelin Confidential Contracts
2
2
 
3
3
  [![Coverage Status](https://codecov.io/gh/OpenZeppelin/openzeppelin-confidential-contracts/graph/badge.svg?token=1OVLRTWTA9)](https://codecov.io/gh/OpenZeppelin/openzeppelin-confidential-contracts)
4
+ [![License](https://img.shields.io/github/license/OpenZeppelin/openzeppelin-confidential-contracts)](https://github.com/OpenZeppelin/openzeppelin-confidential-contracts/blob/master/LICENSE)
5
+ [![Docs](https://img.shields.io/badge/docs-%F0%9F%93%84-yellow)](https://docs.openzeppelin.com/confidential-contracts)
4
6
 
5
7
  **An experimental library for developing on the Zama fhEVM**
6
8
 
7
- > [!IMPORTANT]
8
- > This repository contains unaudited code and is a work in progress. Use at your own risk.
9
-
10
9
  ## Overview
11
10
 
12
- This library contains contracts and utilities that utilize the novel features of the Zama fhEVM coprocessor. Contracts take advantage of the FHE (Fully Homomorphic Encryption) capabilities of the coprocessor to perform confidential transactions. See the [documentation](https://docs.openzeppelin.com/confidential-contracts) and the [Zama documentation](https://docs.zama.ai/fhevm) for more details.
11
+ This library contains contracts and utilities that utilize the novel features of the Zama fhEVM coprocessor. Contracts take advantage of the FHE (Fully Homomorphic Encryption) capabilities of the coprocessor to perform confidential transactions. See the [documentation](https://docs.openzeppelin.com/confidential-contracts) and the [Zama documentation](https://docs.zama.ai/protocol) for more details.
12
+
13
+ ### Installation
14
+
15
+ #### Hardhat (npm)
16
+
17
+ ```
18
+ $ npm install @openzeppelin/confidential-contracts
19
+ ```
20
+ → Installs the latest audited release
21
+
22
+ ### Usage
23
+
24
+ Once installed, you can use the contracts in the library by importing them:
25
+
26
+ ```solidity
27
+ pragma solidity ^0.8.27;
28
+
29
+ import {ERC7984} from "@openzeppelin/confidential-contracts/token/ERC7984/ERC7984.sol";
30
+
31
+ abstract contract MyToken is ERC7984 {
32
+ constructor() ERC7984("MyToken", "MTN", "<CONTRACT-URI>") {
33
+ }
34
+ }
35
+ ```
36
+
37
+ > [!NOTE]
38
+ > All contracts built using confidentiality must set the coprocessor configuration. This can be done by inheriting a config file such as `ZamaEthereumConfig`.
39
+
40
+ > [!WARNING]
41
+ > Developing contracts for confidentiality requires extreme care--many functions do not revert on failure as they would in normal contracts.
13
42
 
14
43
  ## Contribute
15
44
 
@@ -17,8 +46,8 @@ OpenZeppelin Confidential Contracts exists thanks to its contributors. There are
17
46
 
18
47
  ## License
19
48
 
20
- Each contract file should have their own licence specified. In the absence of any specific licence information, file is released under the [MIT License](LICENSE).
49
+ Each contract file should have its own license specified. In the absence of any specific license information, the file is released under the [MIT License](LICENSE).
21
50
 
22
51
  ## Legal
23
52
 
24
- Your use of this Project is governed by the terms found at www.openzeppelin.com/tos (the "Terms").
53
+ Your use of this Project is governed by the terms found at www.openzeppelin.com/tos (the "Terms").
@@ -0,0 +1,544 @@
1
+ {
2
+ "_format": "hh-sol-artifact-1",
3
+ "contractName": "BatcherConfidential",
4
+ "sourceName": "contracts/finance/BatcherConfidential.sol",
5
+ "abi": [
6
+ {
7
+ "inputs": [
8
+ {
9
+ "internalType": "uint256",
10
+ "name": "batchId",
11
+ "type": "uint256"
12
+ }
13
+ ],
14
+ "name": "BatchNonexistent",
15
+ "type": "error"
16
+ },
17
+ {
18
+ "inputs": [
19
+ {
20
+ "internalType": "uint256",
21
+ "name": "batchId",
22
+ "type": "uint256"
23
+ },
24
+ {
25
+ "internalType": "enum BatcherConfidential.BatchState",
26
+ "name": "current",
27
+ "type": "uint8"
28
+ },
29
+ {
30
+ "internalType": "bytes32",
31
+ "name": "expectedStates",
32
+ "type": "bytes32"
33
+ }
34
+ ],
35
+ "name": "BatchUnexpectedState",
36
+ "type": "error"
37
+ },
38
+ {
39
+ "inputs": [
40
+ {
41
+ "internalType": "uint256",
42
+ "name": "batchId",
43
+ "type": "uint256"
44
+ },
45
+ {
46
+ "internalType": "uint256",
47
+ "name": "totalDeposits",
48
+ "type": "uint256"
49
+ },
50
+ {
51
+ "internalType": "uint64",
52
+ "name": "exchangeRate",
53
+ "type": "uint64"
54
+ }
55
+ ],
56
+ "name": "InvalidExchangeRate",
57
+ "type": "error"
58
+ },
59
+ {
60
+ "inputs": [],
61
+ "name": "InvalidKMSSignatures",
62
+ "type": "error"
63
+ },
64
+ {
65
+ "inputs": [
66
+ {
67
+ "internalType": "address",
68
+ "name": "token",
69
+ "type": "address"
70
+ }
71
+ ],
72
+ "name": "InvalidWrapperToken",
73
+ "type": "error"
74
+ },
75
+ {
76
+ "inputs": [],
77
+ "name": "ReentrancyGuardReentrantCall",
78
+ "type": "error"
79
+ },
80
+ {
81
+ "inputs": [
82
+ {
83
+ "internalType": "uint8",
84
+ "name": "bits",
85
+ "type": "uint8"
86
+ },
87
+ {
88
+ "internalType": "uint256",
89
+ "name": "value",
90
+ "type": "uint256"
91
+ }
92
+ ],
93
+ "name": "SafeCastOverflowedUintDowncast",
94
+ "type": "error"
95
+ },
96
+ {
97
+ "inputs": [
98
+ {
99
+ "internalType": "address",
100
+ "name": "token",
101
+ "type": "address"
102
+ }
103
+ ],
104
+ "name": "SafeERC20FailedOperation",
105
+ "type": "error"
106
+ },
107
+ {
108
+ "inputs": [],
109
+ "name": "Unauthorized",
110
+ "type": "error"
111
+ },
112
+ {
113
+ "inputs": [
114
+ {
115
+ "internalType": "uint256",
116
+ "name": "batchId",
117
+ "type": "uint256"
118
+ },
119
+ {
120
+ "internalType": "address",
121
+ "name": "account",
122
+ "type": "address"
123
+ }
124
+ ],
125
+ "name": "ZeroDeposits",
126
+ "type": "error"
127
+ },
128
+ {
129
+ "anonymous": false,
130
+ "inputs": [
131
+ {
132
+ "indexed": true,
133
+ "internalType": "uint256",
134
+ "name": "batchId",
135
+ "type": "uint256"
136
+ }
137
+ ],
138
+ "name": "BatchCanceled",
139
+ "type": "event"
140
+ },
141
+ {
142
+ "anonymous": false,
143
+ "inputs": [
144
+ {
145
+ "indexed": true,
146
+ "internalType": "uint256",
147
+ "name": "batchId",
148
+ "type": "uint256"
149
+ }
150
+ ],
151
+ "name": "BatchDispatched",
152
+ "type": "event"
153
+ },
154
+ {
155
+ "anonymous": false,
156
+ "inputs": [
157
+ {
158
+ "indexed": true,
159
+ "internalType": "uint256",
160
+ "name": "batchId",
161
+ "type": "uint256"
162
+ },
163
+ {
164
+ "indexed": false,
165
+ "internalType": "uint64",
166
+ "name": "exchangeRate",
167
+ "type": "uint64"
168
+ }
169
+ ],
170
+ "name": "BatchFinalized",
171
+ "type": "event"
172
+ },
173
+ {
174
+ "anonymous": false,
175
+ "inputs": [
176
+ {
177
+ "indexed": true,
178
+ "internalType": "uint256",
179
+ "name": "batchId",
180
+ "type": "uint256"
181
+ },
182
+ {
183
+ "indexed": true,
184
+ "internalType": "address",
185
+ "name": "account",
186
+ "type": "address"
187
+ },
188
+ {
189
+ "indexed": false,
190
+ "internalType": "euint64",
191
+ "name": "amount",
192
+ "type": "bytes32"
193
+ }
194
+ ],
195
+ "name": "Claimed",
196
+ "type": "event"
197
+ },
198
+ {
199
+ "anonymous": false,
200
+ "inputs": [
201
+ {
202
+ "indexed": true,
203
+ "internalType": "uint256",
204
+ "name": "batchId",
205
+ "type": "uint256"
206
+ },
207
+ {
208
+ "indexed": true,
209
+ "internalType": "address",
210
+ "name": "account",
211
+ "type": "address"
212
+ },
213
+ {
214
+ "indexed": false,
215
+ "internalType": "euint64",
216
+ "name": "amount",
217
+ "type": "bytes32"
218
+ }
219
+ ],
220
+ "name": "Joined",
221
+ "type": "event"
222
+ },
223
+ {
224
+ "anonymous": false,
225
+ "inputs": [
226
+ {
227
+ "indexed": false,
228
+ "internalType": "bytes32[]",
229
+ "name": "handlesList",
230
+ "type": "bytes32[]"
231
+ },
232
+ {
233
+ "indexed": false,
234
+ "internalType": "bytes",
235
+ "name": "abiEncodedCleartexts",
236
+ "type": "bytes"
237
+ }
238
+ ],
239
+ "name": "PublicDecryptionVerified",
240
+ "type": "event"
241
+ },
242
+ {
243
+ "anonymous": false,
244
+ "inputs": [
245
+ {
246
+ "indexed": true,
247
+ "internalType": "uint256",
248
+ "name": "batchId",
249
+ "type": "uint256"
250
+ },
251
+ {
252
+ "indexed": true,
253
+ "internalType": "address",
254
+ "name": "account",
255
+ "type": "address"
256
+ },
257
+ {
258
+ "indexed": false,
259
+ "internalType": "euint64",
260
+ "name": "amount",
261
+ "type": "bytes32"
262
+ }
263
+ ],
264
+ "name": "Quit",
265
+ "type": "event"
266
+ },
267
+ {
268
+ "inputs": [
269
+ {
270
+ "internalType": "uint256",
271
+ "name": "batchId",
272
+ "type": "uint256"
273
+ }
274
+ ],
275
+ "name": "batchState",
276
+ "outputs": [
277
+ {
278
+ "internalType": "enum BatcherConfidential.BatchState",
279
+ "name": "",
280
+ "type": "uint8"
281
+ }
282
+ ],
283
+ "stateMutability": "view",
284
+ "type": "function"
285
+ },
286
+ {
287
+ "inputs": [
288
+ {
289
+ "internalType": "uint256",
290
+ "name": "batchId",
291
+ "type": "uint256"
292
+ },
293
+ {
294
+ "internalType": "address",
295
+ "name": "account",
296
+ "type": "address"
297
+ }
298
+ ],
299
+ "name": "claim",
300
+ "outputs": [
301
+ {
302
+ "internalType": "euint64",
303
+ "name": "",
304
+ "type": "bytes32"
305
+ }
306
+ ],
307
+ "stateMutability": "nonpayable",
308
+ "type": "function"
309
+ },
310
+ {
311
+ "inputs": [],
312
+ "name": "currentBatchId",
313
+ "outputs": [
314
+ {
315
+ "internalType": "uint256",
316
+ "name": "",
317
+ "type": "uint256"
318
+ }
319
+ ],
320
+ "stateMutability": "view",
321
+ "type": "function"
322
+ },
323
+ {
324
+ "inputs": [
325
+ {
326
+ "internalType": "uint256",
327
+ "name": "batchId",
328
+ "type": "uint256"
329
+ },
330
+ {
331
+ "internalType": "address",
332
+ "name": "account",
333
+ "type": "address"
334
+ }
335
+ ],
336
+ "name": "deposits",
337
+ "outputs": [
338
+ {
339
+ "internalType": "euint64",
340
+ "name": "",
341
+ "type": "bytes32"
342
+ }
343
+ ],
344
+ "stateMutability": "view",
345
+ "type": "function"
346
+ },
347
+ {
348
+ "inputs": [],
349
+ "name": "dispatchBatch",
350
+ "outputs": [],
351
+ "stateMutability": "nonpayable",
352
+ "type": "function"
353
+ },
354
+ {
355
+ "inputs": [
356
+ {
357
+ "internalType": "uint256",
358
+ "name": "batchId",
359
+ "type": "uint256"
360
+ },
361
+ {
362
+ "internalType": "uint64",
363
+ "name": "unwrapAmountCleartext",
364
+ "type": "uint64"
365
+ },
366
+ {
367
+ "internalType": "bytes",
368
+ "name": "decryptionProof",
369
+ "type": "bytes"
370
+ }
371
+ ],
372
+ "name": "dispatchBatchCallback",
373
+ "outputs": [],
374
+ "stateMutability": "nonpayable",
375
+ "type": "function"
376
+ },
377
+ {
378
+ "inputs": [
379
+ {
380
+ "internalType": "uint256",
381
+ "name": "batchId",
382
+ "type": "uint256"
383
+ }
384
+ ],
385
+ "name": "exchangeRate",
386
+ "outputs": [
387
+ {
388
+ "internalType": "uint64",
389
+ "name": "",
390
+ "type": "uint64"
391
+ }
392
+ ],
393
+ "stateMutability": "view",
394
+ "type": "function"
395
+ },
396
+ {
397
+ "inputs": [],
398
+ "name": "exchangeRateDecimals",
399
+ "outputs": [
400
+ {
401
+ "internalType": "uint8",
402
+ "name": "",
403
+ "type": "uint8"
404
+ }
405
+ ],
406
+ "stateMutability": "pure",
407
+ "type": "function"
408
+ },
409
+ {
410
+ "inputs": [],
411
+ "name": "fromToken",
412
+ "outputs": [
413
+ {
414
+ "internalType": "contract IERC7984ERC20Wrapper",
415
+ "name": "",
416
+ "type": "address"
417
+ }
418
+ ],
419
+ "stateMutability": "view",
420
+ "type": "function"
421
+ },
422
+ {
423
+ "inputs": [
424
+ {
425
+ "internalType": "address",
426
+ "name": "",
427
+ "type": "address"
428
+ },
429
+ {
430
+ "internalType": "address",
431
+ "name": "from",
432
+ "type": "address"
433
+ },
434
+ {
435
+ "internalType": "euint64",
436
+ "name": "amount",
437
+ "type": "bytes32"
438
+ },
439
+ {
440
+ "internalType": "bytes",
441
+ "name": "",
442
+ "type": "bytes"
443
+ }
444
+ ],
445
+ "name": "onConfidentialTransferReceived",
446
+ "outputs": [
447
+ {
448
+ "internalType": "ebool",
449
+ "name": "",
450
+ "type": "bytes32"
451
+ }
452
+ ],
453
+ "stateMutability": "nonpayable",
454
+ "type": "function"
455
+ },
456
+ {
457
+ "inputs": [
458
+ {
459
+ "internalType": "uint256",
460
+ "name": "batchId",
461
+ "type": "uint256"
462
+ }
463
+ ],
464
+ "name": "quit",
465
+ "outputs": [
466
+ {
467
+ "internalType": "euint64",
468
+ "name": "",
469
+ "type": "bytes32"
470
+ }
471
+ ],
472
+ "stateMutability": "nonpayable",
473
+ "type": "function"
474
+ },
475
+ {
476
+ "inputs": [],
477
+ "name": "routeDescription",
478
+ "outputs": [
479
+ {
480
+ "internalType": "string",
481
+ "name": "",
482
+ "type": "string"
483
+ }
484
+ ],
485
+ "stateMutability": "pure",
486
+ "type": "function"
487
+ },
488
+ {
489
+ "inputs": [],
490
+ "name": "toToken",
491
+ "outputs": [
492
+ {
493
+ "internalType": "contract IERC7984ERC20Wrapper",
494
+ "name": "",
495
+ "type": "address"
496
+ }
497
+ ],
498
+ "stateMutability": "view",
499
+ "type": "function"
500
+ },
501
+ {
502
+ "inputs": [
503
+ {
504
+ "internalType": "uint256",
505
+ "name": "batchId",
506
+ "type": "uint256"
507
+ }
508
+ ],
509
+ "name": "totalDeposits",
510
+ "outputs": [
511
+ {
512
+ "internalType": "euint64",
513
+ "name": "",
514
+ "type": "bytes32"
515
+ }
516
+ ],
517
+ "stateMutability": "view",
518
+ "type": "function"
519
+ },
520
+ {
521
+ "inputs": [
522
+ {
523
+ "internalType": "uint256",
524
+ "name": "batchId",
525
+ "type": "uint256"
526
+ }
527
+ ],
528
+ "name": "unwrapRequestId",
529
+ "outputs": [
530
+ {
531
+ "internalType": "bytes32",
532
+ "name": "",
533
+ "type": "bytes32"
534
+ }
535
+ ],
536
+ "stateMutability": "view",
537
+ "type": "function"
538
+ }
539
+ ],
540
+ "bytecode": "0x",
541
+ "deployedBytecode": "0x",
542
+ "linkReferences": {},
543
+ "deployedLinkReferences": {}
544
+ }
@@ -3,8 +3,8 @@
3
3
  "contractName": "CheckpointsConfidential",
4
4
  "sourceName": "contracts/utils/structs/CheckpointsConfidential.sol",
5
5
  "abi": [],
6
- "bytecode": "0x60556032600b8282823980515f1a607314602657634e487b7160e01b5f525f60045260245ffd5b305f52607381538281f3fe730000000000000000000000000000000000000000301460806040525f5ffdfea26469706673582212209fe3666278f6df29897de987f7b0712add3bf9ef20aa8543f2e8a089c0d423ea64736f6c634300081d0033",
7
- "deployedBytecode": "0x730000000000000000000000000000000000000000301460806040525f5ffdfea26469706673582212209fe3666278f6df29897de987f7b0712add3bf9ef20aa8543f2e8a089c0d423ea64736f6c634300081d0033",
6
+ "bytecode": "0x60556032600b8282823980515f1a607314602657634e487b7160e01b5f525f60045260245ffd5b305f52607381538281f3fe730000000000000000000000000000000000000000301460806040525f5ffdfea26469706673582212209911b4159ba93814534f221ae80d194900dcacdba46522596739ed85161f0be164736f6c634300081b0033",
7
+ "deployedBytecode": "0x730000000000000000000000000000000000000000301460806040525f5ffdfea26469706673582212209911b4159ba93814534f221ae80d194900dcacdba46522596739ed85161f0be164736f6c634300081b0033",
8
8
  "linkReferences": {},
9
9
  "deployedLinkReferences": {}
10
10
  }
@@ -95,6 +95,22 @@
95
95
  "name": "InvalidKMSSignatures",
96
96
  "type": "error"
97
97
  },
98
+ {
99
+ "inputs": [
100
+ {
101
+ "internalType": "bytes32",
102
+ "name": "handle",
103
+ "type": "bytes32"
104
+ },
105
+ {
106
+ "internalType": "address",
107
+ "name": "sender",
108
+ "type": "address"
109
+ }
110
+ ],
111
+ "name": "SenderNotAllowedToUseHandle",
112
+ "type": "error"
113
+ },
98
114
  {
99
115
  "anonymous": false,
100
116
  "inputs": [