@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
@@ -0,0 +1,223 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity ^0.8.19;
3
+
4
+ import "../../../utils/mpc/MpcCore.sol";
5
+
6
+ contract TransferWithAllowance64_64TestsContract {
7
+
8
+ struct AllGTCastingValues {
9
+ gtUint8 a8_s;
10
+ gtUint8 b8_s;
11
+ gtUint16 a16_s;
12
+ gtUint16 b16_s;
13
+ gtUint32 a32_s;
14
+ gtUint32 b32_s;
15
+ gtUint64 a64_s;
16
+ gtUint64 b64_s;
17
+ }
18
+
19
+ struct AllAmountValues {
20
+ gtUint8 amount8_s;
21
+ gtUint16 amount16_s;
22
+ gtUint32 amount32_s;
23
+ gtUint64 amount64_s;
24
+ uint8 amount;
25
+ }
26
+
27
+ struct AllAllowanceValues {
28
+ gtUint8 allowance8_s;
29
+ gtUint16 allowance16_s;
30
+ gtUint32 allowance32_s;
31
+ gtUint64 allowance64_s;
32
+ uint8 allowance;
33
+ }
34
+
35
+ uint8 newA;
36
+ uint8 newB;
37
+ bool result;
38
+ uint8 newAllowance;
39
+
40
+ function getResults() public view returns (uint8, uint8, bool, uint8) {
41
+ return (newA, newB, result, newAllowance);
42
+ }
43
+
44
+
45
+ function computeAndCheckTransfer64_8_64(
46
+ AllGTCastingValues memory allGTCastingValues,
47
+ AllAmountValues memory allAmountValues,
48
+ AllAllowanceValues memory allAllowanceValues,
49
+ uint8 new_a,
50
+ uint8 new_b,
51
+ bool res,
52
+ uint8 new_allowance
53
+ )
54
+ public
55
+ {
56
+ (gtUint64 newA_s, gtUint64 newB_s, gtBool res_s, gtUint64 newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a8_s, allGTCastingValues.b64_s, allAmountValues.amount8_s, allAllowanceValues.allowance64_s);
57
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 64 failed");
58
+
59
+ (newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a64_s, allGTCastingValues.b8_s, allAmountValues.amount8_s, allAllowanceValues.allowance64_s);
60
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 64 failed");
61
+
62
+ (newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a64_s, allGTCastingValues.b64_s, allAmountValues.amount8_s, allAllowanceValues.allowance64_s);
63
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 64 failed");
64
+
65
+ (newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a16_s, allGTCastingValues.b64_s, allAmountValues.amount8_s, allAllowanceValues.allowance64_s);
66
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 64 failed");
67
+
68
+ (newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a64_s, allGTCastingValues.b16_s, allAmountValues.amount8_s, allAllowanceValues.allowance64_s);
69
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 64 failed");
70
+
71
+ (newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a32_s, allGTCastingValues.b64_s, allAmountValues.amount8_s, allAllowanceValues.allowance64_s);
72
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 64 failed");
73
+
74
+ (newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a64_s, allGTCastingValues.b32_s, allAmountValues.amount8_s, allAllowanceValues.allowance64_s);
75
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 64 failed");
76
+ }
77
+
78
+
79
+ function computeAndCheckTransfer64_16_64(
80
+ AllGTCastingValues memory allGTCastingValues,
81
+ AllAmountValues memory allAmountValues,
82
+ AllAllowanceValues memory allAllowanceValues,
83
+ uint8 new_a,
84
+ uint8 new_b,
85
+ bool res,
86
+ uint8 new_allowance
87
+ )
88
+ public
89
+ {
90
+ (gtUint64 newA_s, gtUint64 newB_s, gtBool res_s, gtUint64 newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a8_s, allGTCastingValues.b64_s, allAmountValues.amount16_s, allAllowanceValues.allowance64_s);
91
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 64 failed");
92
+
93
+ (newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a64_s, allGTCastingValues.b8_s, allAmountValues.amount16_s, allAllowanceValues.allowance64_s);
94
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 64 failed");
95
+
96
+ (newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a16_s, allGTCastingValues.b64_s, allAmountValues.amount16_s, allAllowanceValues.allowance64_s);
97
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 64 failed");
98
+
99
+ (newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a64_s, allGTCastingValues.b16_s, allAmountValues.amount16_s, allAllowanceValues.allowance64_s);
100
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 64 failed");
101
+
102
+ (newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a64_s, allGTCastingValues.b64_s, allAmountValues.amount16_s, allAllowanceValues.allowance64_s);
103
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 64 failed");
104
+
105
+ (newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a32_s, allGTCastingValues.b64_s, allAmountValues.amount16_s, allAllowanceValues.allowance64_s);
106
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 64 failed");
107
+
108
+ (newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a64_s, allGTCastingValues.b32_s, allAmountValues.amount16_s, allAllowanceValues.allowance64_s);
109
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 64 failed");
110
+ }
111
+
112
+
113
+ function computeAndCheckTransfer64_32_64(
114
+ AllGTCastingValues memory allGTCastingValues,
115
+ AllAmountValues memory allAmountValues,
116
+ AllAllowanceValues memory allAllowanceValues,
117
+ uint8 new_a,
118
+ uint8 new_b,
119
+ bool res,
120
+ uint8 new_allowance
121
+ )
122
+ public
123
+ {
124
+ (gtUint64 newA_s, gtUint64 newB_s, gtBool res_s, gtUint64 newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a8_s, allGTCastingValues.b64_s, allAmountValues.amount32_s, allAllowanceValues.allowance64_s);
125
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 64 failed");
126
+
127
+ (newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a64_s, allGTCastingValues.b8_s, allAmountValues.amount32_s, allAllowanceValues.allowance64_s);
128
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 64 failed");
129
+
130
+ (newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a16_s, allGTCastingValues.b64_s, allAmountValues.amount32_s, allAllowanceValues.allowance64_s);
131
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 64 failed");
132
+
133
+ (newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a64_s, allGTCastingValues.b16_s, allAmountValues.amount32_s, allAllowanceValues.allowance64_s);
134
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 64 failed");
135
+
136
+ (newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a32_s, allGTCastingValues.b64_s, allAmountValues.amount32_s, allAllowanceValues.allowance64_s);
137
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 64 failed");
138
+
139
+ (newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a64_s, allGTCastingValues.b32_s, allAmountValues.amount32_s, allAllowanceValues.allowance64_s);
140
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 64 failed");
141
+
142
+ (newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a64_s, allGTCastingValues.b64_s, allAmountValues.amount32_s, allAllowanceValues.allowance64_s);
143
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 64 failed");
144
+ }
145
+
146
+
147
+ function computeAndCheckTransfer64_64_64(
148
+ AllGTCastingValues memory allGTCastingValues,
149
+ AllAmountValues memory allAmountValues,
150
+ AllAllowanceValues memory allAllowanceValues,
151
+ uint8 new_a,
152
+ uint8 new_b,
153
+ bool res,
154
+ uint8 new_allowance
155
+ )
156
+ public
157
+ {
158
+ (gtUint64 newA_s, gtUint64 newB_s, gtBool res_s, gtUint64 newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a64_s, allGTCastingValues.b64_s, allAmountValues.amount64_s, allAllowanceValues.allowance64_s);
159
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 64 failed");
160
+
161
+ (newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a8_s, allGTCastingValues.b64_s, allAmountValues.amount64_s, allAllowanceValues.allowance64_s);
162
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 64 failed");
163
+
164
+ (newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a64_s, allGTCastingValues.b8_s, allAmountValues.amount64_s, allAllowanceValues.allowance64_s);
165
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 64 failed");
166
+
167
+ (newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a16_s, allGTCastingValues.b64_s, allAmountValues.amount64_s, allAllowanceValues.allowance64_s);
168
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 64 failed");
169
+
170
+ (newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a64_s, allGTCastingValues.b16_s, allAmountValues.amount64_s, allAllowanceValues.allowance64_s);
171
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 64 failed");
172
+
173
+ (newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a32_s, allGTCastingValues.b64_s, allAmountValues.amount64_s, allAllowanceValues.allowance64_s);
174
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 64 failed");
175
+
176
+ (newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a64_s, allGTCastingValues.b32_s, allAmountValues.amount64_s, allAllowanceValues.allowance64_s);
177
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 64 failed");
178
+ }
179
+
180
+
181
+ function transferWithAllowance64Test(uint8 a, uint8 b, uint8 amount, uint8 allowance) public returns (uint8, uint8, bool, uint8) {
182
+ AllGTCastingValues memory allGTCastingValues;
183
+ AllAmountValues memory allAmountValues;
184
+ AllAllowanceValues memory allAllowanceValues;
185
+ allGTCastingValues.a8_s = MpcCore.setPublic8(a);
186
+ allGTCastingValues.b8_s = MpcCore.setPublic8(b);
187
+ allGTCastingValues.a16_s = MpcCore.setPublic16(a);
188
+ allGTCastingValues.b16_s = MpcCore.setPublic16(b);
189
+ allGTCastingValues.a32_s = MpcCore.setPublic32(a);
190
+ allGTCastingValues.b32_s = MpcCore.setPublic32(b);
191
+ allGTCastingValues.a64_s = MpcCore.setPublic64(a);
192
+ allGTCastingValues.b64_s = MpcCore.setPublic64(b);
193
+ allAmountValues.amount8_s = MpcCore.setPublic8(amount);
194
+ allAmountValues.amount16_s = MpcCore.setPublic16(amount);
195
+ allAmountValues.amount32_s = MpcCore.setPublic32(amount);
196
+ allAmountValues.amount64_s = MpcCore.setPublic64(amount);
197
+ allAmountValues.amount = amount;
198
+ allAllowanceValues.allowance8_s = MpcCore.setPublic8(allowance);
199
+ allAllowanceValues.allowance16_s = MpcCore.setPublic16(allowance);
200
+ allAllowanceValues.allowance32_s = MpcCore.setPublic32(allowance);
201
+ allAllowanceValues.allowance64_s = MpcCore.setPublic64(allowance);
202
+ allAllowanceValues.allowance = allowance;
203
+
204
+ // Calculate the expected result
205
+ (gtUint8 newA_s, gtUint8 newB_s, gtBool res_s, gtUint8 newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a8_s, allGTCastingValues.b8_s, allAmountValues.amount8_s, allAllowanceValues.allowance8_s);
206
+ newA = MpcCore.decrypt(newA_s);
207
+ newB = MpcCore.decrypt(newB_s);
208
+ result = MpcCore.decrypt(res_s);
209
+ newAllowance = MpcCore.decrypt(newAllowance_s);
210
+
211
+ // Calculate the result with casting to 64
212
+ computeAndCheckTransfer64_8_64(allGTCastingValues, allAmountValues, allAllowanceValues, newA, newB, result, newAllowance);
213
+
214
+ computeAndCheckTransfer64_16_64(allGTCastingValues, allAmountValues, allAllowanceValues, newA, newB, result, newAllowance);
215
+
216
+ computeAndCheckTransfer64_32_64(allGTCastingValues, allAmountValues, allAllowanceValues, newA, newB, result, newAllowance);
217
+
218
+ computeAndCheckTransfer64_64_64(allGTCastingValues, allAmountValues, allAllowanceValues, newA, newB, result, newAllowance);
219
+
220
+ return (newA, newB, result, newAllowance);
221
+ }
222
+
223
+ }
@@ -0,0 +1,222 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity ^0.8.19;
3
+
4
+ import "../../../utils/mpc/MpcCore.sol";
5
+
6
+ contract TransferWithAllowance64_8TestsContract {
7
+
8
+ struct AllGTCastingValues {
9
+ gtUint8 a8_s;
10
+ gtUint8 b8_s;
11
+ gtUint16 a16_s;
12
+ gtUint16 b16_s;
13
+ gtUint32 a32_s;
14
+ gtUint32 b32_s;
15
+ gtUint64 a64_s;
16
+ gtUint64 b64_s;
17
+ }
18
+
19
+ struct AllAmountValues {
20
+ gtUint8 amount8_s;
21
+ gtUint16 amount16_s;
22
+ gtUint32 amount32_s;
23
+ gtUint64 amount64_s;
24
+ uint8 amount;
25
+ }
26
+
27
+ struct AllAllowanceValues {
28
+ gtUint8 allowance8_s;
29
+ gtUint16 allowance16_s;
30
+ gtUint32 allowance32_s;
31
+ gtUint64 allowance64_s;
32
+ uint8 allowance;
33
+ }
34
+
35
+ uint8 newA;
36
+ uint8 newB;
37
+ bool result;
38
+ uint8 newAllowance;
39
+
40
+ function getResults() public view returns (uint8, uint8, bool, uint8) {
41
+ return (newA, newB, result, newAllowance);
42
+ }
43
+
44
+ function computeAndCheckTransfer64_8_8(
45
+ AllGTCastingValues memory allGTCastingValues,
46
+ AllAmountValues memory allAmountValues,
47
+ AllAllowanceValues memory allAllowanceValues,
48
+ uint8 new_a,
49
+ uint8 new_b,
50
+ bool res,
51
+ uint8 new_allowance
52
+ )
53
+ public
54
+ {
55
+ (gtUint64 newA_s, gtUint64 newB_s, gtBool res_s, gtUint64 newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a8_s, allGTCastingValues.b64_s, allAmountValues.amount8_s, allAllowanceValues.allowance8_s);
56
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 64 failed");
57
+
58
+ (newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a64_s, allGTCastingValues.b8_s, allAmountValues.amount8_s, allAllowanceValues.allowance8_s);
59
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 64 failed");
60
+
61
+ (newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a64_s, allGTCastingValues.b64_s, allAmountValues.amount8_s, allAllowanceValues.allowance8_s);
62
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 64 failed");
63
+
64
+ (newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a16_s, allGTCastingValues.b64_s, allAmountValues.amount8_s, allAllowanceValues.allowance8_s);
65
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 64 failed");
66
+
67
+ (newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a64_s, allGTCastingValues.b16_s, allAmountValues.amount8_s, allAllowanceValues.allowance8_s);
68
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 64 failed");
69
+
70
+ (newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a32_s, allGTCastingValues.b64_s, allAmountValues.amount8_s, allAllowanceValues.allowance8_s);
71
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 64 failed");
72
+
73
+ (newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a64_s, allGTCastingValues.b32_s, allAmountValues.amount8_s, allAllowanceValues.allowance8_s);
74
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 64 failed");
75
+ }
76
+
77
+
78
+ function computeAndCheckTransfer64_16_8(
79
+ AllGTCastingValues memory allGTCastingValues,
80
+ AllAmountValues memory allAmountValues,
81
+ AllAllowanceValues memory allAllowanceValues,
82
+ uint8 new_a,
83
+ uint8 new_b,
84
+ bool res,
85
+ uint8 new_allowance
86
+ )
87
+ public
88
+ {
89
+ (gtUint64 newA_s, gtUint64 newB_s, gtBool res_s, gtUint64 newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a8_s, allGTCastingValues.b64_s, allAmountValues.amount16_s, allAllowanceValues.allowance8_s);
90
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 64 failed");
91
+
92
+ (newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a64_s, allGTCastingValues.b8_s, allAmountValues.amount16_s, allAllowanceValues.allowance8_s);
93
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 64 failed");
94
+
95
+ (newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a16_s, allGTCastingValues.b64_s, allAmountValues.amount16_s, allAllowanceValues.allowance8_s);
96
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 64 failed");
97
+
98
+ (newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a64_s, allGTCastingValues.b16_s, allAmountValues.amount16_s, allAllowanceValues.allowance8_s);
99
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 64 failed");
100
+
101
+ (newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a64_s, allGTCastingValues.b64_s, allAmountValues.amount16_s, allAllowanceValues.allowance8_s);
102
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 64 failed");
103
+
104
+ (newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a32_s, allGTCastingValues.b64_s, allAmountValues.amount16_s, allAllowanceValues.allowance8_s);
105
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 64 failed");
106
+
107
+ (newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a64_s, allGTCastingValues.b32_s, allAmountValues.amount16_s, allAllowanceValues.allowance8_s);
108
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 64 failed");
109
+ }
110
+
111
+
112
+ function computeAndCheckTransfer64_32_8(
113
+ AllGTCastingValues memory allGTCastingValues,
114
+ AllAmountValues memory allAmountValues,
115
+ AllAllowanceValues memory allAllowanceValues,
116
+ uint8 new_a,
117
+ uint8 new_b,
118
+ bool res,
119
+ uint8 new_allowance
120
+ )
121
+ public
122
+ {
123
+ (gtUint64 newA_s, gtUint64 newB_s, gtBool res_s, gtUint64 newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a8_s, allGTCastingValues.b64_s, allAmountValues.amount32_s, allAllowanceValues.allowance8_s);
124
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 64 failed");
125
+
126
+ (newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a64_s, allGTCastingValues.b8_s, allAmountValues.amount32_s, allAllowanceValues.allowance8_s);
127
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 64 failed");
128
+
129
+ (newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a32_s, allGTCastingValues.b64_s, allAmountValues.amount32_s, allAllowanceValues.allowance8_s);
130
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 64 failed");
131
+
132
+ (newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a64_s, allGTCastingValues.b32_s, allAmountValues.amount32_s, allAllowanceValues.allowance8_s);
133
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 64 failed");
134
+
135
+ (newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a16_s, allGTCastingValues.b64_s, allAmountValues.amount32_s, allAllowanceValues.allowance8_s);
136
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 64 failed");
137
+
138
+ (newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a64_s, allGTCastingValues.b16_s, allAmountValues.amount32_s, allAllowanceValues.allowance8_s);
139
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 64 failed");
140
+
141
+ (newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a64_s, allGTCastingValues.b64_s, allAmountValues.amount32_s, allAllowanceValues.allowance8_s);
142
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 64 failed");
143
+ }
144
+
145
+
146
+ function computeAndCheckTransfer64_64_8(
147
+ AllGTCastingValues memory allGTCastingValues,
148
+ AllAmountValues memory allAmountValues,
149
+ AllAllowanceValues memory allAllowanceValues,
150
+ uint8 new_a,
151
+ uint8 new_b,
152
+ bool res,
153
+ uint8 new_allowance
154
+ )
155
+ public
156
+ {
157
+ (gtUint64 newA_s, gtUint64 newB_s, gtBool res_s, gtUint64 newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a8_s, allGTCastingValues.b64_s, allAmountValues.amount64_s, allAllowanceValues.allowance8_s);
158
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 64 failed");
159
+
160
+ (newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a64_s, allGTCastingValues.b8_s, allAmountValues.amount64_s, allAllowanceValues.allowance8_s);
161
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 64 failed");
162
+
163
+ (newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a64_s, allGTCastingValues.b64_s, allAmountValues.amount64_s, allAllowanceValues.allowance8_s);
164
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 64 failed");
165
+
166
+ (newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a16_s, allGTCastingValues.b64_s, allAmountValues.amount64_s, allAllowanceValues.allowance8_s);
167
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 64 failed");
168
+
169
+ (newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a64_s, allGTCastingValues.b16_s, allAmountValues.amount64_s, allAllowanceValues.allowance8_s);
170
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 64 failed");
171
+
172
+ (newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a32_s, allGTCastingValues.b64_s, allAmountValues.amount64_s, allAllowanceValues.allowance8_s);
173
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 64 failed");
174
+
175
+ (newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a64_s, allGTCastingValues.b32_s, allAmountValues.amount64_s, allAllowanceValues.allowance8_s);
176
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 64 failed");
177
+ }
178
+
179
+
180
+ function transferWithAllowance64Test(uint8 a, uint8 b, uint8 amount, uint8 allowance) public returns (uint8, uint8, bool, uint8) {
181
+ AllGTCastingValues memory allGTCastingValues;
182
+ AllAmountValues memory allAmountValues;
183
+ AllAllowanceValues memory allAllowanceValues;
184
+ allGTCastingValues.a8_s = MpcCore.setPublic8(a);
185
+ allGTCastingValues.b8_s = MpcCore.setPublic8(b);
186
+ allGTCastingValues.a16_s = MpcCore.setPublic16(a);
187
+ allGTCastingValues.b16_s = MpcCore.setPublic16(b);
188
+ allGTCastingValues.a32_s = MpcCore.setPublic32(a);
189
+ allGTCastingValues.b32_s = MpcCore.setPublic32(b);
190
+ allGTCastingValues.a64_s = MpcCore.setPublic64(a);
191
+ allGTCastingValues.b64_s = MpcCore.setPublic64(b);
192
+ allAmountValues.amount8_s = MpcCore.setPublic8(amount);
193
+ allAmountValues.amount16_s = MpcCore.setPublic16(amount);
194
+ allAmountValues.amount32_s = MpcCore.setPublic32(amount);
195
+ allAmountValues.amount64_s = MpcCore.setPublic64(amount);
196
+ allAmountValues.amount = amount;
197
+ allAllowanceValues.allowance8_s = MpcCore.setPublic8(allowance);
198
+ allAllowanceValues.allowance16_s = MpcCore.setPublic16(allowance);
199
+ allAllowanceValues.allowance32_s = MpcCore.setPublic32(allowance);
200
+ allAllowanceValues.allowance64_s = MpcCore.setPublic64(allowance);
201
+ allAllowanceValues.allowance = allowance;
202
+
203
+ // Calculate the expected result
204
+ (gtUint8 newA_s, gtUint8 newB_s, gtBool res_s, gtUint8 newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a8_s, allGTCastingValues.b8_s, allAmountValues.amount8_s, allAllowanceValues.allowance8_s);
205
+ newA = MpcCore.decrypt(newA_s);
206
+ newB = MpcCore.decrypt(newB_s);
207
+ result = MpcCore.decrypt(res_s);
208
+ newAllowance = MpcCore.decrypt(newAllowance_s);
209
+
210
+ // Calculate the result with casting to 64
211
+ computeAndCheckTransfer64_8_8(allGTCastingValues, allAmountValues, allAllowanceValues, newA, newB, result, newAllowance);
212
+
213
+ computeAndCheckTransfer64_16_8(allGTCastingValues, allAmountValues, allAllowanceValues, newA, newB, result, newAllowance);
214
+
215
+ computeAndCheckTransfer64_32_8(allGTCastingValues, allAmountValues, allAllowanceValues, newA, newB, result, newAllowance);
216
+
217
+ computeAndCheckTransfer64_64_8(allGTCastingValues, allAmountValues, allAllowanceValues, newA, newB, result, newAllowance);
218
+
219
+ return (newA, newB, result, newAllowance);
220
+ }
221
+
222
+ }