@coti-io/coti-contracts 1.0.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 (88) 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/mocks/utils/mpc/ArithmeticTestsContract.sol +152 -0
  6. package/contracts/mocks/utils/mpc/BitwiseTestsContract.sol +11 -1
  7. package/contracts/mocks/utils/mpc/Comparison2TestsContract.sol +8 -0
  8. package/contracts/mocks/utils/mpc/Miscellaneous1TestsContract.sol +33 -4
  9. package/contracts/mocks/utils/mpc/OffboardToUserKeyTestContract.sol +35 -10
  10. package/contracts/mocks/utils/mpc/TransferTestsContract.sol +3 -0
  11. package/contracts/mocks/utils/mpc/TransferWithAllowance64_16TestsContract.sol +222 -0
  12. package/contracts/mocks/utils/mpc/TransferWithAllowance64_32TestsContract.sol +222 -0
  13. package/contracts/mocks/utils/mpc/TransferWithAllowance64_64TestsContract.sol +223 -0
  14. package/contracts/mocks/utils/mpc/TransferWithAllowance64_8TestsContract.sol +222 -0
  15. package/contracts/mocks/utils/mpc/TransferWithAllowanceScalarTestsContract.sol +265 -0
  16. package/contracts/mocks/utils/mpc/TransferWithAllowanceTestsContract.sol +281 -0
  17. package/contracts/token/PrivateERC20/PrivateERC20.sol +1 -1
  18. package/contracts/token/PrivateERC721/IERC721Errors.sol +57 -0
  19. package/contracts/token/PrivateERC721/PrivateERC721.sol +1 -1
  20. package/hardhat.config.ts +9 -1
  21. package/package.json +20 -4
  22. package/test/token/PrivateERC20/PrivateERC20.test.ts +2 -2
  23. package/test/utils/mpc/Precompile.test.ts +16 -2
  24. package/typechain-types/contracts/mocks/utils/mpc/ArithmeticTestsContract.ts +66 -0
  25. package/typechain-types/contracts/mocks/utils/mpc/BitwiseTestsContract.ts +6 -0
  26. package/typechain-types/contracts/mocks/utils/mpc/Comparison2TestsContract.ts +6 -0
  27. package/typechain-types/contracts/mocks/utils/mpc/OffboardToUserKeyTestContract.ts +36 -6
  28. package/typechain-types/contracts/mocks/utils/mpc/TransferWithAllowance64TestsContract.sol/TransferWithAllowance64TestsContract.ts +251 -0
  29. package/typechain-types/contracts/mocks/utils/mpc/TransferWithAllowance64TestsContract.sol/TransferWithAllowanceTestsContract.ts +250 -0
  30. package/typechain-types/contracts/mocks/utils/mpc/TransferWithAllowance64TestsContract.sol/index.ts +5 -0
  31. package/typechain-types/contracts/mocks/utils/mpc/TransferWithAllowance64TestsContract.ts +389 -0
  32. package/typechain-types/contracts/mocks/utils/mpc/TransferWithAllowance64_16TestsContract.ts +391 -0
  33. package/typechain-types/contracts/mocks/utils/mpc/TransferWithAllowance64_32TestsContract.ts +391 -0
  34. package/typechain-types/contracts/mocks/utils/mpc/TransferWithAllowance64_64TestsContract.sol/TransferWithAllowance64_64TestsContract.ts +391 -0
  35. package/typechain-types/contracts/mocks/utils/mpc/TransferWithAllowance64_64TestsContract.sol/TransferWithAllowance64_8TestsContract.ts +391 -0
  36. package/typechain-types/contracts/mocks/utils/mpc/TransferWithAllowance64_64TestsContract.sol/index.ts +5 -0
  37. package/typechain-types/contracts/mocks/utils/mpc/TransferWithAllowance64_64TestsContract.ts +391 -0
  38. package/typechain-types/contracts/mocks/utils/mpc/TransferWithAllowance64_8TestsContract.ts +391 -0
  39. package/typechain-types/contracts/mocks/utils/mpc/TransferWithAllowanceScalarTestsContract.ts +306 -0
  40. package/typechain-types/contracts/mocks/utils/mpc/TransferWithAllowanceTestsContract.sol/TransferTestsContract.ts +125 -0
  41. package/typechain-types/contracts/mocks/utils/mpc/TransferWithAllowanceTestsContract.sol/TransferWithAllowanceTestsContract.ts +125 -0
  42. package/typechain-types/contracts/mocks/utils/mpc/TransferWithAllowanceTestsContract.sol/index.ts +5 -0
  43. package/typechain-types/contracts/mocks/utils/mpc/TransferWithAllowanceTestsContract.ts +296 -0
  44. package/typechain-types/contracts/mocks/utils/mpc/index.ts +6 -0
  45. package/typechain-types/contracts/token/PrivateERC721/IERC721Errors.ts +69 -0
  46. package/typechain-types/contracts/token/PrivateERC721/index.ts +1 -0
  47. package/typechain-types/factories/contracts/mocks/access/DataPrivacyFramework/DataPrivacyFrameworkMock__factory.ts +1 -1
  48. package/typechain-types/factories/contracts/mocks/token/PrivateERC20/PrivateERC20Mock__factory.ts +1 -1
  49. package/typechain-types/factories/contracts/mocks/token/PrivateERC721/PrivateERC721URIStorageMock__factory.ts +1 -1
  50. package/typechain-types/factories/contracts/mocks/utils/mpc/ArithmeticTestsContract__factory.ts +73 -1
  51. package/typechain-types/factories/contracts/mocks/utils/mpc/BitwiseTestsContract__factory.ts +11 -1
  52. package/typechain-types/factories/contracts/mocks/utils/mpc/Comparison1TestsContract__factory.ts +1 -1
  53. package/typechain-types/factories/contracts/mocks/utils/mpc/Comparison2TestsContract__factory.ts +11 -1
  54. package/typechain-types/factories/contracts/mocks/utils/mpc/MinMaxTestsContract__factory.ts +1 -1
  55. package/typechain-types/factories/contracts/mocks/utils/mpc/Miscellaneous1TestsContract__factory.ts +1 -1
  56. package/typechain-types/factories/contracts/mocks/utils/mpc/MiscellaneousTestsContract__factory.ts +1 -1
  57. package/typechain-types/factories/contracts/mocks/utils/mpc/OffboardToUserKeyTestContract__factory.ts +26 -30
  58. package/typechain-types/factories/contracts/mocks/utils/mpc/StringTestsContract__factory.ts +1 -1
  59. package/typechain-types/factories/contracts/mocks/utils/mpc/TransferScalarTestsContract__factory.ts +1 -1
  60. package/typechain-types/factories/contracts/mocks/utils/mpc/TransferTestsContract__factory.ts +1 -1
  61. package/typechain-types/factories/contracts/mocks/utils/mpc/TransferWithAllowance64TestsContract.sol/TransferWithAllowance64TestsContract__factory.ts +294 -0
  62. package/typechain-types/factories/contracts/mocks/utils/mpc/TransferWithAllowance64TestsContract.sol/TransferWithAllowanceTestsContract__factory.ts +292 -0
  63. package/typechain-types/factories/contracts/mocks/utils/mpc/TransferWithAllowance64TestsContract.sol/index.ts +5 -0
  64. package/typechain-types/factories/contracts/mocks/utils/mpc/TransferWithAllowance64TestsContract__factory.ts +720 -0
  65. package/typechain-types/factories/contracts/mocks/utils/mpc/TransferWithAllowance64_16TestsContract__factory.ts +724 -0
  66. package/typechain-types/factories/contracts/mocks/utils/mpc/TransferWithAllowance64_32TestsContract__factory.ts +724 -0
  67. package/typechain-types/factories/contracts/mocks/utils/mpc/TransferWithAllowance64_64TestsContract.sol/TransferWithAllowance64_64TestsContract__factory.ts +724 -0
  68. package/typechain-types/factories/contracts/mocks/utils/mpc/TransferWithAllowance64_64TestsContract.sol/TransferWithAllowance64_8TestsContract__factory.ts +724 -0
  69. package/typechain-types/factories/contracts/mocks/utils/mpc/TransferWithAllowance64_64TestsContract.sol/index.ts +5 -0
  70. package/typechain-types/factories/contracts/mocks/utils/mpc/TransferWithAllowance64_64TestsContract__factory.ts +724 -0
  71. package/typechain-types/factories/contracts/mocks/utils/mpc/TransferWithAllowance64_8TestsContract__factory.ts +724 -0
  72. package/typechain-types/factories/contracts/mocks/utils/mpc/TransferWithAllowanceScalarTestsContract__factory.ts +507 -0
  73. package/typechain-types/factories/contracts/mocks/utils/mpc/TransferWithAllowanceTestsContract.sol/TransferTestsContract__factory.ts +150 -0
  74. package/typechain-types/factories/contracts/mocks/utils/mpc/TransferWithAllowanceTestsContract.sol/TransferWithAllowanceTestsContract__factory.ts +150 -0
  75. package/typechain-types/factories/contracts/mocks/utils/mpc/TransferWithAllowanceTestsContract.sol/index.ts +5 -0
  76. package/typechain-types/factories/contracts/mocks/utils/mpc/TransferWithAllowanceTestsContract__factory.ts +434 -0
  77. package/typechain-types/factories/contracts/mocks/utils/mpc/index.ts +6 -0
  78. package/typechain-types/factories/contracts/mocks/wallet/PrivateERC20Wallet/PrivateERC20WalletMock__factory.ts +1 -1
  79. package/typechain-types/factories/contracts/onboard/AccountOnboard__factory.ts +1 -1
  80. package/typechain-types/factories/contracts/token/PrivateERC721/IERC721Errors__factory.ts +128 -0
  81. package/typechain-types/factories/contracts/token/PrivateERC721/index.ts +1 -0
  82. package/typechain-types/factories/contracts/utils/mpc/MpcCore__factory.ts +1 -1
  83. package/typechain-types/hardhat.d.ts +126 -0
  84. package/typechain-types/index.ts +12 -0
  85. package/contracts/access/DataPrivacyFramework/README.md +0 -68
  86. package/contracts/token/PrivateERC20/README.md +0 -104
  87. package/contracts/token/PrivateERC721/README.md +0 -282
  88. package/contracts/utils/mpc/README.md +0 -82
@@ -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_16TestsContract {
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_16(
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.allowance16_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.allowance16_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.allowance16_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.allowance16_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.allowance16_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.allowance16_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.allowance16_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_16(
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.allowance16_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.allowance16_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.allowance16_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.allowance16_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.allowance16_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.allowance16_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.allowance16_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
+ function computeAndCheckTransfer64_32_16(
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.allowance16_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.allowance16_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.a16_s, allGTCastingValues.b64_s, allAmountValues.amount32_s, allAllowanceValues.allowance16_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.b16_s, allAmountValues.amount32_s, allAllowanceValues.allowance16_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.a32_s, allGTCastingValues.b64_s, allAmountValues.amount32_s, allAllowanceValues.allowance16_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.b32_s, allAmountValues.amount32_s, allAllowanceValues.allowance16_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.allowance16_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_16(
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.allowance16_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.allowance16_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.allowance16_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.allowance16_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.allowance16_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.allowance16_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.allowance16_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_16(allGTCastingValues, allAmountValues, allAllowanceValues, newA, newB, result, newAllowance);
212
+
213
+ computeAndCheckTransfer64_16_16(allGTCastingValues, allAmountValues, allAllowanceValues, newA, newB, result, newAllowance);
214
+
215
+ computeAndCheckTransfer64_32_16(allGTCastingValues, allAmountValues, allAllowanceValues, newA, newB, result, newAllowance);
216
+
217
+ computeAndCheckTransfer64_64_16(allGTCastingValues, allAmountValues, allAllowanceValues, newA, newB, result, newAllowance);
218
+
219
+ return (newA, newB, result, newAllowance);
220
+ }
221
+
222
+ }
@@ -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_32TestsContract {
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_32(
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.allowance32_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.allowance32_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.allowance32_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.allowance32_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.allowance32_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.allowance32_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.allowance32_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_32(
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.allowance32_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.allowance32_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.allowance32_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.allowance32_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.allowance32_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.allowance32_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.allowance32_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_32(
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.allowance32_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.allowance32_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.allowance32_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.allowance32_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.allowance32_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.allowance32_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.allowance32_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
+ function computeAndCheckTransfer64_64_32(
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.allowance32_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.allowance32_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.allowance32_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.allowance32_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.allowance32_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.allowance32_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.allowance32_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_32(allGTCastingValues, allAmountValues, allAllowanceValues, newA, newB, result, newAllowance);
212
+
213
+ computeAndCheckTransfer64_16_32(allGTCastingValues, allAmountValues, allAllowanceValues, newA, newB, result, newAllowance);
214
+
215
+ computeAndCheckTransfer64_32_32(allGTCastingValues, allAmountValues, allAllowanceValues, newA, newB, result, newAllowance);
216
+
217
+ computeAndCheckTransfer64_64_32(allGTCastingValues, allAmountValues, allAllowanceValues, newA, newB, result, newAllowance);
218
+
219
+ return (newA, newB, result, newAllowance);
220
+ }
221
+
222
+ }