@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
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity ^0.8.19;
|
|
3
|
+
|
|
4
|
+
import "../../../utils/mpc/MpcCore.sol";
|
|
5
|
+
|
|
6
|
+
contract TransferWithAllowanceScalarTestsContract {
|
|
7
|
+
|
|
8
|
+
struct AllGTCastingValues {
|
|
9
|
+
gtUint8 a8_s;
|
|
10
|
+
gtUint8 b8_s;
|
|
11
|
+
gtUint16 a16_s;
|
|
12
|
+
gtUint16 b16_s;
|
|
13
|
+
gtUint32 a32_s;
|
|
14
|
+
gtUint32 b32_s;
|
|
15
|
+
gtUint64 a64_s;
|
|
16
|
+
gtUint64 b64_s;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
struct AllAmountValues {
|
|
20
|
+
uint8 amount8_s;
|
|
21
|
+
uint16 amount16_s;
|
|
22
|
+
uint32 amount32_s;
|
|
23
|
+
uint64 amount64_s;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
struct AllAllowanceValues {
|
|
27
|
+
gtUint8 allowance8_s;
|
|
28
|
+
gtUint16 allowance16_s;
|
|
29
|
+
gtUint32 allowance32_s;
|
|
30
|
+
gtUint64 allowance64_s;
|
|
31
|
+
uint8 allowance;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
uint8 newA;
|
|
35
|
+
uint8 newB;
|
|
36
|
+
bool res;
|
|
37
|
+
uint8 newAllowance;
|
|
38
|
+
|
|
39
|
+
function getResults() public view returns (uint8, uint8, bool, uint8) {
|
|
40
|
+
return (newA, newB, res, newAllowance);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function computeAndCheckTransfer16(
|
|
44
|
+
AllGTCastingValues memory allGTCastingValues,
|
|
45
|
+
AllAmountValues memory allAmountValues,
|
|
46
|
+
AllAllowanceValues memory allAllowanceValues
|
|
47
|
+
)
|
|
48
|
+
public
|
|
49
|
+
{
|
|
50
|
+
|
|
51
|
+
// Check all options for casting to 16 while amount is scalar
|
|
52
|
+
(gtUint16 newA_s, gtUint16 newB_s, gtBool res_s, gtUint16 newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a16_s, allGTCastingValues.b16_s, allAmountValues.amount16_s, allAllowanceValues.allowance16_s);
|
|
53
|
+
require(newA == MpcCore.decrypt(newA_s) && newB == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && newAllowance == MpcCore.decrypt(newAllowance_s), "transferTest: check scalar failed");
|
|
54
|
+
|
|
55
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a16_s, allGTCastingValues.b16_s, allAmountValues.amount16_s, allAllowanceValues.allowance16_s);
|
|
56
|
+
require(newA == MpcCore.decrypt(newA_s) && newB == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && newAllowance == MpcCore.decrypt(newAllowance_s), "transferTest: check scalar failed");
|
|
57
|
+
|
|
58
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a8_s, allGTCastingValues.b16_s, allAmountValues.amount16_s, allAllowanceValues.allowance16_s);
|
|
59
|
+
require(newA == MpcCore.decrypt(newA_s) && newB == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && newAllowance == MpcCore.decrypt(newAllowance_s), "transferTest: check scalar failed");
|
|
60
|
+
|
|
61
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a16_s, allGTCastingValues.b8_s, allAmountValues.amount16_s, allAllowanceValues.allowance16_s);
|
|
62
|
+
require(newA == MpcCore.decrypt(newA_s) && newB == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && newAllowance == MpcCore.decrypt(newAllowance_s), "transferTest: check scalar failed");
|
|
63
|
+
|
|
64
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a16_s, allGTCastingValues.b16_s, allAmountValues.amount16_s, allAllowanceValues.allowance8_s);
|
|
65
|
+
require(newA == MpcCore.decrypt(newA_s) && newB == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && newAllowance == MpcCore.decrypt(newAllowance_s), "transferTest: check scalar failed");
|
|
66
|
+
|
|
67
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a8_s, allGTCastingValues.b16_s, allAmountValues.amount16_s, allAllowanceValues.allowance8_s);
|
|
68
|
+
require(newA == MpcCore.decrypt(newA_s) && newB == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && newAllowance == MpcCore.decrypt(newAllowance_s), "transferTest: check scalar failed");
|
|
69
|
+
|
|
70
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a16_s, allGTCastingValues.b8_s, allAmountValues.amount16_s, allAllowanceValues.allowance8_s);
|
|
71
|
+
require(newA == MpcCore.decrypt(newA_s) && newB == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && newAllowance == MpcCore.decrypt(newAllowance_s), "transferTest: check scalar failed");
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function computeAndCheckTransfer32(
|
|
75
|
+
AllGTCastingValues memory allGTCastingValues,
|
|
76
|
+
AllAmountValues memory allAmountValues,
|
|
77
|
+
AllAllowanceValues memory allAllowanceValues
|
|
78
|
+
) public {
|
|
79
|
+
|
|
80
|
+
// Check all options for casting to 32 while amount is scalar
|
|
81
|
+
(gtUint32 newA_s, gtUint32 newB_s, gtBool res_s, gtUint32 newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a32_s, allGTCastingValues.b32_s, allAmountValues.amount32_s, allAllowanceValues.allowance32_s);
|
|
82
|
+
require(newA == MpcCore.decrypt(newA_s) && newB == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && newAllowance == MpcCore.decrypt(newAllowance_s), "transferTest: check scalar failed");
|
|
83
|
+
|
|
84
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a8_s, allGTCastingValues.b32_s, allAmountValues.amount32_s, allAllowanceValues.allowance32_s);
|
|
85
|
+
require(newA == MpcCore.decrypt(newA_s) && newB == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && newAllowance == MpcCore.decrypt(newAllowance_s), "transferTest: check scalar failed");
|
|
86
|
+
|
|
87
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a32_s, allGTCastingValues.b8_s, allAmountValues.amount32_s, allAllowanceValues.allowance32_s);
|
|
88
|
+
require(newA == MpcCore.decrypt(newA_s) && newB == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && newAllowance == MpcCore.decrypt(newAllowance_s), "transferTest: check scalar failed");
|
|
89
|
+
|
|
90
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a16_s, allGTCastingValues.b32_s, allAmountValues.amount32_s, allAllowanceValues.allowance32_s);
|
|
91
|
+
require(newA == MpcCore.decrypt(newA_s) && newB == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && newAllowance == MpcCore.decrypt(newAllowance_s), "transferTest: check scalar failed");
|
|
92
|
+
|
|
93
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a32_s, allGTCastingValues.b16_s, allAmountValues.amount32_s, allAllowanceValues.allowance32_s);
|
|
94
|
+
require(newA == MpcCore.decrypt(newA_s) && newB == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && newAllowance == MpcCore.decrypt(newAllowance_s), "transferTest: check scalar failed");
|
|
95
|
+
|
|
96
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a32_s, allGTCastingValues.b32_s, allAmountValues.amount32_s, allAllowanceValues.allowance8_s);
|
|
97
|
+
require(newA == MpcCore.decrypt(newA_s) && newB == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && newAllowance == MpcCore.decrypt(newAllowance_s), "transferTest: check scalar failed");
|
|
98
|
+
|
|
99
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a8_s, allGTCastingValues.b32_s, allAmountValues.amount32_s, allAllowanceValues.allowance8_s);
|
|
100
|
+
require(newA == MpcCore.decrypt(newA_s) && newB == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && newAllowance == MpcCore.decrypt(newAllowance_s), "transferTest: check scalar failed");
|
|
101
|
+
|
|
102
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a32_s, allGTCastingValues.b8_s, allAmountValues.amount32_s, allAllowanceValues.allowance8_s);
|
|
103
|
+
require(newA == MpcCore.decrypt(newA_s) && newB == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && newAllowance == MpcCore.decrypt(newAllowance_s), "transferTest: check scalar failed");
|
|
104
|
+
|
|
105
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a16_s, allGTCastingValues.b32_s, allAmountValues.amount32_s, allAllowanceValues.allowance8_s);
|
|
106
|
+
require(newA == MpcCore.decrypt(newA_s) && newB == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && newAllowance == MpcCore.decrypt(newAllowance_s), "transferTest: check scalar failed");
|
|
107
|
+
|
|
108
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a32_s, allGTCastingValues.b16_s, allAmountValues.amount32_s, allAllowanceValues.allowance8_s);
|
|
109
|
+
require(newA == MpcCore.decrypt(newA_s) && newB == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && newAllowance == MpcCore.decrypt(newAllowance_s), "transferTest: check scalar failed");
|
|
110
|
+
|
|
111
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a32_s, allGTCastingValues.b32_s, allAmountValues.amount32_s, allAllowanceValues.allowance16_s);
|
|
112
|
+
require(newA == MpcCore.decrypt(newA_s) && newB == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && newAllowance == MpcCore.decrypt(newAllowance_s), "transferTest: check scalar failed");
|
|
113
|
+
|
|
114
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a8_s, allGTCastingValues.b32_s, allAmountValues.amount32_s, allAllowanceValues.allowance16_s);
|
|
115
|
+
require(newA == MpcCore.decrypt(newA_s) && newB == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && newAllowance == MpcCore.decrypt(newAllowance_s), "transferTest: check scalar failed");
|
|
116
|
+
|
|
117
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a32_s, allGTCastingValues.b8_s, allAmountValues.amount32_s, allAllowanceValues.allowance16_s);
|
|
118
|
+
require(newA == MpcCore.decrypt(newA_s) && newB == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && newAllowance == MpcCore.decrypt(newAllowance_s), "transferTest: check scalar failed");
|
|
119
|
+
|
|
120
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a16_s, allGTCastingValues.b32_s, allAmountValues.amount32_s, allAllowanceValues.allowance16_s);
|
|
121
|
+
require(newA == MpcCore.decrypt(newA_s) && newB == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && newAllowance == MpcCore.decrypt(newAllowance_s), "transferTest: check scalar failed");
|
|
122
|
+
|
|
123
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a32_s, allGTCastingValues.b16_s, allAmountValues.amount32_s, allAllowanceValues.allowance16_s);
|
|
124
|
+
require(newA == MpcCore.decrypt(newA_s) && newB == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && newAllowance == MpcCore.decrypt(newAllowance_s), "transferTest: check scalar failed");
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function computeAndCheckTransfer64(
|
|
128
|
+
AllGTCastingValues memory allGTCastingValues,
|
|
129
|
+
AllAmountValues memory allAmountValues,
|
|
130
|
+
AllAllowanceValues memory allAllowanceValues
|
|
131
|
+
) public {
|
|
132
|
+
|
|
133
|
+
// Check all options for casting to 64 while amount is scalar
|
|
134
|
+
(gtUint64 newA_s, gtUint64 newB_s, gtBool res_s, gtUint64 newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a64_s, allGTCastingValues.b64_s, allAmountValues.amount64_s, allAllowanceValues.allowance64_s);
|
|
135
|
+
require(newA == MpcCore.decrypt(newA_s) && newB == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && newAllowance == MpcCore.decrypt(newAllowance_s), "transferTest: check scalar failed");
|
|
136
|
+
|
|
137
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a64_s, allGTCastingValues.b64_s, allAmountValues.amount64_s, allAllowanceValues.allowance64_s);
|
|
138
|
+
require(newA == MpcCore.decrypt(newA_s) && newB == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && newAllowance == MpcCore.decrypt(newAllowance_s), "transferTest: check scalar failed");
|
|
139
|
+
|
|
140
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a8_s, allGTCastingValues.b64_s, allAmountValues.amount64_s, allAllowanceValues.allowance64_s);
|
|
141
|
+
require(newA == MpcCore.decrypt(newA_s) && newB == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && newAllowance == MpcCore.decrypt(newAllowance_s), "transferTest: check scalar failed");
|
|
142
|
+
|
|
143
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a64_s, allGTCastingValues.b8_s, allAmountValues.amount64_s, allAllowanceValues.allowance64_s);
|
|
144
|
+
require(newA == MpcCore.decrypt(newA_s) && newB == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && newAllowance == MpcCore.decrypt(newAllowance_s), "transferTest: check scalar failed");
|
|
145
|
+
|
|
146
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a16_s, allGTCastingValues.b64_s, allAmountValues.amount64_s, allAllowanceValues.allowance64_s);
|
|
147
|
+
require(newA == MpcCore.decrypt(newA_s) && newB == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && newAllowance == MpcCore.decrypt(newAllowance_s), "transferTest: check scalar failed");
|
|
148
|
+
|
|
149
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a64_s, allGTCastingValues.b16_s, allAmountValues.amount64_s, allAllowanceValues.allowance64_s);
|
|
150
|
+
require(newA == MpcCore.decrypt(newA_s) && newB == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && newAllowance == MpcCore.decrypt(newAllowance_s), "transferTest: check scalar failed");
|
|
151
|
+
|
|
152
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a32_s, allGTCastingValues.b64_s, allAmountValues.amount64_s, allAllowanceValues.allowance64_s);
|
|
153
|
+
require(newA == MpcCore.decrypt(newA_s) && newB == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && newAllowance == MpcCore.decrypt(newAllowance_s), "transferTest: check scalar failed");
|
|
154
|
+
|
|
155
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a64_s, allGTCastingValues.b32_s, allAmountValues.amount64_s, allAllowanceValues.allowance64_s);
|
|
156
|
+
require(newA == MpcCore.decrypt(newA_s) && newB == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && newAllowance == MpcCore.decrypt(newAllowance_s), "transferTest: check scalar failed");
|
|
157
|
+
|
|
158
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a64_s, allGTCastingValues.b64_s, allAmountValues.amount64_s, allAllowanceValues.allowance8_s);
|
|
159
|
+
require(newA == MpcCore.decrypt(newA_s) && newB == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && newAllowance == MpcCore.decrypt(newAllowance_s), "transferTest: check scalar failed");
|
|
160
|
+
|
|
161
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a8_s, allGTCastingValues.b64_s, allAmountValues.amount64_s, allAllowanceValues.allowance8_s);
|
|
162
|
+
require(newA == MpcCore.decrypt(newA_s) && newB == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && newAllowance == MpcCore.decrypt(newAllowance_s), "transferTest: check scalar failed");
|
|
163
|
+
|
|
164
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a64_s, allGTCastingValues.b8_s, allAmountValues.amount64_s, allAllowanceValues.allowance8_s);
|
|
165
|
+
require(newA == MpcCore.decrypt(newA_s) && newB == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && newAllowance == MpcCore.decrypt(newAllowance_s), "transferTest: check scalar failed");
|
|
166
|
+
|
|
167
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a16_s, allGTCastingValues.b64_s, allAmountValues.amount64_s, allAllowanceValues.allowance8_s);
|
|
168
|
+
require(newA == MpcCore.decrypt(newA_s) && newB == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && newAllowance == MpcCore.decrypt(newAllowance_s), "transferTest: check scalar failed");
|
|
169
|
+
|
|
170
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a64_s, allGTCastingValues.b16_s, allAmountValues.amount64_s, allAllowanceValues.allowance8_s);
|
|
171
|
+
require(newA == MpcCore.decrypt(newA_s) && newB == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && newAllowance == MpcCore.decrypt(newAllowance_s), "transferTest: check scalar failed");
|
|
172
|
+
|
|
173
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a32_s, allGTCastingValues.b64_s, allAmountValues.amount64_s, allAllowanceValues.allowance8_s);
|
|
174
|
+
require(newA == MpcCore.decrypt(newA_s) && newB == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && newAllowance == MpcCore.decrypt(newAllowance_s), "transferTest: check scalar failed");
|
|
175
|
+
|
|
176
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a64_s, allGTCastingValues.b32_s, allAmountValues.amount64_s, allAllowanceValues.allowance8_s);
|
|
177
|
+
require(newA == MpcCore.decrypt(newA_s) && newB == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && newAllowance == MpcCore.decrypt(newAllowance_s), "transferTest: check scalar failed");
|
|
178
|
+
|
|
179
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a64_s, allGTCastingValues.b64_s, allAmountValues.amount64_s, allAllowanceValues.allowance16_s);
|
|
180
|
+
require(newA == MpcCore.decrypt(newA_s) && newB == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && newAllowance == MpcCore.decrypt(newAllowance_s), "transferTest: check scalar failed");
|
|
181
|
+
|
|
182
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a8_s, allGTCastingValues.b64_s, allAmountValues.amount64_s, allAllowanceValues.allowance16_s);
|
|
183
|
+
require(newA == MpcCore.decrypt(newA_s) && newB == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && newAllowance == MpcCore.decrypt(newAllowance_s), "transferTest: check scalar failed");
|
|
184
|
+
|
|
185
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a64_s, allGTCastingValues.b8_s, allAmountValues.amount64_s, allAllowanceValues.allowance16_s);
|
|
186
|
+
require(newA == MpcCore.decrypt(newA_s) && newB == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && newAllowance == MpcCore.decrypt(newAllowance_s), "transferTest: check scalar failed");
|
|
187
|
+
|
|
188
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a16_s, allGTCastingValues.b64_s, allAmountValues.amount64_s, allAllowanceValues.allowance16_s);
|
|
189
|
+
require(newA == MpcCore.decrypt(newA_s) && newB == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && newAllowance == MpcCore.decrypt(newAllowance_s), "transferTest: check scalar failed");
|
|
190
|
+
|
|
191
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a64_s, allGTCastingValues.b16_s, allAmountValues.amount64_s, allAllowanceValues.allowance16_s);
|
|
192
|
+
require(newA == MpcCore.decrypt(newA_s) && newB == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && newAllowance == MpcCore.decrypt(newAllowance_s), "transferTest: check scalar failed");
|
|
193
|
+
|
|
194
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a32_s, allGTCastingValues.b64_s, allAmountValues.amount64_s, allAllowanceValues.allowance16_s);
|
|
195
|
+
require(newA == MpcCore.decrypt(newA_s) && newB == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && newAllowance == MpcCore.decrypt(newAllowance_s), "transferTest: check scalar failed");
|
|
196
|
+
|
|
197
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a64_s, allGTCastingValues.b32_s, allAmountValues.amount64_s, allAllowanceValues.allowance16_s);
|
|
198
|
+
require(newA == MpcCore.decrypt(newA_s) && newB == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && newAllowance == MpcCore.decrypt(newAllowance_s), "transferTest: check scalar failed");
|
|
199
|
+
|
|
200
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a64_s, allGTCastingValues.b64_s, allAmountValues.amount64_s, allAllowanceValues.allowance32_s);
|
|
201
|
+
require(newA == MpcCore.decrypt(newA_s) && newB == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && newAllowance == MpcCore.decrypt(newAllowance_s), "transferTest: check scalar failed");
|
|
202
|
+
|
|
203
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a8_s, allGTCastingValues.b64_s, allAmountValues.amount64_s, allAllowanceValues.allowance32_s);
|
|
204
|
+
require(newA == MpcCore.decrypt(newA_s) && newB == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && newAllowance == MpcCore.decrypt(newAllowance_s), "transferTest: check scalar failed");
|
|
205
|
+
|
|
206
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a64_s, allGTCastingValues.b8_s, allAmountValues.amount64_s, allAllowanceValues.allowance32_s);
|
|
207
|
+
require(newA == MpcCore.decrypt(newA_s) && newB == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && newAllowance == MpcCore.decrypt(newAllowance_s), "transferTest: check scalar failed");
|
|
208
|
+
|
|
209
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a16_s, allGTCastingValues.b64_s, allAmountValues.amount64_s, allAllowanceValues.allowance32_s);
|
|
210
|
+
require(newA == MpcCore.decrypt(newA_s) && newB == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && newAllowance == MpcCore.decrypt(newAllowance_s), "transferTest: check scalar failed");
|
|
211
|
+
|
|
212
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a64_s, allGTCastingValues.b16_s, allAmountValues.amount64_s, allAllowanceValues.allowance32_s);
|
|
213
|
+
require(newA == MpcCore.decrypt(newA_s) && newB == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && newAllowance == MpcCore.decrypt(newAllowance_s), "transferTest: check scalar failed");
|
|
214
|
+
|
|
215
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a32_s, allGTCastingValues.b64_s, allAmountValues.amount64_s, allAllowanceValues.allowance32_s);
|
|
216
|
+
require(newA == MpcCore.decrypt(newA_s) && newB == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && newAllowance == MpcCore.decrypt(newAllowance_s), "transferTest: check scalar failed");
|
|
217
|
+
|
|
218
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a64_s, allGTCastingValues.b32_s, allAmountValues.amount64_s, allAllowanceValues.allowance32_s);
|
|
219
|
+
require(newA == MpcCore.decrypt(newA_s) && newB == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && newAllowance == MpcCore.decrypt(newAllowance_s), "transferTest: check scalar failed");
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
function transferWithAllowanceScalarTest(uint8 a, uint8 b, uint8 amount, uint8 allowance) public returns (uint8, uint8, bool, uint8) {
|
|
224
|
+
AllGTCastingValues memory allGTCastingValues;
|
|
225
|
+
AllAmountValues memory allAmountValues;
|
|
226
|
+
AllAllowanceValues memory allAllowanceValues;
|
|
227
|
+
allGTCastingValues.a8_s = MpcCore.setPublic8(a);
|
|
228
|
+
allGTCastingValues.b8_s = MpcCore.setPublic8(b);
|
|
229
|
+
allGTCastingValues.a16_s = MpcCore.setPublic16(a);
|
|
230
|
+
allGTCastingValues.b16_s = MpcCore.setPublic16(b);
|
|
231
|
+
allGTCastingValues.a32_s = MpcCore.setPublic32(a);
|
|
232
|
+
allGTCastingValues.b32_s = MpcCore.setPublic32(b);
|
|
233
|
+
allGTCastingValues.a64_s = MpcCore.setPublic64(a);
|
|
234
|
+
allGTCastingValues.b64_s = MpcCore.setPublic64(b);
|
|
235
|
+
allAmountValues.amount8_s = amount;
|
|
236
|
+
allAmountValues.amount16_s = uint16(amount);
|
|
237
|
+
allAmountValues.amount32_s = uint32(amount);
|
|
238
|
+
allAmountValues.amount64_s = uint64(amount);
|
|
239
|
+
allAllowanceValues.allowance8_s = MpcCore.setPublic8(allowance);
|
|
240
|
+
allAllowanceValues.allowance16_s = MpcCore.setPublic16(allowance);
|
|
241
|
+
allAllowanceValues.allowance32_s = MpcCore.setPublic32(allowance);
|
|
242
|
+
allAllowanceValues.allowance64_s = MpcCore.setPublic64(allowance);
|
|
243
|
+
allAllowanceValues.allowance = allowance;
|
|
244
|
+
|
|
245
|
+
// Calculate the expected result
|
|
246
|
+
(gtUint8 newA_s, gtUint8 newB_s, gtBool res_s, gtUint8 newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a8_s, allGTCastingValues.b8_s, amount, allAllowanceValues.allowance8_s);
|
|
247
|
+
newA = MpcCore.decrypt(newA_s);
|
|
248
|
+
newB = MpcCore.decrypt(newB_s);
|
|
249
|
+
res = MpcCore.decrypt(res_s);
|
|
250
|
+
newAllowance = MpcCore.decrypt(newAllowance_s);
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
// Calculate the result with casting to 16
|
|
254
|
+
computeAndCheckTransfer16(allGTCastingValues, allAmountValues, allAllowanceValues);
|
|
255
|
+
|
|
256
|
+
// Calculate the result with casting to 32
|
|
257
|
+
computeAndCheckTransfer32(allGTCastingValues, allAmountValues, allAllowanceValues);
|
|
258
|
+
|
|
259
|
+
// Calculate the result with casting to 64
|
|
260
|
+
computeAndCheckTransfer64(allGTCastingValues, allAmountValues, allAllowanceValues);
|
|
261
|
+
|
|
262
|
+
return (newA, newB, res, newAllowance);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
}
|
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity ^0.8.19;
|
|
3
|
+
|
|
4
|
+
import "../../../utils/mpc/MpcCore.sol";
|
|
5
|
+
|
|
6
|
+
contract TransferWithAllowanceTestsContract {
|
|
7
|
+
|
|
8
|
+
struct AllGTCastingValues {
|
|
9
|
+
gtUint8 a8_s;
|
|
10
|
+
gtUint8 b8_s;
|
|
11
|
+
gtUint16 a16_s;
|
|
12
|
+
gtUint16 b16_s;
|
|
13
|
+
gtUint32 a32_s;
|
|
14
|
+
gtUint32 b32_s;
|
|
15
|
+
gtUint64 a64_s;
|
|
16
|
+
gtUint64 b64_s;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
struct AllAmountValues {
|
|
20
|
+
gtUint8 amount8_s;
|
|
21
|
+
gtUint16 amount16_s;
|
|
22
|
+
gtUint32 amount32_s;
|
|
23
|
+
gtUint64 amount64_s;
|
|
24
|
+
uint8 amount;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
struct AllAllowanceValues {
|
|
28
|
+
gtUint8 allowance8_s;
|
|
29
|
+
gtUint16 allowance16_s;
|
|
30
|
+
gtUint32 allowance32_s;
|
|
31
|
+
gtUint64 allowance64_s;
|
|
32
|
+
uint8 allowance;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
uint8 newA;
|
|
36
|
+
uint8 newB;
|
|
37
|
+
bool result;
|
|
38
|
+
uint8 newAllowance;
|
|
39
|
+
|
|
40
|
+
function getResults() public view returns (uint8, uint8, bool, uint8) {
|
|
41
|
+
return (newA, newB, result, newAllowance);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
function computeAndCheckTransfer16(
|
|
46
|
+
AllGTCastingValues memory allGTCastingValues,
|
|
47
|
+
AllAmountValues memory allAmountValues,
|
|
48
|
+
AllAllowanceValues memory allAllowanceValues,
|
|
49
|
+
uint8 new_a,
|
|
50
|
+
uint8 new_b,
|
|
51
|
+
bool res,
|
|
52
|
+
uint8 new_allowance
|
|
53
|
+
)
|
|
54
|
+
public
|
|
55
|
+
{
|
|
56
|
+
(gtUint16 newA_s, gtUint16 newB_s, gtBool res_s, gtUint16 newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a16_s, allGTCastingValues.b16_s, allAmountValues.amount16_s, allAllowanceValues.allowance16_s);
|
|
57
|
+
require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 16 failed");
|
|
58
|
+
|
|
59
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a16_s, allGTCastingValues.b8_s, allAmountValues.amount8_s, allAllowanceValues.allowance8_s);
|
|
60
|
+
require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 16 failed");
|
|
61
|
+
|
|
62
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a8_s, allGTCastingValues.b16_s, allAmountValues.amount8_s, allAllowanceValues.allowance8_s);
|
|
63
|
+
require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 16 failed");
|
|
64
|
+
|
|
65
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a16_s, allGTCastingValues.b8_s, allAmountValues.amount16_s, allAllowanceValues.allowance8_s);
|
|
66
|
+
require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 16 failed");
|
|
67
|
+
|
|
68
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a8_s, allGTCastingValues.b16_s, allAmountValues.amount16_s, allAllowanceValues.allowance8_s);
|
|
69
|
+
require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 16 failed");
|
|
70
|
+
|
|
71
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a16_s, allGTCastingValues.b16_s, allAmountValues.amount8_s, allAllowanceValues.allowance8_s);
|
|
72
|
+
require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 16 failed");
|
|
73
|
+
|
|
74
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a16_s, allGTCastingValues.b16_s, allAmountValues.amount16_s, allAllowanceValues.allowance8_s);
|
|
75
|
+
require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 16 failed");
|
|
76
|
+
|
|
77
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a16_s, allGTCastingValues.b8_s, allAmountValues.amount8_s, allAllowanceValues.allowance16_s);
|
|
78
|
+
require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 16 failed");
|
|
79
|
+
|
|
80
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a8_s, allGTCastingValues.b16_s, allAmountValues.amount8_s, allAllowanceValues.allowance16_s);
|
|
81
|
+
require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 16 failed");
|
|
82
|
+
|
|
83
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a16_s, allGTCastingValues.b8_s, allAmountValues.amount16_s, allAllowanceValues.allowance16_s);
|
|
84
|
+
require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 16 failed");
|
|
85
|
+
|
|
86
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a8_s, allGTCastingValues.b16_s, allAmountValues.amount16_s, allAllowanceValues.allowance16_s);
|
|
87
|
+
require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 16 failed");
|
|
88
|
+
|
|
89
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a16_s, allGTCastingValues.b16_s, allAmountValues.amount8_s, allAllowanceValues.allowance16_s);
|
|
90
|
+
require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 16 failed");
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
function computeAndCheckTransfer32(
|
|
95
|
+
AllGTCastingValues memory allGTCastingValues,
|
|
96
|
+
AllAmountValues memory allAmountValues,
|
|
97
|
+
AllAllowanceValues memory allAllowanceValues,
|
|
98
|
+
uint8 new_a,
|
|
99
|
+
uint8 new_b,
|
|
100
|
+
bool res,
|
|
101
|
+
uint8 new_allowance
|
|
102
|
+
)
|
|
103
|
+
public
|
|
104
|
+
{
|
|
105
|
+
(gtUint32 newA_s, gtUint32 newB_s, gtBool res_s, gtUint32 newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a32_s, allGTCastingValues.b32_s, allAmountValues.amount32_s, allAllowanceValues.allowance32_s);
|
|
106
|
+
require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 32 failed");
|
|
107
|
+
|
|
108
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a32_s, allGTCastingValues.b8_s, allAmountValues.amount8_s, allAllowanceValues.allowance8_s);
|
|
109
|
+
require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 32 failed");
|
|
110
|
+
|
|
111
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a8_s, allGTCastingValues.b32_s, allAmountValues.amount8_s, allAllowanceValues.allowance8_s);
|
|
112
|
+
require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 32 failed");
|
|
113
|
+
|
|
114
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a32_s, allGTCastingValues.b8_s, allAmountValues.amount32_s, allAllowanceValues.allowance8_s);
|
|
115
|
+
require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 32 failed");
|
|
116
|
+
|
|
117
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a8_s, allGTCastingValues.b32_s, allAmountValues.amount32_s, allAllowanceValues.allowance8_s);
|
|
118
|
+
require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 32 failed");
|
|
119
|
+
|
|
120
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a32_s, allGTCastingValues.b32_s, allAmountValues.amount32_s, allAllowanceValues.allowance8_s);
|
|
121
|
+
require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 32 failed");
|
|
122
|
+
|
|
123
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a32_s, allGTCastingValues.b8_s, allAmountValues.amount16_s, allAllowanceValues.allowance8_s);
|
|
124
|
+
require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 32 failed");
|
|
125
|
+
|
|
126
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a8_s, allGTCastingValues.b32_s, allAmountValues.amount16_s, allAllowanceValues.allowance8_s);
|
|
127
|
+
require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 32 failed");
|
|
128
|
+
|
|
129
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a32_s, allGTCastingValues.b32_s, allAmountValues.amount8_s, allAllowanceValues.allowance8_s);
|
|
130
|
+
require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 32 failed");
|
|
131
|
+
|
|
132
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a32_s, allGTCastingValues.b8_s, allAmountValues.amount8_s, allAllowanceValues.allowance16_s);
|
|
133
|
+
require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 32 failed");
|
|
134
|
+
|
|
135
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a8_s, allGTCastingValues.b32_s, allAmountValues.amount8_s, allAllowanceValues.allowance16_s);
|
|
136
|
+
require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 32 failed");
|
|
137
|
+
|
|
138
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a32_s, allGTCastingValues.b8_s, allAmountValues.amount32_s, allAllowanceValues.allowance16_s);
|
|
139
|
+
require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 32 failed");
|
|
140
|
+
|
|
141
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a8_s, allGTCastingValues.b32_s, allAmountValues.amount32_s, allAllowanceValues.allowance16_s);
|
|
142
|
+
require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 32 failed");
|
|
143
|
+
|
|
144
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a32_s, allGTCastingValues.b8_s, allAmountValues.amount16_s, allAllowanceValues.allowance16_s);
|
|
145
|
+
require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 32 failed");
|
|
146
|
+
|
|
147
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a8_s, allGTCastingValues.b32_s, allAmountValues.amount16_s, allAllowanceValues.allowance16_s);
|
|
148
|
+
require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 32 failed");
|
|
149
|
+
|
|
150
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a32_s, allGTCastingValues.b32_s, allAmountValues.amount8_s, allAllowanceValues.allowance16_s);
|
|
151
|
+
require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 32 failed");
|
|
152
|
+
|
|
153
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a32_s, allGTCastingValues.b8_s, allAmountValues.amount8_s, allAllowanceValues.allowance32_s);
|
|
154
|
+
require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 32 failed");
|
|
155
|
+
|
|
156
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a8_s, allGTCastingValues.b32_s, allAmountValues.amount8_s, allAllowanceValues.allowance32_s);
|
|
157
|
+
require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 32 failed");
|
|
158
|
+
|
|
159
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a32_s, allGTCastingValues.b8_s, allAmountValues.amount32_s, allAllowanceValues.allowance32_s);
|
|
160
|
+
require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 32 failed");
|
|
161
|
+
|
|
162
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a8_s, allGTCastingValues.b32_s, allAmountValues.amount32_s, allAllowanceValues.allowance32_s);
|
|
163
|
+
require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 32 failed");
|
|
164
|
+
|
|
165
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a32_s, allGTCastingValues.b8_s, allAmountValues.amount16_s, allAllowanceValues.allowance32_s);
|
|
166
|
+
require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 32 failed");
|
|
167
|
+
|
|
168
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a8_s, allGTCastingValues.b32_s, allAmountValues.amount16_s, allAllowanceValues.allowance32_s);
|
|
169
|
+
require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 32 failed");
|
|
170
|
+
|
|
171
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a32_s, allGTCastingValues.b32_s, allAmountValues.amount8_s, allAllowanceValues.allowance32_s);
|
|
172
|
+
require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 32 failed");
|
|
173
|
+
|
|
174
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a16_s, allGTCastingValues.b32_s, allAmountValues.amount8_s, allAllowanceValues.allowance8_s);
|
|
175
|
+
require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 32 failed");
|
|
176
|
+
|
|
177
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a32_s, allGTCastingValues.b16_s, allAmountValues.amount8_s, allAllowanceValues.allowance8_s);
|
|
178
|
+
require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 32 failed");
|
|
179
|
+
|
|
180
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a16_s, allGTCastingValues.b32_s, allAmountValues.amount16_s, allAllowanceValues.allowance8_s);
|
|
181
|
+
require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 32 failed");
|
|
182
|
+
|
|
183
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a32_s, allGTCastingValues.b16_s, allAmountValues.amount16_s, allAllowanceValues.allowance8_s);
|
|
184
|
+
require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 32 failed");
|
|
185
|
+
|
|
186
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a16_s, allGTCastingValues.b32_s, allAmountValues.amount32_s, allAllowanceValues.allowance8_s);
|
|
187
|
+
require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 32 failed");
|
|
188
|
+
|
|
189
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a32_s, allGTCastingValues.b16_s, allAmountValues.amount32_s, allAllowanceValues.allowance8_s);
|
|
190
|
+
require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 32 failed");
|
|
191
|
+
|
|
192
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a32_s, allGTCastingValues.b32_s, allAmountValues.amount16_s, allAllowanceValues.allowance8_s);
|
|
193
|
+
require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 32 failed");
|
|
194
|
+
|
|
195
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a16_s, allGTCastingValues.b32_s, allAmountValues.amount8_s, allAllowanceValues.allowance16_s);
|
|
196
|
+
require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 32 failed");
|
|
197
|
+
|
|
198
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a32_s, allGTCastingValues.b16_s, allAmountValues.amount8_s, allAllowanceValues.allowance16_s);
|
|
199
|
+
require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 32 failed");
|
|
200
|
+
|
|
201
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a16_s, allGTCastingValues.b32_s, allAmountValues.amount16_s, allAllowanceValues.allowance16_s);
|
|
202
|
+
require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 32 failed");
|
|
203
|
+
|
|
204
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a32_s, allGTCastingValues.b16_s, allAmountValues.amount16_s, allAllowanceValues.allowance16_s);
|
|
205
|
+
require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 32 failed");
|
|
206
|
+
|
|
207
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a16_s, allGTCastingValues.b32_s, allAmountValues.amount32_s, allAllowanceValues.allowance16_s);
|
|
208
|
+
require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 32 failed");
|
|
209
|
+
|
|
210
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a32_s, allGTCastingValues.b16_s, allAmountValues.amount32_s, allAllowanceValues.allowance16_s);
|
|
211
|
+
require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 32 failed");
|
|
212
|
+
|
|
213
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a32_s, allGTCastingValues.b32_s, allAmountValues.amount16_s, allAllowanceValues.allowance16_s);
|
|
214
|
+
require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 32 failed");
|
|
215
|
+
|
|
216
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a32_s, allGTCastingValues.b32_s, allAmountValues.amount32_s, allAllowanceValues.allowance16_s);
|
|
217
|
+
require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 32 failed");
|
|
218
|
+
|
|
219
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a16_s, allGTCastingValues.b32_s, allAmountValues.amount8_s, allAllowanceValues.allowance32_s);
|
|
220
|
+
require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 32 failed");
|
|
221
|
+
|
|
222
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a32_s, allGTCastingValues.b16_s, allAmountValues.amount8_s, allAllowanceValues.allowance32_s);
|
|
223
|
+
require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 32 failed");
|
|
224
|
+
|
|
225
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a16_s, allGTCastingValues.b32_s, allAmountValues.amount16_s, allAllowanceValues.allowance32_s);
|
|
226
|
+
require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 32 failed");
|
|
227
|
+
|
|
228
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a32_s, allGTCastingValues.b16_s, allAmountValues.amount16_s, allAllowanceValues.allowance32_s);
|
|
229
|
+
require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 32 failed");
|
|
230
|
+
|
|
231
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a16_s, allGTCastingValues.b32_s, allAmountValues.amount32_s, allAllowanceValues.allowance32_s);
|
|
232
|
+
require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 32 failed");
|
|
233
|
+
|
|
234
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a32_s, allGTCastingValues.b16_s, allAmountValues.amount32_s, allAllowanceValues.allowance32_s);
|
|
235
|
+
require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 32 failed");
|
|
236
|
+
|
|
237
|
+
(newA_s, newB_s, res_s, newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a32_s, allGTCastingValues.b32_s, allAmountValues.amount16_s, allAllowanceValues.allowance32_s);
|
|
238
|
+
require(new_a == MpcCore.decrypt(newA_s) && new_b == MpcCore.decrypt(newB_s) && res == MpcCore.decrypt(res_s) && new_allowance == MpcCore.decrypt(newAllowance_s), "transferTest: cast 32 failed");
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
function transferWithAllowanceTest(uint8 a, uint8 b, uint8 amount, uint8 allowance) public returns (uint8, uint8, bool, uint8) {
|
|
243
|
+
AllGTCastingValues memory allGTCastingValues;
|
|
244
|
+
AllAmountValues memory allAmountValues;
|
|
245
|
+
AllAllowanceValues memory allAllowanceValues;
|
|
246
|
+
allGTCastingValues.a8_s = MpcCore.setPublic8(a);
|
|
247
|
+
allGTCastingValues.b8_s = MpcCore.setPublic8(b);
|
|
248
|
+
allGTCastingValues.a16_s = MpcCore.setPublic16(a);
|
|
249
|
+
allGTCastingValues.b16_s = MpcCore.setPublic16(b);
|
|
250
|
+
allGTCastingValues.a32_s = MpcCore.setPublic32(a);
|
|
251
|
+
allGTCastingValues.b32_s = MpcCore.setPublic32(b);
|
|
252
|
+
allGTCastingValues.a64_s = MpcCore.setPublic64(a);
|
|
253
|
+
allGTCastingValues.b64_s = MpcCore.setPublic64(b);
|
|
254
|
+
allAmountValues.amount8_s = MpcCore.setPublic8(amount);
|
|
255
|
+
allAmountValues.amount16_s = MpcCore.setPublic16(amount);
|
|
256
|
+
allAmountValues.amount32_s = MpcCore.setPublic32(amount);
|
|
257
|
+
allAmountValues.amount64_s = MpcCore.setPublic64(amount);
|
|
258
|
+
allAmountValues.amount = amount;
|
|
259
|
+
allAllowanceValues.allowance8_s = MpcCore.setPublic8(allowance);
|
|
260
|
+
allAllowanceValues.allowance16_s = MpcCore.setPublic16(allowance);
|
|
261
|
+
allAllowanceValues.allowance32_s = MpcCore.setPublic32(allowance);
|
|
262
|
+
allAllowanceValues.allowance64_s = MpcCore.setPublic64(allowance);
|
|
263
|
+
allAllowanceValues.allowance = allowance;
|
|
264
|
+
|
|
265
|
+
// Calculate the expected result
|
|
266
|
+
(gtUint8 newA_s, gtUint8 newB_s, gtBool res_s, gtUint8 newAllowance_s) = MpcCore.transferWithAllowance(allGTCastingValues.a8_s, allGTCastingValues.b8_s, allAmountValues.amount8_s, allAllowanceValues.allowance8_s);
|
|
267
|
+
newA = MpcCore.decrypt(newA_s);
|
|
268
|
+
newB = MpcCore.decrypt(newB_s);
|
|
269
|
+
result = MpcCore.decrypt(res_s);
|
|
270
|
+
newAllowance = MpcCore.decrypt(newAllowance_s);
|
|
271
|
+
|
|
272
|
+
// Calculate the result with casting to 16
|
|
273
|
+
computeAndCheckTransfer16(allGTCastingValues, allAmountValues, allAllowanceValues, newA, newB, result, newAllowance);
|
|
274
|
+
|
|
275
|
+
// Calculate the result with casting to 32
|
|
276
|
+
computeAndCheckTransfer32(allGTCastingValues, allAmountValues, allAllowanceValues, newA, newB, result, newAllowance);
|
|
277
|
+
|
|
278
|
+
return (newA, newB, result, newAllowance);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
}
|
|
@@ -6,7 +6,7 @@ import "../utils/mpc/MpcCore.sol";
|
|
|
6
6
|
|
|
7
7
|
contract AccountOnboard {
|
|
8
8
|
|
|
9
|
-
event AccountOnboarded(address indexed _from, bytes
|
|
9
|
+
event AccountOnboarded(address indexed _from, bytes userKey1, bytes userKey2);
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* @notice onboards the account and emits the users AES encryption key in encrypted form
|
|
@@ -15,7 +15,7 @@ contract AccountOnboard {
|
|
|
15
15
|
* @param signedEK signed hash of the RSA public key
|
|
16
16
|
*/
|
|
17
17
|
function onboardAccount(bytes calldata publicKey, bytes calldata signedEK) public {
|
|
18
|
-
bytes memory
|
|
19
|
-
emit AccountOnboarded(msg.sender,
|
|
18
|
+
(bytes memory accountKey1, bytes memory accountKey2)= MpcCore.getUserKey(publicKey, signedEK);
|
|
19
|
+
emit AccountOnboarded(msg.sender, accountKey1, accountKey2);
|
|
20
20
|
}
|
|
21
21
|
}
|