@coti-io/coti-contracts 0.1.0 → 1.0.2

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 (125) hide show
  1. package/.github/workflows/npm-publish.yml +2 -1
  2. package/CONTRIBUTING.md +2 -2
  3. package/LICENSE +1 -1
  4. package/README.md +18 -35
  5. package/contracts/access/DataPrivacyFramework/extensions/DataPrivacyFrameworkMpc.sol +3 -115
  6. package/contracts/mocks/README.md +1 -1
  7. package/contracts/mocks/utils/mpc/ArithmeticTestsContract.sol +257 -280
  8. package/contracts/mocks/utils/mpc/BitwiseTestsContract.sol +93 -187
  9. package/contracts/mocks/utils/mpc/{Comparison1Tests.Contract.sol → Comparison1TestsContract.sol} +67 -115
  10. package/contracts/mocks/utils/mpc/Comparison2TestsContract.sol +76 -116
  11. package/contracts/mocks/utils/mpc/MinMaxTestsContract.sol +69 -164
  12. package/contracts/mocks/utils/mpc/Miscellaneous1TestsContract.sol +103 -56
  13. package/contracts/mocks/utils/mpc/MiscellaneousTestsContract.sol +270 -0
  14. package/contracts/mocks/utils/mpc/OffboardToUserKeyTestContract.sol +127 -0
  15. package/contracts/mocks/utils/mpc/README.md +12 -12
  16. package/contracts/mocks/utils/mpc/TransferScalarTestsContract.sol +54 -211
  17. package/contracts/mocks/utils/mpc/TransferTestsContract.sol +165 -640
  18. package/contracts/mocks/utils/mpc/TransferWithAllowance64_16TestsContract.sol +222 -0
  19. package/contracts/mocks/utils/mpc/TransferWithAllowance64_32TestsContract.sol +222 -0
  20. package/contracts/mocks/utils/mpc/TransferWithAllowance64_64TestsContract.sol +223 -0
  21. package/contracts/mocks/utils/mpc/TransferWithAllowance64_8TestsContract.sol +222 -0
  22. package/contracts/mocks/utils/mpc/TransferWithAllowanceScalarTestsContract.sol +265 -0
  23. package/contracts/mocks/utils/mpc/TransferWithAllowanceTestsContract.sol +281 -0
  24. package/contracts/onboard/AccountOnboard.sol +3 -3
  25. package/contracts/token/PrivateERC20/PrivateERC20.sol +1 -1
  26. package/contracts/token/PrivateERC721/IERC721Errors.sol +57 -0
  27. package/contracts/token/PrivateERC721/PrivateERC721.sol +1 -1
  28. package/contracts/utils/mpc/MpcCore.sol +2835 -988
  29. package/contracts/utils/mpc/MpcInterface.sol +6 -4
  30. package/hardhat.config.ts +17 -6
  31. package/package.json +20 -4
  32. package/test/token/PrivateERC20/PrivateERC20.test.ts +2 -2
  33. package/test/utils/accounts.ts +1 -1
  34. package/test/utils/mpc/Precompile.test.ts +42 -39
  35. package/typechain-types/contracts/mocks/utils/mpc/ArithmeticTestsContract.sol/ArithmeticTestsContract.ts +374 -0
  36. package/typechain-types/contracts/mocks/utils/mpc/ArithmeticTestsContract.sol/PrecompilesArythmeticTestsContract.ts +374 -0
  37. package/typechain-types/contracts/mocks/utils/mpc/ArithmeticTestsContract.sol/index.ts +5 -0
  38. package/typechain-types/contracts/mocks/utils/mpc/ArithmeticTestsContract.ts +96 -10
  39. package/typechain-types/contracts/mocks/utils/mpc/BitwiseTestsContract.ts +45 -5
  40. package/typechain-types/contracts/mocks/utils/mpc/Comparison1TestsContract.ts +374 -0
  41. package/typechain-types/contracts/mocks/utils/mpc/Comparison2TestsContract.ts +45 -5
  42. package/typechain-types/contracts/mocks/utils/mpc/MinMaxTestsContract.ts +25 -5
  43. package/typechain-types/contracts/mocks/utils/mpc/Miscellaneous1TestsContract.ts +62 -0
  44. package/typechain-types/contracts/mocks/utils/mpc/MiscellaneousTestsContract.ts +396 -0
  45. package/typechain-types/contracts/mocks/utils/mpc/OffboardToUserKeyTestContract.ts +251 -0
  46. package/typechain-types/contracts/mocks/utils/mpc/OffboardToUserKeyTestsContract.sol/OffboardToUserKeyTestContract.ts +11 -8
  47. package/typechain-types/contracts/mocks/utils/mpc/TransferScalarTestsContract.ts +15 -15
  48. package/typechain-types/contracts/mocks/utils/mpc/TransferTestsContract.ts +15 -15
  49. package/typechain-types/contracts/mocks/utils/mpc/TransferWithAllowance64TestsContract.sol/TransferWithAllowance64TestsContract.ts +251 -0
  50. package/typechain-types/contracts/mocks/utils/mpc/TransferWithAllowance64TestsContract.sol/TransferWithAllowanceTestsContract.ts +250 -0
  51. package/typechain-types/contracts/mocks/utils/mpc/TransferWithAllowance64TestsContract.sol/index.ts +5 -0
  52. package/typechain-types/contracts/mocks/utils/mpc/TransferWithAllowance64TestsContract.ts +389 -0
  53. package/typechain-types/contracts/mocks/utils/mpc/TransferWithAllowance64_16TestsContract.ts +391 -0
  54. package/typechain-types/contracts/mocks/utils/mpc/TransferWithAllowance64_32TestsContract.ts +391 -0
  55. package/typechain-types/contracts/mocks/utils/mpc/TransferWithAllowance64_64TestsContract.sol/TransferWithAllowance64_64TestsContract.ts +391 -0
  56. package/typechain-types/contracts/mocks/utils/mpc/TransferWithAllowance64_64TestsContract.sol/TransferWithAllowance64_8TestsContract.ts +391 -0
  57. package/typechain-types/contracts/mocks/utils/mpc/TransferWithAllowance64_64TestsContract.sol/index.ts +5 -0
  58. package/typechain-types/contracts/mocks/utils/mpc/TransferWithAllowance64_64TestsContract.ts +391 -0
  59. package/typechain-types/contracts/mocks/utils/mpc/TransferWithAllowance64_8TestsContract.ts +391 -0
  60. package/typechain-types/contracts/mocks/utils/mpc/TransferWithAllowanceScalarTestsContract.ts +306 -0
  61. package/typechain-types/contracts/mocks/utils/mpc/TransferWithAllowanceTestsContract.sol/TransferTestsContract.ts +125 -0
  62. package/typechain-types/contracts/mocks/utils/mpc/TransferWithAllowanceTestsContract.sol/TransferWithAllowanceTestsContract.ts +125 -0
  63. package/typechain-types/contracts/mocks/utils/mpc/TransferWithAllowanceTestsContract.sol/index.ts +5 -0
  64. package/typechain-types/contracts/mocks/utils/mpc/TransferWithAllowanceTestsContract.ts +296 -0
  65. package/typechain-types/contracts/mocks/utils/mpc/index.ts +9 -6
  66. package/typechain-types/contracts/onboard/AccountOnboard.ts +9 -4
  67. package/typechain-types/contracts/token/PrivateERC721/IERC721Errors.ts +69 -0
  68. package/typechain-types/contracts/token/PrivateERC721/index.ts +1 -0
  69. package/typechain-types/contracts/utils/mpc/MpcCore.ts +84 -0
  70. package/typechain-types/contracts/utils/mpc/MpcInterface.sol/ExtendedOperations.ts +81 -40
  71. package/typechain-types/contracts/utils/mpc/index.ts +1 -0
  72. package/typechain-types/factories/contracts/mocks/access/DataPrivacyFramework/DataPrivacyFrameworkMock__factory.ts +1 -1
  73. package/typechain-types/factories/contracts/mocks/token/PrivateERC20/PrivateERC20Mock__factory.ts +1 -1
  74. package/typechain-types/factories/contracts/mocks/token/PrivateERC721/PrivateERC721URIStorageMock__factory.ts +1 -1
  75. package/typechain-types/factories/contracts/mocks/utils/mpc/ArithmeticTestsContract.sol/ArithmeticTestsContract__factory.ts +387 -0
  76. package/typechain-types/factories/contracts/mocks/utils/mpc/ArithmeticTestsContract.sol/PrecompilesArythmeticTestsContract__factory.ts +388 -0
  77. package/typechain-types/factories/contracts/mocks/utils/mpc/ArithmeticTestsContract.sol/index.ts +5 -0
  78. package/typechain-types/factories/contracts/mocks/utils/mpc/ArithmeticTestsContract__factory.ts +92 -7
  79. package/typechain-types/factories/contracts/mocks/utils/mpc/BitwiseTestsContract__factory.ts +38 -2
  80. package/typechain-types/factories/contracts/mocks/utils/mpc/Comparison1Tests.Contract.sol/Comparison1TestsContract__factory.ts +1 -1
  81. package/typechain-types/factories/contracts/mocks/utils/mpc/Comparison1TestsContract__factory.ts +387 -0
  82. package/typechain-types/factories/contracts/mocks/utils/mpc/Comparison2TestsContract__factory.ts +38 -2
  83. package/typechain-types/factories/contracts/mocks/utils/mpc/MinMaxTestsContract__factory.ts +15 -2
  84. package/typechain-types/factories/contracts/mocks/utils/mpc/Miscellaneous1TestsContract__factory.ts +66 -1
  85. package/typechain-types/factories/contracts/mocks/utils/mpc/Miscellaneous2TestsContract__factory.ts +1 -1
  86. package/typechain-types/factories/contracts/mocks/utils/mpc/MiscellaneousTestsContract__factory.ts +424 -0
  87. package/typechain-types/factories/contracts/mocks/utils/mpc/OffboardToUserKeyTestContract__factory.ts +285 -0
  88. package/typechain-types/factories/contracts/mocks/utils/mpc/OffboardToUserKeyTestsContract.sol/OffboardToUserKeyTestContract__factory.ts +19 -3
  89. package/typechain-types/factories/contracts/mocks/utils/mpc/ShiftTestsContract__factory.ts +1 -1
  90. package/typechain-types/factories/contracts/mocks/utils/mpc/StringTestsContract__factory.ts +1 -1
  91. package/typechain-types/factories/contracts/mocks/utils/mpc/TransferScalarTestsContract__factory.ts +4 -4
  92. package/typechain-types/factories/contracts/mocks/utils/mpc/TransferTestsContract__factory.ts +4 -4
  93. package/typechain-types/factories/contracts/mocks/utils/mpc/TransferWithAllowance64TestsContract.sol/TransferWithAllowance64TestsContract__factory.ts +294 -0
  94. package/typechain-types/factories/contracts/mocks/utils/mpc/TransferWithAllowance64TestsContract.sol/TransferWithAllowanceTestsContract__factory.ts +292 -0
  95. package/typechain-types/factories/contracts/mocks/utils/mpc/TransferWithAllowance64TestsContract.sol/index.ts +5 -0
  96. package/typechain-types/factories/contracts/mocks/utils/mpc/TransferWithAllowance64TestsContract__factory.ts +720 -0
  97. package/typechain-types/factories/contracts/mocks/utils/mpc/TransferWithAllowance64_16TestsContract__factory.ts +724 -0
  98. package/typechain-types/factories/contracts/mocks/utils/mpc/TransferWithAllowance64_32TestsContract__factory.ts +724 -0
  99. package/typechain-types/factories/contracts/mocks/utils/mpc/TransferWithAllowance64_64TestsContract.sol/TransferWithAllowance64_64TestsContract__factory.ts +724 -0
  100. package/typechain-types/factories/contracts/mocks/utils/mpc/TransferWithAllowance64_64TestsContract.sol/TransferWithAllowance64_8TestsContract__factory.ts +724 -0
  101. package/typechain-types/factories/contracts/mocks/utils/mpc/TransferWithAllowance64_64TestsContract.sol/index.ts +5 -0
  102. package/typechain-types/factories/contracts/mocks/utils/mpc/TransferWithAllowance64_64TestsContract__factory.ts +724 -0
  103. package/typechain-types/factories/contracts/mocks/utils/mpc/TransferWithAllowance64_8TestsContract__factory.ts +724 -0
  104. package/typechain-types/factories/contracts/mocks/utils/mpc/TransferWithAllowanceScalarTestsContract__factory.ts +507 -0
  105. package/typechain-types/factories/contracts/mocks/utils/mpc/TransferWithAllowanceTestsContract.sol/TransferTestsContract__factory.ts +150 -0
  106. package/typechain-types/factories/contracts/mocks/utils/mpc/TransferWithAllowanceTestsContract.sol/TransferWithAllowanceTestsContract__factory.ts +150 -0
  107. package/typechain-types/factories/contracts/mocks/utils/mpc/TransferWithAllowanceTestsContract.sol/index.ts +5 -0
  108. package/typechain-types/factories/contracts/mocks/utils/mpc/TransferWithAllowanceTestsContract__factory.ts +434 -0
  109. package/typechain-types/factories/contracts/mocks/utils/mpc/index.ts +9 -4
  110. package/typechain-types/factories/contracts/mocks/wallet/PrivateERC20Wallet/PrivateERC20WalletMock__factory.ts +1 -1
  111. package/typechain-types/factories/contracts/onboard/AccountOnboard__factory.ts +8 -2
  112. package/typechain-types/factories/contracts/token/PrivateERC721/IERC721Errors__factory.ts +128 -0
  113. package/typechain-types/factories/contracts/token/PrivateERC721/index.ts +1 -0
  114. package/typechain-types/factories/contracts/utils/mpc/MpcCore__factory.ts +77 -0
  115. package/typechain-types/factories/contracts/utils/mpc/MpcInterface.sol/ExtendedOperations__factory.ts +124 -61
  116. package/typechain-types/factories/contracts/utils/mpc/index.ts +1 -0
  117. package/typechain-types/hardhat.d.ts +152 -26
  118. package/typechain-types/index.ts +20 -8
  119. package/contracts/access/DataPrivacyFramework/README.md +0 -68
  120. package/contracts/mocks/utils/mpc/Miscellaneous2TestsContract.sol +0 -448
  121. package/contracts/mocks/utils/mpc/OffboardToUserKeyTestsContract.sol +0 -81
  122. package/contracts/mocks/utils/mpc/ShiftTestsContract.sol +0 -311
  123. package/contracts/token/PrivateERC20/README.md +0 -104
  124. package/contracts/token/PrivateERC721/README.md +0 -282
  125. package/contracts/utils/mpc/README.md +0 -82
@@ -12,15 +12,16 @@ interface ExtendedOperations {
12
12
  function RandBoundedBits(bytes1 metaData, uint8 numBits) external returns (uint256 result);
13
13
 
14
14
  function Add(bytes3 metaData, uint256 lhs, uint256 rhs) external returns (uint256 result);
15
+ function CheckedAdd(bytes3 metaData, uint256 lhs, uint256 rhs) external returns (uint256 overflowBit, uint256 result);
15
16
  function Sub(bytes3 metaData, uint256 lhs, uint256 rhs) external returns (uint256 result);
17
+ function CheckedSub(bytes3 metaData, uint256 lhs, uint256 rhs) external returns (uint256 overflowBit, uint256 result);
16
18
  function Mul(bytes3 metaData, uint256 lhs, uint256 rhs) external returns (uint256 result);
19
+ function CheckedMul(bytes3 metaData, uint256 lhs, uint256 rhs) external returns (uint256 overflowBit, uint256 result);
17
20
  function Div(bytes3 metaData, uint256 lhs, uint256 rhs) external returns (uint256 result);
18
21
  function Rem(bytes3 metaData, uint256 lhs, uint256 rhs) external returns (uint256 result);
19
22
  function And(bytes3 metaData, uint256 lhs, uint256 rhs) external returns (uint256 result);
20
23
  function Or(bytes3 metaData, uint256 lhs, uint256 rhs) external returns (uint256 result);
21
24
  function Xor(bytes3 metaData, uint256 lhs, uint256 rhs) external returns (uint256 result);
22
- function Shl(bytes3 metaData, uint256 lhs, uint256 rhs) external returns (uint256 result);
23
- function Shr(bytes3 metaData, uint256 lhs, uint256 rhs) external returns (uint256 result);
24
25
  function Eq(bytes3 metaData, uint256 lhs, uint256 rhs) external returns (uint256 result);
25
26
  function Ne(bytes3 metaData, uint256 lhs, uint256 rhs) external returns (uint256 result);
26
27
  function Ge(bytes3 metaData, uint256 lhs, uint256 rhs) external returns (uint256 result);
@@ -33,9 +34,10 @@ interface ExtendedOperations {
33
34
  function Mux(bytes3 metaData, uint256 bit, uint256 a,uint256 b) external returns (uint256 result);
34
35
  function Not(bytes1 metaData, uint256 a) external returns (uint256 result);
35
36
  function Transfer(bytes4 metaData, uint256 a, uint256 b, uint256 amount) external returns (uint256 new_a, uint256 new_b, uint256 res);
36
- function TransferWithAllowance(bytes4 metaData, uint256 a, uint256 b, uint256 amount, uint256 allowance) external returns (uint256 new_a, uint256 new_b, uint256 res, uint256 new_allowance);
37
+ function TransferWithAllowance(bytes5 metaData, uint256 a, uint256 b, uint256 amount, uint256 allowance) external returns (uint256 new_a, uint256 new_b, uint256 res, uint256 new_allowance);
37
38
  function ValidateCiphertext(bytes1 metaData, uint256 ciphertext, bytes calldata signature) external returns (uint256 result);
38
- function GetUserKey(bytes calldata signedEK) external view returns (bytes memory encryptedKey);
39
+ function GetUserKey(bytes calldata signedEK) external returns (bytes memory encryptedKey);
40
+ function DeleteUserKey(bytes calldata signature) external returns (bool);
39
41
  }
40
42
 
41
43
  address constant MPC_PRECOMPILE = address(0x0000000000000000000000000000000000000064);
package/hardhat.config.ts CHANGED
@@ -5,14 +5,25 @@ import dotenv from "dotenv"
5
5
  dotenv.config()
6
6
 
7
7
  const config: HardhatUserConfig = {
8
- defaultNetwork: "devnet",
9
- solidity: "0.8.20",
8
+ defaultNetwork: "testnet",
9
+ solidity: {
10
+ version: "0.8.19",
11
+ settings: {
12
+ optimizer: {
13
+ enabled: true,
14
+ runs: 10000
15
+ }
16
+ }
17
+ },
10
18
  networks: {
11
- devnet: {
12
- url: "https://devnet.coti.io/rpc",
13
- chainId: 13068200,
19
+ testnet: {
20
+ url: "https://testnet.coti.io/rpc",
21
+ chainId: 7082400,
14
22
  },
15
- }
23
+ },
24
+ mocha: {
25
+ timeout: 100000000
26
+ },
16
27
  }
17
28
 
18
29
  export default config;
package/package.json CHANGED
@@ -1,14 +1,30 @@
1
1
  {
2
2
  "name": "@coti-io/coti-contracts",
3
- "version": "0.1.0",
4
- "description": "",
3
+ "version": "1.0.2",
4
+ "description": "A library for smart contract development on the COTI network.",
5
+ "author": "COTI Development",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git://github.com/coti-io/coti-contracts.git"
9
+ },
10
+ "homepage": "https://docs.coti.io/coti-v2-documentation/build-on-coti/tools/contracts-library",
11
+ "keywords": [
12
+ "coti",
13
+ "privacy",
14
+ "ethereum",
15
+ "blockchain",
16
+ "web3",
17
+ "garbled-circuits",
18
+ "l2",
19
+ "on-chain-compute"
20
+ ],
5
21
  "devDependencies": {
6
22
  "@nomicfoundation/hardhat-toolbox": "^5.0.0",
7
23
  "hardhat": "^2.22.8"
8
24
  },
9
25
  "dependencies": {
10
- "@coti-io/coti-ethers": "^0.1.1-b",
11
- "@openzeppelin/contracts": "^5.0.2",
26
+ "@coti-io/coti-ethers": "^1.0.3",
27
+ "@openzeppelin/contracts": "^4.9.6",
12
28
  "dotenv": "^16.4.5"
13
29
  }
14
30
  }
@@ -50,8 +50,8 @@ describe("Private ERC20", function () {
50
50
  await expect(await contract.symbol()).to.equal("PE20M");
51
51
  })
52
52
 
53
- it('has 2 decimals', async function () {
54
- await expect(await contract.decimals()).to.equal(2n);
53
+ it('has 6 decimals', async function () {
54
+ await expect(await contract.decimals()).to.equal(6n);
55
55
  })
56
56
  })
57
57
 
@@ -4,7 +4,7 @@ import { CotiNetwork, getDefaultProvider, parseEther, Wallet } from "@coti-io/co
4
4
  let pks = process.env.SIGNING_KEYS ? process.env.SIGNING_KEYS.split(",") : []
5
5
 
6
6
  export async function setupAccounts() {
7
- const provider = getDefaultProvider(CotiNetwork.Devnet);
7
+ const provider = getDefaultProvider(CotiNetwork.Testnet);
8
8
 
9
9
  if (pks.length == 0) {
10
10
  const key1 = Wallet.createRandom(provider)
@@ -15,13 +15,13 @@ function buildTest(
15
15
  it(`${contractName}.${func}(${params}) should return ${expectedResults}`, async function () {
16
16
  const [owner] = await setupAccounts()
17
17
 
18
- const factory = await hre.ethers.getContractFactory(contractName, owner)
18
+ const factory = await hre.ethers.getContractFactory(contractName, owner as any)
19
19
  const contract = await factory.deploy({ gasLimit })
20
20
  await contract.waitForDeployment()
21
21
 
22
22
  await (await contract.getFunction(func)(...params, { gasLimit })).wait()
23
23
  const result = await contract.getFunction(resFunc)()
24
- if (resFunc === "getRandom") {
24
+ if (resFunc === "getRandom" || resFunc === "getRandomBounded") {
25
25
  expect(result).to.not.equal(expectedResults[0])
26
26
  last_random_value = result
27
27
  } else if (expectedResults.length === 1) {
@@ -36,14 +36,18 @@ function buildTestWithUser(contractName: string, func: string, resFunc: string,
36
36
  it(`${contractName}.${func}(${params}, <address>) should return the correct user decrypted value`, async function () {
37
37
  const [owner] = await setupAccounts()
38
38
 
39
- const factory = await hre.ethers.getContractFactory(contractName, owner)
39
+ const factory = await hre.ethers.getContractFactory(contractName, owner as any)
40
40
  const contract = await factory.deploy({ gasLimit })
41
41
  await contract.waitForDeployment()
42
42
 
43
43
  await (await contract.getFunction(func)(param, owner.address, { gasLimit: 12000000 })).wait()
44
44
  const results = await contract.getFunction(resFunc)()
45
- for (const result of results) {
46
- expect(await owner.decryptValue(result)).to.equal(param)
45
+ for (let i = 0; i < results.length; i++) {
46
+ if (i === 0) {
47
+ expect(Boolean(await owner.decryptValue(results[i]))).to.equal(true)
48
+ } else {
49
+ expect(await owner.decryptValue(results[i])).to.equal(param)
50
+ }
47
51
  }
48
52
  })
49
53
  }
@@ -56,46 +60,45 @@ const bool_a = true
56
60
  const bool_b = false
57
61
  const [a, b] = params
58
62
  describe("Precompile", function () {
59
- buildTest("ArithmeticTestsContract", "addTest", "getResult", params, a + b)
60
- buildTest("ArithmeticTestsContract", "subTest", "getResult", params, a - b)
61
- buildTest("ArithmeticTestsContract", "mulTest", "getResult16", params, a * b)
62
-
63
- buildTest("Miscellaneous2TestsContract", "divTest", "getResult", params, a / b)
64
- buildTest("Miscellaneous2TestsContract", "remTest", "getResult", params, a % b)
65
-
66
- buildTest("BitwiseTestsContract", "andTest", "getResult", params, a & b)
67
- buildTest("BitwiseTestsContract", "orTest", "getResult", params, a | b)
68
- buildTest("BitwiseTestsContract", "xorTest", "getResult", params, a ^ b)
69
-
70
- buildTest(
71
- "ShiftTestsContract",
72
- "shlTest",
73
- "getAllShiftResults",
74
- [a, shift],
75
- ...[2, 4, 8, 16].map((x) => BigInt(a << shift) & BigInt(`0x${"f".repeat(x)}`))
76
- )
77
- buildTest("ShiftTestsContract", "shrTest", "getResult", params, a >> b)
78
-
79
- buildTest("MinMaxTestsContract", "minTest", "getResult", params, Math.min(a, b))
80
- buildTest("MinMaxTestsContract", "maxTest", "getResult", params, Math.max(a, b))
81
- buildTest("Comparison2TestsContract", "eqTest", "getResult", params, a == b)
82
- buildTest("Comparison2TestsContract", "neTest", "getResult", params, a != b)
83
- buildTest("Comparison2TestsContract", "geTest", "getResult", params, a >= b)
84
- buildTest("Comparison1TestsContract", "gtTest", "getResult", params, a > b)
85
- buildTest("Comparison1TestsContract", "leTest", "getResult", params, a <= b)
86
- buildTest("Comparison1TestsContract", "ltTest", "getResult", params, a < b)
87
- buildTest("Miscellaneous2TestsContract", "muxTest", "getResult", [bit, a, b], bit === false ? a : b)
63
+ buildTest("ArithmeticTestsContract", "addTest", "getAddResult", params, a + b)
64
+ buildTest("ArithmeticTestsContract", "checkedAddTest", "getAddResult", params, a + b)
65
+ buildTest("ArithmeticTestsContract", "subTest", "getSubResult", params, a - b)
66
+ buildTest("ArithmeticTestsContract", "checkedSubTest", "getSubResult", params, a - b)
67
+ buildTest("ArithmeticTestsContract", "mulTest", "getMulResult", params, a * b)
68
+ buildTest("ArithmeticTestsContract", "checkedMulTest", "getMulResult", params, a * b)
69
+
70
+ buildTest("MiscellaneousTestsContract", "divTest", "getDivResult", params, a / b)
71
+ buildTest("MiscellaneousTestsContract", "remTest", "getRemResult", params, a % b)
72
+
73
+ buildTest("BitwiseTestsContract", "andTest", "getAndResult", params, a & b)
74
+ buildTest("BitwiseTestsContract", "orTest", "getOrResult", params, a | b)
75
+ buildTest("BitwiseTestsContract", "xorTest", "getXorResult", params, a ^ b)
76
+
77
+ buildTest("MinMaxTestsContract", "minTest", "getMinResult", params, Math.min(a, b))
78
+ buildTest("MinMaxTestsContract", "maxTest", "getMaxResult", params, Math.max(a, b))
79
+ buildTest("Comparison2TestsContract", "eqTest", "getEqResult", params, a == b)
80
+ buildTest("Comparison2TestsContract", "neTest", "getNeResult", params, a != b)
81
+ buildTest("Comparison2TestsContract", "geTest", "getGeResult", params, a >= b)
82
+ buildTest("Comparison1TestsContract", "gtTest", "getGtResult", params, a > b)
83
+ buildTest("Comparison1TestsContract", "leTest", "getLeResult", params, a <= b)
84
+ buildTest("Comparison1TestsContract", "ltTest", "getLtResult", params, a < b)
85
+ buildTest("MiscellaneousTestsContract", "muxTest", "getMuxResult", [bit, a, b], bit === false ? a : b)
88
86
 
89
87
  buildTest("TransferTestsContract", "transferTest", "getResults", [a, b, b], a - b, b + b, true)
90
88
  buildTest("TransferScalarTestsContract", "transferScalarTest", "getResults", [a, b, b], a - b, b + b, true)
91
-
92
- buildTest("Miscellaneous2TestsContract", "offboardOnboardTest", "getResult", [a, a, a, a], a)
93
- buildTest("Miscellaneous2TestsContract", "notTest", "getBoolResult", [!!a], !a)
89
+ buildTest("TransferWithAllowanceTestsContract", "transferWithAllowanceTest", "getResults", [a, b, b, b], a - b, b + b, true, 0)
90
+ buildTest("TransferWithAllowance64_8TestsContract", "transferWithAllowance64Test", "getResults", [a, b, b, b], a - b, b + b, true, 0)
91
+ buildTest("TransferWithAllowance64_16TestsContract", "transferWithAllowance64Test", "getResults", [a, b, b, b], a - b, b + b, true, 0)
92
+ buildTest("TransferWithAllowance64_32TestsContract", "transferWithAllowance64Test", "getResults", [a, b, b, b], a - b, b + b, true, 0)
93
+ buildTest("TransferWithAllowance64_64TestsContract", "transferWithAllowance64Test", "getResults", [a, b, b, b], a - b, b + b, true, 0)
94
+ buildTest("TransferWithAllowanceScalarTestsContract", "transferWithAllowanceScalarTest", "getResults", [a, b, b, b], a - b, b + b, true, 0)
95
+ buildTest("OffboardToUserKeyTestContract", "offboardOnboardTest", "getOnboardOffboardResult", [a, a, a, a], a)
96
+ buildTest("MiscellaneousTestsContract", "notTest", "getBoolResult", [!!a], !a)
94
97
 
95
98
  buildTestWithUser("OffboardToUserKeyTestContract", "offboardToUserTest", "getCTs", a)
96
-
99
+ buildTestWithUser("OffboardToUserKeyTestContract", "offboardCombinedTest", "getCTs", a)
97
100
  buildTest("Miscellaneous1TestsContract", "randomTest", "getRandom", [], last_random_value)
98
- buildTest("Miscellaneous1TestsContract", "randomBoundedTest", "getRandom", [numBits], last_random_value)
101
+ buildTest("Miscellaneous1TestsContract", "randomBoundedTest", "getRandomBounded", [numBits], last_random_value)
99
102
  buildTest(
100
103
  "Miscellaneous1TestsContract",
101
104
  "booleanTest",
@@ -0,0 +1,374 @@
1
+ /* Autogenerated file. Do not edit manually. */
2
+ /* tslint:disable */
3
+ /* eslint-disable */
4
+ import type {
5
+ BaseContract,
6
+ BigNumberish,
7
+ BytesLike,
8
+ FunctionFragment,
9
+ Result,
10
+ Interface,
11
+ ContractRunner,
12
+ ContractMethod,
13
+ Listener,
14
+ } from "ethers";
15
+ import type {
16
+ TypedContractEvent,
17
+ TypedDeferredTopicFilter,
18
+ TypedEventLog,
19
+ TypedListener,
20
+ TypedContractMethod,
21
+ } from "../../../../../common";
22
+
23
+ export declare namespace ArithmeticTestsContract {
24
+ export type Check16Struct = {
25
+ res16_16: BigNumberish;
26
+ res8_16: BigNumberish;
27
+ res16_8: BigNumberish;
28
+ };
29
+
30
+ export type Check16StructOutput = [
31
+ res16_16: bigint,
32
+ res8_16: bigint,
33
+ res16_8: bigint
34
+ ] & { res16_16: bigint; res8_16: bigint; res16_8: bigint };
35
+
36
+ export type Check32Struct = {
37
+ res32_32: BigNumberish;
38
+ res8_32: BigNumberish;
39
+ res32_8: BigNumberish;
40
+ res16_32: BigNumberish;
41
+ res32_16: BigNumberish;
42
+ };
43
+
44
+ export type Check32StructOutput = [
45
+ res32_32: bigint,
46
+ res8_32: bigint,
47
+ res32_8: bigint,
48
+ res16_32: bigint,
49
+ res32_16: bigint
50
+ ] & {
51
+ res32_32: bigint;
52
+ res8_32: bigint;
53
+ res32_8: bigint;
54
+ res16_32: bigint;
55
+ res32_16: bigint;
56
+ };
57
+
58
+ export type Check64Struct = {
59
+ res64_64: BigNumberish;
60
+ res8_64: BigNumberish;
61
+ res64_8: BigNumberish;
62
+ res16_64: BigNumberish;
63
+ res64_16: BigNumberish;
64
+ res32_64: BigNumberish;
65
+ res64_32: BigNumberish;
66
+ };
67
+
68
+ export type Check64StructOutput = [
69
+ res64_64: bigint,
70
+ res8_64: bigint,
71
+ res64_8: bigint,
72
+ res16_64: bigint,
73
+ res64_16: bigint,
74
+ res32_64: bigint,
75
+ res64_32: bigint
76
+ ] & {
77
+ res64_64: bigint;
78
+ res8_64: bigint;
79
+ res64_8: bigint;
80
+ res16_64: bigint;
81
+ res64_16: bigint;
82
+ res32_64: bigint;
83
+ res64_32: bigint;
84
+ };
85
+
86
+ export type AllGTCastingValuesStruct = {
87
+ a8_s: BigNumberish;
88
+ b8_s: BigNumberish;
89
+ a16_s: BigNumberish;
90
+ b16_s: BigNumberish;
91
+ a32_s: BigNumberish;
92
+ b32_s: BigNumberish;
93
+ a64_s: BigNumberish;
94
+ b64_s: BigNumberish;
95
+ };
96
+
97
+ export type AllGTCastingValuesStructOutput = [
98
+ a8_s: bigint,
99
+ b8_s: bigint,
100
+ a16_s: bigint,
101
+ b16_s: bigint,
102
+ a32_s: bigint,
103
+ b32_s: bigint,
104
+ a64_s: bigint,
105
+ b64_s: bigint
106
+ ] & {
107
+ a8_s: bigint;
108
+ b8_s: bigint;
109
+ a16_s: bigint;
110
+ b16_s: bigint;
111
+ a32_s: bigint;
112
+ b32_s: bigint;
113
+ a64_s: bigint;
114
+ b64_s: bigint;
115
+ };
116
+ }
117
+
118
+ export interface ArithmeticTestsContractInterface extends Interface {
119
+ getFunction(
120
+ nameOrSignature:
121
+ | "addTest"
122
+ | "decryptAndCompareResults16"
123
+ | "decryptAndCompareResults32"
124
+ | "decryptAndCompareResults64"
125
+ | "getAddResult"
126
+ | "getMulResult"
127
+ | "getSubResult"
128
+ | "mulTest"
129
+ | "setPublicValues"
130
+ | "subTest"
131
+ ): FunctionFragment;
132
+
133
+ encodeFunctionData(
134
+ functionFragment: "addTest",
135
+ values: [BigNumberish, BigNumberish]
136
+ ): string;
137
+ encodeFunctionData(
138
+ functionFragment: "decryptAndCompareResults16",
139
+ values: [ArithmeticTestsContract.Check16Struct]
140
+ ): string;
141
+ encodeFunctionData(
142
+ functionFragment: "decryptAndCompareResults32",
143
+ values: [ArithmeticTestsContract.Check32Struct]
144
+ ): string;
145
+ encodeFunctionData(
146
+ functionFragment: "decryptAndCompareResults64",
147
+ values: [ArithmeticTestsContract.Check64Struct]
148
+ ): string;
149
+ encodeFunctionData(
150
+ functionFragment: "getAddResult",
151
+ values?: undefined
152
+ ): string;
153
+ encodeFunctionData(
154
+ functionFragment: "getMulResult",
155
+ values?: undefined
156
+ ): string;
157
+ encodeFunctionData(
158
+ functionFragment: "getSubResult",
159
+ values?: undefined
160
+ ): string;
161
+ encodeFunctionData(
162
+ functionFragment: "mulTest",
163
+ values: [BigNumberish, BigNumberish]
164
+ ): string;
165
+ encodeFunctionData(
166
+ functionFragment: "setPublicValues",
167
+ values: [
168
+ ArithmeticTestsContract.AllGTCastingValuesStruct,
169
+ BigNumberish,
170
+ BigNumberish
171
+ ]
172
+ ): string;
173
+ encodeFunctionData(
174
+ functionFragment: "subTest",
175
+ values: [BigNumberish, BigNumberish]
176
+ ): string;
177
+
178
+ decodeFunctionResult(functionFragment: "addTest", data: BytesLike): Result;
179
+ decodeFunctionResult(
180
+ functionFragment: "decryptAndCompareResults16",
181
+ data: BytesLike
182
+ ): Result;
183
+ decodeFunctionResult(
184
+ functionFragment: "decryptAndCompareResults32",
185
+ data: BytesLike
186
+ ): Result;
187
+ decodeFunctionResult(
188
+ functionFragment: "decryptAndCompareResults64",
189
+ data: BytesLike
190
+ ): Result;
191
+ decodeFunctionResult(
192
+ functionFragment: "getAddResult",
193
+ data: BytesLike
194
+ ): Result;
195
+ decodeFunctionResult(
196
+ functionFragment: "getMulResult",
197
+ data: BytesLike
198
+ ): Result;
199
+ decodeFunctionResult(
200
+ functionFragment: "getSubResult",
201
+ data: BytesLike
202
+ ): Result;
203
+ decodeFunctionResult(functionFragment: "mulTest", data: BytesLike): Result;
204
+ decodeFunctionResult(
205
+ functionFragment: "setPublicValues",
206
+ data: BytesLike
207
+ ): Result;
208
+ decodeFunctionResult(functionFragment: "subTest", data: BytesLike): Result;
209
+ }
210
+
211
+ export interface ArithmeticTestsContract extends BaseContract {
212
+ connect(runner?: ContractRunner | null): ArithmeticTestsContract;
213
+ waitForDeployment(): Promise<this>;
214
+
215
+ interface: ArithmeticTestsContractInterface;
216
+
217
+ queryFilter<TCEvent extends TypedContractEvent>(
218
+ event: TCEvent,
219
+ fromBlockOrBlockhash?: string | number | undefined,
220
+ toBlock?: string | number | undefined
221
+ ): Promise<Array<TypedEventLog<TCEvent>>>;
222
+ queryFilter<TCEvent extends TypedContractEvent>(
223
+ filter: TypedDeferredTopicFilter<TCEvent>,
224
+ fromBlockOrBlockhash?: string | number | undefined,
225
+ toBlock?: string | number | undefined
226
+ ): Promise<Array<TypedEventLog<TCEvent>>>;
227
+
228
+ on<TCEvent extends TypedContractEvent>(
229
+ event: TCEvent,
230
+ listener: TypedListener<TCEvent>
231
+ ): Promise<this>;
232
+ on<TCEvent extends TypedContractEvent>(
233
+ filter: TypedDeferredTopicFilter<TCEvent>,
234
+ listener: TypedListener<TCEvent>
235
+ ): Promise<this>;
236
+
237
+ once<TCEvent extends TypedContractEvent>(
238
+ event: TCEvent,
239
+ listener: TypedListener<TCEvent>
240
+ ): Promise<this>;
241
+ once<TCEvent extends TypedContractEvent>(
242
+ filter: TypedDeferredTopicFilter<TCEvent>,
243
+ listener: TypedListener<TCEvent>
244
+ ): Promise<this>;
245
+
246
+ listeners<TCEvent extends TypedContractEvent>(
247
+ event: TCEvent
248
+ ): Promise<Array<TypedListener<TCEvent>>>;
249
+ listeners(eventName?: string): Promise<Array<Listener>>;
250
+ removeAllListeners<TCEvent extends TypedContractEvent>(
251
+ event?: TCEvent
252
+ ): Promise<this>;
253
+
254
+ addTest: TypedContractMethod<
255
+ [a: BigNumberish, b: BigNumberish],
256
+ [bigint],
257
+ "nonpayable"
258
+ >;
259
+
260
+ decryptAndCompareResults16: TypedContractMethod<
261
+ [check16: ArithmeticTestsContract.Check16Struct],
262
+ [bigint],
263
+ "nonpayable"
264
+ >;
265
+
266
+ decryptAndCompareResults32: TypedContractMethod<
267
+ [check32: ArithmeticTestsContract.Check32Struct],
268
+ [bigint],
269
+ "nonpayable"
270
+ >;
271
+
272
+ decryptAndCompareResults64: TypedContractMethod<
273
+ [check64: ArithmeticTestsContract.Check64Struct],
274
+ [bigint],
275
+ "nonpayable"
276
+ >;
277
+
278
+ getAddResult: TypedContractMethod<[], [bigint], "view">;
279
+
280
+ getMulResult: TypedContractMethod<[], [bigint], "view">;
281
+
282
+ getSubResult: TypedContractMethod<[], [bigint], "view">;
283
+
284
+ mulTest: TypedContractMethod<
285
+ [a: BigNumberish, b: BigNumberish],
286
+ [bigint],
287
+ "nonpayable"
288
+ >;
289
+
290
+ setPublicValues: TypedContractMethod<
291
+ [
292
+ castingValues: ArithmeticTestsContract.AllGTCastingValuesStruct,
293
+ a: BigNumberish,
294
+ b: BigNumberish
295
+ ],
296
+ [void],
297
+ "nonpayable"
298
+ >;
299
+
300
+ subTest: TypedContractMethod<
301
+ [a: BigNumberish, b: BigNumberish],
302
+ [bigint],
303
+ "nonpayable"
304
+ >;
305
+
306
+ getFunction<T extends ContractMethod = ContractMethod>(
307
+ key: string | FunctionFragment
308
+ ): T;
309
+
310
+ getFunction(
311
+ nameOrSignature: "addTest"
312
+ ): TypedContractMethod<
313
+ [a: BigNumberish, b: BigNumberish],
314
+ [bigint],
315
+ "nonpayable"
316
+ >;
317
+ getFunction(
318
+ nameOrSignature: "decryptAndCompareResults16"
319
+ ): TypedContractMethod<
320
+ [check16: ArithmeticTestsContract.Check16Struct],
321
+ [bigint],
322
+ "nonpayable"
323
+ >;
324
+ getFunction(
325
+ nameOrSignature: "decryptAndCompareResults32"
326
+ ): TypedContractMethod<
327
+ [check32: ArithmeticTestsContract.Check32Struct],
328
+ [bigint],
329
+ "nonpayable"
330
+ >;
331
+ getFunction(
332
+ nameOrSignature: "decryptAndCompareResults64"
333
+ ): TypedContractMethod<
334
+ [check64: ArithmeticTestsContract.Check64Struct],
335
+ [bigint],
336
+ "nonpayable"
337
+ >;
338
+ getFunction(
339
+ nameOrSignature: "getAddResult"
340
+ ): TypedContractMethod<[], [bigint], "view">;
341
+ getFunction(
342
+ nameOrSignature: "getMulResult"
343
+ ): TypedContractMethod<[], [bigint], "view">;
344
+ getFunction(
345
+ nameOrSignature: "getSubResult"
346
+ ): TypedContractMethod<[], [bigint], "view">;
347
+ getFunction(
348
+ nameOrSignature: "mulTest"
349
+ ): TypedContractMethod<
350
+ [a: BigNumberish, b: BigNumberish],
351
+ [bigint],
352
+ "nonpayable"
353
+ >;
354
+ getFunction(
355
+ nameOrSignature: "setPublicValues"
356
+ ): TypedContractMethod<
357
+ [
358
+ castingValues: ArithmeticTestsContract.AllGTCastingValuesStruct,
359
+ a: BigNumberish,
360
+ b: BigNumberish
361
+ ],
362
+ [void],
363
+ "nonpayable"
364
+ >;
365
+ getFunction(
366
+ nameOrSignature: "subTest"
367
+ ): TypedContractMethod<
368
+ [a: BigNumberish, b: BigNumberish],
369
+ [bigint],
370
+ "nonpayable"
371
+ >;
372
+
373
+ filters: {};
374
+ }