@openzeppelin/confidential-contracts 0.2.0-rc.1

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 (31) hide show
  1. package/README.md +24 -0
  2. package/build/contracts/Checkpoints.json +16 -0
  3. package/build/contracts/CheckpointsConfidential.json +16 -0
  4. package/build/contracts/ConfidentialFungibleToken.json +614 -0
  5. package/build/contracts/ConfidentialFungibleTokenERC20Wrapper.json +793 -0
  6. package/build/contracts/ConfidentialFungibleTokenUtils.json +10 -0
  7. package/build/contracts/ConfidentialFungibleTokenVotes.json +1002 -0
  8. package/build/contracts/ERC7821WithExecutor.json +145 -0
  9. package/build/contracts/IConfidentialFungibleToken.json +458 -0
  10. package/build/contracts/IConfidentialFungibleTokenReceiver.json +45 -0
  11. package/build/contracts/TFHESafeMath.json +10 -0
  12. package/build/contracts/VestingWalletCliffConfidential.json +275 -0
  13. package/build/contracts/VestingWalletCliffExecutorConfidential.json +424 -0
  14. package/build/contracts/VestingWalletCliffExecutorConfidentialFactory.json +290 -0
  15. package/build/contracts/VestingWalletConfidential.json +246 -0
  16. package/build/contracts/VotesConfidential.json +412 -0
  17. package/finance/ERC7821WithExecutor.sol +46 -0
  18. package/finance/VestingWalletCliffConfidential.sol +62 -0
  19. package/finance/VestingWalletCliffExecutorConfidentialFactory.sol +203 -0
  20. package/finance/VestingWalletConfidential.sol +130 -0
  21. package/governance/utils/VotesConfidential.sol +202 -0
  22. package/interfaces/IConfidentialFungibleToken.sol +135 -0
  23. package/interfaces/IConfidentialFungibleTokenReceiver.sol +19 -0
  24. package/package.json +39 -0
  25. package/token/ConfidentialFungibleToken.sol +314 -0
  26. package/token/extensions/ConfidentialFungibleTokenERC20Wrapper.sol +175 -0
  27. package/token/extensions/ConfidentialFungibleTokenVotes.sol +29 -0
  28. package/token/utils/ConfidentialFungibleTokenUtils.sol +46 -0
  29. package/utils/TFHESafeMath.sol +37 -0
  30. package/utils/structs/CheckpointsConfidential.sol +193 -0
  31. package/utils/structs/temporary-Checkpoints.sol +835 -0
package/README.md ADDED
@@ -0,0 +1,24 @@
1
+ # <img src="logo.svg" alt="OpenZeppelin" height="40px">
2
+
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
+
5
+ **An experimental library for developing on the Zama fhEVM**
6
+
7
+ > [!IMPORTANT]
8
+ > This repository contains unaudited code and is a work in progress. Use at your own risk.
9
+
10
+ ## Overview
11
+
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.
13
+
14
+ ## Contribute
15
+
16
+ OpenZeppelin Confidential Contracts exists thanks to its contributors. There are many ways you can participate and help build high quality software. Check out the [contribution guide](https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/CONTRIBUTING.md)! This repository follows the same engineering guidelines as [OpenZeppelin Contracts](https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/GUIDELINES.md).
17
+
18
+ ## License
19
+
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).
21
+
22
+ ## Legal
23
+
24
+ Your use of this Project is governed by the terms found at www.openzeppelin.com/tos (the "Terms").
@@ -0,0 +1,16 @@
1
+ {
2
+ "_format": "hh-sol-artifact-1",
3
+ "contractName": "Checkpoints",
4
+ "sourceName": "contracts/utils/structs/temporary-Checkpoints.sol",
5
+ "abi": [
6
+ {
7
+ "inputs": [],
8
+ "name": "CheckpointUnorderedInsertion",
9
+ "type": "error"
10
+ }
11
+ ],
12
+ "bytecode": "0x60556032600b8282823980515f1a607314602657634e487b7160e01b5f525f60045260245ffd5b305f52607381538281f3fe730000000000000000000000000000000000000000301460806040525f5ffdfea26469706673582212202badf2b27d3126f95b223aabf2129c5cd7d4ec2067b5ad4b9865cdad9fad273b64736f6c634300081d0033",
13
+ "deployedBytecode": "0x730000000000000000000000000000000000000000301460806040525f5ffdfea26469706673582212202badf2b27d3126f95b223aabf2129c5cd7d4ec2067b5ad4b9865cdad9fad273b64736f6c634300081d0033",
14
+ "linkReferences": {},
15
+ "deployedLinkReferences": {}
16
+ }
@@ -0,0 +1,16 @@
1
+ {
2
+ "_format": "hh-sol-artifact-1",
3
+ "contractName": "CheckpointsConfidential",
4
+ "sourceName": "contracts/utils/structs/CheckpointsConfidential.sol",
5
+ "abi": [
6
+ {
7
+ "inputs": [],
8
+ "name": "CheckpointUnorderedInsertion",
9
+ "type": "error"
10
+ }
11
+ ],
12
+ "bytecode": "0x60556032600b8282823980515f1a607314602657634e487b7160e01b5f525f60045260245ffd5b305f52607381538281f3fe730000000000000000000000000000000000000000301460806040525f5ffdfea2646970667358221220364ffbf1ba7183f1c16596a69be847e39b8e467761b3ce24b8ce5f16c879b66764736f6c634300081d0033",
13
+ "deployedBytecode": "0x730000000000000000000000000000000000000000301460806040525f5ffdfea2646970667358221220364ffbf1ba7183f1c16596a69be847e39b8e467761b3ce24b8ce5f16c879b66764736f6c634300081d0033",
14
+ "linkReferences": {},
15
+ "deployedLinkReferences": {}
16
+ }
@@ -0,0 +1,614 @@
1
+ {
2
+ "_format": "hh-sol-artifact-1",
3
+ "contractName": "ConfidentialFungibleToken",
4
+ "sourceName": "contracts/token/ConfidentialFungibleToken.sol",
5
+ "abi": [
6
+ {
7
+ "inputs": [
8
+ {
9
+ "internalType": "uint256",
10
+ "name": "requestId",
11
+ "type": "uint256"
12
+ }
13
+ ],
14
+ "name": "ConfidentialFungibleTokenInvalidGatewayRequest",
15
+ "type": "error"
16
+ },
17
+ {
18
+ "inputs": [
19
+ {
20
+ "internalType": "address",
21
+ "name": "receiver",
22
+ "type": "address"
23
+ }
24
+ ],
25
+ "name": "ConfidentialFungibleTokenInvalidReceiver",
26
+ "type": "error"
27
+ },
28
+ {
29
+ "inputs": [
30
+ {
31
+ "internalType": "address",
32
+ "name": "sender",
33
+ "type": "address"
34
+ }
35
+ ],
36
+ "name": "ConfidentialFungibleTokenInvalidSender",
37
+ "type": "error"
38
+ },
39
+ {
40
+ "inputs": [
41
+ {
42
+ "internalType": "address",
43
+ "name": "caller",
44
+ "type": "address"
45
+ }
46
+ ],
47
+ "name": "ConfidentialFungibleTokenUnauthorizedCaller",
48
+ "type": "error"
49
+ },
50
+ {
51
+ "inputs": [
52
+ {
53
+ "internalType": "address",
54
+ "name": "holder",
55
+ "type": "address"
56
+ },
57
+ {
58
+ "internalType": "address",
59
+ "name": "spender",
60
+ "type": "address"
61
+ }
62
+ ],
63
+ "name": "ConfidentialFungibleTokenUnauthorizedSpender",
64
+ "type": "error"
65
+ },
66
+ {
67
+ "inputs": [
68
+ {
69
+ "internalType": "euint64",
70
+ "name": "amount",
71
+ "type": "bytes32"
72
+ },
73
+ {
74
+ "internalType": "address",
75
+ "name": "user",
76
+ "type": "address"
77
+ }
78
+ ],
79
+ "name": "ConfidentialFungibleTokenUnauthorizedUseOfEncryptedAmount",
80
+ "type": "error"
81
+ },
82
+ {
83
+ "inputs": [
84
+ {
85
+ "internalType": "address",
86
+ "name": "holder",
87
+ "type": "address"
88
+ }
89
+ ],
90
+ "name": "ConfidentialFungibleTokenZeroBalance",
91
+ "type": "error"
92
+ },
93
+ {
94
+ "inputs": [],
95
+ "name": "HandlesAlreadySavedForRequestID",
96
+ "type": "error"
97
+ },
98
+ {
99
+ "inputs": [],
100
+ "name": "InvalidKMSSignatures",
101
+ "type": "error"
102
+ },
103
+ {
104
+ "inputs": [],
105
+ "name": "NoHandleFoundForRequestID",
106
+ "type": "error"
107
+ },
108
+ {
109
+ "inputs": [],
110
+ "name": "UnsupportedHandleType",
111
+ "type": "error"
112
+ },
113
+ {
114
+ "anonymous": false,
115
+ "inputs": [
116
+ {
117
+ "indexed": true,
118
+ "internalType": "euint64",
119
+ "name": "encryptedAmount",
120
+ "type": "bytes32"
121
+ },
122
+ {
123
+ "indexed": false,
124
+ "internalType": "uint64",
125
+ "name": "amount",
126
+ "type": "uint64"
127
+ }
128
+ ],
129
+ "name": "AmountDisclosed",
130
+ "type": "event"
131
+ },
132
+ {
133
+ "anonymous": false,
134
+ "inputs": [
135
+ {
136
+ "indexed": true,
137
+ "internalType": "address",
138
+ "name": "from",
139
+ "type": "address"
140
+ },
141
+ {
142
+ "indexed": true,
143
+ "internalType": "address",
144
+ "name": "to",
145
+ "type": "address"
146
+ },
147
+ {
148
+ "indexed": true,
149
+ "internalType": "euint64",
150
+ "name": "amount",
151
+ "type": "bytes32"
152
+ }
153
+ ],
154
+ "name": "ConfidentialTransfer",
155
+ "type": "event"
156
+ },
157
+ {
158
+ "anonymous": false,
159
+ "inputs": [
160
+ {
161
+ "indexed": true,
162
+ "internalType": "uint256",
163
+ "name": "requestID",
164
+ "type": "uint256"
165
+ }
166
+ ],
167
+ "name": "DecryptionFulfilled",
168
+ "type": "event"
169
+ },
170
+ {
171
+ "anonymous": false,
172
+ "inputs": [
173
+ {
174
+ "indexed": true,
175
+ "internalType": "address",
176
+ "name": "holder",
177
+ "type": "address"
178
+ },
179
+ {
180
+ "indexed": true,
181
+ "internalType": "address",
182
+ "name": "operator",
183
+ "type": "address"
184
+ },
185
+ {
186
+ "indexed": false,
187
+ "internalType": "uint48",
188
+ "name": "until",
189
+ "type": "uint48"
190
+ }
191
+ ],
192
+ "name": "OperatorSet",
193
+ "type": "event"
194
+ },
195
+ {
196
+ "inputs": [
197
+ {
198
+ "internalType": "address",
199
+ "name": "account",
200
+ "type": "address"
201
+ }
202
+ ],
203
+ "name": "confidentialBalanceOf",
204
+ "outputs": [
205
+ {
206
+ "internalType": "euint64",
207
+ "name": "",
208
+ "type": "bytes32"
209
+ }
210
+ ],
211
+ "stateMutability": "view",
212
+ "type": "function"
213
+ },
214
+ {
215
+ "inputs": [],
216
+ "name": "confidentialTotalSupply",
217
+ "outputs": [
218
+ {
219
+ "internalType": "euint64",
220
+ "name": "",
221
+ "type": "bytes32"
222
+ }
223
+ ],
224
+ "stateMutability": "view",
225
+ "type": "function"
226
+ },
227
+ {
228
+ "inputs": [
229
+ {
230
+ "internalType": "address",
231
+ "name": "to",
232
+ "type": "address"
233
+ },
234
+ {
235
+ "internalType": "externalEuint64",
236
+ "name": "encryptedAmount",
237
+ "type": "bytes32"
238
+ },
239
+ {
240
+ "internalType": "bytes",
241
+ "name": "inputProof",
242
+ "type": "bytes"
243
+ }
244
+ ],
245
+ "name": "confidentialTransfer",
246
+ "outputs": [
247
+ {
248
+ "internalType": "euint64",
249
+ "name": "",
250
+ "type": "bytes32"
251
+ }
252
+ ],
253
+ "stateMutability": "nonpayable",
254
+ "type": "function"
255
+ },
256
+ {
257
+ "inputs": [
258
+ {
259
+ "internalType": "address",
260
+ "name": "to",
261
+ "type": "address"
262
+ },
263
+ {
264
+ "internalType": "euint64",
265
+ "name": "amount",
266
+ "type": "bytes32"
267
+ }
268
+ ],
269
+ "name": "confidentialTransfer",
270
+ "outputs": [
271
+ {
272
+ "internalType": "euint64",
273
+ "name": "",
274
+ "type": "bytes32"
275
+ }
276
+ ],
277
+ "stateMutability": "nonpayable",
278
+ "type": "function"
279
+ },
280
+ {
281
+ "inputs": [
282
+ {
283
+ "internalType": "address",
284
+ "name": "to",
285
+ "type": "address"
286
+ },
287
+ {
288
+ "internalType": "euint64",
289
+ "name": "amount",
290
+ "type": "bytes32"
291
+ },
292
+ {
293
+ "internalType": "bytes",
294
+ "name": "data",
295
+ "type": "bytes"
296
+ }
297
+ ],
298
+ "name": "confidentialTransferAndCall",
299
+ "outputs": [
300
+ {
301
+ "internalType": "euint64",
302
+ "name": "transferred",
303
+ "type": "bytes32"
304
+ }
305
+ ],
306
+ "stateMutability": "nonpayable",
307
+ "type": "function"
308
+ },
309
+ {
310
+ "inputs": [
311
+ {
312
+ "internalType": "address",
313
+ "name": "to",
314
+ "type": "address"
315
+ },
316
+ {
317
+ "internalType": "externalEuint64",
318
+ "name": "encryptedAmount",
319
+ "type": "bytes32"
320
+ },
321
+ {
322
+ "internalType": "bytes",
323
+ "name": "inputProof",
324
+ "type": "bytes"
325
+ },
326
+ {
327
+ "internalType": "bytes",
328
+ "name": "data",
329
+ "type": "bytes"
330
+ }
331
+ ],
332
+ "name": "confidentialTransferAndCall",
333
+ "outputs": [
334
+ {
335
+ "internalType": "euint64",
336
+ "name": "transferred",
337
+ "type": "bytes32"
338
+ }
339
+ ],
340
+ "stateMutability": "nonpayable",
341
+ "type": "function"
342
+ },
343
+ {
344
+ "inputs": [
345
+ {
346
+ "internalType": "address",
347
+ "name": "from",
348
+ "type": "address"
349
+ },
350
+ {
351
+ "internalType": "address",
352
+ "name": "to",
353
+ "type": "address"
354
+ },
355
+ {
356
+ "internalType": "externalEuint64",
357
+ "name": "encryptedAmount",
358
+ "type": "bytes32"
359
+ },
360
+ {
361
+ "internalType": "bytes",
362
+ "name": "inputProof",
363
+ "type": "bytes"
364
+ }
365
+ ],
366
+ "name": "confidentialTransferFrom",
367
+ "outputs": [
368
+ {
369
+ "internalType": "euint64",
370
+ "name": "transferred",
371
+ "type": "bytes32"
372
+ }
373
+ ],
374
+ "stateMutability": "nonpayable",
375
+ "type": "function"
376
+ },
377
+ {
378
+ "inputs": [
379
+ {
380
+ "internalType": "address",
381
+ "name": "from",
382
+ "type": "address"
383
+ },
384
+ {
385
+ "internalType": "address",
386
+ "name": "to",
387
+ "type": "address"
388
+ },
389
+ {
390
+ "internalType": "euint64",
391
+ "name": "amount",
392
+ "type": "bytes32"
393
+ }
394
+ ],
395
+ "name": "confidentialTransferFrom",
396
+ "outputs": [
397
+ {
398
+ "internalType": "euint64",
399
+ "name": "transferred",
400
+ "type": "bytes32"
401
+ }
402
+ ],
403
+ "stateMutability": "nonpayable",
404
+ "type": "function"
405
+ },
406
+ {
407
+ "inputs": [
408
+ {
409
+ "internalType": "address",
410
+ "name": "from",
411
+ "type": "address"
412
+ },
413
+ {
414
+ "internalType": "address",
415
+ "name": "to",
416
+ "type": "address"
417
+ },
418
+ {
419
+ "internalType": "externalEuint64",
420
+ "name": "encryptedAmount",
421
+ "type": "bytes32"
422
+ },
423
+ {
424
+ "internalType": "bytes",
425
+ "name": "inputProof",
426
+ "type": "bytes"
427
+ },
428
+ {
429
+ "internalType": "bytes",
430
+ "name": "data",
431
+ "type": "bytes"
432
+ }
433
+ ],
434
+ "name": "confidentialTransferFromAndCall",
435
+ "outputs": [
436
+ {
437
+ "internalType": "euint64",
438
+ "name": "transferred",
439
+ "type": "bytes32"
440
+ }
441
+ ],
442
+ "stateMutability": "nonpayable",
443
+ "type": "function"
444
+ },
445
+ {
446
+ "inputs": [
447
+ {
448
+ "internalType": "address",
449
+ "name": "from",
450
+ "type": "address"
451
+ },
452
+ {
453
+ "internalType": "address",
454
+ "name": "to",
455
+ "type": "address"
456
+ },
457
+ {
458
+ "internalType": "euint64",
459
+ "name": "amount",
460
+ "type": "bytes32"
461
+ },
462
+ {
463
+ "internalType": "bytes",
464
+ "name": "data",
465
+ "type": "bytes"
466
+ }
467
+ ],
468
+ "name": "confidentialTransferFromAndCall",
469
+ "outputs": [
470
+ {
471
+ "internalType": "euint64",
472
+ "name": "transferred",
473
+ "type": "bytes32"
474
+ }
475
+ ],
476
+ "stateMutability": "nonpayable",
477
+ "type": "function"
478
+ },
479
+ {
480
+ "inputs": [],
481
+ "name": "decimals",
482
+ "outputs": [
483
+ {
484
+ "internalType": "uint8",
485
+ "name": "",
486
+ "type": "uint8"
487
+ }
488
+ ],
489
+ "stateMutability": "view",
490
+ "type": "function"
491
+ },
492
+ {
493
+ "inputs": [
494
+ {
495
+ "internalType": "euint64",
496
+ "name": "encryptedAmount",
497
+ "type": "bytes32"
498
+ }
499
+ ],
500
+ "name": "discloseEncryptedAmount",
501
+ "outputs": [],
502
+ "stateMutability": "nonpayable",
503
+ "type": "function"
504
+ },
505
+ {
506
+ "inputs": [
507
+ {
508
+ "internalType": "uint256",
509
+ "name": "requestId",
510
+ "type": "uint256"
511
+ },
512
+ {
513
+ "internalType": "uint64",
514
+ "name": "amount",
515
+ "type": "uint64"
516
+ },
517
+ {
518
+ "internalType": "bytes[]",
519
+ "name": "signatures",
520
+ "type": "bytes[]"
521
+ }
522
+ ],
523
+ "name": "finalizeDiscloseEncryptedAmount",
524
+ "outputs": [],
525
+ "stateMutability": "nonpayable",
526
+ "type": "function"
527
+ },
528
+ {
529
+ "inputs": [
530
+ {
531
+ "internalType": "address",
532
+ "name": "holder",
533
+ "type": "address"
534
+ },
535
+ {
536
+ "internalType": "address",
537
+ "name": "spender",
538
+ "type": "address"
539
+ }
540
+ ],
541
+ "name": "isOperator",
542
+ "outputs": [
543
+ {
544
+ "internalType": "bool",
545
+ "name": "",
546
+ "type": "bool"
547
+ }
548
+ ],
549
+ "stateMutability": "view",
550
+ "type": "function"
551
+ },
552
+ {
553
+ "inputs": [],
554
+ "name": "name",
555
+ "outputs": [
556
+ {
557
+ "internalType": "string",
558
+ "name": "",
559
+ "type": "string"
560
+ }
561
+ ],
562
+ "stateMutability": "view",
563
+ "type": "function"
564
+ },
565
+ {
566
+ "inputs": [
567
+ {
568
+ "internalType": "address",
569
+ "name": "operator",
570
+ "type": "address"
571
+ },
572
+ {
573
+ "internalType": "uint48",
574
+ "name": "until",
575
+ "type": "uint48"
576
+ }
577
+ ],
578
+ "name": "setOperator",
579
+ "outputs": [],
580
+ "stateMutability": "nonpayable",
581
+ "type": "function"
582
+ },
583
+ {
584
+ "inputs": [],
585
+ "name": "symbol",
586
+ "outputs": [
587
+ {
588
+ "internalType": "string",
589
+ "name": "",
590
+ "type": "string"
591
+ }
592
+ ],
593
+ "stateMutability": "view",
594
+ "type": "function"
595
+ },
596
+ {
597
+ "inputs": [],
598
+ "name": "tokenURI",
599
+ "outputs": [
600
+ {
601
+ "internalType": "string",
602
+ "name": "",
603
+ "type": "string"
604
+ }
605
+ ],
606
+ "stateMutability": "view",
607
+ "type": "function"
608
+ }
609
+ ],
610
+ "bytecode": "0x",
611
+ "deployedBytecode": "0x",
612
+ "linkReferences": {},
613
+ "deployedLinkReferences": {}
614
+ }