@coti-io/coti-contracts 0.1.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/contracts/access/DataPrivacyFramework/extensions/DataPrivacyFrameworkMpc.sol +3 -115
  2. package/contracts/mocks/README.md +1 -1
  3. package/contracts/mocks/utils/mpc/ArithmeticTestsContract.sol +105 -280
  4. package/contracts/mocks/utils/mpc/BitwiseTestsContract.sol +83 -187
  5. package/contracts/mocks/utils/mpc/{Comparison1Tests.Contract.sol → Comparison1TestsContract.sol} +67 -115
  6. package/contracts/mocks/utils/mpc/Comparison2TestsContract.sol +68 -116
  7. package/contracts/mocks/utils/mpc/MinMaxTestsContract.sol +69 -164
  8. package/contracts/mocks/utils/mpc/Miscellaneous1TestsContract.sol +70 -52
  9. package/contracts/mocks/utils/mpc/MiscellaneousTestsContract.sol +270 -0
  10. package/contracts/mocks/utils/mpc/OffboardToUserKeyTestContract.sol +102 -0
  11. package/contracts/mocks/utils/mpc/README.md +12 -12
  12. package/contracts/mocks/utils/mpc/TransferScalarTestsContract.sol +54 -211
  13. package/contracts/mocks/utils/mpc/TransferTestsContract.sol +162 -640
  14. package/contracts/onboard/AccountOnboard.sol +3 -3
  15. package/contracts/utils/mpc/MpcCore.sol +2835 -988
  16. package/contracts/utils/mpc/MpcInterface.sol +6 -4
  17. package/hardhat.config.ts +8 -5
  18. package/package.json +2 -2
  19. package/test/utils/accounts.ts +1 -1
  20. package/test/utils/mpc/Precompile.test.ts +26 -37
  21. package/typechain-types/contracts/mocks/utils/mpc/ArithmeticTestsContract.sol/ArithmeticTestsContract.ts +374 -0
  22. package/typechain-types/contracts/mocks/utils/mpc/ArithmeticTestsContract.sol/PrecompilesArythmeticTestsContract.ts +374 -0
  23. package/typechain-types/contracts/mocks/utils/mpc/ArithmeticTestsContract.sol/index.ts +5 -0
  24. package/typechain-types/contracts/mocks/utils/mpc/ArithmeticTestsContract.ts +30 -10
  25. package/typechain-types/contracts/mocks/utils/mpc/BitwiseTestsContract.ts +39 -5
  26. package/typechain-types/contracts/mocks/utils/mpc/Comparison1TestsContract.ts +374 -0
  27. package/typechain-types/contracts/mocks/utils/mpc/Comparison2TestsContract.ts +39 -5
  28. package/typechain-types/contracts/mocks/utils/mpc/MinMaxTestsContract.ts +25 -5
  29. package/typechain-types/contracts/mocks/utils/mpc/Miscellaneous1TestsContract.ts +62 -0
  30. package/typechain-types/contracts/mocks/utils/mpc/MiscellaneousTestsContract.ts +396 -0
  31. package/typechain-types/contracts/mocks/utils/mpc/OffboardToUserKeyTestContract.ts +221 -0
  32. package/typechain-types/contracts/mocks/utils/mpc/OffboardToUserKeyTestsContract.sol/OffboardToUserKeyTestContract.ts +11 -8
  33. package/typechain-types/contracts/mocks/utils/mpc/TransferScalarTestsContract.ts +15 -15
  34. package/typechain-types/contracts/mocks/utils/mpc/TransferTestsContract.ts +15 -15
  35. package/typechain-types/contracts/mocks/utils/mpc/index.ts +3 -6
  36. package/typechain-types/contracts/onboard/AccountOnboard.ts +9 -4
  37. package/typechain-types/contracts/utils/mpc/MpcCore.ts +84 -0
  38. package/typechain-types/contracts/utils/mpc/MpcInterface.sol/ExtendedOperations.ts +81 -40
  39. package/typechain-types/contracts/utils/mpc/index.ts +1 -0
  40. package/typechain-types/factories/contracts/mocks/access/DataPrivacyFramework/DataPrivacyFrameworkMock__factory.ts +1 -1
  41. package/typechain-types/factories/contracts/mocks/token/PrivateERC20/PrivateERC20Mock__factory.ts +1 -1
  42. package/typechain-types/factories/contracts/mocks/token/PrivateERC721/PrivateERC721URIStorageMock__factory.ts +1 -1
  43. package/typechain-types/factories/contracts/mocks/utils/mpc/ArithmeticTestsContract.sol/ArithmeticTestsContract__factory.ts +387 -0
  44. package/typechain-types/factories/contracts/mocks/utils/mpc/ArithmeticTestsContract.sol/PrecompilesArythmeticTestsContract__factory.ts +388 -0
  45. package/typechain-types/factories/contracts/mocks/utils/mpc/ArithmeticTestsContract.sol/index.ts +5 -0
  46. package/typechain-types/factories/contracts/mocks/utils/mpc/ArithmeticTestsContract__factory.ts +20 -7
  47. package/typechain-types/factories/contracts/mocks/utils/mpc/BitwiseTestsContract__factory.ts +28 -2
  48. package/typechain-types/factories/contracts/mocks/utils/mpc/Comparison1Tests.Contract.sol/Comparison1TestsContract__factory.ts +1 -1
  49. package/typechain-types/factories/contracts/mocks/utils/mpc/Comparison1TestsContract__factory.ts +387 -0
  50. package/typechain-types/factories/contracts/mocks/utils/mpc/Comparison2TestsContract__factory.ts +28 -2
  51. package/typechain-types/factories/contracts/mocks/utils/mpc/MinMaxTestsContract__factory.ts +15 -2
  52. package/typechain-types/factories/contracts/mocks/utils/mpc/Miscellaneous1TestsContract__factory.ts +66 -1
  53. package/typechain-types/factories/contracts/mocks/utils/mpc/Miscellaneous2TestsContract__factory.ts +1 -1
  54. package/typechain-types/factories/contracts/mocks/utils/mpc/MiscellaneousTestsContract__factory.ts +424 -0
  55. package/typechain-types/factories/contracts/mocks/utils/mpc/OffboardToUserKeyTestContract__factory.ts +289 -0
  56. package/typechain-types/factories/contracts/mocks/utils/mpc/OffboardToUserKeyTestsContract.sol/OffboardToUserKeyTestContract__factory.ts +19 -3
  57. package/typechain-types/factories/contracts/mocks/utils/mpc/ShiftTestsContract__factory.ts +1 -1
  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 +4 -4
  60. package/typechain-types/factories/contracts/mocks/utils/mpc/TransferTestsContract__factory.ts +4 -4
  61. package/typechain-types/factories/contracts/mocks/utils/mpc/index.ts +3 -4
  62. package/typechain-types/factories/contracts/mocks/wallet/PrivateERC20Wallet/PrivateERC20WalletMock__factory.ts +1 -1
  63. package/typechain-types/factories/contracts/onboard/AccountOnboard__factory.ts +8 -2
  64. package/typechain-types/factories/contracts/utils/mpc/MpcCore__factory.ts +77 -0
  65. package/typechain-types/factories/contracts/utils/mpc/MpcInterface.sol/ExtendedOperations__factory.ts +124 -61
  66. package/typechain-types/factories/contracts/utils/mpc/index.ts +1 -0
  67. package/typechain-types/hardhat.d.ts +26 -26
  68. package/typechain-types/index.ts +8 -8
  69. package/contracts/mocks/utils/mpc/Miscellaneous2TestsContract.sol +0 -448
  70. package/contracts/mocks/utils/mpc/OffboardToUserKeyTestsContract.sol +0 -81
  71. package/contracts/mocks/utils/mpc/ShiftTestsContract.sol +0 -311
@@ -1,4 +1,4 @@
1
- # ArithmeticTestsContract.sol
1
+ # PrecompilesArythmeticTestsContract.sol
2
2
 
3
3
  Performs arithmetic operations (addition, subtraction, and multiplication) on different bit-length values and ensures consistency across various data types.
4
4
 
@@ -49,7 +49,7 @@ The contract relies on the `MpcCore` library for:
49
49
  ## Summary
50
50
  The contract ensures that arithmetic operations on various bit-length values are consistent and correct by performing the operations, decrypting the results, and comparing them across different types and combinations. This can be particularly useful for testing and validating the correctness of arithmetic operations in a decentralized environment.
51
51
 
52
- # BitwiseTestsContract.sol
52
+ # PrecompilesBitwiseTestsContract.sol
53
53
 
54
54
  Performs bitwise operations (AND, OR, XOR) on different bit-length values and ensures consistency across various data types.
55
55
 
@@ -97,7 +97,7 @@ The contract relies on the `MpcCore` library for:
97
97
  ## Summary
98
98
  The contract ensures that bitwise operations on various bit-length values are consistent and correct by performing the operations, decrypting the results, and comparing them across different types and combinations. This can be particularly useful for testing and validating the correctness of bitwise operations in a decentralized environment.
99
99
 
100
- # Comparison1TestsContract.sol
100
+ # PrecompilesComparison1TestsContract.sol
101
101
 
102
102
  Performs comparison operations (greater than, less than or equal to, and less than) on different bit-length values and ensures consistency across various data types.
103
103
 
@@ -145,7 +145,7 @@ The contract relies on the `MpcCore` library for:
145
145
  ## Summary
146
146
  The contract ensures that comparison operations on various bit-length values are consistent and correct by performing the operations, decrypting the results, and comparing them across different types and combinations. This can be particularly useful for testing and validating the correctness of comparison operations in a decentralized environment.
147
147
 
148
- # Comparison2TestsContract.sol
148
+ # PrecompilesComparison2TestsContract.sol
149
149
 
150
150
  Performs additional comparison operations (equal to, not equal to, greater than or equal to) on different bit-length values and ensures consistency across various data types.
151
151
 
@@ -193,7 +193,7 @@ The contract relies on the `MpcCore` library for:
193
193
  ## Summary
194
194
  The contract ensures that comparison operations on various bit-length values are consistent and correct by performing the operations, decrypting the results, and comparing them across different types and combinations. This can be particularly useful for testing and validating the correctness of comparison operations in a decentralized environment.
195
195
 
196
- # MinMaxTestsContract.sol
196
+ # PrecompilesMinMaxTestsContract.sol
197
197
 
198
198
  Performs minimum and maximum operations on different bit-length values and ensures consistency across various data types.
199
199
 
@@ -235,7 +235,7 @@ The contract relies on the `MpcCore` library for:
235
235
  ## Summary
236
236
  The contract ensures that min/max operations on various bit-length values are consistent and correct by performing the operations, decrypting the results, and comparing them across different types and combinations. This can be particularly useful for testing and validating the correctness of min/max operations in a decentralized environment.
237
237
 
238
- # Miscellaneous1TestsContract.sol
238
+ # PrecompilesMiscellaneous1TestsContract.sol
239
239
 
240
240
  Performs various miscellaneous operations including random number generation and boolean logic operations.
241
241
 
@@ -277,7 +277,7 @@ The contract relies on the `MpcCore` library for:
277
277
  ## Summary
278
278
  The contract ensures the correctness of random number generation and boolean operations by performing the operations, decrypting the results, and comparing them as necessary. This can be particularly useful for testing and validating the correctness of these operations in a decentralized environment.
279
279
 
280
- # Miscellaneous2TestsContract.sol
280
+ # PrecompilesMiscellaneousTestsContract.sol
281
281
 
282
282
  Performs various miscellaneous operations including division, remainder, mux, offboard/onboard, and boolean NOT operations.
283
283
 
@@ -334,7 +334,7 @@ The contract relies on the `MpcCore` library for:
334
334
  ## Summary
335
335
  The contract ensures the correctness of various miscellaneous operations by performing the operations, decrypting the results, and comparing them as necessary. This can be particularly useful for testing and validating the correctness of these operations in a decentralized environment.
336
336
 
337
- # OffboardToUserKeyTestContract.sol
337
+ # PrecompilesOffboardToUserKeyTestContract.sol
338
338
 
339
339
  Performs operations involving offboarding data to a user key and handling various cryptographic operations.
340
340
 
@@ -373,7 +373,7 @@ The contract relies on the `MpcCore` library for:
373
373
  ## Summary
374
374
  The contract ensures the correctness of operations involving offboarding to user keys by performing the operations, decrypting the results, and comparing them as necessary. This can be particularly useful for testing and validating the correctness of these operations in a decentralized environment.
375
375
 
376
- # ShiftTestsContract.sol
376
+ # PrecompilesShiftTestsContract.sol
377
377
 
378
378
  Performs various shift operations (left and right) on different bit-length values and ensures consistency across various data types.
379
379
 
@@ -419,7 +419,7 @@ The contract relies on the `MpcCore` library for:
419
419
  ## Summary
420
420
  The contract ensures the correctness of shift operations on various bit-length values by performing the operations, decrypting the results, and comparing them as necessary. This can be particularly useful for testing and validating the correctness of these operations in a decentralized environment.
421
421
 
422
- # TransferScalarTestsContract.sol
422
+ # PrecompilesTransferScalarTestsContract.sol
423
423
 
424
424
  Performs transfer operations with scalar values, checking the correctness of these operations across different bit-length values.
425
425
 
@@ -456,7 +456,7 @@ The contract relies on the `MpcCore` library for:
456
456
  ## Summary
457
457
  The contract ensures the correctness of transfer operations with scalar values by performing the operations, decrypting the results, and comparing them as necessary. This can be particularly useful for testing and validating the correctness of these operations in a decentralized environment.
458
458
 
459
- # TransferTestsContract.sol
459
+ # PrecompilesTransferTestsContract.sol
460
460
 
461
461
  Designed to test the transfer functionality of the `MpcCore` library with different data types and casting scenarios. The contract includes several key components and functions.
462
462
 
@@ -483,4 +483,4 @@ The contract relies on the `MpcCore` library for its core operations, which incl
483
483
  3. `MpcCore.setPublic*`: These functions set the public values for different data types (8, 16, 32, and 64-bit unsigned integers).
484
484
 
485
485
  ## Summary
486
- The `PrecompilesTransferTestsContract` ensures that the transfer functionality of the `MpcCore` library works correctly with various data types and casting scenarios by comparing the results of the `MpcCore.transfer` function with the expected values using `MpcCore.decrypt`.
486
+ The `PrecompilesTransferTestsContract` ensures that the transfer functionality of the `MpcCore` library works correctly with various data types and casting scenarios by comparing the results of the `MpcCore.transfer` function with the expected values using `MpcCore.decrypt`.
@@ -1,11 +1,10 @@
1
1
  // SPDX-License-Identifier: MIT
2
-
3
2
  pragma solidity ^0.8.19;
4
3
 
5
4
  import "../../../utils/mpc/MpcCore.sol";
6
5
 
7
6
  contract TransferScalarTestsContract {
8
-
7
+
9
8
  struct AllGTCastingValues {
10
9
  gtUint8 a8_s;
11
10
  gtUint8 b8_s;
@@ -25,247 +24,91 @@ contract TransferScalarTestsContract {
25
24
  return (new_a, new_b, res);
26
25
  }
27
26
 
28
- function computeAndChekTransfer16(
29
- AllGTCastingValues memory allGTCastingValues,
30
- uint8 new_a,
31
- uint8 new_b,
32
- bool res,
33
- uint8 amount
34
- ) public {
27
+ function computeAndCheckTransfer16(AllGTCastingValues memory allGTCastingValues, uint8 new_a, uint8 new_b, bool res, uint8 amount) public {
28
+
35
29
  // Check all options for casting to 16 while amount is scalar
36
- (gtUint16 newA_s, gtUint16 newB_s, gtBool res_s) = MpcCore.transfer(
37
- allGTCastingValues.a16_s,
38
- allGTCastingValues.b16_s,
39
- amount
40
- );
41
- require(
42
- new_a == MpcCore.decrypt(newA_s) &&
43
- new_b == MpcCore.decrypt(newB_s) &&
44
- res == MpcCore.decrypt(res_s),
45
- "transferTest: check scalar failed"
46
- );
30
+ (gtUint16 newA_s, gtUint16 newB_s, gtBool res_s) = MpcCore.transfer(allGTCastingValues.a16_s, allGTCastingValues.b16_s, amount);
31
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s), "transferTest: check scalar failed");
47
32
 
48
- (newA_s, newB_s, res_s) = MpcCore.transfer(
49
- allGTCastingValues.a8_s,
50
- allGTCastingValues.b16_s,
51
- amount
52
- );
53
- require(
54
- new_a == MpcCore.decrypt(newA_s) &&
55
- new_b == MpcCore.decrypt(newB_s) &&
56
- res == MpcCore.decrypt(res_s),
57
- "transferTest: check scalar failed"
58
- );
33
+ (newA_s, newB_s, res_s) = MpcCore.transfer(allGTCastingValues.a8_s, allGTCastingValues.b16_s, amount);
34
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s), "transferTest: check scalar failed");
59
35
 
60
- (newA_s, newB_s, res_s) = MpcCore.transfer(
61
- allGTCastingValues.a16_s,
62
- allGTCastingValues.b8_s,
63
- amount
64
- );
65
- require(
66
- new_a == MpcCore.decrypt(newA_s) &&
67
- new_b == MpcCore.decrypt(newB_s) &&
68
- res == MpcCore.decrypt(res_s),
69
- "transferTest: check scalar failed"
70
- );
36
+ (newA_s, newB_s, res_s) = MpcCore.transfer(allGTCastingValues.a16_s, allGTCastingValues.b8_s, amount);
37
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s), "transferTest: check scalar failed");
71
38
  }
72
39
 
73
- function computeAndChekTransfer32(
74
- AllGTCastingValues memory allGTCastingValues,
75
- uint8 new_a,
76
- uint8 new_b,
77
- bool res,
78
- uint8 amount
79
- ) public {
40
+ function computeAndCheckTransfer32(AllGTCastingValues memory allGTCastingValues, uint8 new_a, uint8 new_b, bool res, uint8 amount) public {
41
+
80
42
  // Check all options for casting to 32 while amount is scalar
81
- (gtUint32 newA_s, gtUint32 newB_s, gtBool res_s) = MpcCore.transfer(
82
- allGTCastingValues.a32_s,
83
- allGTCastingValues.b32_s,
84
- amount
85
- );
86
- require(
87
- new_a == MpcCore.decrypt(newA_s) &&
88
- new_b == MpcCore.decrypt(newB_s) &&
89
- res == MpcCore.decrypt(res_s),
90
- "transferTest: check scalar failed"
91
- );
43
+ (gtUint32 newA_s, gtUint32 newB_s, gtBool res_s) = MpcCore.transfer(allGTCastingValues.a32_s, allGTCastingValues.b32_s, amount);
44
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s), "transferTest: check scalar failed");
92
45
 
93
- (newA_s, newB_s, res_s) = MpcCore.transfer(
94
- allGTCastingValues.a8_s,
95
- allGTCastingValues.b32_s,
96
- amount
97
- );
98
- require(
99
- new_a == MpcCore.decrypt(newA_s) &&
100
- new_b == MpcCore.decrypt(newB_s) &&
101
- res == MpcCore.decrypt(res_s),
102
- "transferTest: check scalar failed"
103
- );
46
+ (newA_s, newB_s, res_s) = MpcCore.transfer(allGTCastingValues.a8_s, allGTCastingValues.b32_s, amount);
47
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s), "transferTest: check scalar failed");
104
48
 
105
- (newA_s, newB_s, res_s) = MpcCore.transfer(
106
- allGTCastingValues.a32_s,
107
- allGTCastingValues.b8_s,
108
- amount
109
- );
110
- require(
111
- new_a == MpcCore.decrypt(newA_s) &&
112
- new_b == MpcCore.decrypt(newB_s) &&
113
- res == MpcCore.decrypt(res_s),
114
- "transferTest: check scalar failed"
115
- );
49
+ (newA_s, newB_s, res_s) = MpcCore.transfer(allGTCastingValues.a32_s, allGTCastingValues.b8_s, amount);
50
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s), "transferTest: check scalar failed");
116
51
 
117
- (newA_s, newB_s, res_s) = MpcCore.transfer(
118
- allGTCastingValues.a16_s,
119
- allGTCastingValues.b32_s,
120
- amount
121
- );
122
- require(
123
- new_a == MpcCore.decrypt(newA_s) &&
124
- new_b == MpcCore.decrypt(newB_s) &&
125
- res == MpcCore.decrypt(res_s),
126
- "transferTest: check scalar failed"
127
- );
52
+ (newA_s, newB_s, res_s) = MpcCore.transfer(allGTCastingValues.a16_s, allGTCastingValues.b32_s, amount);
53
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s), "transferTest: check scalar failed");
128
54
 
129
- (newA_s, newB_s, res_s) = MpcCore.transfer(
130
- allGTCastingValues.a32_s,
131
- allGTCastingValues.b16_s,
132
- amount
133
- );
134
- require(
135
- new_a == MpcCore.decrypt(newA_s) &&
136
- new_b == MpcCore.decrypt(newB_s) &&
137
- res == MpcCore.decrypt(res_s),
138
- "transferTest: check scalar failed"
139
- );
55
+ (newA_s, newB_s, res_s) = MpcCore.transfer(allGTCastingValues.a32_s, allGTCastingValues.b16_s, amount);
56
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s), "transferTest: check scalar failed");
140
57
  }
141
58
 
142
- function computeAndChekTransfer64(
143
- AllGTCastingValues memory allGTCastingValues,
144
- uint8 new_a,
145
- uint8 new_b,
146
- bool res,
147
- uint8 amount
148
- ) public {
59
+ function computeAndCheckTransfer64(AllGTCastingValues memory allGTCastingValues, uint8 new_a, uint8 new_b, bool res, uint8 amount) public {
60
+
149
61
  // Check all options for casting to 64 while amount is scalar
150
- (gtUint64 newA_s, gtUint64 newB_s, gtBool res_s) = MpcCore.transfer(
151
- allGTCastingValues.a64_s,
152
- allGTCastingValues.b64_s,
153
- amount
154
- );
155
- require(
156
- new_a == MpcCore.decrypt(newA_s) &&
157
- new_b == MpcCore.decrypt(newB_s) &&
158
- res == MpcCore.decrypt(res_s),
159
- "transferTest: check scalar failed"
160
- );
62
+ (gtUint64 newA_s, gtUint64 newB_s, gtBool res_s) = MpcCore.transfer(allGTCastingValues.a64_s, allGTCastingValues.b64_s, amount);
63
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s), "transferTest: check scalar failed");
161
64
 
162
- (newA_s, newB_s, res_s) = MpcCore.transfer(
163
- allGTCastingValues.a8_s,
164
- allGTCastingValues.b64_s,
165
- amount
166
- );
167
- require(
168
- new_a == MpcCore.decrypt(newA_s) &&
169
- new_b == MpcCore.decrypt(newB_s) &&
170
- res == MpcCore.decrypt(res_s),
171
- "transferTest: check scalar failed"
172
- );
65
+ (newA_s, newB_s, res_s) = MpcCore.transfer(allGTCastingValues.a8_s, allGTCastingValues.b64_s, amount);
66
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s), "transferTest: check scalar failed");
173
67
 
174
- (newA_s, newB_s, res_s) = MpcCore.transfer(
175
- allGTCastingValues.a64_s,
176
- allGTCastingValues.b8_s,
177
- amount
178
- );
179
- require(
180
- new_a == MpcCore.decrypt(newA_s) &&
181
- new_b == MpcCore.decrypt(newB_s) &&
182
- res == MpcCore.decrypt(res_s),
183
- "transferTest: check scalar failed"
184
- );
68
+ (newA_s, newB_s, res_s) = MpcCore.transfer(allGTCastingValues.a64_s, allGTCastingValues.b8_s, amount);
69
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s), "transferTest: check scalar failed");
185
70
 
186
- (newA_s, newB_s, res_s) = MpcCore.transfer(
187
- allGTCastingValues.a16_s,
188
- allGTCastingValues.b64_s,
189
- amount
190
- );
191
- require(
192
- new_a == MpcCore.decrypt(newA_s) &&
193
- new_b == MpcCore.decrypt(newB_s) &&
194
- res == MpcCore.decrypt(res_s),
195
- "transferTest: check scalar failed"
196
- );
71
+ (newA_s, newB_s, res_s) = MpcCore.transfer(allGTCastingValues.a16_s, allGTCastingValues.b64_s, amount);
72
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s), "transferTest: check scalar failed");
197
73
 
198
- (newA_s, newB_s, res_s) = MpcCore.transfer(
199
- allGTCastingValues.a64_s,
200
- allGTCastingValues.b16_s,
201
- amount
202
- );
203
- require(
204
- new_a == MpcCore.decrypt(newA_s) &&
205
- new_b == MpcCore.decrypt(newB_s) &&
206
- res == MpcCore.decrypt(res_s),
207
- "transferTest: check scalar failed"
208
- );
74
+ (newA_s, newB_s, res_s) = MpcCore.transfer(allGTCastingValues.a64_s, allGTCastingValues.b16_s, amount);
75
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s), "transferTest: check scalar failed");
209
76
 
210
- (newA_s, newB_s, res_s) = MpcCore.transfer(
211
- allGTCastingValues.a32_s,
212
- allGTCastingValues.b64_s,
213
- amount
214
- );
215
- require(
216
- new_a == MpcCore.decrypt(newA_s) &&
217
- new_b == MpcCore.decrypt(newB_s) &&
218
- res == MpcCore.decrypt(res_s),
219
- "transferTest: check scalar failed"
220
- );
77
+ (newA_s, newB_s, res_s) = MpcCore.transfer(allGTCastingValues.a32_s, allGTCastingValues.b64_s, amount);
78
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s), "transferTest: check scalar failed");
221
79
 
222
- (newA_s, newB_s, res_s) = MpcCore.transfer(
223
- allGTCastingValues.a64_s,
224
- allGTCastingValues.b32_s,
225
- amount
226
- );
227
- require(
228
- new_a == MpcCore.decrypt(newA_s) &&
229
- new_b == MpcCore.decrypt(newB_s) &&
230
- res == MpcCore.decrypt(res_s),
231
- "transferTest: check scalar failed"
232
- );
80
+ (newA_s, newB_s, res_s) = MpcCore.transfer(allGTCastingValues.a64_s, allGTCastingValues.b32_s, amount);
81
+ require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s), "transferTest: check scalar failed");
233
82
  }
234
83
 
235
- function transferScalarTest(
236
- uint8 a,
237
- uint8 b,
238
- uint8 amount
239
- ) public returns (uint8, uint8, bool) {
84
+
85
+ function transferScalarTest(uint8 a, uint8 b, uint8 amount) public returns (uint8, uint8, bool) {
240
86
  AllGTCastingValues memory allGTCastingValues;
241
87
  allGTCastingValues.a8_s = MpcCore.setPublic8(a);
242
88
  allGTCastingValues.b8_s = MpcCore.setPublic8(b);
243
- allGTCastingValues.a16_s = MpcCore.setPublic16(a);
244
- allGTCastingValues.b16_s = MpcCore.setPublic16(b);
245
- allGTCastingValues.a32_s = MpcCore.setPublic32(a);
246
- allGTCastingValues.b32_s = MpcCore.setPublic32(b);
247
- allGTCastingValues.a64_s = MpcCore.setPublic64(a);
248
- allGTCastingValues.b64_s = MpcCore.setPublic64(b);
89
+ allGTCastingValues.a16_s = MpcCore.setPublic16(a);
90
+ allGTCastingValues.b16_s = MpcCore.setPublic16(b);
91
+ allGTCastingValues.a32_s = MpcCore.setPublic32(a);
92
+ allGTCastingValues.b32_s = MpcCore.setPublic32(b);
93
+ allGTCastingValues.a64_s = MpcCore.setPublic64(a);
94
+ allGTCastingValues.b64_s = MpcCore.setPublic64(b);
249
95
 
250
96
  // Calculate the expected result
251
- (gtUint8 newA_s, gtUint8 newB_s, gtBool res_s) = MpcCore.transfer(
252
- allGTCastingValues.a8_s,
253
- allGTCastingValues.b8_s,
254
- amount
255
- );
256
- new_a = MpcCore.decrypt(newA_s);
257
- new_b = MpcCore.decrypt(newB_s);
258
- res = MpcCore.decrypt(res_s);
97
+ (gtUint8 newA_s, gtUint8 newB_s, gtBool res_s) = MpcCore.transfer(allGTCastingValues.a8_s, allGTCastingValues.b8_s, amount);
98
+ new_a = MpcCore.decrypt(newA_s);
99
+ new_b = MpcCore.decrypt(newB_s);
100
+ res = MpcCore.decrypt(res_s);
259
101
 
260
102
  // Calculate the result with casting to 16
261
- computeAndChekTransfer16(allGTCastingValues, new_a, new_b, res, amount);
103
+ computeAndCheckTransfer16(allGTCastingValues, new_a, new_b, res, amount);
262
104
 
263
105
  // Calculate the result with casting to 32
264
- computeAndChekTransfer32(allGTCastingValues, new_a, new_b, res, amount);
106
+ computeAndCheckTransfer32(allGTCastingValues, new_a, new_b, res, amount);
265
107
 
266
108
  // Calculate the result with casting to 64
267
- computeAndChekTransfer64(allGTCastingValues, new_a, new_b, res, amount);
109
+ computeAndCheckTransfer64(allGTCastingValues, new_a, new_b, res, amount);
268
110
 
269
111
  return (new_a, new_b, res);
270
112
  }
271
- }
113
+
114
+ }