@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.
- package/.github/workflows/npm-publish.yml +2 -1
- package/CONTRIBUTING.md +2 -2
- package/LICENSE +1 -1
- package/README.md +18 -35
- package/contracts/access/DataPrivacyFramework/extensions/DataPrivacyFrameworkMpc.sol +3 -115
- package/contracts/mocks/README.md +1 -1
- package/contracts/mocks/utils/mpc/ArithmeticTestsContract.sol +257 -280
- package/contracts/mocks/utils/mpc/BitwiseTestsContract.sol +93 -187
- package/contracts/mocks/utils/mpc/{Comparison1Tests.Contract.sol → Comparison1TestsContract.sol} +67 -115
- package/contracts/mocks/utils/mpc/Comparison2TestsContract.sol +76 -116
- package/contracts/mocks/utils/mpc/MinMaxTestsContract.sol +69 -164
- package/contracts/mocks/utils/mpc/Miscellaneous1TestsContract.sol +103 -56
- package/contracts/mocks/utils/mpc/MiscellaneousTestsContract.sol +270 -0
- package/contracts/mocks/utils/mpc/OffboardToUserKeyTestContract.sol +127 -0
- package/contracts/mocks/utils/mpc/README.md +12 -12
- package/contracts/mocks/utils/mpc/TransferScalarTestsContract.sol +54 -211
- package/contracts/mocks/utils/mpc/TransferTestsContract.sol +165 -640
- package/contracts/mocks/utils/mpc/TransferWithAllowance64_16TestsContract.sol +222 -0
- package/contracts/mocks/utils/mpc/TransferWithAllowance64_32TestsContract.sol +222 -0
- package/contracts/mocks/utils/mpc/TransferWithAllowance64_64TestsContract.sol +223 -0
- package/contracts/mocks/utils/mpc/TransferWithAllowance64_8TestsContract.sol +222 -0
- package/contracts/mocks/utils/mpc/TransferWithAllowanceScalarTestsContract.sol +265 -0
- package/contracts/mocks/utils/mpc/TransferWithAllowanceTestsContract.sol +281 -0
- package/contracts/onboard/AccountOnboard.sol +3 -3
- package/contracts/token/PrivateERC20/PrivateERC20.sol +1 -1
- package/contracts/token/PrivateERC721/IERC721Errors.sol +57 -0
- package/contracts/token/PrivateERC721/PrivateERC721.sol +1 -1
- package/contracts/utils/mpc/MpcCore.sol +2835 -988
- package/contracts/utils/mpc/MpcInterface.sol +6 -4
- package/hardhat.config.ts +17 -6
- package/package.json +20 -4
- package/test/token/PrivateERC20/PrivateERC20.test.ts +2 -2
- package/test/utils/accounts.ts +1 -1
- package/test/utils/mpc/Precompile.test.ts +42 -39
- package/typechain-types/contracts/mocks/utils/mpc/ArithmeticTestsContract.sol/ArithmeticTestsContract.ts +374 -0
- package/typechain-types/contracts/mocks/utils/mpc/ArithmeticTestsContract.sol/PrecompilesArythmeticTestsContract.ts +374 -0
- package/typechain-types/contracts/mocks/utils/mpc/ArithmeticTestsContract.sol/index.ts +5 -0
- package/typechain-types/contracts/mocks/utils/mpc/ArithmeticTestsContract.ts +96 -10
- package/typechain-types/contracts/mocks/utils/mpc/BitwiseTestsContract.ts +45 -5
- package/typechain-types/contracts/mocks/utils/mpc/Comparison1TestsContract.ts +374 -0
- package/typechain-types/contracts/mocks/utils/mpc/Comparison2TestsContract.ts +45 -5
- package/typechain-types/contracts/mocks/utils/mpc/MinMaxTestsContract.ts +25 -5
- package/typechain-types/contracts/mocks/utils/mpc/Miscellaneous1TestsContract.ts +62 -0
- package/typechain-types/contracts/mocks/utils/mpc/MiscellaneousTestsContract.ts +396 -0
- package/typechain-types/contracts/mocks/utils/mpc/OffboardToUserKeyTestContract.ts +251 -0
- package/typechain-types/contracts/mocks/utils/mpc/OffboardToUserKeyTestsContract.sol/OffboardToUserKeyTestContract.ts +11 -8
- package/typechain-types/contracts/mocks/utils/mpc/TransferScalarTestsContract.ts +15 -15
- package/typechain-types/contracts/mocks/utils/mpc/TransferTestsContract.ts +15 -15
- package/typechain-types/contracts/mocks/utils/mpc/TransferWithAllowance64TestsContract.sol/TransferWithAllowance64TestsContract.ts +251 -0
- package/typechain-types/contracts/mocks/utils/mpc/TransferWithAllowance64TestsContract.sol/TransferWithAllowanceTestsContract.ts +250 -0
- package/typechain-types/contracts/mocks/utils/mpc/TransferWithAllowance64TestsContract.sol/index.ts +5 -0
- package/typechain-types/contracts/mocks/utils/mpc/TransferWithAllowance64TestsContract.ts +389 -0
- package/typechain-types/contracts/mocks/utils/mpc/TransferWithAllowance64_16TestsContract.ts +391 -0
- package/typechain-types/contracts/mocks/utils/mpc/TransferWithAllowance64_32TestsContract.ts +391 -0
- package/typechain-types/contracts/mocks/utils/mpc/TransferWithAllowance64_64TestsContract.sol/TransferWithAllowance64_64TestsContract.ts +391 -0
- package/typechain-types/contracts/mocks/utils/mpc/TransferWithAllowance64_64TestsContract.sol/TransferWithAllowance64_8TestsContract.ts +391 -0
- package/typechain-types/contracts/mocks/utils/mpc/TransferWithAllowance64_64TestsContract.sol/index.ts +5 -0
- package/typechain-types/contracts/mocks/utils/mpc/TransferWithAllowance64_64TestsContract.ts +391 -0
- package/typechain-types/contracts/mocks/utils/mpc/TransferWithAllowance64_8TestsContract.ts +391 -0
- package/typechain-types/contracts/mocks/utils/mpc/TransferWithAllowanceScalarTestsContract.ts +306 -0
- package/typechain-types/contracts/mocks/utils/mpc/TransferWithAllowanceTestsContract.sol/TransferTestsContract.ts +125 -0
- package/typechain-types/contracts/mocks/utils/mpc/TransferWithAllowanceTestsContract.sol/TransferWithAllowanceTestsContract.ts +125 -0
- package/typechain-types/contracts/mocks/utils/mpc/TransferWithAllowanceTestsContract.sol/index.ts +5 -0
- package/typechain-types/contracts/mocks/utils/mpc/TransferWithAllowanceTestsContract.ts +296 -0
- package/typechain-types/contracts/mocks/utils/mpc/index.ts +9 -6
- package/typechain-types/contracts/onboard/AccountOnboard.ts +9 -4
- package/typechain-types/contracts/token/PrivateERC721/IERC721Errors.ts +69 -0
- package/typechain-types/contracts/token/PrivateERC721/index.ts +1 -0
- package/typechain-types/contracts/utils/mpc/MpcCore.ts +84 -0
- package/typechain-types/contracts/utils/mpc/MpcInterface.sol/ExtendedOperations.ts +81 -40
- package/typechain-types/contracts/utils/mpc/index.ts +1 -0
- package/typechain-types/factories/contracts/mocks/access/DataPrivacyFramework/DataPrivacyFrameworkMock__factory.ts +1 -1
- package/typechain-types/factories/contracts/mocks/token/PrivateERC20/PrivateERC20Mock__factory.ts +1 -1
- package/typechain-types/factories/contracts/mocks/token/PrivateERC721/PrivateERC721URIStorageMock__factory.ts +1 -1
- package/typechain-types/factories/contracts/mocks/utils/mpc/ArithmeticTestsContract.sol/ArithmeticTestsContract__factory.ts +387 -0
- package/typechain-types/factories/contracts/mocks/utils/mpc/ArithmeticTestsContract.sol/PrecompilesArythmeticTestsContract__factory.ts +388 -0
- package/typechain-types/factories/contracts/mocks/utils/mpc/ArithmeticTestsContract.sol/index.ts +5 -0
- package/typechain-types/factories/contracts/mocks/utils/mpc/ArithmeticTestsContract__factory.ts +92 -7
- package/typechain-types/factories/contracts/mocks/utils/mpc/BitwiseTestsContract__factory.ts +38 -2
- package/typechain-types/factories/contracts/mocks/utils/mpc/Comparison1Tests.Contract.sol/Comparison1TestsContract__factory.ts +1 -1
- package/typechain-types/factories/contracts/mocks/utils/mpc/Comparison1TestsContract__factory.ts +387 -0
- package/typechain-types/factories/contracts/mocks/utils/mpc/Comparison2TestsContract__factory.ts +38 -2
- package/typechain-types/factories/contracts/mocks/utils/mpc/MinMaxTestsContract__factory.ts +15 -2
- package/typechain-types/factories/contracts/mocks/utils/mpc/Miscellaneous1TestsContract__factory.ts +66 -1
- package/typechain-types/factories/contracts/mocks/utils/mpc/Miscellaneous2TestsContract__factory.ts +1 -1
- package/typechain-types/factories/contracts/mocks/utils/mpc/MiscellaneousTestsContract__factory.ts +424 -0
- package/typechain-types/factories/contracts/mocks/utils/mpc/OffboardToUserKeyTestContract__factory.ts +285 -0
- package/typechain-types/factories/contracts/mocks/utils/mpc/OffboardToUserKeyTestsContract.sol/OffboardToUserKeyTestContract__factory.ts +19 -3
- package/typechain-types/factories/contracts/mocks/utils/mpc/ShiftTestsContract__factory.ts +1 -1
- package/typechain-types/factories/contracts/mocks/utils/mpc/StringTestsContract__factory.ts +1 -1
- package/typechain-types/factories/contracts/mocks/utils/mpc/TransferScalarTestsContract__factory.ts +4 -4
- package/typechain-types/factories/contracts/mocks/utils/mpc/TransferTestsContract__factory.ts +4 -4
- package/typechain-types/factories/contracts/mocks/utils/mpc/TransferWithAllowance64TestsContract.sol/TransferWithAllowance64TestsContract__factory.ts +294 -0
- package/typechain-types/factories/contracts/mocks/utils/mpc/TransferWithAllowance64TestsContract.sol/TransferWithAllowanceTestsContract__factory.ts +292 -0
- package/typechain-types/factories/contracts/mocks/utils/mpc/TransferWithAllowance64TestsContract.sol/index.ts +5 -0
- package/typechain-types/factories/contracts/mocks/utils/mpc/TransferWithAllowance64TestsContract__factory.ts +720 -0
- package/typechain-types/factories/contracts/mocks/utils/mpc/TransferWithAllowance64_16TestsContract__factory.ts +724 -0
- package/typechain-types/factories/contracts/mocks/utils/mpc/TransferWithAllowance64_32TestsContract__factory.ts +724 -0
- package/typechain-types/factories/contracts/mocks/utils/mpc/TransferWithAllowance64_64TestsContract.sol/TransferWithAllowance64_64TestsContract__factory.ts +724 -0
- package/typechain-types/factories/contracts/mocks/utils/mpc/TransferWithAllowance64_64TestsContract.sol/TransferWithAllowance64_8TestsContract__factory.ts +724 -0
- package/typechain-types/factories/contracts/mocks/utils/mpc/TransferWithAllowance64_64TestsContract.sol/index.ts +5 -0
- package/typechain-types/factories/contracts/mocks/utils/mpc/TransferWithAllowance64_64TestsContract__factory.ts +724 -0
- package/typechain-types/factories/contracts/mocks/utils/mpc/TransferWithAllowance64_8TestsContract__factory.ts +724 -0
- package/typechain-types/factories/contracts/mocks/utils/mpc/TransferWithAllowanceScalarTestsContract__factory.ts +507 -0
- package/typechain-types/factories/contracts/mocks/utils/mpc/TransferWithAllowanceTestsContract.sol/TransferTestsContract__factory.ts +150 -0
- package/typechain-types/factories/contracts/mocks/utils/mpc/TransferWithAllowanceTestsContract.sol/TransferWithAllowanceTestsContract__factory.ts +150 -0
- package/typechain-types/factories/contracts/mocks/utils/mpc/TransferWithAllowanceTestsContract.sol/index.ts +5 -0
- package/typechain-types/factories/contracts/mocks/utils/mpc/TransferWithAllowanceTestsContract__factory.ts +434 -0
- package/typechain-types/factories/contracts/mocks/utils/mpc/index.ts +9 -4
- package/typechain-types/factories/contracts/mocks/wallet/PrivateERC20Wallet/PrivateERC20WalletMock__factory.ts +1 -1
- package/typechain-types/factories/contracts/onboard/AccountOnboard__factory.ts +8 -2
- package/typechain-types/factories/contracts/token/PrivateERC721/IERC721Errors__factory.ts +128 -0
- package/typechain-types/factories/contracts/token/PrivateERC721/index.ts +1 -0
- package/typechain-types/factories/contracts/utils/mpc/MpcCore__factory.ts +77 -0
- package/typechain-types/factories/contracts/utils/mpc/MpcInterface.sol/ExtendedOperations__factory.ts +124 -61
- package/typechain-types/factories/contracts/utils/mpc/index.ts +1 -0
- package/typechain-types/hardhat.d.ts +152 -26
- package/typechain-types/index.ts +20 -8
- package/contracts/access/DataPrivacyFramework/README.md +0 -68
- package/contracts/mocks/utils/mpc/Miscellaneous2TestsContract.sol +0 -448
- package/contracts/mocks/utils/mpc/OffboardToUserKeyTestsContract.sol +0 -81
- package/contracts/mocks/utils/mpc/ShiftTestsContract.sol +0 -311
- package/contracts/token/PrivateERC20/README.md +0 -104
- package/contracts/token/PrivateERC721/README.md +0 -282
- package/contracts/utils/mpc/README.md +0 -82
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
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
|
-
#
|
|
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
|
-
#
|
|
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
|
-
#
|
|
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
|
-
#
|
|
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
|
-
#
|
|
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
|
-
#
|
|
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
|
-
#
|
|
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
|
-
#
|
|
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
|
-
#
|
|
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
|
-
#
|
|
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
|
|
29
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
74
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
143
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
236
|
-
|
|
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 =
|
|
244
|
-
allGTCastingValues.b16_s =
|
|
245
|
-
allGTCastingValues.a32_s =
|
|
246
|
-
allGTCastingValues.b32_s =
|
|
247
|
-
allGTCastingValues.a64_s =
|
|
248
|
-
allGTCastingValues.b64_s =
|
|
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
|
-
|
|
253
|
-
|
|
254
|
-
|
|
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
|
-
|
|
103
|
+
computeAndCheckTransfer16(allGTCastingValues, new_a, new_b, res, amount);
|
|
262
104
|
|
|
263
105
|
// Calculate the result with casting to 32
|
|
264
|
-
|
|
106
|
+
computeAndCheckTransfer32(allGTCastingValues, new_a, new_b, res, amount);
|
|
265
107
|
|
|
266
108
|
// Calculate the result with casting to 64
|
|
267
|
-
|
|
109
|
+
computeAndCheckTransfer64(allGTCastingValues, new_a, new_b, res, amount);
|
|
268
110
|
|
|
269
111
|
return (new_a, new_b, res);
|
|
270
112
|
}
|
|
271
|
-
|
|
113
|
+
|
|
114
|
+
}
|