@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
@@ -1,5 +1,4 @@
1
1
  // SPDX-License-Identifier: MIT
2
-
3
2
  pragma solidity ^0.8.19;
4
3
 
5
4
  import "../../../utils/mpc/MpcCore.sol";
@@ -33,640 +32,187 @@ contract TransferTestsContract {
33
32
  return (newA, newB, result);
34
33
  }
35
34
 
36
- function computeAndChekTransfer16(
37
- AllGTCastingValues memory allGTCastingValues,
38
- AllAmountValues memory allAmountValues,
39
- uint8 new_a,
40
- uint8 new_b,
41
- bool res
42
- ) public {
43
- (gtUint16 newA_s, gtUint16 newB_s, gtBool res_s) = MpcCore.transfer(
44
- allGTCastingValues.a16_s,
45
- allGTCastingValues.b16_s,
46
- allAmountValues.amount8_s
47
- );
48
- require(
49
- new_a == MpcCore.decrypt(newA_s) &&
50
- new_b == MpcCore.decrypt(newB_s) &&
51
- res == MpcCore.decrypt(res_s),
52
- "transferTest: cast 16 failed"
53
- );
54
-
55
- (newA_s, newB_s, res_s) = MpcCore.transfer(
56
- allGTCastingValues.a8_s,
57
- allGTCastingValues.b16_s,
58
- allAmountValues.amount8_s
59
- );
60
- require(
61
- new_a == MpcCore.decrypt(newA_s) &&
62
- new_b == MpcCore.decrypt(newB_s) &&
63
- res == MpcCore.decrypt(res_s),
64
- "transferTest: cast 16 failed"
65
- );
66
-
67
- (newA_s, newB_s, res_s) = MpcCore.transfer(
68
- allGTCastingValues.a16_s,
69
- allGTCastingValues.b8_s,
70
- allAmountValues.amount8_s
71
- );
72
- require(
73
- new_a == MpcCore.decrypt(newA_s) &&
74
- new_b == MpcCore.decrypt(newB_s) &&
75
- res == MpcCore.decrypt(res_s),
76
- "transferTest: cast 16 failed"
77
- );
78
-
79
- (newA_s, newB_s, res_s) = MpcCore.transfer(
80
- allGTCastingValues.a16_s,
81
- allGTCastingValues.b16_s,
82
- allAmountValues.amount16_s
83
- );
84
- require(
85
- new_a == MpcCore.decrypt(newA_s) &&
86
- new_b == MpcCore.decrypt(newB_s) &&
87
- res == MpcCore.decrypt(res_s),
88
- "transferTest: cast 16 failed"
89
- );
90
-
91
- (newA_s, newB_s, res_s) = MpcCore.transfer(
92
- allGTCastingValues.a8_s,
93
- allGTCastingValues.b16_s,
94
- allAmountValues.amount16_s
95
- );
96
- require(
97
- new_a == MpcCore.decrypt(newA_s) &&
98
- new_b == MpcCore.decrypt(newB_s) &&
99
- res == MpcCore.decrypt(res_s),
100
- "transferTest: cast 16 failed"
101
- );
102
-
103
- (newA_s, newB_s, res_s) = MpcCore.transfer(
104
- allGTCastingValues.a16_s,
105
- allGTCastingValues.b8_s,
106
- allAmountValues.amount16_s
107
- );
108
- require(
109
- new_a == MpcCore.decrypt(newA_s) &&
110
- new_b == MpcCore.decrypt(newB_s) &&
111
- res == MpcCore.decrypt(res_s),
112
- "transferTest: cast 16 failed"
113
- );
35
+
36
+ function computeAndCheckTransfer16(AllGTCastingValues memory allGTCastingValues, AllAmountValues memory allAmountValues, uint8 new_a, uint8 new_b, bool res) public {
37
+ (gtUint16 newA_s, gtUint16 newB_s, gtBool res_s) = MpcCore.transfer(allGTCastingValues.a16_s, allGTCastingValues.b16_s, allAmountValues.amount8_s);
38
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s), "transferTest: cast 16 failed");
39
+
40
+ (newA_s, newB_s, res_s) = MpcCore.transfer(allGTCastingValues.a8_s, allGTCastingValues.b16_s, allAmountValues.amount8_s);
41
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s), "transferTest: cast 16 failed");
42
+
43
+ (newA_s, newB_s, res_s) = MpcCore.transfer(allGTCastingValues.a16_s, allGTCastingValues.b8_s, allAmountValues.amount8_s);
44
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s), "transferTest: cast 16 failed");
45
+
46
+ (newA_s, newB_s, res_s) = MpcCore.transfer(allGTCastingValues.a16_s, allGTCastingValues.b16_s, allAmountValues.amount16_s);
47
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s), "transferTest: cast 16 failed");
48
+
49
+ (newA_s, newB_s, res_s) = MpcCore.transfer(allGTCastingValues.a8_s, allGTCastingValues.b16_s, allAmountValues.amount16_s);
50
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s), "transferTest: cast 16 failed");
51
+
52
+ (newA_s, newB_s, res_s) = MpcCore.transfer(allGTCastingValues.a16_s, allGTCastingValues.b8_s, allAmountValues.amount16_s);
53
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s), "transferTest: cast 16 failed");
54
+
55
+ (newA_s, newB_s, res_s) = MpcCore.transfer(allGTCastingValues.a16_s, allGTCastingValues.b16_s, allAmountValues.amount8_s);
56
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s), "transferTest: cast 16 failed");
114
57
  }
115
58
 
116
- function computeAndChekTransfer32(
117
- AllGTCastingValues memory allGTCastingValues,
118
- AllAmountValues memory allAmountValues,
119
- uint8 new_a,
120
- uint8 new_b,
121
- bool res
122
- ) public {
59
+ function computeAndCheckTransfer32(AllGTCastingValues memory allGTCastingValues, AllAmountValues memory allAmountValues, uint8 new_a, uint8 new_b, bool res) public {
60
+
123
61
  // Check all options for casting to 32 while amount is 32
124
- (gtUint32 newA_s, gtUint32 newB_s, gtBool res_s) = MpcCore.transfer(
125
- allGTCastingValues.a32_s,
126
- allGTCastingValues.b32_s,
127
- allAmountValues.amount32_s
128
- );
129
- require(
130
- new_a == MpcCore.decrypt(newA_s) &&
131
- new_b == MpcCore.decrypt(newB_s) &&
132
- res == MpcCore.decrypt(res_s),
133
- "transferTest: cast 32 failed"
134
- );
135
-
136
- (newA_s, newB_s, res_s) = MpcCore.transfer(
137
- allGTCastingValues.a8_s,
138
- allGTCastingValues.b32_s,
139
- allAmountValues.amount32_s
140
- );
141
- require(
142
- new_a == MpcCore.decrypt(newA_s) &&
143
- new_b == MpcCore.decrypt(newB_s) &&
144
- res == MpcCore.decrypt(res_s),
145
- "transferTest: cast 32 failed"
146
- );
147
-
148
- (newA_s, newB_s, res_s) = MpcCore.transfer(
149
- allGTCastingValues.a32_s,
150
- allGTCastingValues.b8_s,
151
- allAmountValues.amount32_s
152
- );
153
- require(
154
- new_a == MpcCore.decrypt(newA_s) &&
155
- new_b == MpcCore.decrypt(newB_s) &&
156
- res == MpcCore.decrypt(res_s),
157
- "transferTest: cast 32 failed"
158
- );
159
-
160
- (newA_s, newB_s, res_s) = MpcCore.transfer(
161
- allGTCastingValues.a16_s,
162
- allGTCastingValues.b32_s,
163
- allAmountValues.amount32_s
164
- );
165
- require(
166
- new_a == MpcCore.decrypt(newA_s) &&
167
- new_b == MpcCore.decrypt(newB_s) &&
168
- res == MpcCore.decrypt(res_s),
169
- "transferTest: cast 32 failed"
170
- );
171
-
172
- (newA_s, newB_s, res_s) = MpcCore.transfer(
173
- allGTCastingValues.a32_s,
174
- allGTCastingValues.b16_s,
175
- allAmountValues.amount32_s
176
- );
177
- require(
178
- new_a == MpcCore.decrypt(newA_s) &&
179
- new_b == MpcCore.decrypt(newB_s) &&
180
- res == MpcCore.decrypt(res_s),
181
- "transferTest: cast 32 failed"
182
- );
62
+ (gtUint32 newA_s, gtUint32 newB_s, gtBool res_s) = MpcCore.transfer(allGTCastingValues.a32_s, allGTCastingValues.b32_s, allAmountValues.amount32_s);
63
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s), "transferTest: cast 32 failed");
64
+
65
+ (newA_s, newB_s, res_s) = MpcCore.transfer(allGTCastingValues.a8_s, allGTCastingValues.b32_s, allAmountValues.amount32_s);
66
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s), "transferTest: cast 32 failed");
67
+
68
+ (newA_s, newB_s, res_s) = MpcCore.transfer(allGTCastingValues.a32_s, allGTCastingValues.b8_s, allAmountValues.amount32_s);
69
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s), "transferTest: cast 32 failed");
70
+
71
+ (newA_s, newB_s, res_s) = MpcCore.transfer(allGTCastingValues.a16_s, allGTCastingValues.b32_s, allAmountValues.amount32_s);
72
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s), "transferTest: cast 32 failed");
73
+
74
+ (newA_s, newB_s, res_s) = MpcCore.transfer(allGTCastingValues.a32_s, allGTCastingValues.b16_s, allAmountValues.amount32_s);
75
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s), "transferTest: cast 32 failed");
76
+
183
77
 
184
78
  // Check all options for casting to 32 while amount is 8
185
- (newA_s, newB_s, res_s) = MpcCore.transfer(
186
- allGTCastingValues.a32_s,
187
- allGTCastingValues.b32_s,
188
- allAmountValues.amount8_s
189
- );
190
- require(
191
- new_a == MpcCore.decrypt(newA_s) &&
192
- new_b == MpcCore.decrypt(newB_s) &&
193
- res == MpcCore.decrypt(res_s),
194
- "transferTest: cast 32 failed"
195
- );
196
-
197
- (newA_s, newB_s, res_s) = MpcCore.transfer(
198
- allGTCastingValues.a8_s,
199
- allGTCastingValues.b32_s,
200
- allAmountValues.amount8_s
201
- );
202
- require(
203
- new_a == MpcCore.decrypt(newA_s) &&
204
- new_b == MpcCore.decrypt(newB_s) &&
205
- res == MpcCore.decrypt(res_s),
206
- "transferTest: cast 32 failed"
207
- );
208
-
209
- (newA_s, newB_s, res_s) = MpcCore.transfer(
210
- allGTCastingValues.a32_s,
211
- allGTCastingValues.b8_s,
212
- allAmountValues.amount8_s
213
- );
214
- require(
215
- new_a == MpcCore.decrypt(newA_s) &&
216
- new_b == MpcCore.decrypt(newB_s) &&
217
- res == MpcCore.decrypt(res_s),
218
- "transferTest: cast 32 failed"
219
- );
220
-
221
- (newA_s, newB_s, res_s) = MpcCore.transfer(
222
- allGTCastingValues.a16_s,
223
- allGTCastingValues.b32_s,
224
- allAmountValues.amount8_s
225
- );
226
- require(
227
- new_a == MpcCore.decrypt(newA_s) &&
228
- new_b == MpcCore.decrypt(newB_s) &&
229
- res == MpcCore.decrypt(res_s),
230
- "transferTest: cast 32 failed"
231
- );
232
-
233
- (newA_s, newB_s, res_s) = MpcCore.transfer(
234
- allGTCastingValues.a32_s,
235
- allGTCastingValues.b16_s,
236
- allAmountValues.amount8_s
237
- );
238
- require(
239
- new_a == MpcCore.decrypt(newA_s) &&
240
- new_b == MpcCore.decrypt(newB_s) &&
241
- res == MpcCore.decrypt(res_s),
242
- "transferTest: cast 32 failed"
243
- );
79
+ (newA_s, newB_s, res_s) = MpcCore.transfer(allGTCastingValues.a32_s, allGTCastingValues.b32_s, allAmountValues.amount8_s);
80
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s), "transferTest: cast 32 failed");
81
+
82
+ (newA_s, newB_s, res_s) = MpcCore.transfer(allGTCastingValues.a8_s, allGTCastingValues.b32_s, allAmountValues.amount8_s);
83
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s), "transferTest: cast 32 failed");
84
+
85
+ (newA_s, newB_s, res_s) = MpcCore.transfer(allGTCastingValues.a32_s, allGTCastingValues.b8_s, allAmountValues.amount8_s);
86
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s), "transferTest: cast 32 failed");
87
+
88
+ (newA_s, newB_s, res_s) = MpcCore.transfer(allGTCastingValues.a16_s, allGTCastingValues.b32_s, allAmountValues.amount8_s);
89
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s), "transferTest: cast 32 failed");
90
+
91
+ (newA_s, newB_s, res_s) = MpcCore.transfer(allGTCastingValues.a32_s, allGTCastingValues.b16_s, allAmountValues.amount8_s);
92
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s), "transferTest: cast 32 failed");
244
93
 
245
94
  // Check all options for casting to 32 while amount is 16
246
- (newA_s, newB_s, res_s) = MpcCore.transfer(
247
- allGTCastingValues.a32_s,
248
- allGTCastingValues.b32_s,
249
- allAmountValues.amount16_s
250
- );
251
- require(
252
- new_a == MpcCore.decrypt(newA_s) &&
253
- new_b == MpcCore.decrypt(newB_s) &&
254
- res == MpcCore.decrypt(res_s),
255
- "transferTest: cast 32 failed"
256
- );
257
-
258
- (newA_s, newB_s, res_s) = MpcCore.transfer(
259
- allGTCastingValues.a8_s,
260
- allGTCastingValues.b32_s,
261
- allAmountValues.amount16_s
262
- );
263
- require(
264
- new_a == MpcCore.decrypt(newA_s) &&
265
- new_b == MpcCore.decrypt(newB_s) &&
266
- res == MpcCore.decrypt(res_s),
267
- "transferTest: cast 32 failed"
268
- );
269
-
270
- (newA_s, newB_s, res_s) = MpcCore.transfer(
271
- allGTCastingValues.a32_s,
272
- allGTCastingValues.b8_s,
273
- allAmountValues.amount16_s
274
- );
275
- require(
276
- new_a == MpcCore.decrypt(newA_s) &&
277
- new_b == MpcCore.decrypt(newB_s) &&
278
- res == MpcCore.decrypt(res_s),
279
- "transferTest: cast 32 failed"
280
- );
281
-
282
- (newA_s, newB_s, res_s) = MpcCore.transfer(
283
- allGTCastingValues.a16_s,
284
- allGTCastingValues.b32_s,
285
- allAmountValues.amount16_s
286
- );
287
- require(
288
- new_a == MpcCore.decrypt(newA_s) &&
289
- new_b == MpcCore.decrypt(newB_s) &&
290
- res == MpcCore.decrypt(res_s),
291
- "transferTest: cast 32 failed"
292
- );
293
-
294
- (newA_s, newB_s, res_s) = MpcCore.transfer(
295
- allGTCastingValues.a32_s,
296
- allGTCastingValues.b16_s,
297
- allAmountValues.amount16_s
298
- );
299
- require(
300
- new_a == MpcCore.decrypt(newA_s) &&
301
- new_b == MpcCore.decrypt(newB_s) &&
302
- res == MpcCore.decrypt(res_s),
303
- "transferTest: cast 32 failed"
304
- );
95
+ (newA_s, newB_s, res_s) = MpcCore.transfer(allGTCastingValues.a32_s, allGTCastingValues.b32_s, allAmountValues.amount16_s);
96
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s), "transferTest: cast 32 failed");
97
+
98
+ (newA_s, newB_s, res_s) = MpcCore.transfer(allGTCastingValues.a8_s, allGTCastingValues.b32_s, allAmountValues.amount16_s);
99
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s), "transferTest: cast 32 failed");
100
+
101
+ (newA_s, newB_s, res_s) = MpcCore.transfer(allGTCastingValues.a32_s, allGTCastingValues.b8_s, allAmountValues.amount16_s);
102
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s), "transferTest: cast 32 failed");
103
+
104
+ (newA_s, newB_s, res_s) = MpcCore.transfer(allGTCastingValues.a16_s, allGTCastingValues.b32_s, allAmountValues.amount16_s);
105
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s), "transferTest: cast 32 failed");
106
+
107
+ (newA_s, newB_s, res_s) = MpcCore.transfer(allGTCastingValues.a32_s, allGTCastingValues.b16_s, allAmountValues.amount16_s);
108
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s), "transferTest: cast 32 failed");
305
109
  }
306
110
 
307
- function computeAndChekTransfer64(
308
- AllGTCastingValues memory allGTCastingValues,
309
- AllAmountValues memory allAmountValues,
310
- uint8 new_a,
311
- uint8 new_b,
312
- bool res
313
- ) public {
111
+ function computeAndCheckTransfer64(AllGTCastingValues memory allGTCastingValues, AllAmountValues memory allAmountValues, uint8 new_a, uint8 new_b, bool res) public {
112
+
314
113
  // Check all options for casting to 64 while amount is 64
315
- (gtUint64 newA_s, gtUint64 newB_s, gtBool res_s) = MpcCore.transfer(
316
- allGTCastingValues.a64_s,
317
- allGTCastingValues.b64_s,
318
- allAmountValues.amount64_s
319
- );
320
- require(
321
- new_a == MpcCore.decrypt(newA_s) &&
322
- new_b == MpcCore.decrypt(newB_s) &&
323
- res == MpcCore.decrypt(res_s),
324
- "transferTest: cast 64 failed"
325
- );
326
-
327
- (newA_s, newB_s, res_s) = MpcCore.transfer(
328
- allGTCastingValues.a8_s,
329
- allGTCastingValues.b64_s,
330
- allAmountValues.amount64_s
331
- );
332
- require(
333
- new_a == MpcCore.decrypt(newA_s) &&
334
- new_b == MpcCore.decrypt(newB_s) &&
335
- res == MpcCore.decrypt(res_s),
336
- "transferTest: cast 64 failed"
337
- );
338
-
339
- (newA_s, newB_s, res_s) = MpcCore.transfer(
340
- allGTCastingValues.a64_s,
341
- allGTCastingValues.b8_s,
342
- allAmountValues.amount64_s
343
- );
344
- require(
345
- new_a == MpcCore.decrypt(newA_s) &&
346
- new_b == MpcCore.decrypt(newB_s) &&
347
- res == MpcCore.decrypt(res_s),
348
- "transferTest: cast 64 failed"
349
- );
350
-
351
- (newA_s, newB_s, res_s) = MpcCore.transfer(
352
- allGTCastingValues.a16_s,
353
- allGTCastingValues.b64_s,
354
- allAmountValues.amount64_s
355
- );
356
- require(
357
- new_a == MpcCore.decrypt(newA_s) &&
358
- new_b == MpcCore.decrypt(newB_s) &&
359
- res == MpcCore.decrypt(res_s),
360
- "transferTest: cast 64 failed"
361
- );
362
-
363
- (newA_s, newB_s, res_s) = MpcCore.transfer(
364
- allGTCastingValues.a64_s,
365
- allGTCastingValues.b16_s,
366
- allAmountValues.amount64_s
367
- );
368
- require(
369
- new_a == MpcCore.decrypt(newA_s) &&
370
- new_b == MpcCore.decrypt(newB_s) &&
371
- res == MpcCore.decrypt(res_s),
372
- "transferTest: cast 64 failed"
373
- );
374
-
375
- (newA_s, newB_s, res_s) = MpcCore.transfer(
376
- allGTCastingValues.a32_s,
377
- allGTCastingValues.b64_s,
378
- allAmountValues.amount64_s
379
- );
380
- require(
381
- new_a == MpcCore.decrypt(newA_s) &&
382
- new_b == MpcCore.decrypt(newB_s) &&
383
- res == MpcCore.decrypt(res_s),
384
- "transferTest: cast 64 failed"
385
- );
386
-
387
- (newA_s, newB_s, res_s) = MpcCore.transfer(
388
- allGTCastingValues.a64_s,
389
- allGTCastingValues.b32_s,
390
- allAmountValues.amount64_s
391
- );
392
- require(
393
- new_a == MpcCore.decrypt(newA_s) &&
394
- new_b == MpcCore.decrypt(newB_s) &&
395
- res == MpcCore.decrypt(res_s),
396
- "transferTest: cast 64 failed"
397
- );
114
+ (gtUint64 newA_s, gtUint64 newB_s, gtBool res_s) = MpcCore.transfer(allGTCastingValues.a64_s, allGTCastingValues.b64_s, allAmountValues.amount64_s);
115
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s), "transferTest: cast 64 failed");
116
+
117
+ (newA_s, newB_s, res_s) = MpcCore.transfer(allGTCastingValues.a8_s, allGTCastingValues.b64_s, allAmountValues.amount64_s);
118
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s), "transferTest: cast 64 failed");
119
+
120
+ (newA_s, newB_s, res_s) = MpcCore.transfer(allGTCastingValues.a64_s, allGTCastingValues.b8_s, allAmountValues.amount64_s);
121
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s), "transferTest: cast 64 failed");
122
+
123
+ (newA_s, newB_s, res_s) = MpcCore.transfer(allGTCastingValues.a16_s, allGTCastingValues.b64_s, allAmountValues.amount64_s);
124
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s), "transferTest: cast 64 failed");
125
+
126
+ (newA_s, newB_s, res_s) = MpcCore.transfer(allGTCastingValues.a64_s, allGTCastingValues.b16_s, allAmountValues.amount64_s);
127
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s), "transferTest: cast 64 failed");
128
+
129
+ (newA_s, newB_s, res_s) = MpcCore.transfer(allGTCastingValues.a32_s, allGTCastingValues.b64_s, allAmountValues.amount64_s);
130
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s), "transferTest: cast 64 failed");
131
+
132
+ (newA_s, newB_s, res_s) = MpcCore.transfer(allGTCastingValues.a64_s, allGTCastingValues.b32_s, allAmountValues.amount64_s);
133
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s), "transferTest: cast 64 failed");
134
+
398
135
 
399
136
  // Check all options for casting to 64 while amount is 32
400
- (newA_s, newB_s, res_s) = MpcCore.transfer(
401
- allGTCastingValues.a64_s,
402
- allGTCastingValues.b64_s,
403
- allAmountValues.amount32_s
404
- );
405
- require(
406
- new_a == MpcCore.decrypt(newA_s) &&
407
- new_b == MpcCore.decrypt(newB_s) &&
408
- res == MpcCore.decrypt(res_s),
409
- "transferTest: cast 32 failed"
410
- );
411
-
412
- (newA_s, newB_s, res_s) = MpcCore.transfer(
413
- allGTCastingValues.a8_s,
414
- allGTCastingValues.b64_s,
415
- allAmountValues.amount32_s
416
- );
417
- require(
418
- new_a == MpcCore.decrypt(newA_s) &&
419
- new_b == MpcCore.decrypt(newB_s) &&
420
- res == MpcCore.decrypt(res_s),
421
- "transferTest: cast 32 failed"
422
- );
423
-
424
- (newA_s, newB_s, res_s) = MpcCore.transfer(
425
- allGTCastingValues.a64_s,
426
- allGTCastingValues.b8_s,
427
- allAmountValues.amount32_s
428
- );
429
- require(
430
- new_a == MpcCore.decrypt(newA_s) &&
431
- new_b == MpcCore.decrypt(newB_s) &&
432
- res == MpcCore.decrypt(res_s),
433
- "transferTest: cast 32 failed"
434
- );
435
-
436
- (newA_s, newB_s, res_s) = MpcCore.transfer(
437
- allGTCastingValues.a16_s,
438
- allGTCastingValues.b64_s,
439
- allAmountValues.amount32_s
440
- );
441
- require(
442
- new_a == MpcCore.decrypt(newA_s) &&
443
- new_b == MpcCore.decrypt(newB_s) &&
444
- res == MpcCore.decrypt(res_s),
445
- "transferTest: cast 32 failed"
446
- );
447
-
448
- (newA_s, newB_s, res_s) = MpcCore.transfer(
449
- allGTCastingValues.a64_s,
450
- allGTCastingValues.b16_s,
451
- allAmountValues.amount32_s
452
- );
453
- require(
454
- new_a == MpcCore.decrypt(newA_s) &&
455
- new_b == MpcCore.decrypt(newB_s) &&
456
- res == MpcCore.decrypt(res_s),
457
- "transferTest: cast 32 failed"
458
- );
459
-
460
- (newA_s, newB_s, res_s) = MpcCore.transfer(
461
- allGTCastingValues.a32_s,
462
- allGTCastingValues.b64_s,
463
- allAmountValues.amount32_s
464
- );
465
- require(
466
- new_a == MpcCore.decrypt(newA_s) &&
467
- new_b == MpcCore.decrypt(newB_s) &&
468
- res == MpcCore.decrypt(res_s),
469
- "transferTest: cast 32 failed"
470
- );
471
-
472
- (newA_s, newB_s, res_s) = MpcCore.transfer(
473
- allGTCastingValues.a64_s,
474
- allGTCastingValues.b32_s,
475
- allAmountValues.amount32_s
476
- );
477
- require(
478
- new_a == MpcCore.decrypt(newA_s) &&
479
- new_b == MpcCore.decrypt(newB_s) &&
480
- res == MpcCore.decrypt(res_s),
481
- "transferTest: cast 32 failed"
482
- );
137
+ (newA_s, newB_s, res_s) = MpcCore.transfer(allGTCastingValues.a64_s, allGTCastingValues.b64_s, allAmountValues.amount32_s);
138
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s), "transferTest: cast 32 failed");
139
+
140
+ (newA_s, newB_s, res_s) = MpcCore.transfer(allGTCastingValues.a8_s, allGTCastingValues.b64_s, allAmountValues.amount32_s);
141
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s), "transferTest: cast 32 failed");
142
+
143
+ (newA_s, newB_s, res_s) = MpcCore.transfer(allGTCastingValues.a64_s, allGTCastingValues.b8_s, allAmountValues.amount32_s);
144
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s), "transferTest: cast 32 failed");
145
+
146
+ (newA_s, newB_s, res_s) = MpcCore.transfer(allGTCastingValues.a16_s, allGTCastingValues.b64_s, allAmountValues.amount32_s);
147
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s), "transferTest: cast 32 failed");
148
+
149
+ (newA_s, newB_s, res_s) = MpcCore.transfer(allGTCastingValues.a64_s, allGTCastingValues.b16_s, allAmountValues.amount32_s);
150
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s), "transferTest: cast 32 failed");
151
+
152
+ (newA_s, newB_s, res_s) = MpcCore.transfer(allGTCastingValues.a32_s, allGTCastingValues.b64_s, allAmountValues.amount32_s);
153
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s), "transferTest: cast 32 failed");
154
+
155
+ (newA_s, newB_s, res_s) = MpcCore.transfer(allGTCastingValues.a64_s, allGTCastingValues.b32_s, allAmountValues.amount32_s);
156
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s), "transferTest: cast 32 failed");
157
+
483
158
 
484
159
  // Check all options for casting to 64 while amount is 8
485
- (newA_s, newB_s, res_s) = MpcCore.transfer(
486
- allGTCastingValues.a64_s,
487
- allGTCastingValues.b64_s,
488
- allAmountValues.amount8_s
489
- );
490
- require(
491
- new_a == MpcCore.decrypt(newA_s) &&
492
- new_b == MpcCore.decrypt(newB_s) &&
493
- res == MpcCore.decrypt(res_s),
494
- "transferTest: cast 8 failed"
495
- );
496
-
497
- (newA_s, newB_s, res_s) = MpcCore.transfer(
498
- allGTCastingValues.a8_s,
499
- allGTCastingValues.b64_s,
500
- allAmountValues.amount8_s
501
- );
502
- require(
503
- new_a == MpcCore.decrypt(newA_s) &&
504
- new_b == MpcCore.decrypt(newB_s) &&
505
- res == MpcCore.decrypt(res_s),
506
- "transferTest: cast 8 failed"
507
- );
508
-
509
- (newA_s, newB_s, res_s) = MpcCore.transfer(
510
- allGTCastingValues.a64_s,
511
- allGTCastingValues.b8_s,
512
- allAmountValues.amount8_s
513
- );
514
- require(
515
- new_a == MpcCore.decrypt(newA_s) &&
516
- new_b == MpcCore.decrypt(newB_s) &&
517
- res == MpcCore.decrypt(res_s),
518
- "transferTest: cast 8 failed"
519
- );
520
-
521
- (newA_s, newB_s, res_s) = MpcCore.transfer(
522
- allGTCastingValues.a16_s,
523
- allGTCastingValues.b64_s,
524
- allAmountValues.amount8_s
525
- );
526
- require(
527
- new_a == MpcCore.decrypt(newA_s) &&
528
- new_b == MpcCore.decrypt(newB_s) &&
529
- res == MpcCore.decrypt(res_s),
530
- "transferTest: cast 8 failed"
531
- );
532
-
533
- (newA_s, newB_s, res_s) = MpcCore.transfer(
534
- allGTCastingValues.a64_s,
535
- allGTCastingValues.b16_s,
536
- allAmountValues.amount8_s
537
- );
538
- require(
539
- new_a == MpcCore.decrypt(newA_s) &&
540
- new_b == MpcCore.decrypt(newB_s) &&
541
- res == MpcCore.decrypt(res_s),
542
- "transferTest: cast 8 failed"
543
- );
544
-
545
- (newA_s, newB_s, res_s) = MpcCore.transfer(
546
- allGTCastingValues.a32_s,
547
- allGTCastingValues.b64_s,
548
- allAmountValues.amount8_s
549
- );
550
- require(
551
- new_a == MpcCore.decrypt(newA_s) &&
552
- new_b == MpcCore.decrypt(newB_s) &&
553
- res == MpcCore.decrypt(res_s),
554
- "transferTest: cast 8 failed"
555
- );
556
-
557
- (newA_s, newB_s, res_s) = MpcCore.transfer(
558
- allGTCastingValues.a64_s,
559
- allGTCastingValues.b32_s,
560
- allAmountValues.amount8_s
561
- );
562
- require(
563
- new_a == MpcCore.decrypt(newA_s) &&
564
- new_b == MpcCore.decrypt(newB_s) &&
565
- res == MpcCore.decrypt(res_s),
566
- "transferTest: cast 8 failed"
567
- );
160
+ (newA_s, newB_s, res_s) = MpcCore.transfer(allGTCastingValues.a64_s, allGTCastingValues.b64_s, allAmountValues.amount8_s);
161
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s), "transferTest: cast 8 failed");
162
+
163
+ (newA_s, newB_s, res_s) = MpcCore.transfer(allGTCastingValues.a8_s, allGTCastingValues.b64_s, allAmountValues.amount8_s);
164
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s), "transferTest: cast 8 failed");
165
+
166
+ (newA_s, newB_s, res_s) = MpcCore.transfer(allGTCastingValues.a64_s, allGTCastingValues.b8_s, allAmountValues.amount8_s);
167
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s), "transferTest: cast 8 failed");
168
+
169
+ (newA_s, newB_s, res_s) = MpcCore.transfer(allGTCastingValues.a16_s, allGTCastingValues.b64_s, allAmountValues.amount8_s);
170
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s), "transferTest: cast 8 failed");
171
+
172
+ (newA_s, newB_s, res_s) = MpcCore.transfer(allGTCastingValues.a64_s, allGTCastingValues.b16_s, allAmountValues.amount8_s);
173
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s), "transferTest: cast 8 failed");
174
+
175
+ (newA_s, newB_s, res_s) = MpcCore.transfer(allGTCastingValues.a32_s, allGTCastingValues.b64_s, allAmountValues.amount8_s);
176
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s), "transferTest: cast 8 failed");
177
+
178
+ (newA_s, newB_s, res_s) = MpcCore.transfer(allGTCastingValues.a64_s, allGTCastingValues.b32_s, allAmountValues.amount8_s);
179
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s), "transferTest: cast 8 failed");
568
180
 
569
181
  // Check all options for casting to 64 while amount is 16
570
- (newA_s, newB_s, res_s) = MpcCore.transfer(
571
- allGTCastingValues.a64_s,
572
- allGTCastingValues.b64_s,
573
- allAmountValues.amount16_s
574
- );
575
- require(
576
- new_a == MpcCore.decrypt(newA_s) &&
577
- new_b == MpcCore.decrypt(newB_s) &&
578
- res == MpcCore.decrypt(res_s),
579
- "transferTest: cast 16 failed"
580
- );
581
-
582
- (newA_s, newB_s, res_s) = MpcCore.transfer(
583
- allGTCastingValues.a8_s,
584
- allGTCastingValues.b64_s,
585
- allAmountValues.amount16_s
586
- );
587
- require(
588
- new_a == MpcCore.decrypt(newA_s) &&
589
- new_b == MpcCore.decrypt(newB_s) &&
590
- res == MpcCore.decrypt(res_s),
591
- "transferTest: cast 16 failed"
592
- );
593
-
594
- (newA_s, newB_s, res_s) = MpcCore.transfer(
595
- allGTCastingValues.a64_s,
596
- allGTCastingValues.b8_s,
597
- allAmountValues.amount16_s
598
- );
599
- require(
600
- new_a == MpcCore.decrypt(newA_s) &&
601
- new_b == MpcCore.decrypt(newB_s) &&
602
- res == MpcCore.decrypt(res_s),
603
- "transferTest: cast 16 failed"
604
- );
605
-
606
- (newA_s, newB_s, res_s) = MpcCore.transfer(
607
- allGTCastingValues.a16_s,
608
- allGTCastingValues.b64_s,
609
- allAmountValues.amount16_s
610
- );
611
- require(
612
- new_a == MpcCore.decrypt(newA_s) &&
613
- new_b == MpcCore.decrypt(newB_s) &&
614
- res == MpcCore.decrypt(res_s),
615
- "transferTest: cast 16 failed"
616
- );
617
-
618
- (newA_s, newB_s, res_s) = MpcCore.transfer(
619
- allGTCastingValues.a64_s,
620
- allGTCastingValues.b16_s,
621
- allAmountValues.amount16_s
622
- );
623
- require(
624
- new_a == MpcCore.decrypt(newA_s) &&
625
- new_b == MpcCore.decrypt(newB_s) &&
626
- res == MpcCore.decrypt(res_s),
627
- "transferTest: cast 16 failed"
628
- );
629
-
630
- (newA_s, newB_s, res_s) = MpcCore.transfer(
631
- allGTCastingValues.a32_s,
632
- allGTCastingValues.b64_s,
633
- allAmountValues.amount16_s
634
- );
635
- require(
636
- new_a == MpcCore.decrypt(newA_s) &&
637
- new_b == MpcCore.decrypt(newB_s) &&
638
- res == MpcCore.decrypt(res_s),
639
- "transferTest: cast 16 failed"
640
- );
641
-
642
- (newA_s, newB_s, res_s) = MpcCore.transfer(
643
- allGTCastingValues.a64_s,
644
- allGTCastingValues.b32_s,
645
- allAmountValues.amount16_s
646
- );
647
- require(
648
- new_a == MpcCore.decrypt(newA_s) &&
649
- new_b == MpcCore.decrypt(newB_s) &&
650
- res == MpcCore.decrypt(res_s),
651
- "transferTest: cast 16 failed"
652
- );
182
+ (newA_s, newB_s, res_s) = MpcCore.transfer(allGTCastingValues.a64_s, allGTCastingValues.b64_s, allAmountValues.amount16_s);
183
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s), "transferTest: cast 16 failed");
184
+
185
+ (newA_s, newB_s, res_s) = MpcCore.transfer(allGTCastingValues.a8_s, allGTCastingValues.b64_s, allAmountValues.amount16_s);
186
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s), "transferTest: cast 16 failed");
187
+
188
+ (newA_s, newB_s, res_s) = MpcCore.transfer(allGTCastingValues.a64_s, allGTCastingValues.b8_s, allAmountValues.amount16_s);
189
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s), "transferTest: cast 16 failed");
190
+
191
+ (newA_s, newB_s, res_s) = MpcCore.transfer(allGTCastingValues.a16_s, allGTCastingValues.b64_s, allAmountValues.amount16_s);
192
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s), "transferTest: cast 16 failed");
193
+
194
+ (newA_s, newB_s, res_s) = MpcCore.transfer(allGTCastingValues.a64_s, allGTCastingValues.b16_s, allAmountValues.amount16_s);
195
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s), "transferTest: cast 16 failed");
196
+
197
+ (newA_s, newB_s, res_s) = MpcCore.transfer(allGTCastingValues.a32_s, allGTCastingValues.b64_s, allAmountValues.amount16_s);
198
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s), "transferTest: cast 16 failed");
199
+
200
+ (newA_s, newB_s, res_s) = MpcCore.transfer(allGTCastingValues.a64_s, allGTCastingValues.b32_s, allAmountValues.amount16_s);
201
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s), "transferTest: cast 16 failed");
653
202
  }
654
203
 
655
- function transferTest(
656
- uint8 a,
657
- uint8 b,
658
- uint8 amount
659
- ) public returns (uint8, uint8, bool) {
204
+
205
+ function transferTest(uint8 a, uint8 b, uint8 amount) public returns (uint8, uint8, bool) {
660
206
  AllGTCastingValues memory allGTCastingValues;
661
207
  AllAmountValues memory allAmountValues;
662
208
  allGTCastingValues.a8_s = MpcCore.setPublic8(a);
663
209
  allGTCastingValues.b8_s = MpcCore.setPublic8(b);
664
- allGTCastingValues.a16_s = MpcCore.setPublic16(a);
665
- allGTCastingValues.b16_s = MpcCore.setPublic16(b);
666
- allGTCastingValues.a32_s = MpcCore.setPublic32(a);
667
- allGTCastingValues.b32_s = MpcCore.setPublic32(b);
668
- allGTCastingValues.a64_s = MpcCore.setPublic64(a);
669
- allGTCastingValues.b64_s = MpcCore.setPublic64(b);
210
+ allGTCastingValues.a16_s = MpcCore.setPublic16(a);
211
+ allGTCastingValues.b16_s = MpcCore.setPublic16(b);
212
+ allGTCastingValues.a32_s = MpcCore.setPublic32(a);
213
+ allGTCastingValues.b32_s = MpcCore.setPublic32(b);
214
+ allGTCastingValues.a64_s = MpcCore.setPublic64(a);
215
+ allGTCastingValues.b64_s = MpcCore.setPublic64(b);
670
216
  allAmountValues.amount8_s = MpcCore.setPublic8(amount);
671
217
  allAmountValues.amount16_s = MpcCore.setPublic16(amount);
672
218
  allAmountValues.amount32_s = MpcCore.setPublic32(amount);
@@ -674,42 +220,21 @@ contract TransferTestsContract {
674
220
  allAmountValues.amount = amount;
675
221
 
676
222
  // Calculate the expected result
677
- (gtUint8 newA_s, gtUint8 newB_s, gtBool res_s) = MpcCore.transfer(
678
- allGTCastingValues.a8_s,
679
- allGTCastingValues.b8_s,
680
- allAmountValues.amount8_s
681
- );
223
+ (gtUint8 newA_s, gtUint8 newB_s, gtBool res_s) = MpcCore.transfer(allGTCastingValues.a8_s, allGTCastingValues.b8_s, allAmountValues.amount8_s);
682
224
  newA = MpcCore.decrypt(newA_s);
683
225
  newB = MpcCore.decrypt(newB_s);
684
226
  result = MpcCore.decrypt(res_s);
685
227
 
686
228
  // Calculate the result with casting to 16
687
- computeAndChekTransfer16(
688
- allGTCastingValues,
689
- allAmountValues,
690
- newA,
691
- newB,
692
- result
693
- );
229
+ computeAndCheckTransfer16(allGTCastingValues, allAmountValues, newA, newB, result);
694
230
 
695
231
  // Calculate the result with casting to 32
696
- computeAndChekTransfer32(
697
- allGTCastingValues,
698
- allAmountValues,
699
- newA,
700
- newB,
701
- result
702
- );
232
+ computeAndCheckTransfer32(allGTCastingValues, allAmountValues, newA, newB, result);
703
233
 
704
234
  // Calculate the result with casting to 64
705
- computeAndChekTransfer64(
706
- allGTCastingValues,
707
- allAmountValues,
708
- newA,
709
- newB,
710
- result
711
- );
235
+ computeAndCheckTransfer64(allGTCastingValues, allAmountValues, newA, newB, result);
712
236
 
713
237
  return (newA, newB, result);
714
238
  }
715
- }
239
+
240
+ }