@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,5 +1,4 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
|
-
|
|
3
2
|
pragma solidity ^0.8.19;
|
|
4
3
|
|
|
5
4
|
import "../../../utils/mpc/MpcCore.sol";
|
|
@@ -7,6 +6,8 @@ import "../../../utils/mpc/MpcCore.sol";
|
|
|
7
6
|
contract BitwiseTestsContract {
|
|
8
7
|
|
|
9
8
|
struct AllGTCastingValues {
|
|
9
|
+
gtBool aBool_s;
|
|
10
|
+
gtBool bBool_s;
|
|
10
11
|
gtUint8 a8_s;
|
|
11
12
|
gtUint8 b8_s;
|
|
12
13
|
gtUint16 a16_s;
|
|
@@ -41,74 +42,65 @@ contract BitwiseTestsContract {
|
|
|
41
42
|
gtUint64 res64_32;
|
|
42
43
|
}
|
|
43
44
|
|
|
44
|
-
uint8
|
|
45
|
+
uint8 andResult;
|
|
46
|
+
uint8 orResult;
|
|
47
|
+
uint8 xorResult;
|
|
45
48
|
|
|
46
|
-
function
|
|
47
|
-
return
|
|
49
|
+
function getAndResult() public view returns (uint8) {
|
|
50
|
+
return andResult;
|
|
51
|
+
}
|
|
52
|
+
function getOrResult() public view returns (uint8) {
|
|
53
|
+
return orResult;
|
|
54
|
+
}
|
|
55
|
+
function getXorResult() public view returns (uint8) {
|
|
56
|
+
return xorResult;
|
|
48
57
|
}
|
|
49
58
|
|
|
50
|
-
function setPublicValues(
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
uint8 b
|
|
54
|
-
) public {
|
|
59
|
+
function setPublicValues(AllGTCastingValues memory castingValues, uint8 a, uint8 b) public {
|
|
60
|
+
castingValues.aBool_s = MpcCore.setPublic(a > b);
|
|
61
|
+
castingValues.bBool_s = MpcCore.setPublic(b > a);
|
|
55
62
|
castingValues.a8_s = MpcCore.setPublic8(a);
|
|
56
63
|
castingValues.b8_s = MpcCore.setPublic8(b);
|
|
57
|
-
castingValues.a16_s =
|
|
58
|
-
castingValues.b16_s =
|
|
59
|
-
castingValues.a32_s =
|
|
60
|
-
castingValues.b32_s =
|
|
61
|
-
castingValues.a64_s =
|
|
62
|
-
castingValues.b64_s =
|
|
64
|
+
castingValues.a16_s = MpcCore.setPublic16(a);
|
|
65
|
+
castingValues.b16_s = MpcCore.setPublic16(b);
|
|
66
|
+
castingValues.a32_s = MpcCore.setPublic32(a);
|
|
67
|
+
castingValues.b32_s = MpcCore.setPublic32(b);
|
|
68
|
+
castingValues.a64_s = MpcCore.setPublic64(a);
|
|
69
|
+
castingValues.b64_s = MpcCore.setPublic64(b);
|
|
63
70
|
}
|
|
64
71
|
|
|
65
|
-
function decryptAndCompareResults16(
|
|
66
|
-
|
|
67
|
-
) public returns (uint16) {
|
|
72
|
+
function decryptAndCompareResults16(Check16 memory check16) public returns (uint16){
|
|
73
|
+
|
|
68
74
|
// Calculate the result
|
|
69
75
|
uint16 result = MpcCore.decrypt(check16.res16_16);
|
|
70
76
|
|
|
71
|
-
require(
|
|
72
|
-
|
|
73
|
-
result == MpcCore.decrypt(check16.res16_8),
|
|
74
|
-
"decryptAndCompareAllResults: Failed to decrypt and compare all results"
|
|
75
|
-
);
|
|
77
|
+
require(result == MpcCore.decrypt(check16.res8_16) && result == MpcCore.decrypt(check16.res16_8),
|
|
78
|
+
"decryptAndCompareAllResults: Failed to decrypt and compare all results");
|
|
76
79
|
|
|
77
80
|
return result;
|
|
78
81
|
}
|
|
79
82
|
|
|
80
|
-
function decryptAndCompareResults32(
|
|
81
|
-
|
|
82
|
-
) public returns (uint32) {
|
|
83
|
+
function decryptAndCompareResults32(Check32 memory check32) public returns (uint32){
|
|
84
|
+
|
|
83
85
|
// Calculate the result
|
|
84
86
|
uint32 result = MpcCore.decrypt(check32.res32_32);
|
|
85
87
|
|
|
86
|
-
require(
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
result == MpcCore.decrypt(check32.res32_16) &&
|
|
90
|
-
result == MpcCore.decrypt(check32.res16_32),
|
|
91
|
-
"decryptAndCompareAllResults: Failed to decrypt and compare all results"
|
|
92
|
-
);
|
|
88
|
+
require(result == MpcCore.decrypt(check32.res8_32) && result == MpcCore.decrypt(check32.res32_8)
|
|
89
|
+
&& result == MpcCore.decrypt(check32.res32_16) && result == MpcCore.decrypt(check32.res16_32),
|
|
90
|
+
"decryptAndCompareAllResults: Failed to decrypt and compare all results");
|
|
93
91
|
|
|
94
92
|
return result;
|
|
95
93
|
}
|
|
96
94
|
|
|
97
|
-
function decryptAndCompareResults64(
|
|
98
|
-
|
|
99
|
-
) public returns (uint64) {
|
|
95
|
+
function decryptAndCompareResults64(Check64 memory check64) public returns (uint64){
|
|
96
|
+
|
|
100
97
|
// Calculate the result
|
|
101
98
|
uint64 result = MpcCore.decrypt(check64.res64_64);
|
|
102
99
|
|
|
103
|
-
require(
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
result == MpcCore.decrypt(check64.res16_64) &&
|
|
108
|
-
result == MpcCore.decrypt(check64.res64_32) &&
|
|
109
|
-
result == MpcCore.decrypt(check64.res32_64),
|
|
110
|
-
"decryptAndCompareAllResults: Failed to decrypt and compare all results"
|
|
111
|
-
);
|
|
100
|
+
require(result == MpcCore.decrypt(check64.res8_64) && result == MpcCore.decrypt(check64.res64_8)
|
|
101
|
+
&& result == MpcCore.decrypt(check64.res64_16) && result == MpcCore.decrypt(check64.res16_64)
|
|
102
|
+
&& result == MpcCore.decrypt(check64.res64_32) && result == MpcCore.decrypt(check64.res32_64),
|
|
103
|
+
"decryptAndCompareAllResults: Failed to decrypt and compare all results");
|
|
112
104
|
|
|
113
105
|
return result;
|
|
114
106
|
}
|
|
@@ -120,86 +112,48 @@ contract BitwiseTestsContract {
|
|
|
120
112
|
Check64 memory check64;
|
|
121
113
|
setPublicValues(castingValues, a, b);
|
|
122
114
|
|
|
115
|
+
MpcCore.decrypt(MpcCore.and(castingValues.aBool_s, castingValues.bBool_s));
|
|
116
|
+
|
|
123
117
|
// Calculate the expected result
|
|
124
|
-
result =
|
|
125
|
-
|
|
126
|
-
);
|
|
118
|
+
uint8 result = MpcCore.decrypt(MpcCore.and(castingValues.a8_s, castingValues.b8_s));
|
|
119
|
+
andResult = result;
|
|
127
120
|
|
|
128
121
|
// Calculate the results with casting to 16
|
|
129
|
-
check16.res16_16 = MpcCore.and(
|
|
130
|
-
castingValues.a16_s,
|
|
131
|
-
castingValues.b16_s
|
|
132
|
-
);
|
|
122
|
+
check16.res16_16 = MpcCore.and(castingValues.a16_s, castingValues.b16_s);
|
|
133
123
|
check16.res8_16 = MpcCore.and(castingValues.a8_s, castingValues.b16_s);
|
|
134
124
|
check16.res16_8 = MpcCore.and(castingValues.a16_s, castingValues.b8_s);
|
|
135
125
|
uint16 res16 = decryptAndCompareResults16(check16);
|
|
136
126
|
require(res16 == result, "andTest: cast 16 failed");
|
|
137
127
|
|
|
138
128
|
// Calculate the result with casting to 32
|
|
139
|
-
check32.res32_32 = MpcCore.and(
|
|
140
|
-
castingValues.a32_s,
|
|
141
|
-
castingValues.b32_s
|
|
142
|
-
);
|
|
129
|
+
check32.res32_32 = MpcCore.and(castingValues.a32_s, castingValues.b32_s);
|
|
143
130
|
check32.res8_32 = MpcCore.and(castingValues.a8_s, castingValues.b32_s);
|
|
144
131
|
check32.res32_8 = MpcCore.and(castingValues.a32_s, castingValues.b8_s);
|
|
145
|
-
check32.res16_32 = MpcCore.and(
|
|
146
|
-
|
|
147
|
-
castingValues.b32_s
|
|
148
|
-
);
|
|
149
|
-
check32.res32_16 = MpcCore.and(
|
|
150
|
-
castingValues.a32_s,
|
|
151
|
-
castingValues.b16_s
|
|
152
|
-
);
|
|
132
|
+
check32.res16_32 = MpcCore.and(castingValues.a16_s, castingValues.b32_s);
|
|
133
|
+
check32.res32_16 = MpcCore.and(castingValues.a32_s, castingValues.b16_s);
|
|
153
134
|
uint32 res32 = decryptAndCompareResults32(check32);
|
|
154
135
|
require(result == res32, "andTest: cast 32 failed");
|
|
155
136
|
|
|
156
137
|
// Calculate the result with casting to 64
|
|
157
|
-
check64.res64_64 = MpcCore.and(
|
|
158
|
-
castingValues.a64_s,
|
|
159
|
-
castingValues.b64_s
|
|
160
|
-
);
|
|
138
|
+
check64.res64_64 = MpcCore.and(castingValues.a64_s, castingValues.b64_s);
|
|
161
139
|
check64.res8_64 = MpcCore.and(castingValues.a8_s, castingValues.b64_s);
|
|
162
140
|
check64.res64_8 = MpcCore.and(castingValues.a64_s, castingValues.b8_s);
|
|
163
|
-
check64.res16_64 = MpcCore.and(
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
);
|
|
167
|
-
check64.res64_16 = MpcCore.and(
|
|
168
|
-
castingValues.a64_s,
|
|
169
|
-
castingValues.b16_s
|
|
170
|
-
);
|
|
171
|
-
check64.res32_64 = MpcCore.and(
|
|
172
|
-
castingValues.a32_s,
|
|
173
|
-
castingValues.b64_s
|
|
174
|
-
);
|
|
175
|
-
check64.res64_32 = MpcCore.and(
|
|
176
|
-
castingValues.a64_s,
|
|
177
|
-
castingValues.b32_s
|
|
178
|
-
);
|
|
141
|
+
check64.res16_64 = MpcCore.and(castingValues.a16_s, castingValues.b64_s);
|
|
142
|
+
check64.res64_16 = MpcCore.and(castingValues.a64_s, castingValues.b16_s);
|
|
143
|
+
check64.res32_64 = MpcCore.and(castingValues.a32_s, castingValues.b64_s);
|
|
144
|
+
check64.res64_32 = MpcCore.and(castingValues.a64_s, castingValues.b32_s);
|
|
179
145
|
uint64 res64 = decryptAndCompareResults64(check64);
|
|
180
146
|
require(result == res64, "andTest: cast 64 failed");
|
|
181
147
|
|
|
182
148
|
// Check the result with scalar
|
|
183
|
-
require(
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
"andTest: test
|
|
187
|
-
)
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
"andTest: test 16 bits with scalar failed"
|
|
192
|
-
);
|
|
193
|
-
require(
|
|
194
|
-
result == MpcCore.decrypt(MpcCore.and(a, castingValues.b32_s)) &&
|
|
195
|
-
result == MpcCore.decrypt(MpcCore.and(castingValues.a32_s, b)),
|
|
196
|
-
"andTest: test 32 bits with scalar failed"
|
|
197
|
-
);
|
|
198
|
-
require(
|
|
199
|
-
result == MpcCore.decrypt(MpcCore.and(a, castingValues.b64_s)) &&
|
|
200
|
-
result == MpcCore.decrypt(MpcCore.and(castingValues.a64_s, b)),
|
|
201
|
-
"andTest: test 64 bits with scalar failed"
|
|
202
|
-
);
|
|
149
|
+
require(result == MpcCore.decrypt(MpcCore.and(a, castingValues.b8_s)) && result == MpcCore.decrypt(MpcCore.and(castingValues.a8_s, b)),
|
|
150
|
+
"andTest: test 8 bits with scalar failed");
|
|
151
|
+
require(result == MpcCore.decrypt(MpcCore.and(a, castingValues.b16_s)) && result == MpcCore.decrypt(MpcCore.and(castingValues.a16_s, b)),
|
|
152
|
+
"andTest: test 16 bits with scalar failed");
|
|
153
|
+
require(result == MpcCore.decrypt(MpcCore.and(a, castingValues.b32_s)) && result == MpcCore.decrypt(MpcCore.and(castingValues.a32_s, b)),
|
|
154
|
+
"andTest: test 32 bits with scalar failed");
|
|
155
|
+
require(result == MpcCore.decrypt(MpcCore.and(a, castingValues.b64_s)) && result == MpcCore.decrypt(MpcCore.and(castingValues.a64_s, b)),
|
|
156
|
+
"andTest: test 64 bits with scalar failed");
|
|
203
157
|
|
|
204
158
|
return result;
|
|
205
159
|
}
|
|
@@ -211,10 +165,11 @@ contract BitwiseTestsContract {
|
|
|
211
165
|
Check64 memory check64;
|
|
212
166
|
setPublicValues(castingValues, a, b);
|
|
213
167
|
|
|
168
|
+
MpcCore.decrypt(MpcCore.or(castingValues.aBool_s, castingValues.bBool_s));
|
|
169
|
+
|
|
214
170
|
// Calculate the expected result
|
|
215
|
-
result =
|
|
216
|
-
|
|
217
|
-
);
|
|
171
|
+
uint8 result = MpcCore.decrypt(MpcCore.or(castingValues.a8_s, castingValues.b8_s));
|
|
172
|
+
orResult = result;
|
|
218
173
|
|
|
219
174
|
// Calculate the results with casting to 16
|
|
220
175
|
check16.res16_16 = MpcCore.or(castingValues.a16_s, castingValues.b16_s);
|
|
@@ -244,26 +199,14 @@ contract BitwiseTestsContract {
|
|
|
244
199
|
require(result == res64, "orTest: cast 64 failed");
|
|
245
200
|
|
|
246
201
|
// Check the result with scalar
|
|
247
|
-
require(
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
"orTest: test
|
|
251
|
-
)
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
"orTest: test 16 bits with scalar failed"
|
|
256
|
-
);
|
|
257
|
-
require(
|
|
258
|
-
result == MpcCore.decrypt(MpcCore.or(a, castingValues.b32_s)) &&
|
|
259
|
-
result == MpcCore.decrypt(MpcCore.or(castingValues.a32_s, b)),
|
|
260
|
-
"orTest: test 32 bits with scalar failed"
|
|
261
|
-
);
|
|
262
|
-
require(
|
|
263
|
-
result == MpcCore.decrypt(MpcCore.or(a, castingValues.b64_s)) &&
|
|
264
|
-
result == MpcCore.decrypt(MpcCore.or(castingValues.a64_s, b)),
|
|
265
|
-
"orTest: test 64 bits with scalar failed"
|
|
266
|
-
);
|
|
202
|
+
require(result == MpcCore.decrypt(MpcCore.or(a, castingValues.b8_s)) && result == MpcCore.decrypt(MpcCore.or(castingValues.a8_s, b)),
|
|
203
|
+
"orTest: test 8 bits with scalar failed");
|
|
204
|
+
require(result == MpcCore.decrypt(MpcCore.or(a, castingValues.b16_s)) && result == MpcCore.decrypt(MpcCore.or(castingValues.a16_s, b)),
|
|
205
|
+
"orTest: test 16 bits with scalar failed");
|
|
206
|
+
require(result == MpcCore.decrypt(MpcCore.or(a, castingValues.b32_s)) && result == MpcCore.decrypt(MpcCore.or(castingValues.a32_s, b)),
|
|
207
|
+
"orTest: test 32 bits with scalar failed");
|
|
208
|
+
require(result == MpcCore.decrypt(MpcCore.or(a, castingValues.b64_s)) && result == MpcCore.decrypt(MpcCore.or(castingValues.a64_s, b)),
|
|
209
|
+
"orTest: test 64 bits with scalar failed");
|
|
267
210
|
|
|
268
211
|
return result;
|
|
269
212
|
}
|
|
@@ -275,87 +218,50 @@ contract BitwiseTestsContract {
|
|
|
275
218
|
Check64 memory check64;
|
|
276
219
|
setPublicValues(castingValues, a, b);
|
|
277
220
|
|
|
221
|
+
MpcCore.decrypt(MpcCore.xor(castingValues.aBool_s, castingValues.bBool_s));
|
|
222
|
+
|
|
278
223
|
// Calculate the expected result
|
|
279
|
-
result =
|
|
280
|
-
|
|
281
|
-
);
|
|
224
|
+
uint8 result = MpcCore.decrypt(MpcCore.xor(castingValues.a8_s, castingValues.b8_s));
|
|
225
|
+
xorResult = result;
|
|
282
226
|
|
|
283
227
|
// Calculate the results with casting to 16
|
|
284
|
-
check16.res16_16 = MpcCore.xor(
|
|
285
|
-
castingValues.a16_s,
|
|
286
|
-
castingValues.b16_s
|
|
287
|
-
);
|
|
228
|
+
check16.res16_16 = MpcCore.xor(castingValues.a16_s, castingValues.b16_s);
|
|
288
229
|
check16.res8_16 = MpcCore.xor(castingValues.a8_s, castingValues.b16_s);
|
|
289
230
|
check16.res16_8 = MpcCore.xor(castingValues.a16_s, castingValues.b8_s);
|
|
290
231
|
uint16 res16 = decryptAndCompareResults16(check16);
|
|
291
232
|
require(res16 == result, "xorTest: cast 16 failed");
|
|
292
233
|
|
|
293
234
|
// Calculate the result with casting to 32
|
|
294
|
-
check32.res32_32 = MpcCore.xor(
|
|
295
|
-
castingValues.a32_s,
|
|
296
|
-
castingValues.b32_s
|
|
297
|
-
);
|
|
235
|
+
check32.res32_32 = MpcCore.xor(castingValues.a32_s, castingValues.b32_s);
|
|
298
236
|
check32.res8_32 = MpcCore.xor(castingValues.a8_s, castingValues.b32_s);
|
|
299
237
|
check32.res32_8 = MpcCore.xor(castingValues.a32_s, castingValues.b8_s);
|
|
300
|
-
check32.res16_32 = MpcCore.xor(
|
|
301
|
-
|
|
302
|
-
castingValues.b32_s
|
|
303
|
-
);
|
|
304
|
-
check32.res32_16 = MpcCore.xor(
|
|
305
|
-
castingValues.a32_s,
|
|
306
|
-
castingValues.b16_s
|
|
307
|
-
);
|
|
238
|
+
check32.res16_32 = MpcCore.xor(castingValues.a16_s, castingValues.b32_s);
|
|
239
|
+
check32.res32_16 = MpcCore.xor(castingValues.a32_s, castingValues.b16_s);
|
|
308
240
|
uint32 res32 = decryptAndCompareResults32(check32);
|
|
309
241
|
require(result == res32, "xorTest: cast 32 failed");
|
|
310
242
|
|
|
311
243
|
// Calculate the result with casting to 64
|
|
312
|
-
check64.res64_64 = MpcCore.xor(
|
|
313
|
-
castingValues.a64_s,
|
|
314
|
-
castingValues.b64_s
|
|
315
|
-
);
|
|
244
|
+
check64.res64_64 = MpcCore.xor(castingValues.a64_s, castingValues.b64_s);
|
|
316
245
|
check64.res8_64 = MpcCore.xor(castingValues.a8_s, castingValues.b64_s);
|
|
317
246
|
check64.res64_8 = MpcCore.xor(castingValues.a64_s, castingValues.b8_s);
|
|
318
|
-
check64.res16_64 = MpcCore.xor(
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
);
|
|
322
|
-
check64.res64_16 = MpcCore.xor(
|
|
323
|
-
castingValues.a64_s,
|
|
324
|
-
castingValues.b16_s
|
|
325
|
-
);
|
|
326
|
-
check64.res32_64 = MpcCore.xor(
|
|
327
|
-
castingValues.a32_s,
|
|
328
|
-
castingValues.b64_s
|
|
329
|
-
);
|
|
330
|
-
check64.res64_32 = MpcCore.xor(
|
|
331
|
-
castingValues.a64_s,
|
|
332
|
-
castingValues.b32_s
|
|
333
|
-
);
|
|
247
|
+
check64.res16_64 = MpcCore.xor(castingValues.a16_s, castingValues.b64_s);
|
|
248
|
+
check64.res64_16 = MpcCore.xor(castingValues.a64_s, castingValues.b16_s);
|
|
249
|
+
check64.res32_64 = MpcCore.xor(castingValues.a32_s, castingValues.b64_s);
|
|
250
|
+
check64.res64_32 = MpcCore.xor(castingValues.a64_s, castingValues.b32_s);
|
|
334
251
|
uint64 res64 = decryptAndCompareResults64(check64);
|
|
335
252
|
require(result == res64, "xorTest: cast 64 failed");
|
|
336
253
|
|
|
337
254
|
// Check the result with scalar
|
|
338
|
-
require(
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
"xorTest: test
|
|
342
|
-
)
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
"xorTest: test 16 bits with scalar failed"
|
|
347
|
-
);
|
|
348
|
-
require(
|
|
349
|
-
result == MpcCore.decrypt(MpcCore.xor(a, castingValues.b32_s)) &&
|
|
350
|
-
result == MpcCore.decrypt(MpcCore.xor(castingValues.a32_s, b)),
|
|
351
|
-
"xorTest: test 32 bits with scalar failed"
|
|
352
|
-
);
|
|
353
|
-
require(
|
|
354
|
-
result == MpcCore.decrypt(MpcCore.xor(a, castingValues.b64_s)) &&
|
|
355
|
-
result == MpcCore.decrypt(MpcCore.xor(castingValues.a64_s, b)),
|
|
356
|
-
"xorTest: test 64 bits with scalar failed"
|
|
357
|
-
);
|
|
255
|
+
require(result == MpcCore.decrypt(MpcCore.xor(a, castingValues.b8_s)) && result == MpcCore.decrypt(MpcCore.xor(castingValues.a8_s, b)),
|
|
256
|
+
"xorTest: test 8 bits with scalar failed");
|
|
257
|
+
require(result == MpcCore.decrypt(MpcCore.xor(a, castingValues.b16_s)) && result == MpcCore.decrypt(MpcCore.xor(castingValues.a16_s, b)),
|
|
258
|
+
"xorTest: test 16 bits with scalar failed");
|
|
259
|
+
require(result == MpcCore.decrypt(MpcCore.xor(a, castingValues.b32_s)) && result == MpcCore.decrypt(MpcCore.xor(castingValues.a32_s, b)),
|
|
260
|
+
"xorTest: test 32 bits with scalar failed");
|
|
261
|
+
require(result == MpcCore.decrypt(MpcCore.xor(a, castingValues.b64_s)) && result == MpcCore.decrypt(MpcCore.xor(castingValues.a64_s, b)),
|
|
262
|
+
"xorTest: test 64 bits with scalar failed");
|
|
358
263
|
|
|
359
264
|
return result;
|
|
360
265
|
}
|
|
361
|
-
|
|
266
|
+
|
|
267
|
+
}
|
package/contracts/mocks/utils/mpc/{Comparison1Tests.Contract.sol → Comparison1TestsContract.sol}
RENAMED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
|
-
|
|
3
2
|
pragma solidity ^0.8.19;
|
|
4
3
|
|
|
5
4
|
import "../../../utils/mpc/MpcCore.sol";
|
|
@@ -41,74 +40,63 @@ contract Comparison1TestsContract {
|
|
|
41
40
|
gtBool res64_32;
|
|
42
41
|
}
|
|
43
42
|
|
|
44
|
-
bool
|
|
43
|
+
bool gtResult;
|
|
44
|
+
bool leResult;
|
|
45
|
+
bool ltResult;
|
|
45
46
|
|
|
46
|
-
function
|
|
47
|
-
return
|
|
47
|
+
function getGtResult() public view returns (bool) {
|
|
48
|
+
return gtResult;
|
|
49
|
+
}
|
|
50
|
+
function getLeResult() public view returns (bool) {
|
|
51
|
+
return leResult;
|
|
52
|
+
}
|
|
53
|
+
function getLtResult() public view returns (bool) {
|
|
54
|
+
return ltResult;
|
|
48
55
|
}
|
|
49
56
|
|
|
50
|
-
function setPublicValues(
|
|
51
|
-
AllGTCastingValues memory castingValues,
|
|
52
|
-
uint8 a,
|
|
53
|
-
uint8 b
|
|
54
|
-
) public {
|
|
57
|
+
function setPublicValues(AllGTCastingValues memory castingValues, uint8 a, uint8 b) public{
|
|
55
58
|
castingValues.a8_s = MpcCore.setPublic8(a);
|
|
56
59
|
castingValues.b8_s = MpcCore.setPublic8(b);
|
|
57
|
-
castingValues.a16_s =
|
|
58
|
-
castingValues.b16_s =
|
|
59
|
-
castingValues.a32_s =
|
|
60
|
-
castingValues.b32_s =
|
|
61
|
-
castingValues.a64_s =
|
|
62
|
-
castingValues.b64_s =
|
|
60
|
+
castingValues.a16_s = MpcCore.setPublic16(a);
|
|
61
|
+
castingValues.b16_s = MpcCore.setPublic16(b);
|
|
62
|
+
castingValues.a32_s = MpcCore.setPublic32(a);
|
|
63
|
+
castingValues.b32_s = MpcCore.setPublic32(b);
|
|
64
|
+
castingValues.a64_s = MpcCore.setPublic64(a);
|
|
65
|
+
castingValues.b64_s = MpcCore.setPublic64(b);
|
|
63
66
|
}
|
|
64
67
|
|
|
65
|
-
function decryptAndCompareResults16(
|
|
66
|
-
|
|
67
|
-
) public returns (bool) {
|
|
68
|
+
function decryptAndCompareResults16(Check16 memory check16) public returns (bool){
|
|
69
|
+
|
|
68
70
|
// Calculate the result
|
|
69
71
|
bool result = MpcCore.decrypt(check16.res16_16);
|
|
70
72
|
|
|
71
|
-
require(
|
|
72
|
-
|
|
73
|
-
result == MpcCore.decrypt(check16.res16_8),
|
|
74
|
-
"decryptAndCompareAllResults: Failed to decrypt and compare all results"
|
|
75
|
-
);
|
|
73
|
+
require(result == MpcCore.decrypt(check16.res8_16) && result == MpcCore.decrypt(check16.res16_8),
|
|
74
|
+
"decryptAndCompareAllResults: Failed to decrypt and compare all results");
|
|
76
75
|
|
|
77
76
|
return result;
|
|
78
77
|
}
|
|
79
78
|
|
|
80
|
-
function decryptAndCompareResults32(
|
|
81
|
-
|
|
82
|
-
) public returns (bool) {
|
|
79
|
+
function decryptAndCompareResults32(Check32 memory check32) public returns (bool){
|
|
80
|
+
|
|
83
81
|
// Calculate the result
|
|
84
82
|
bool result = MpcCore.decrypt(check32.res32_32);
|
|
85
83
|
|
|
86
|
-
require(
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
result == MpcCore.decrypt(check32.res32_16) &&
|
|
90
|
-
result == MpcCore.decrypt(check32.res16_32),
|
|
91
|
-
"decryptAndCompareAllResults: Failed to decrypt and compare all results"
|
|
92
|
-
);
|
|
84
|
+
require(result == MpcCore.decrypt(check32.res8_32) && result == MpcCore.decrypt(check32.res32_8)
|
|
85
|
+
&& result == MpcCore.decrypt(check32.res32_16) && result == MpcCore.decrypt(check32.res16_32),
|
|
86
|
+
"decryptAndCompareAllResults: Failed to decrypt and compare all results");
|
|
93
87
|
|
|
94
88
|
return result;
|
|
95
89
|
}
|
|
96
90
|
|
|
97
|
-
function decryptAndCompareResults64(
|
|
98
|
-
|
|
99
|
-
) public returns (bool) {
|
|
91
|
+
function decryptAndCompareResults64(Check64 memory check64) public returns (bool){
|
|
92
|
+
|
|
100
93
|
// Calculate the result
|
|
101
94
|
bool result = MpcCore.decrypt(check64.res64_64);
|
|
102
95
|
|
|
103
|
-
require(
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
result == MpcCore.decrypt(check64.res16_64) &&
|
|
108
|
-
result == MpcCore.decrypt(check64.res64_32) &&
|
|
109
|
-
result == MpcCore.decrypt(check64.res32_64),
|
|
110
|
-
"decryptAndCompareAllResults: Failed to decrypt and compare all results"
|
|
111
|
-
);
|
|
96
|
+
require(result == MpcCore.decrypt(check64.res8_64) && result == MpcCore.decrypt(check64.res64_8)
|
|
97
|
+
&& result == MpcCore.decrypt(check64.res64_16) && result == MpcCore.decrypt(check64.res16_64)
|
|
98
|
+
&& result == MpcCore.decrypt(check64.res64_32) && result == MpcCore.decrypt(check64.res32_64),
|
|
99
|
+
"decryptAndCompareAllResults: Failed to decrypt and compare all results");
|
|
112
100
|
|
|
113
101
|
return result;
|
|
114
102
|
}
|
|
@@ -121,9 +109,8 @@ contract Comparison1TestsContract {
|
|
|
121
109
|
setPublicValues(castingValues, a, b);
|
|
122
110
|
|
|
123
111
|
// Calculate the expected result
|
|
124
|
-
result =
|
|
125
|
-
|
|
126
|
-
);
|
|
112
|
+
bool result = MpcCore.decrypt(MpcCore.gt(castingValues.a8_s, castingValues.b8_s));
|
|
113
|
+
gtResult = result;
|
|
127
114
|
|
|
128
115
|
// Calculate the results with cating to 16
|
|
129
116
|
check16.res16_16 = MpcCore.gt(castingValues.a16_s, castingValues.b16_s);
|
|
@@ -153,26 +140,14 @@ contract Comparison1TestsContract {
|
|
|
153
140
|
require(result == res64, "gtTest: cast 64 failed");
|
|
154
141
|
|
|
155
142
|
// Check the result with scalar
|
|
156
|
-
require(
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
"gtTest: test
|
|
160
|
-
)
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
"gtTest: test 16 bits with scalar failed"
|
|
165
|
-
);
|
|
166
|
-
require(
|
|
167
|
-
result == MpcCore.decrypt(MpcCore.gt(a, castingValues.b32_s)) &&
|
|
168
|
-
result == MpcCore.decrypt(MpcCore.gt(castingValues.a32_s, b)),
|
|
169
|
-
"gtTest: test 32 bits with scalar failed"
|
|
170
|
-
);
|
|
171
|
-
require(
|
|
172
|
-
result == MpcCore.decrypt(MpcCore.gt(a, castingValues.b64_s)) &&
|
|
173
|
-
result == MpcCore.decrypt(MpcCore.gt(castingValues.a64_s, b)),
|
|
174
|
-
"gtTest: test 64 bits with scalar failed"
|
|
175
|
-
);
|
|
143
|
+
require(result == MpcCore.decrypt(MpcCore.gt(a, castingValues.b8_s)) && result == MpcCore.decrypt(MpcCore.gt(castingValues.a8_s, b)),
|
|
144
|
+
"gtTest: test 8 bits with scalar failed");
|
|
145
|
+
require(result == MpcCore.decrypt(MpcCore.gt(a, castingValues.b16_s)) && result == MpcCore.decrypt(MpcCore.gt(castingValues.a16_s, b)),
|
|
146
|
+
"gtTest: test 16 bits with scalar failed");
|
|
147
|
+
require(result == MpcCore.decrypt(MpcCore.gt(a, castingValues.b32_s)) && result == MpcCore.decrypt(MpcCore.gt(castingValues.a32_s, b)),
|
|
148
|
+
"gtTest: test 32 bits with scalar failed");
|
|
149
|
+
require(result == MpcCore.decrypt(MpcCore.gt(a, castingValues.b64_s)) && result == MpcCore.decrypt(MpcCore.gt(castingValues.a64_s, b)),
|
|
150
|
+
"gtTest: test 64 bits with scalar failed");
|
|
176
151
|
|
|
177
152
|
return result;
|
|
178
153
|
}
|
|
@@ -185,9 +160,8 @@ contract Comparison1TestsContract {
|
|
|
185
160
|
setPublicValues(castingValues, a, b);
|
|
186
161
|
|
|
187
162
|
// Calculate the expected result
|
|
188
|
-
result =
|
|
189
|
-
|
|
190
|
-
);
|
|
163
|
+
bool result = MpcCore.decrypt(MpcCore.le(castingValues.a8_s, castingValues.b8_s));
|
|
164
|
+
leResult = result;
|
|
191
165
|
|
|
192
166
|
// Calculate the results with cating to 16
|
|
193
167
|
check16.res16_16 = MpcCore.le(castingValues.a16_s, castingValues.b16_s);
|
|
@@ -217,26 +191,14 @@ contract Comparison1TestsContract {
|
|
|
217
191
|
require(result == res64, "leTest: cast 64 failed");
|
|
218
192
|
|
|
219
193
|
// Check the result with scalar
|
|
220
|
-
require(
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
"leTest: test
|
|
224
|
-
)
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
"leTest: test 16 bits with scalar failed"
|
|
229
|
-
);
|
|
230
|
-
require(
|
|
231
|
-
result == MpcCore.decrypt(MpcCore.le(a, castingValues.b32_s)) &&
|
|
232
|
-
result == MpcCore.decrypt(MpcCore.le(castingValues.a32_s, b)),
|
|
233
|
-
"leTest: test 32 bits with scalar failed"
|
|
234
|
-
);
|
|
235
|
-
require(
|
|
236
|
-
result == MpcCore.decrypt(MpcCore.le(a, castingValues.b64_s)) &&
|
|
237
|
-
result == MpcCore.decrypt(MpcCore.le(castingValues.a64_s, b)),
|
|
238
|
-
"leTest: test 64 bits with scalar failed"
|
|
239
|
-
);
|
|
194
|
+
require(result == MpcCore.decrypt(MpcCore.le(a, castingValues.b8_s)) && result == MpcCore.decrypt(MpcCore.le(castingValues.a8_s, b)),
|
|
195
|
+
"leTest: test 8 bits with scalar failed");
|
|
196
|
+
require(result == MpcCore.decrypt(MpcCore.le(a, castingValues.b16_s)) && result == MpcCore.decrypt(MpcCore.le(castingValues.a16_s, b)),
|
|
197
|
+
"leTest: test 16 bits with scalar failed");
|
|
198
|
+
require(result == MpcCore.decrypt(MpcCore.le(a, castingValues.b32_s)) && result == MpcCore.decrypt(MpcCore.le(castingValues.a32_s, b)),
|
|
199
|
+
"leTest: test 32 bits with scalar failed");
|
|
200
|
+
require(result == MpcCore.decrypt(MpcCore.le(a, castingValues.b64_s)) && result == MpcCore.decrypt(MpcCore.le(castingValues.a64_s, b)),
|
|
201
|
+
"leTest: test 64 bits with scalar failed");
|
|
240
202
|
|
|
241
203
|
return result;
|
|
242
204
|
}
|
|
@@ -249,9 +211,8 @@ contract Comparison1TestsContract {
|
|
|
249
211
|
setPublicValues(castingValues, a, b);
|
|
250
212
|
|
|
251
213
|
// Calculate the expected result
|
|
252
|
-
result =
|
|
253
|
-
|
|
254
|
-
);
|
|
214
|
+
bool result = MpcCore.decrypt(MpcCore.lt(castingValues.a8_s, castingValues.b8_s));
|
|
215
|
+
ltResult = result;
|
|
255
216
|
|
|
256
217
|
// Calculate the results with cating to 16
|
|
257
218
|
check16.res16_16 = MpcCore.lt(castingValues.a16_s, castingValues.b16_s);
|
|
@@ -281,27 +242,18 @@ contract Comparison1TestsContract {
|
|
|
281
242
|
require(result == res64, "letTest: cast 64 failed");
|
|
282
243
|
|
|
283
244
|
// Check the result with scalar
|
|
284
|
-
require(
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
"letTest: test
|
|
288
|
-
)
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
"letTest: test 16 bits with scalar failed"
|
|
293
|
-
);
|
|
294
|
-
require(
|
|
295
|
-
result == MpcCore.decrypt(MpcCore.lt(a, castingValues.b32_s)) &&
|
|
296
|
-
result == MpcCore.decrypt(MpcCore.lt(castingValues.a32_s, b)),
|
|
297
|
-
"letTest: test 32 bits with scalar failed"
|
|
298
|
-
);
|
|
299
|
-
require(
|
|
300
|
-
result == MpcCore.decrypt(MpcCore.lt(a, castingValues.b64_s)) &&
|
|
301
|
-
result == MpcCore.decrypt(MpcCore.lt(castingValues.a64_s, b)),
|
|
302
|
-
"letTest: test 64 bits with scalar failed"
|
|
303
|
-
);
|
|
245
|
+
require(result == MpcCore.decrypt(MpcCore.lt(a, castingValues.b8_s)) && result == MpcCore.decrypt(MpcCore.lt(castingValues.a8_s, b)),
|
|
246
|
+
"letTest: test 8 bits with scalar failed");
|
|
247
|
+
require(result == MpcCore.decrypt(MpcCore.lt(a, castingValues.b16_s)) && result == MpcCore.decrypt(MpcCore.lt(castingValues.a16_s, b)),
|
|
248
|
+
"letTest: test 16 bits with scalar failed");
|
|
249
|
+
require(result == MpcCore.decrypt(MpcCore.lt(a, castingValues.b32_s)) && result == MpcCore.decrypt(MpcCore.lt(castingValues.a32_s, b)),
|
|
250
|
+
"letTest: test 32 bits with scalar failed");
|
|
251
|
+
require(result == MpcCore.decrypt(MpcCore.lt(a, castingValues.b64_s)) && result == MpcCore.decrypt(MpcCore.lt(castingValues.a64_s, b)),
|
|
252
|
+
"letTest: test 64 bits with scalar failed");
|
|
304
253
|
|
|
305
254
|
return result;
|
|
306
255
|
}
|
|
307
|
-
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
}
|