@coti-io/coti-contracts 0.1.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 (180) hide show
  1. package/.github/workflows/npm-publish.yml +52 -0
  2. package/CODE_OF_CONDUCT.md +44 -0
  3. package/CONTRIBUTING.md +101 -0
  4. package/LICENSE +201 -0
  5. package/README.md +48 -0
  6. package/contracts/access/DataPrivacyFramework/DataPrivacyFramework.sol +480 -0
  7. package/contracts/access/DataPrivacyFramework/README.md +68 -0
  8. package/contracts/access/DataPrivacyFramework/extensions/DataPrivacyFrameworkMpc.sol +1139 -0
  9. package/contracts/mocks/README.md +5 -0
  10. package/contracts/mocks/access/DataPrivacyFramework/DataPrivacyFrameworkMock.sol +9 -0
  11. package/contracts/mocks/token/PrivateERC20/PrivateERC20Mock.sol +17 -0
  12. package/contracts/mocks/token/PrivateERC721/PrivateERC721URIStorageMock.sol +34 -0
  13. package/contracts/mocks/utils/mpc/ArithmeticTestsContract.sol +431 -0
  14. package/contracts/mocks/utils/mpc/BitwiseTestsContract.sol +361 -0
  15. package/contracts/mocks/utils/mpc/Comparison1Tests.Contract.sol +307 -0
  16. package/contracts/mocks/utils/mpc/Comparison2TestsContract.sol +307 -0
  17. package/contracts/mocks/utils/mpc/MinMaxTestsContract.sol +297 -0
  18. package/contracts/mocks/utils/mpc/Miscellaneous1TestsContract.sol +185 -0
  19. package/contracts/mocks/utils/mpc/Miscellaneous2TestsContract.sol +448 -0
  20. package/contracts/mocks/utils/mpc/OffboardToUserKeyTestsContract.sol +81 -0
  21. package/contracts/mocks/utils/mpc/README.md +486 -0
  22. package/contracts/mocks/utils/mpc/ShiftTestsContract.sol +311 -0
  23. package/contracts/mocks/utils/mpc/StringTestsContract.sol +59 -0
  24. package/contracts/mocks/utils/mpc/TransferScalarTestsContract.sol +271 -0
  25. package/contracts/mocks/utils/mpc/TransferTestsContract.sol +715 -0
  26. package/contracts/mocks/wallet/PrivateERC20Wallet/PrivateERC20WalletMock.sol +25 -0
  27. package/contracts/onboard/AccountOnboard.sol +21 -0
  28. package/contracts/onboard/README.md +65 -0
  29. package/contracts/package.json +11 -0
  30. package/contracts/token/PrivateERC20/IPrivateERC20.sol +142 -0
  31. package/contracts/token/PrivateERC20/PrivateERC20.sol +478 -0
  32. package/contracts/token/PrivateERC20/README.md +104 -0
  33. package/contracts/token/PrivateERC721/PrivateERC721.sol +458 -0
  34. package/contracts/token/PrivateERC721/README.md +282 -0
  35. package/contracts/token/PrivateERC721/extensions/PrivateERC721URIStorage.sol +87 -0
  36. package/contracts/utils/mpc/MpcCore.sol +3215 -0
  37. package/contracts/utils/mpc/MpcInterface.sol +41 -0
  38. package/contracts/utils/mpc/README.md +82 -0
  39. package/hardhat.config.ts +18 -0
  40. package/package.json +14 -0
  41. package/test/access/DataPrivacyFramework/DataPrivacyFramework.test.ts +780 -0
  42. package/test/onboard/AccountOnboard.test.ts +45 -0
  43. package/test/token/PrivateERC20/PrivateERC20.test.ts +546 -0
  44. package/test/token/PrivateERC721/PrivateERC721.test.ts +223 -0
  45. package/test/utils/accounts.ts +55 -0
  46. package/test/utils/mpc/Precompile.test.ts +113 -0
  47. package/test/utils/mpc/String.test.ts +227 -0
  48. package/tsconfig.json +11 -0
  49. package/typechain-types/@openzeppelin/contracts/index.ts +9 -0
  50. package/typechain-types/@openzeppelin/contracts/interfaces/IERC4906.ts +462 -0
  51. package/typechain-types/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/IERC1155Errors.ts +69 -0
  52. package/typechain-types/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/IERC20Errors.ts +69 -0
  53. package/typechain-types/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/IERC721Errors.ts +69 -0
  54. package/typechain-types/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/index.ts +6 -0
  55. package/typechain-types/@openzeppelin/contracts/interfaces/index.ts +6 -0
  56. package/typechain-types/@openzeppelin/contracts/token/ERC721/IERC721.ts +393 -0
  57. package/typechain-types/@openzeppelin/contracts/token/ERC721/IERC721Receiver.ts +110 -0
  58. package/typechain-types/@openzeppelin/contracts/token/ERC721/index.ts +5 -0
  59. package/typechain-types/@openzeppelin/contracts/token/index.ts +5 -0
  60. package/typechain-types/@openzeppelin/contracts/utils/index.ts +5 -0
  61. package/typechain-types/@openzeppelin/contracts/utils/introspection/ERC165.ts +94 -0
  62. package/typechain-types/@openzeppelin/contracts/utils/introspection/IERC165.ts +94 -0
  63. package/typechain-types/@openzeppelin/contracts/utils/introspection/index.ts +5 -0
  64. package/typechain-types/@openzeppelin/index.ts +5 -0
  65. package/typechain-types/common.ts +131 -0
  66. package/typechain-types/contracts/access/DataPrivacyFramework/DataPrivacyFramework.ts +598 -0
  67. package/typechain-types/contracts/access/DataPrivacyFramework/extensions/DataPrivacyFrameworkMpc.ts +598 -0
  68. package/typechain-types/contracts/access/DataPrivacyFramework/extensions/index.ts +4 -0
  69. package/typechain-types/contracts/access/DataPrivacyFramework/index.ts +6 -0
  70. package/typechain-types/contracts/access/index.ts +5 -0
  71. package/typechain-types/contracts/index.ts +13 -0
  72. package/typechain-types/contracts/mocks/access/DataPrivacyFramework/DataPrivacyFrameworkMock.ts +598 -0
  73. package/typechain-types/contracts/mocks/access/DataPrivacyFramework/index.ts +4 -0
  74. package/typechain-types/contracts/mocks/access/index.ts +5 -0
  75. package/typechain-types/contracts/mocks/index.ts +11 -0
  76. package/typechain-types/contracts/mocks/token/PrivateERC20/PrivateERC20Mock.ts +543 -0
  77. package/typechain-types/contracts/mocks/token/PrivateERC20/index.ts +4 -0
  78. package/typechain-types/contracts/mocks/token/PrivateERC721/PrivateERC721URIStorageMock.ts +576 -0
  79. package/typechain-types/contracts/mocks/token/PrivateERC721/index.ts +4 -0
  80. package/typechain-types/contracts/mocks/token/index.ts +7 -0
  81. package/typechain-types/contracts/mocks/utils/index.ts +5 -0
  82. package/typechain-types/contracts/mocks/utils/mpc/ArithmeticTestsContract.ts +354 -0
  83. package/typechain-types/contracts/mocks/utils/mpc/BitwiseTestsContract.ts +340 -0
  84. package/typechain-types/contracts/mocks/utils/mpc/Comparison1Tests.Contract.sol/Comparison1TestsContract.ts +340 -0
  85. package/typechain-types/contracts/mocks/utils/mpc/Comparison1Tests.Contract.sol/index.ts +4 -0
  86. package/typechain-types/contracts/mocks/utils/mpc/Comparison2TestsContract.ts +340 -0
  87. package/typechain-types/contracts/mocks/utils/mpc/MinMaxTestsContract.ts +321 -0
  88. package/typechain-types/contracts/mocks/utils/mpc/Miscellaneous1TestsContract.ts +199 -0
  89. package/typechain-types/contracts/mocks/utils/mpc/Miscellaneous2TestsContract.ts +384 -0
  90. package/typechain-types/contracts/mocks/utils/mpc/OffboardToUserKeyTestsContract.sol/OffboardToUserKeyTestContract.ts +218 -0
  91. package/typechain-types/contracts/mocks/utils/mpc/OffboardToUserKeyTestsContract.sol/index.ts +4 -0
  92. package/typechain-types/contracts/mocks/utils/mpc/ShiftTestsContract.ts +339 -0
  93. package/typechain-types/contracts/mocks/utils/mpc/StringTestsContract.ts +211 -0
  94. package/typechain-types/contracts/mocks/utils/mpc/TransferScalarTestsContract.ts +266 -0
  95. package/typechain-types/contracts/mocks/utils/mpc/TransferTestsContract.ts +288 -0
  96. package/typechain-types/contracts/mocks/utils/mpc/index.ts +17 -0
  97. package/typechain-types/contracts/mocks/wallet/PrivateERC20Wallet/PrivateERC20WalletMock.ts +173 -0
  98. package/typechain-types/contracts/mocks/wallet/PrivateERC20Wallet/index.ts +4 -0
  99. package/typechain-types/contracts/mocks/wallet/index.ts +5 -0
  100. package/typechain-types/contracts/onboard/AccountOnboard.ts +135 -0
  101. package/typechain-types/contracts/onboard/index.ts +4 -0
  102. package/typechain-types/contracts/token/PrivateERC20/IPrivateERC20.ts +437 -0
  103. package/typechain-types/contracts/token/PrivateERC20/PrivateERC20.ts +505 -0
  104. package/typechain-types/contracts/token/PrivateERC20/index.ts +5 -0
  105. package/typechain-types/contracts/token/PrivateERC721/PrivateERC721.ts +409 -0
  106. package/typechain-types/contracts/token/PrivateERC721/extensions/PrivateERC721URIStorage.ts +501 -0
  107. package/typechain-types/contracts/token/PrivateERC721/extensions/index.ts +4 -0
  108. package/typechain-types/contracts/token/PrivateERC721/index.ts +6 -0
  109. package/typechain-types/contracts/token/index.ts +7 -0
  110. package/typechain-types/contracts/utils/index.ts +5 -0
  111. package/typechain-types/contracts/utils/mpc/MpcInterface.sol/ExtendedOperations.ts +698 -0
  112. package/typechain-types/contracts/utils/mpc/MpcInterface.sol/index.ts +4 -0
  113. package/typechain-types/contracts/utils/mpc/index.ts +5 -0
  114. package/typechain-types/factories/@openzeppelin/contracts/index.ts +6 -0
  115. package/typechain-types/factories/@openzeppelin/contracts/interfaces/IERC4906__factory.ts +339 -0
  116. package/typechain-types/factories/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/IERC1155Errors__factory.ts +127 -0
  117. package/typechain-types/factories/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/IERC20Errors__factory.ts +111 -0
  118. package/typechain-types/factories/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/IERC721Errors__factory.ts +128 -0
  119. package/typechain-types/factories/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/index.ts +6 -0
  120. package/typechain-types/factories/@openzeppelin/contracts/interfaces/index.ts +5 -0
  121. package/typechain-types/factories/@openzeppelin/contracts/token/ERC721/IERC721Receiver__factory.ts +59 -0
  122. package/typechain-types/factories/@openzeppelin/contracts/token/ERC721/IERC721__factory.ts +307 -0
  123. package/typechain-types/factories/@openzeppelin/contracts/token/ERC721/index.ts +5 -0
  124. package/typechain-types/factories/@openzeppelin/contracts/token/index.ts +4 -0
  125. package/typechain-types/factories/@openzeppelin/contracts/utils/index.ts +4 -0
  126. package/typechain-types/factories/@openzeppelin/contracts/utils/introspection/ERC165__factory.ts +41 -0
  127. package/typechain-types/factories/@openzeppelin/contracts/utils/introspection/IERC165__factory.ts +41 -0
  128. package/typechain-types/factories/@openzeppelin/contracts/utils/introspection/index.ts +5 -0
  129. package/typechain-types/factories/@openzeppelin/index.ts +4 -0
  130. package/typechain-types/factories/contracts/access/DataPrivacyFramework/DataPrivacyFramework__factory.ts +621 -0
  131. package/typechain-types/factories/contracts/access/DataPrivacyFramework/extensions/DataPrivacyFrameworkMpc__factory.ts +621 -0
  132. package/typechain-types/factories/contracts/access/DataPrivacyFramework/extensions/index.ts +4 -0
  133. package/typechain-types/factories/contracts/access/DataPrivacyFramework/index.ts +5 -0
  134. package/typechain-types/factories/contracts/access/index.ts +4 -0
  135. package/typechain-types/factories/contracts/index.ts +8 -0
  136. package/typechain-types/factories/contracts/mocks/access/DataPrivacyFramework/DataPrivacyFrameworkMock__factory.ts +670 -0
  137. package/typechain-types/factories/contracts/mocks/access/DataPrivacyFramework/index.ts +4 -0
  138. package/typechain-types/factories/contracts/mocks/access/index.ts +4 -0
  139. package/typechain-types/factories/contracts/mocks/index.ts +7 -0
  140. package/typechain-types/factories/contracts/mocks/token/PrivateERC20/PrivateERC20Mock__factory.ts +615 -0
  141. package/typechain-types/factories/contracts/mocks/token/PrivateERC20/index.ts +4 -0
  142. package/typechain-types/factories/contracts/mocks/token/PrivateERC721/PrivateERC721URIStorageMock__factory.ts +630 -0
  143. package/typechain-types/factories/contracts/mocks/token/PrivateERC721/index.ts +4 -0
  144. package/typechain-types/factories/contracts/mocks/token/index.ts +5 -0
  145. package/typechain-types/factories/contracts/mocks/utils/index.ts +4 -0
  146. package/typechain-types/factories/contracts/mocks/utils/mpc/ArithmeticTestsContract__factory.ts +374 -0
  147. package/typechain-types/factories/contracts/mocks/utils/mpc/BitwiseTestsContract__factory.ts +361 -0
  148. package/typechain-types/factories/contracts/mocks/utils/mpc/Comparison1Tests.Contract.sol/Comparison1TestsContract__factory.ts +361 -0
  149. package/typechain-types/factories/contracts/mocks/utils/mpc/Comparison1Tests.Contract.sol/index.ts +4 -0
  150. package/typechain-types/factories/contracts/mocks/utils/mpc/Comparison2TestsContract__factory.ts +361 -0
  151. package/typechain-types/factories/contracts/mocks/utils/mpc/MinMaxTestsContract__factory.ts +337 -0
  152. package/typechain-types/factories/contracts/mocks/utils/mpc/Miscellaneous1TestsContract__factory.ts +236 -0
  153. package/typechain-types/factories/contracts/mocks/utils/mpc/Miscellaneous2TestsContract__factory.ts +432 -0
  154. package/typechain-types/factories/contracts/mocks/utils/mpc/OffboardToUserKeyTestsContract.sol/OffboardToUserKeyTestContract__factory.ts +245 -0
  155. package/typechain-types/factories/contracts/mocks/utils/mpc/OffboardToUserKeyTestsContract.sol/index.ts +4 -0
  156. package/typechain-types/factories/contracts/mocks/utils/mpc/ShiftTestsContract__factory.ts +374 -0
  157. package/typechain-types/factories/contracts/mocks/utils/mpc/StringTestsContract__factory.ts +264 -0
  158. package/typechain-types/factories/contracts/mocks/utils/mpc/TransferScalarTestsContract__factory.ts +360 -0
  159. package/typechain-types/factories/contracts/mocks/utils/mpc/TransferTestsContract__factory.ts +441 -0
  160. package/typechain-types/factories/contracts/mocks/utils/mpc/index.ts +15 -0
  161. package/typechain-types/factories/contracts/mocks/wallet/PrivateERC20Wallet/PrivateERC20WalletMock__factory.ts +194 -0
  162. package/typechain-types/factories/contracts/mocks/wallet/PrivateERC20Wallet/index.ts +4 -0
  163. package/typechain-types/factories/contracts/mocks/wallet/index.ts +4 -0
  164. package/typechain-types/factories/contracts/onboard/AccountOnboard__factory.ts +104 -0
  165. package/typechain-types/factories/contracts/onboard/index.ts +4 -0
  166. package/typechain-types/factories/contracts/token/PrivateERC20/IPrivateERC20__factory.ts +406 -0
  167. package/typechain-types/factories/contracts/token/PrivateERC20/PrivateERC20__factory.ts +532 -0
  168. package/typechain-types/factories/contracts/token/PrivateERC20/index.ts +5 -0
  169. package/typechain-types/factories/contracts/token/PrivateERC721/PrivateERC721__factory.ts +439 -0
  170. package/typechain-types/factories/contracts/token/PrivateERC721/extensions/PrivateERC721URIStorage__factory.ts +512 -0
  171. package/typechain-types/factories/contracts/token/PrivateERC721/extensions/index.ts +4 -0
  172. package/typechain-types/factories/contracts/token/PrivateERC721/index.ts +5 -0
  173. package/typechain-types/factories/contracts/token/index.ts +5 -0
  174. package/typechain-types/factories/contracts/utils/index.ts +4 -0
  175. package/typechain-types/factories/contracts/utils/mpc/MpcInterface.sol/ExtendedOperations__factory.ts +919 -0
  176. package/typechain-types/factories/contracts/utils/mpc/MpcInterface.sol/index.ts +4 -0
  177. package/typechain-types/factories/contracts/utils/mpc/index.ts +4 -0
  178. package/typechain-types/factories/index.ts +5 -0
  179. package/typechain-types/hardhat.d.ts +621 -0
  180. package/typechain-types/index.ts +72 -0
@@ -0,0 +1,25 @@
1
+ // SPDX-License-Identifier: MIT
2
+
3
+ pragma solidity ^0.8.19;
4
+
5
+ import "../../../token/PrivateERC20/IPrivateERC20.sol";
6
+
7
+ contract PrivateERC20WalletMock {
8
+ constructor() {}
9
+
10
+ function setAccountEncryptionAddress(address token, address accountEncryptionAddress) public returns (bool) {
11
+ return IPrivateERC20(token).setAccountEncryptionAddress(accountEncryptionAddress);
12
+ }
13
+
14
+ function transfer(address token, address to, uint64 value) public returns (gtBool) {
15
+ return IPrivateERC20(token).transfer(to, MpcCore.setPublic64(value));
16
+ }
17
+
18
+ function approve(address token, address spender, uint64 value) public returns (bool) {
19
+ return IPrivateERC20(token).approve(spender, MpcCore.setPublic64(value));
20
+ }
21
+
22
+ function transferFrom(address token, address from, address to, uint64 value) public returns (gtBool) {
23
+ return IPrivateERC20(token).transferFrom(from, to, MpcCore.setPublic64(value));
24
+ }
25
+ }
@@ -0,0 +1,21 @@
1
+ // SPDX-License-Identifier: MIT
2
+
3
+ pragma solidity ^0.8.19;
4
+
5
+ import "../utils/mpc/MpcCore.sol";
6
+
7
+ contract AccountOnboard {
8
+
9
+ event AccountOnboarded(address indexed _from, bytes userKey);
10
+
11
+ /**
12
+ * @notice onboards the account and emits the users AES encryption key in encrypted form
13
+ * @dev the AES key must be decrypted in order to be used to pass encrypted data to the chain
14
+ * @param publicKey RSA public key
15
+ * @param signedEK signed hash of the RSA public key
16
+ */
17
+ function onboardAccount(bytes calldata publicKey, bytes calldata signedEK) public {
18
+ bytes memory accountKey = MpcCore.getUserKey(publicKey, signedEK);
19
+ emit AccountOnboarded(msg.sender, accountKey);
20
+ }
21
+ }
@@ -0,0 +1,65 @@
1
+ # AccountOnboard
2
+
3
+ ## Overview
4
+
5
+ The `AccountOnboard` contract is responsible for onboarding user accounts to the system, leveraging RSA public keys and AES encryption. During onboarding, the user's AES encryption key is emitted in an encrypted form. This contract interacts with a utility contract `MpcCore` to retrieve the user key.
6
+
7
+ ## Prerequisites
8
+
9
+ - **Solidity Version**: `^0.8.19`
10
+ - **License**: MIT
11
+ - **Dependencies**:
12
+ - Imports from `../utils/mpc/MpcCore.sol`.
13
+
14
+ ## Table of Contents
15
+ - [Events](#events)
16
+ - [AccountOnboarded](#accountonboarded)
17
+ - [Functions](#functions)
18
+ - [onboardAccount](#onboardaccount)
19
+
20
+ ## Events
21
+
22
+ ### AccountOnboarded
23
+
24
+ This event is triggered when a new account is successfully onboarded. It logs the user's account information, including the sender's address and the AES encryption key in its encrypted form.
25
+
26
+ #### Parameters:
27
+ - **`_from`**: (`address`) The address of the account that initiated the onboarding process.
28
+ - **`userKey`**: (`bytes`) The user's AES encryption key, encrypted using RSA. This key must be decrypted before use.
29
+
30
+ ```solidity
31
+ event AccountOnboarded(address indexed _from, bytes userKey);
32
+ ```
33
+
34
+ ## Functions
35
+
36
+ ### onboardAccount
37
+
38
+ The `onboardAccount` function is responsible for onboarding a new user account. It takes an RSA public key and a signed hash of the key, verifies the credentials, and emits the encrypted AES key.
39
+
40
+ #### Function Definition:
41
+
42
+ ```solidity
43
+ function onboardAccount(bytes calldata publicKey, bytes calldata signedEK) public;
44
+ ```
45
+
46
+ #### Parameters:
47
+ - **`publicKey`**: (`bytes`) The RSA public key of the user. This is used to verify and generate the AES encryption key.
48
+ - **`signedEK`**: (`bytes`) A signed hash of the RSA public key, used to ensure the authenticity of the public key.
49
+
50
+ #### Logic:
51
+ 1. Calls the external `MpcCore.getUserKey()` function to retrieve the user's AES encryption key using the provided RSA public key and its signed hash.
52
+ 2. Emits the `AccountOnboarded` event, logging the caller's address and the encrypted AES key.
53
+
54
+ #### Example Usage:
55
+
56
+ ```solidity
57
+ function onboardAccount(bytes calldata publicKey, bytes calldata signedEK) public {
58
+ bytes memory accountKey = MpcCore.getUserKey(publicKey, signedEK);
59
+ emit AccountOnboarded(msg.sender, accountKey);
60
+ }
61
+ ```
62
+
63
+ ### External Function Calls:
64
+ - **`MpcCore.getUserKey(publicKey, signedEK)`**:
65
+ - Retrieves the user's AES encryption key, based on the RSA public key and signed hash.
@@ -0,0 +1,11 @@
1
+ {
2
+ "name": "contracts",
3
+ "version": "1.0.0",
4
+ "description": "",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1"
8
+ },
9
+ "author": "",
10
+ "license": "ISC"
11
+ }
@@ -0,0 +1,142 @@
1
+ // SPDX-License-Identifier: MIT
2
+
3
+ pragma solidity ^0.8.19;
4
+
5
+ import "../../utils/mpc/MpcCore.sol";
6
+
7
+ /**
8
+ * @dev Interface of the COTI Private ERC-20 standard.
9
+ */
10
+ interface IPrivateERC20 {
11
+ struct Allowance {
12
+ ctUint64 ciphertext;
13
+ ctUint64 ownerCiphertext;
14
+ ctUint64 spenderCiphertext;
15
+ }
16
+
17
+ /**
18
+ * @dev Emitted when `senderValue/receiverValue` tokens are moved from one account (`from`) to
19
+ * another (`to`).
20
+ *
21
+ * Note that `senderValue/receiverValue` may be zero.
22
+ */
23
+ event Transfer(address indexed from, address indexed to, ctUint64 senderValue, ctUint64 receiverValue);
24
+
25
+ /**
26
+ * @dev Emitted when the allowance of a `spender` for an `owner` is set by
27
+ * a call to {approve}. `ownerValue` and `spenderValue` are the new allowance encrypted with the respective users AES key.
28
+ */
29
+ event Approval(address indexed owner, address indexed spender, ctUint64 ownerValue, ctUint64 spenderValue);
30
+
31
+ /**
32
+ * @dev Returns the value of tokens in existence.
33
+ */
34
+ function totalSupply() external view returns (uint256);
35
+
36
+ /**
37
+ * @dev Returns the value of tokens owned by `account` encrypted with their AES key.
38
+ */
39
+ function balanceOf(address account) external view returns (ctUint64);
40
+
41
+ /**
42
+ * @dev Returns the value of tokens owned by the caller.
43
+ */
44
+ function balanceOf() external returns (gtUint64);
45
+
46
+ /**
47
+ * @dev Reencrypts the caller's balance using the AES key of `addr`.
48
+ */
49
+ function setAccountEncryptionAddress(address addr) external returns (bool);
50
+
51
+ /**
52
+ * @dev Moves a `value` amount of tokens from the caller's account to `to`.
53
+ *
54
+ * Returns an encrypted boolean value indicating whether the operation succeeded.
55
+ *
56
+ * Emits a {Transfer} event.
57
+ */
58
+ function transfer(address to, itUint64 calldata value) external returns (gtBool);
59
+
60
+ /**
61
+ * @dev Moves a `value` amount of tokens from the caller's account to `to`.
62
+ *
63
+ * Returns an encrypted boolean value indicating whether the operation succeeded.
64
+ *
65
+ * Emits a {Transfer} event.
66
+ */
67
+ function transfer(address to, gtUint64 value) external returns (gtBool);
68
+
69
+ /**
70
+ * @dev Returns the remaining number of tokens that `spender` will be
71
+ * allowed to spend on behalf of `owner` through {transferFrom}. This is
72
+ * zero by default.
73
+ *
74
+ * This value changes when {approve} or {transferFrom} are called.
75
+ */
76
+ function allowance(address owner, address spender) external view returns (Allowance memory);
77
+
78
+ /**
79
+ * @dev Returns the remaining number of tokens that `account` will be
80
+ * allowed to spend on behalf of the caller through {transferFrom} (or vice
81
+ * versa depending on the value of `isSpender`). This is zero by default.
82
+ *
83
+ * This value changes when {approve} or {transferFrom} are called.
84
+ */
85
+ function allowance(address account, bool isSpender) external returns (gtUint64);
86
+
87
+ /**
88
+ * @dev Sets a `value` amount of tokens as the allowance of `spender` over the
89
+ * caller's tokens.
90
+ *
91
+ * Returns an encrypted boolean value indicating whether the operation succeeded.
92
+ *
93
+ * IMPORTANT: Beware that changing an allowance with this method brings the risk
94
+ * that someone may use both the old and the new allowance by unfortunate
95
+ * transaction ordering. One possible solution to mitigate this race
96
+ * condition is to first reduce the spender's allowance to 0 and set the
97
+ * desired value afterwards:
98
+ * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
99
+ *
100
+ * Emits an {Approval} event.
101
+ */
102
+ function approve(address spender, itUint64 calldata value) external returns (bool);
103
+
104
+ /**
105
+ * @dev Sets a `value` amount of tokens as the allowance of `spender` over the
106
+ * caller's tokens.
107
+ *
108
+ * Returns an encrypted boolean value indicating whether the operation succeeded.
109
+ *
110
+ * IMPORTANT: Beware that changing an allowance with this method brings the risk
111
+ * that someone may use both the old and the new allowance by unfortunate
112
+ * transaction ordering. One possible solution to mitigate this race
113
+ * condition is to first reduce the spender's allowance to 0 and set the
114
+ * desired value afterwards:
115
+ * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
116
+ *
117
+ * Emits an {Approval} event.
118
+ */
119
+ function approve(address spender, gtUint64 value) external returns (bool);
120
+
121
+ /**
122
+ * @dev Moves a `value` amount of tokens from `from` to `to` using the
123
+ * allowance mechanism. `value` is then deducted from the caller's
124
+ * allowance.
125
+ *
126
+ * Returns an encrypted boolean value indicating whether the operation succeeded.
127
+ *
128
+ * Emits a {Transfer} event.
129
+ */
130
+ function transferFrom(address from, address to, itUint64 calldata value) external returns (gtBool);
131
+
132
+ /**
133
+ * @dev Moves a `value` amount of tokens from `from` to `to` using the
134
+ * allowance mechanism. `value` is then deducted from the caller's
135
+ * allowance.
136
+ *
137
+ * Returns an encrypted boolean value indicating whether the operation succeeded.
138
+ *
139
+ * Emits a {Transfer} event.
140
+ */
141
+ function transferFrom(address from, address to, gtUint64 value) external returns (gtBool);
142
+ }