@inco/lightning 0.8.0-devnet-28 → 0.8.0-devnet-30
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/manifest.yaml +17 -0
- package/package.json +1 -1
- package/src/DeployUtils.sol +22 -28
- package/src/Lib.alphanet.sol +28 -2
- package/src/Lib.demonet.sol +28 -2
- package/src/Lib.devnet.sol +28 -2
- package/src/Lib.sol +28 -2
- package/src/Lib.template.sol +46 -2
- package/src/Lib.testnet.sol +28 -2
- package/src/Types.sol +3 -0
- package/src/libs/incoLightning_alphanet_v0_297966649.sol +28 -2
- package/src/libs/incoLightning_alphanet_v1_725458969.sol +28 -2
- package/src/libs/incoLightning_alphanet_v2_976644394.sol +28 -2
- package/src/libs/incoLightning_demonet_v0_863421733.sol +28 -2
- package/src/libs/incoLightning_demonet_v2_467437523.sol +28 -2
- package/src/libs/incoLightning_devnet_v0_340846814.sol +28 -2
- package/src/libs/incoLightning_devnet_v1_904635675.sol +28 -2
- package/src/libs/incoLightning_devnet_v2_295237520.sol +28 -2
- package/src/libs/incoLightning_devnet_v3_976859633.sol +28 -2
- package/src/libs/incoLightning_devnet_v4_409204766.sol +28 -2
- package/src/libs/incoLightning_devnet_v5_203964628.sol +28 -2
- package/src/libs/incoLightning_devnet_v6_281949651.sol +28 -2
- package/src/libs/incoLightning_devnet_v7_24560427.sol +28 -2
- package/src/libs/incoLightning_devnet_v8_985328058.sol +28 -2
- package/src/libs/incoLightning_devnet_v9_269218568.sol +28 -2
- package/src/libs/incoLightning_testnet_v0_183408998.sol +28 -2
- package/src/libs/incoLightning_testnet_v2_889158349.sol +28 -2
- package/src/lightning-parts/AccessControl/interfaces/IBaseAccessControlList.sol +1 -0
- package/src/lightning-parts/EList.sol +1 -1
- package/src/lightning-parts/EncryptedInput.sol +18 -3
- package/src/lightning-parts/EncryptedOperations.sol +0 -14
- package/src/lightning-parts/interfaces/IEncryptedOperations.sol +0 -1
- package/src/lightning-parts/test/HandleMetadata.t.sol +0 -7
- package/src/test/EListTester.sol +4 -0
- package/src/test/FakeIncoInfra/MockOpHandler.sol +7 -9
- package/src/test/FakeIncoInfra/getOpForSelector.sol +0 -2
- package/src/test/IncoTest.sol +17 -5
- package/src/test/OpsTest.sol +3 -2
- package/src/test/TestLib.t.sol +142 -1
- package/src/test/TestUpgrade.t.sol +24 -47
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
pragma solidity ^0.8;
|
|
7
7
|
|
|
8
8
|
import { IncoLightning } from "../IncoLightning.sol";
|
|
9
|
-
import { ebool, euint256, eaddress, ETypes, elist, IndexOutOfRange, InvalidRange, SliceOutOfRange, UnsupportedListType } from "../Types.sol";
|
|
9
|
+
import { ebool, euint256, eaddress, ETypes, elist, IndexOutOfRange, InvalidRange, SliceOutOfRange, UnsupportedListType, HandleMismatch, InvalidTEEAttestation, UnexpectedDecryptedValue } from "../Types.sol";
|
|
10
|
+
import { asBool } from "../shared/TypeUtils.sol";
|
|
10
11
|
import { DecryptionAttestation, ElementAttestationWithProof } from "../lightning-parts/DecryptionAttester.types.sol";
|
|
11
12
|
|
|
12
13
|
IncoLightning constant inco = IncoLightning(payable(0x28676Cd3b10b03b2FDF105Ba280425b45a674F2A));
|
|
@@ -687,7 +688,8 @@ library e {
|
|
|
687
688
|
/// @dev costs the inco fee
|
|
688
689
|
/// @return The encrypted random value
|
|
689
690
|
function rand() internal returns (euint256) {
|
|
690
|
-
bytes32
|
|
691
|
+
bytes32 boundHandle = euint256.unwrap(asEuint256(0));
|
|
692
|
+
bytes32 result = _callWithFeeRetry(abi.encodeWithSelector(inco.eRandBounded.selector, boundHandle, ETypes.Uint256));
|
|
691
693
|
return euint256.wrap(result);
|
|
692
694
|
}
|
|
693
695
|
|
|
@@ -1194,4 +1196,28 @@ library e {
|
|
|
1194
1196
|
function verifyEListDecryption(elist elistHandle, ElementAttestationWithProof[] memory proofElements, bytes32 proof, bytes[] memory signatures) internal view returns (bool) {
|
|
1195
1197
|
return inco.incoVerifier().isValidEListDecryptionAttestation(elist.unwrap(elistHandle), proofElements, proof, signatures);
|
|
1196
1198
|
}
|
|
1199
|
+
|
|
1200
|
+
/// @notice Checks a decryption attestation for an encrypted bool against an expected plaintext value
|
|
1201
|
+
/// @param handle The encrypted handle
|
|
1202
|
+
/// @param expected The expected plaintext value
|
|
1203
|
+
/// @param decryption The decryption attestation to verify
|
|
1204
|
+
/// @param signatures The covalidator signatures for the attestation
|
|
1205
|
+
/// @dev Reverts if the handle doesn't match, the decrypted value doesn't match the expected value, or the attestation is invalid
|
|
1206
|
+
function requireEqual(ebool handle, bool expected, DecryptionAttestation memory decryption, bytes[] memory signatures) internal view {
|
|
1207
|
+
require(ebool.unwrap(handle) == decryption.handle, HandleMismatch());
|
|
1208
|
+
require(asBool(decryption.value) == expected, UnexpectedDecryptedValue());
|
|
1209
|
+
require(inco.incoVerifier().isValidDecryptionAttestation(decryption, signatures), InvalidTEEAttestation());
|
|
1210
|
+
}
|
|
1211
|
+
|
|
1212
|
+
/// @notice Checks a decryption attestation for an encrypted uint256 against an expected plaintext value
|
|
1213
|
+
/// @param handle The encrypted handle
|
|
1214
|
+
/// @param expected The expected plaintext value
|
|
1215
|
+
/// @param decryption The decryption attestation to verify
|
|
1216
|
+
/// @param signatures The covalidator signatures for the attestation
|
|
1217
|
+
/// @dev Reverts if the handle doesn't match, the decrypted value doesn't match the expected value, or the attestation is invalid
|
|
1218
|
+
function requireEqual(euint256 handle, uint256 expected, DecryptionAttestation memory decryption, bytes[] memory signatures) internal view {
|
|
1219
|
+
require(euint256.unwrap(handle) == decryption.handle, HandleMismatch());
|
|
1220
|
+
require(uint256(decryption.value) == expected, UnexpectedDecryptedValue());
|
|
1221
|
+
require(inco.incoVerifier().isValidDecryptionAttestation(decryption, signatures), InvalidTEEAttestation());
|
|
1222
|
+
}
|
|
1197
1223
|
}
|
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
pragma solidity ^0.8;
|
|
7
7
|
|
|
8
8
|
import { IncoLightning } from "../IncoLightning.sol";
|
|
9
|
-
import { ebool, euint256, eaddress, ETypes, elist, IndexOutOfRange, InvalidRange, SliceOutOfRange, UnsupportedListType } from "../Types.sol";
|
|
9
|
+
import { ebool, euint256, eaddress, ETypes, elist, IndexOutOfRange, InvalidRange, SliceOutOfRange, UnsupportedListType, HandleMismatch, InvalidTEEAttestation, UnexpectedDecryptedValue } from "../Types.sol";
|
|
10
|
+
import { asBool } from "../shared/TypeUtils.sol";
|
|
10
11
|
import { DecryptionAttestation, ElementAttestationWithProof } from "../lightning-parts/DecryptionAttester.types.sol";
|
|
11
12
|
|
|
12
13
|
IncoLightning constant inco = IncoLightning(payable(0xc0d693DeEF0A91CE39208676b6da09B822abd199));
|
|
@@ -687,7 +688,8 @@ library e {
|
|
|
687
688
|
/// @dev costs the inco fee
|
|
688
689
|
/// @return The encrypted random value
|
|
689
690
|
function rand() internal returns (euint256) {
|
|
690
|
-
bytes32
|
|
691
|
+
bytes32 boundHandle = euint256.unwrap(asEuint256(0));
|
|
692
|
+
bytes32 result = _callWithFeeRetry(abi.encodeWithSelector(inco.eRandBounded.selector, boundHandle, ETypes.Uint256));
|
|
691
693
|
return euint256.wrap(result);
|
|
692
694
|
}
|
|
693
695
|
|
|
@@ -1194,4 +1196,28 @@ library e {
|
|
|
1194
1196
|
function verifyEListDecryption(elist elistHandle, ElementAttestationWithProof[] memory proofElements, bytes32 proof, bytes[] memory signatures) internal view returns (bool) {
|
|
1195
1197
|
return inco.incoVerifier().isValidEListDecryptionAttestation(elist.unwrap(elistHandle), proofElements, proof, signatures);
|
|
1196
1198
|
}
|
|
1199
|
+
|
|
1200
|
+
/// @notice Checks a decryption attestation for an encrypted bool against an expected plaintext value
|
|
1201
|
+
/// @param handle The encrypted handle
|
|
1202
|
+
/// @param expected The expected plaintext value
|
|
1203
|
+
/// @param decryption The decryption attestation to verify
|
|
1204
|
+
/// @param signatures The covalidator signatures for the attestation
|
|
1205
|
+
/// @dev Reverts if the handle doesn't match, the decrypted value doesn't match the expected value, or the attestation is invalid
|
|
1206
|
+
function requireEqual(ebool handle, bool expected, DecryptionAttestation memory decryption, bytes[] memory signatures) internal view {
|
|
1207
|
+
require(ebool.unwrap(handle) == decryption.handle, HandleMismatch());
|
|
1208
|
+
require(asBool(decryption.value) == expected, UnexpectedDecryptedValue());
|
|
1209
|
+
require(inco.incoVerifier().isValidDecryptionAttestation(decryption, signatures), InvalidTEEAttestation());
|
|
1210
|
+
}
|
|
1211
|
+
|
|
1212
|
+
/// @notice Checks a decryption attestation for an encrypted uint256 against an expected plaintext value
|
|
1213
|
+
/// @param handle The encrypted handle
|
|
1214
|
+
/// @param expected The expected plaintext value
|
|
1215
|
+
/// @param decryption The decryption attestation to verify
|
|
1216
|
+
/// @param signatures The covalidator signatures for the attestation
|
|
1217
|
+
/// @dev Reverts if the handle doesn't match, the decrypted value doesn't match the expected value, or the attestation is invalid
|
|
1218
|
+
function requireEqual(euint256 handle, uint256 expected, DecryptionAttestation memory decryption, bytes[] memory signatures) internal view {
|
|
1219
|
+
require(euint256.unwrap(handle) == decryption.handle, HandleMismatch());
|
|
1220
|
+
require(uint256(decryption.value) == expected, UnexpectedDecryptedValue());
|
|
1221
|
+
require(inco.incoVerifier().isValidDecryptionAttestation(decryption, signatures), InvalidTEEAttestation());
|
|
1222
|
+
}
|
|
1197
1223
|
}
|
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
pragma solidity ^0.8;
|
|
7
7
|
|
|
8
8
|
import { IncoLightning } from "../IncoLightning.sol";
|
|
9
|
-
import { ebool, euint256, eaddress, ETypes, elist, IndexOutOfRange, InvalidRange, SliceOutOfRange, UnsupportedListType } from "../Types.sol";
|
|
9
|
+
import { ebool, euint256, eaddress, ETypes, elist, IndexOutOfRange, InvalidRange, SliceOutOfRange, UnsupportedListType, HandleMismatch, InvalidTEEAttestation, UnexpectedDecryptedValue } from "../Types.sol";
|
|
10
|
+
import { asBool } from "../shared/TypeUtils.sol";
|
|
10
11
|
import { DecryptionAttestation, ElementAttestationWithProof } from "../lightning-parts/DecryptionAttester.types.sol";
|
|
11
12
|
|
|
12
13
|
IncoLightning constant inco = IncoLightning(payable(0xeBAFF6D578733E4603b99CBdbb221482F29a78E1));
|
|
@@ -687,7 +688,8 @@ library e {
|
|
|
687
688
|
/// @dev costs the inco fee
|
|
688
689
|
/// @return The encrypted random value
|
|
689
690
|
function rand() internal returns (euint256) {
|
|
690
|
-
bytes32
|
|
691
|
+
bytes32 boundHandle = euint256.unwrap(asEuint256(0));
|
|
692
|
+
bytes32 result = _callWithFeeRetry(abi.encodeWithSelector(inco.eRandBounded.selector, boundHandle, ETypes.Uint256));
|
|
691
693
|
return euint256.wrap(result);
|
|
692
694
|
}
|
|
693
695
|
|
|
@@ -1194,4 +1196,28 @@ library e {
|
|
|
1194
1196
|
function verifyEListDecryption(elist elistHandle, ElementAttestationWithProof[] memory proofElements, bytes32 proof, bytes[] memory signatures) internal view returns (bool) {
|
|
1195
1197
|
return inco.incoVerifier().isValidEListDecryptionAttestation(elist.unwrap(elistHandle), proofElements, proof, signatures);
|
|
1196
1198
|
}
|
|
1199
|
+
|
|
1200
|
+
/// @notice Checks a decryption attestation for an encrypted bool against an expected plaintext value
|
|
1201
|
+
/// @param handle The encrypted handle
|
|
1202
|
+
/// @param expected The expected plaintext value
|
|
1203
|
+
/// @param decryption The decryption attestation to verify
|
|
1204
|
+
/// @param signatures The covalidator signatures for the attestation
|
|
1205
|
+
/// @dev Reverts if the handle doesn't match, the decrypted value doesn't match the expected value, or the attestation is invalid
|
|
1206
|
+
function requireEqual(ebool handle, bool expected, DecryptionAttestation memory decryption, bytes[] memory signatures) internal view {
|
|
1207
|
+
require(ebool.unwrap(handle) == decryption.handle, HandleMismatch());
|
|
1208
|
+
require(asBool(decryption.value) == expected, UnexpectedDecryptedValue());
|
|
1209
|
+
require(inco.incoVerifier().isValidDecryptionAttestation(decryption, signatures), InvalidTEEAttestation());
|
|
1210
|
+
}
|
|
1211
|
+
|
|
1212
|
+
/// @notice Checks a decryption attestation for an encrypted uint256 against an expected plaintext value
|
|
1213
|
+
/// @param handle The encrypted handle
|
|
1214
|
+
/// @param expected The expected plaintext value
|
|
1215
|
+
/// @param decryption The decryption attestation to verify
|
|
1216
|
+
/// @param signatures The covalidator signatures for the attestation
|
|
1217
|
+
/// @dev Reverts if the handle doesn't match, the decrypted value doesn't match the expected value, or the attestation is invalid
|
|
1218
|
+
function requireEqual(euint256 handle, uint256 expected, DecryptionAttestation memory decryption, bytes[] memory signatures) internal view {
|
|
1219
|
+
require(euint256.unwrap(handle) == decryption.handle, HandleMismatch());
|
|
1220
|
+
require(uint256(decryption.value) == expected, UnexpectedDecryptedValue());
|
|
1221
|
+
require(inco.incoVerifier().isValidDecryptionAttestation(decryption, signatures), InvalidTEEAttestation());
|
|
1222
|
+
}
|
|
1197
1223
|
}
|
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
pragma solidity ^0.8;
|
|
7
7
|
|
|
8
8
|
import { IncoLightning } from "../IncoLightning.sol";
|
|
9
|
-
import { ebool, euint256, eaddress, ETypes, elist, IndexOutOfRange, InvalidRange, SliceOutOfRange, UnsupportedListType } from "../Types.sol";
|
|
9
|
+
import { ebool, euint256, eaddress, ETypes, elist, IndexOutOfRange, InvalidRange, SliceOutOfRange, UnsupportedListType, HandleMismatch, InvalidTEEAttestation, UnexpectedDecryptedValue } from "../Types.sol";
|
|
10
|
+
import { asBool } from "../shared/TypeUtils.sol";
|
|
10
11
|
import { DecryptionAttestation, ElementAttestationWithProof } from "../lightning-parts/DecryptionAttester.types.sol";
|
|
11
12
|
|
|
12
13
|
IncoLightning constant inco = IncoLightning(payable(0xA95EAbCE575f5f1e52605358Ee893F6536166378));
|
|
@@ -687,7 +688,8 @@ library e {
|
|
|
687
688
|
/// @dev costs the inco fee
|
|
688
689
|
/// @return The encrypted random value
|
|
689
690
|
function rand() internal returns (euint256) {
|
|
690
|
-
bytes32
|
|
691
|
+
bytes32 boundHandle = euint256.unwrap(asEuint256(0));
|
|
692
|
+
bytes32 result = _callWithFeeRetry(abi.encodeWithSelector(inco.eRandBounded.selector, boundHandle, ETypes.Uint256));
|
|
691
693
|
return euint256.wrap(result);
|
|
692
694
|
}
|
|
693
695
|
|
|
@@ -1194,4 +1196,28 @@ library e {
|
|
|
1194
1196
|
function verifyEListDecryption(elist elistHandle, ElementAttestationWithProof[] memory proofElements, bytes32 proof, bytes[] memory signatures) internal view returns (bool) {
|
|
1195
1197
|
return inco.incoVerifier().isValidEListDecryptionAttestation(elist.unwrap(elistHandle), proofElements, proof, signatures);
|
|
1196
1198
|
}
|
|
1199
|
+
|
|
1200
|
+
/// @notice Checks a decryption attestation for an encrypted bool against an expected plaintext value
|
|
1201
|
+
/// @param handle The encrypted handle
|
|
1202
|
+
/// @param expected The expected plaintext value
|
|
1203
|
+
/// @param decryption The decryption attestation to verify
|
|
1204
|
+
/// @param signatures The covalidator signatures for the attestation
|
|
1205
|
+
/// @dev Reverts if the handle doesn't match, the decrypted value doesn't match the expected value, or the attestation is invalid
|
|
1206
|
+
function requireEqual(ebool handle, bool expected, DecryptionAttestation memory decryption, bytes[] memory signatures) internal view {
|
|
1207
|
+
require(ebool.unwrap(handle) == decryption.handle, HandleMismatch());
|
|
1208
|
+
require(asBool(decryption.value) == expected, UnexpectedDecryptedValue());
|
|
1209
|
+
require(inco.incoVerifier().isValidDecryptionAttestation(decryption, signatures), InvalidTEEAttestation());
|
|
1210
|
+
}
|
|
1211
|
+
|
|
1212
|
+
/// @notice Checks a decryption attestation for an encrypted uint256 against an expected plaintext value
|
|
1213
|
+
/// @param handle The encrypted handle
|
|
1214
|
+
/// @param expected The expected plaintext value
|
|
1215
|
+
/// @param decryption The decryption attestation to verify
|
|
1216
|
+
/// @param signatures The covalidator signatures for the attestation
|
|
1217
|
+
/// @dev Reverts if the handle doesn't match, the decrypted value doesn't match the expected value, or the attestation is invalid
|
|
1218
|
+
function requireEqual(euint256 handle, uint256 expected, DecryptionAttestation memory decryption, bytes[] memory signatures) internal view {
|
|
1219
|
+
require(euint256.unwrap(handle) == decryption.handle, HandleMismatch());
|
|
1220
|
+
require(uint256(decryption.value) == expected, UnexpectedDecryptedValue());
|
|
1221
|
+
require(inco.incoVerifier().isValidDecryptionAttestation(decryption, signatures), InvalidTEEAttestation());
|
|
1222
|
+
}
|
|
1197
1223
|
}
|
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
pragma solidity ^0.8;
|
|
7
7
|
|
|
8
8
|
import { IncoLightning } from "../IncoLightning.sol";
|
|
9
|
-
import { ebool, euint256, eaddress, ETypes, elist, IndexOutOfRange, InvalidRange, SliceOutOfRange, UnsupportedListType } from "../Types.sol";
|
|
9
|
+
import { ebool, euint256, eaddress, ETypes, elist, IndexOutOfRange, InvalidRange, SliceOutOfRange, UnsupportedListType, HandleMismatch, InvalidTEEAttestation, UnexpectedDecryptedValue } from "../Types.sol";
|
|
10
|
+
import { asBool } from "../shared/TypeUtils.sol";
|
|
10
11
|
import { DecryptionAttestation, ElementAttestationWithProof } from "../lightning-parts/DecryptionAttester.types.sol";
|
|
11
12
|
|
|
12
13
|
IncoLightning constant inco = IncoLightning(payable(0x3B22be60Ae699933959CA3cE147C96caa88Ccd3D));
|
|
@@ -687,7 +688,8 @@ library e {
|
|
|
687
688
|
/// @dev costs the inco fee
|
|
688
689
|
/// @return The encrypted random value
|
|
689
690
|
function rand() internal returns (euint256) {
|
|
690
|
-
bytes32
|
|
691
|
+
bytes32 boundHandle = euint256.unwrap(asEuint256(0));
|
|
692
|
+
bytes32 result = _callWithFeeRetry(abi.encodeWithSelector(inco.eRandBounded.selector, boundHandle, ETypes.Uint256));
|
|
691
693
|
return euint256.wrap(result);
|
|
692
694
|
}
|
|
693
695
|
|
|
@@ -1194,4 +1196,28 @@ library e {
|
|
|
1194
1196
|
function verifyEListDecryption(elist elistHandle, ElementAttestationWithProof[] memory proofElements, bytes32 proof, bytes[] memory signatures) internal view returns (bool) {
|
|
1195
1197
|
return inco.incoVerifier().isValidEListDecryptionAttestation(elist.unwrap(elistHandle), proofElements, proof, signatures);
|
|
1196
1198
|
}
|
|
1199
|
+
|
|
1200
|
+
/// @notice Checks a decryption attestation for an encrypted bool against an expected plaintext value
|
|
1201
|
+
/// @param handle The encrypted handle
|
|
1202
|
+
/// @param expected The expected plaintext value
|
|
1203
|
+
/// @param decryption The decryption attestation to verify
|
|
1204
|
+
/// @param signatures The covalidator signatures for the attestation
|
|
1205
|
+
/// @dev Reverts if the handle doesn't match, the decrypted value doesn't match the expected value, or the attestation is invalid
|
|
1206
|
+
function requireEqual(ebool handle, bool expected, DecryptionAttestation memory decryption, bytes[] memory signatures) internal view {
|
|
1207
|
+
require(ebool.unwrap(handle) == decryption.handle, HandleMismatch());
|
|
1208
|
+
require(asBool(decryption.value) == expected, UnexpectedDecryptedValue());
|
|
1209
|
+
require(inco.incoVerifier().isValidDecryptionAttestation(decryption, signatures), InvalidTEEAttestation());
|
|
1210
|
+
}
|
|
1211
|
+
|
|
1212
|
+
/// @notice Checks a decryption attestation for an encrypted uint256 against an expected plaintext value
|
|
1213
|
+
/// @param handle The encrypted handle
|
|
1214
|
+
/// @param expected The expected plaintext value
|
|
1215
|
+
/// @param decryption The decryption attestation to verify
|
|
1216
|
+
/// @param signatures The covalidator signatures for the attestation
|
|
1217
|
+
/// @dev Reverts if the handle doesn't match, the decrypted value doesn't match the expected value, or the attestation is invalid
|
|
1218
|
+
function requireEqual(euint256 handle, uint256 expected, DecryptionAttestation memory decryption, bytes[] memory signatures) internal view {
|
|
1219
|
+
require(euint256.unwrap(handle) == decryption.handle, HandleMismatch());
|
|
1220
|
+
require(uint256(decryption.value) == expected, UnexpectedDecryptedValue());
|
|
1221
|
+
require(inco.incoVerifier().isValidDecryptionAttestation(decryption, signatures), InvalidTEEAttestation());
|
|
1222
|
+
}
|
|
1197
1223
|
}
|
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
pragma solidity ^0.8;
|
|
7
7
|
|
|
8
8
|
import { IncoLightning } from "../IncoLightning.sol";
|
|
9
|
-
import { ebool, euint256, eaddress, ETypes, elist, IndexOutOfRange, InvalidRange, SliceOutOfRange, UnsupportedListType } from "../Types.sol";
|
|
9
|
+
import { ebool, euint256, eaddress, ETypes, elist, IndexOutOfRange, InvalidRange, SliceOutOfRange, UnsupportedListType, HandleMismatch, InvalidTEEAttestation, UnexpectedDecryptedValue } from "../Types.sol";
|
|
10
|
+
import { asBool } from "../shared/TypeUtils.sol";
|
|
10
11
|
import { DecryptionAttestation, ElementAttestationWithProof } from "../lightning-parts/DecryptionAttester.types.sol";
|
|
11
12
|
|
|
12
13
|
IncoLightning constant inco = IncoLightning(payable(0x3473820DcAa71Af8157b93C7f2bf1c676A2A39A6));
|
|
@@ -687,7 +688,8 @@ library e {
|
|
|
687
688
|
/// @dev costs the inco fee
|
|
688
689
|
/// @return The encrypted random value
|
|
689
690
|
function rand() internal returns (euint256) {
|
|
690
|
-
bytes32
|
|
691
|
+
bytes32 boundHandle = euint256.unwrap(asEuint256(0));
|
|
692
|
+
bytes32 result = _callWithFeeRetry(abi.encodeWithSelector(inco.eRandBounded.selector, boundHandle, ETypes.Uint256));
|
|
691
693
|
return euint256.wrap(result);
|
|
692
694
|
}
|
|
693
695
|
|
|
@@ -1194,4 +1196,28 @@ library e {
|
|
|
1194
1196
|
function verifyEListDecryption(elist elistHandle, ElementAttestationWithProof[] memory proofElements, bytes32 proof, bytes[] memory signatures) internal view returns (bool) {
|
|
1195
1197
|
return inco.incoVerifier().isValidEListDecryptionAttestation(elist.unwrap(elistHandle), proofElements, proof, signatures);
|
|
1196
1198
|
}
|
|
1199
|
+
|
|
1200
|
+
/// @notice Checks a decryption attestation for an encrypted bool against an expected plaintext value
|
|
1201
|
+
/// @param handle The encrypted handle
|
|
1202
|
+
/// @param expected The expected plaintext value
|
|
1203
|
+
/// @param decryption The decryption attestation to verify
|
|
1204
|
+
/// @param signatures The covalidator signatures for the attestation
|
|
1205
|
+
/// @dev Reverts if the handle doesn't match, the decrypted value doesn't match the expected value, or the attestation is invalid
|
|
1206
|
+
function requireEqual(ebool handle, bool expected, DecryptionAttestation memory decryption, bytes[] memory signatures) internal view {
|
|
1207
|
+
require(ebool.unwrap(handle) == decryption.handle, HandleMismatch());
|
|
1208
|
+
require(asBool(decryption.value) == expected, UnexpectedDecryptedValue());
|
|
1209
|
+
require(inco.incoVerifier().isValidDecryptionAttestation(decryption, signatures), InvalidTEEAttestation());
|
|
1210
|
+
}
|
|
1211
|
+
|
|
1212
|
+
/// @notice Checks a decryption attestation for an encrypted uint256 against an expected plaintext value
|
|
1213
|
+
/// @param handle The encrypted handle
|
|
1214
|
+
/// @param expected The expected plaintext value
|
|
1215
|
+
/// @param decryption The decryption attestation to verify
|
|
1216
|
+
/// @param signatures The covalidator signatures for the attestation
|
|
1217
|
+
/// @dev Reverts if the handle doesn't match, the decrypted value doesn't match the expected value, or the attestation is invalid
|
|
1218
|
+
function requireEqual(euint256 handle, uint256 expected, DecryptionAttestation memory decryption, bytes[] memory signatures) internal view {
|
|
1219
|
+
require(euint256.unwrap(handle) == decryption.handle, HandleMismatch());
|
|
1220
|
+
require(uint256(decryption.value) == expected, UnexpectedDecryptedValue());
|
|
1221
|
+
require(inco.incoVerifier().isValidDecryptionAttestation(decryption, signatures), InvalidTEEAttestation());
|
|
1222
|
+
}
|
|
1197
1223
|
}
|
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
pragma solidity ^0.8;
|
|
7
7
|
|
|
8
8
|
import { IncoLightning } from "../IncoLightning.sol";
|
|
9
|
-
import { ebool, euint256, eaddress, ETypes, elist, IndexOutOfRange, InvalidRange, SliceOutOfRange, UnsupportedListType } from "../Types.sol";
|
|
9
|
+
import { ebool, euint256, eaddress, ETypes, elist, IndexOutOfRange, InvalidRange, SliceOutOfRange, UnsupportedListType, HandleMismatch, InvalidTEEAttestation, UnexpectedDecryptedValue } from "../Types.sol";
|
|
10
|
+
import { asBool } from "../shared/TypeUtils.sol";
|
|
10
11
|
import { DecryptionAttestation, ElementAttestationWithProof } from "../lightning-parts/DecryptionAttester.types.sol";
|
|
11
12
|
|
|
12
13
|
IncoLightning constant inco = IncoLightning(payable(0xC64BB070D6F5aa796e79fA19c1008647ffF736ED));
|
|
@@ -687,7 +688,8 @@ library e {
|
|
|
687
688
|
/// @dev costs the inco fee
|
|
688
689
|
/// @return The encrypted random value
|
|
689
690
|
function rand() internal returns (euint256) {
|
|
690
|
-
bytes32
|
|
691
|
+
bytes32 boundHandle = euint256.unwrap(asEuint256(0));
|
|
692
|
+
bytes32 result = _callWithFeeRetry(abi.encodeWithSelector(inco.eRandBounded.selector, boundHandle, ETypes.Uint256));
|
|
691
693
|
return euint256.wrap(result);
|
|
692
694
|
}
|
|
693
695
|
|
|
@@ -1194,4 +1196,28 @@ library e {
|
|
|
1194
1196
|
function verifyEListDecryption(elist elistHandle, ElementAttestationWithProof[] memory proofElements, bytes32 proof, bytes[] memory signatures) internal view returns (bool) {
|
|
1195
1197
|
return inco.incoVerifier().isValidEListDecryptionAttestation(elist.unwrap(elistHandle), proofElements, proof, signatures);
|
|
1196
1198
|
}
|
|
1199
|
+
|
|
1200
|
+
/// @notice Checks a decryption attestation for an encrypted bool against an expected plaintext value
|
|
1201
|
+
/// @param handle The encrypted handle
|
|
1202
|
+
/// @param expected The expected plaintext value
|
|
1203
|
+
/// @param decryption The decryption attestation to verify
|
|
1204
|
+
/// @param signatures The covalidator signatures for the attestation
|
|
1205
|
+
/// @dev Reverts if the handle doesn't match, the decrypted value doesn't match the expected value, or the attestation is invalid
|
|
1206
|
+
function requireEqual(ebool handle, bool expected, DecryptionAttestation memory decryption, bytes[] memory signatures) internal view {
|
|
1207
|
+
require(ebool.unwrap(handle) == decryption.handle, HandleMismatch());
|
|
1208
|
+
require(asBool(decryption.value) == expected, UnexpectedDecryptedValue());
|
|
1209
|
+
require(inco.incoVerifier().isValidDecryptionAttestation(decryption, signatures), InvalidTEEAttestation());
|
|
1210
|
+
}
|
|
1211
|
+
|
|
1212
|
+
/// @notice Checks a decryption attestation for an encrypted uint256 against an expected plaintext value
|
|
1213
|
+
/// @param handle The encrypted handle
|
|
1214
|
+
/// @param expected The expected plaintext value
|
|
1215
|
+
/// @param decryption The decryption attestation to verify
|
|
1216
|
+
/// @param signatures The covalidator signatures for the attestation
|
|
1217
|
+
/// @dev Reverts if the handle doesn't match, the decrypted value doesn't match the expected value, or the attestation is invalid
|
|
1218
|
+
function requireEqual(euint256 handle, uint256 expected, DecryptionAttestation memory decryption, bytes[] memory signatures) internal view {
|
|
1219
|
+
require(euint256.unwrap(handle) == decryption.handle, HandleMismatch());
|
|
1220
|
+
require(uint256(decryption.value) == expected, UnexpectedDecryptedValue());
|
|
1221
|
+
require(inco.incoVerifier().isValidDecryptionAttestation(decryption, signatures), InvalidTEEAttestation());
|
|
1222
|
+
}
|
|
1197
1223
|
}
|
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
pragma solidity ^0.8;
|
|
7
7
|
|
|
8
8
|
import { IncoLightning } from "../IncoLightning.sol";
|
|
9
|
-
import { ebool, euint256, eaddress, ETypes, elist, IndexOutOfRange, InvalidRange, SliceOutOfRange, UnsupportedListType } from "../Types.sol";
|
|
9
|
+
import { ebool, euint256, eaddress, ETypes, elist, IndexOutOfRange, InvalidRange, SliceOutOfRange, UnsupportedListType, HandleMismatch, InvalidTEEAttestation, UnexpectedDecryptedValue } from "../Types.sol";
|
|
10
|
+
import { asBool } from "../shared/TypeUtils.sol";
|
|
10
11
|
import { DecryptionAttestation, ElementAttestationWithProof } from "../lightning-parts/DecryptionAttester.types.sol";
|
|
11
12
|
|
|
12
13
|
IncoLightning constant inco = IncoLightning(payable(0x4732520194584a04Cac0224e067658619F4086bD));
|
|
@@ -687,7 +688,8 @@ library e {
|
|
|
687
688
|
/// @dev costs the inco fee
|
|
688
689
|
/// @return The encrypted random value
|
|
689
690
|
function rand() internal returns (euint256) {
|
|
690
|
-
bytes32
|
|
691
|
+
bytes32 boundHandle = euint256.unwrap(asEuint256(0));
|
|
692
|
+
bytes32 result = _callWithFeeRetry(abi.encodeWithSelector(inco.eRandBounded.selector, boundHandle, ETypes.Uint256));
|
|
691
693
|
return euint256.wrap(result);
|
|
692
694
|
}
|
|
693
695
|
|
|
@@ -1194,4 +1196,28 @@ library e {
|
|
|
1194
1196
|
function verifyEListDecryption(elist elistHandle, ElementAttestationWithProof[] memory proofElements, bytes32 proof, bytes[] memory signatures) internal view returns (bool) {
|
|
1195
1197
|
return inco.incoVerifier().isValidEListDecryptionAttestation(elist.unwrap(elistHandle), proofElements, proof, signatures);
|
|
1196
1198
|
}
|
|
1199
|
+
|
|
1200
|
+
/// @notice Checks a decryption attestation for an encrypted bool against an expected plaintext value
|
|
1201
|
+
/// @param handle The encrypted handle
|
|
1202
|
+
/// @param expected The expected plaintext value
|
|
1203
|
+
/// @param decryption The decryption attestation to verify
|
|
1204
|
+
/// @param signatures The covalidator signatures for the attestation
|
|
1205
|
+
/// @dev Reverts if the handle doesn't match, the decrypted value doesn't match the expected value, or the attestation is invalid
|
|
1206
|
+
function requireEqual(ebool handle, bool expected, DecryptionAttestation memory decryption, bytes[] memory signatures) internal view {
|
|
1207
|
+
require(ebool.unwrap(handle) == decryption.handle, HandleMismatch());
|
|
1208
|
+
require(asBool(decryption.value) == expected, UnexpectedDecryptedValue());
|
|
1209
|
+
require(inco.incoVerifier().isValidDecryptionAttestation(decryption, signatures), InvalidTEEAttestation());
|
|
1210
|
+
}
|
|
1211
|
+
|
|
1212
|
+
/// @notice Checks a decryption attestation for an encrypted uint256 against an expected plaintext value
|
|
1213
|
+
/// @param handle The encrypted handle
|
|
1214
|
+
/// @param expected The expected plaintext value
|
|
1215
|
+
/// @param decryption The decryption attestation to verify
|
|
1216
|
+
/// @param signatures The covalidator signatures for the attestation
|
|
1217
|
+
/// @dev Reverts if the handle doesn't match, the decrypted value doesn't match the expected value, or the attestation is invalid
|
|
1218
|
+
function requireEqual(euint256 handle, uint256 expected, DecryptionAttestation memory decryption, bytes[] memory signatures) internal view {
|
|
1219
|
+
require(euint256.unwrap(handle) == decryption.handle, HandleMismatch());
|
|
1220
|
+
require(uint256(decryption.value) == expected, UnexpectedDecryptedValue());
|
|
1221
|
+
require(inco.incoVerifier().isValidDecryptionAttestation(decryption, signatures), InvalidTEEAttestation());
|
|
1222
|
+
}
|
|
1197
1223
|
}
|
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
pragma solidity ^0.8;
|
|
7
7
|
|
|
8
8
|
import { IncoLightning } from "../IncoLightning.sol";
|
|
9
|
-
import { ebool, euint256, eaddress, ETypes, elist, IndexOutOfRange, InvalidRange, SliceOutOfRange, UnsupportedListType } from "../Types.sol";
|
|
9
|
+
import { ebool, euint256, eaddress, ETypes, elist, IndexOutOfRange, InvalidRange, SliceOutOfRange, UnsupportedListType, HandleMismatch, InvalidTEEAttestation, UnexpectedDecryptedValue } from "../Types.sol";
|
|
10
|
+
import { asBool } from "../shared/TypeUtils.sol";
|
|
10
11
|
import { DecryptionAttestation, ElementAttestationWithProof } from "../lightning-parts/DecryptionAttester.types.sol";
|
|
11
12
|
|
|
12
13
|
IncoLightning constant inco = IncoLightning(payable(0x4046b737B454b0430FBF29cea070e3337AdE95aD));
|
|
@@ -687,7 +688,8 @@ library e {
|
|
|
687
688
|
/// @dev costs the inco fee
|
|
688
689
|
/// @return The encrypted random value
|
|
689
690
|
function rand() internal returns (euint256) {
|
|
690
|
-
bytes32
|
|
691
|
+
bytes32 boundHandle = euint256.unwrap(asEuint256(0));
|
|
692
|
+
bytes32 result = _callWithFeeRetry(abi.encodeWithSelector(inco.eRandBounded.selector, boundHandle, ETypes.Uint256));
|
|
691
693
|
return euint256.wrap(result);
|
|
692
694
|
}
|
|
693
695
|
|
|
@@ -1194,4 +1196,28 @@ library e {
|
|
|
1194
1196
|
function verifyEListDecryption(elist elistHandle, ElementAttestationWithProof[] memory proofElements, bytes32 proof, bytes[] memory signatures) internal view returns (bool) {
|
|
1195
1197
|
return inco.incoVerifier().isValidEListDecryptionAttestation(elist.unwrap(elistHandle), proofElements, proof, signatures);
|
|
1196
1198
|
}
|
|
1199
|
+
|
|
1200
|
+
/// @notice Checks a decryption attestation for an encrypted bool against an expected plaintext value
|
|
1201
|
+
/// @param handle The encrypted handle
|
|
1202
|
+
/// @param expected The expected plaintext value
|
|
1203
|
+
/// @param decryption The decryption attestation to verify
|
|
1204
|
+
/// @param signatures The covalidator signatures for the attestation
|
|
1205
|
+
/// @dev Reverts if the handle doesn't match, the decrypted value doesn't match the expected value, or the attestation is invalid
|
|
1206
|
+
function requireEqual(ebool handle, bool expected, DecryptionAttestation memory decryption, bytes[] memory signatures) internal view {
|
|
1207
|
+
require(ebool.unwrap(handle) == decryption.handle, HandleMismatch());
|
|
1208
|
+
require(asBool(decryption.value) == expected, UnexpectedDecryptedValue());
|
|
1209
|
+
require(inco.incoVerifier().isValidDecryptionAttestation(decryption, signatures), InvalidTEEAttestation());
|
|
1210
|
+
}
|
|
1211
|
+
|
|
1212
|
+
/// @notice Checks a decryption attestation for an encrypted uint256 against an expected plaintext value
|
|
1213
|
+
/// @param handle The encrypted handle
|
|
1214
|
+
/// @param expected The expected plaintext value
|
|
1215
|
+
/// @param decryption The decryption attestation to verify
|
|
1216
|
+
/// @param signatures The covalidator signatures for the attestation
|
|
1217
|
+
/// @dev Reverts if the handle doesn't match, the decrypted value doesn't match the expected value, or the attestation is invalid
|
|
1218
|
+
function requireEqual(euint256 handle, uint256 expected, DecryptionAttestation memory decryption, bytes[] memory signatures) internal view {
|
|
1219
|
+
require(euint256.unwrap(handle) == decryption.handle, HandleMismatch());
|
|
1220
|
+
require(uint256(decryption.value) == expected, UnexpectedDecryptedValue());
|
|
1221
|
+
require(inco.incoVerifier().isValidDecryptionAttestation(decryption, signatures), InvalidTEEAttestation());
|
|
1222
|
+
}
|
|
1197
1223
|
}
|
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
pragma solidity ^0.8;
|
|
7
7
|
|
|
8
8
|
import { IncoLightning } from "../IncoLightning.sol";
|
|
9
|
-
import { ebool, euint256, eaddress, ETypes, elist, IndexOutOfRange, InvalidRange, SliceOutOfRange, UnsupportedListType } from "../Types.sol";
|
|
9
|
+
import { ebool, euint256, eaddress, ETypes, elist, IndexOutOfRange, InvalidRange, SliceOutOfRange, UnsupportedListType, HandleMismatch, InvalidTEEAttestation, UnexpectedDecryptedValue } from "../Types.sol";
|
|
10
|
+
import { asBool } from "../shared/TypeUtils.sol";
|
|
10
11
|
import { DecryptionAttestation, ElementAttestationWithProof } from "../lightning-parts/DecryptionAttester.types.sol";
|
|
11
12
|
|
|
12
13
|
IncoLightning constant inco = IncoLightning(payable(0x8D5D75CC00E2Fc84ec4dE085aE1708223591c6b6));
|
|
@@ -687,7 +688,8 @@ library e {
|
|
|
687
688
|
/// @dev costs the inco fee
|
|
688
689
|
/// @return The encrypted random value
|
|
689
690
|
function rand() internal returns (euint256) {
|
|
690
|
-
bytes32
|
|
691
|
+
bytes32 boundHandle = euint256.unwrap(asEuint256(0));
|
|
692
|
+
bytes32 result = _callWithFeeRetry(abi.encodeWithSelector(inco.eRandBounded.selector, boundHandle, ETypes.Uint256));
|
|
691
693
|
return euint256.wrap(result);
|
|
692
694
|
}
|
|
693
695
|
|
|
@@ -1194,4 +1196,28 @@ library e {
|
|
|
1194
1196
|
function verifyEListDecryption(elist elistHandle, ElementAttestationWithProof[] memory proofElements, bytes32 proof, bytes[] memory signatures) internal view returns (bool) {
|
|
1195
1197
|
return inco.incoVerifier().isValidEListDecryptionAttestation(elist.unwrap(elistHandle), proofElements, proof, signatures);
|
|
1196
1198
|
}
|
|
1199
|
+
|
|
1200
|
+
/// @notice Checks a decryption attestation for an encrypted bool against an expected plaintext value
|
|
1201
|
+
/// @param handle The encrypted handle
|
|
1202
|
+
/// @param expected The expected plaintext value
|
|
1203
|
+
/// @param decryption The decryption attestation to verify
|
|
1204
|
+
/// @param signatures The covalidator signatures for the attestation
|
|
1205
|
+
/// @dev Reverts if the handle doesn't match, the decrypted value doesn't match the expected value, or the attestation is invalid
|
|
1206
|
+
function requireEqual(ebool handle, bool expected, DecryptionAttestation memory decryption, bytes[] memory signatures) internal view {
|
|
1207
|
+
require(ebool.unwrap(handle) == decryption.handle, HandleMismatch());
|
|
1208
|
+
require(asBool(decryption.value) == expected, UnexpectedDecryptedValue());
|
|
1209
|
+
require(inco.incoVerifier().isValidDecryptionAttestation(decryption, signatures), InvalidTEEAttestation());
|
|
1210
|
+
}
|
|
1211
|
+
|
|
1212
|
+
/// @notice Checks a decryption attestation for an encrypted uint256 against an expected plaintext value
|
|
1213
|
+
/// @param handle The encrypted handle
|
|
1214
|
+
/// @param expected The expected plaintext value
|
|
1215
|
+
/// @param decryption The decryption attestation to verify
|
|
1216
|
+
/// @param signatures The covalidator signatures for the attestation
|
|
1217
|
+
/// @dev Reverts if the handle doesn't match, the decrypted value doesn't match the expected value, or the attestation is invalid
|
|
1218
|
+
function requireEqual(euint256 handle, uint256 expected, DecryptionAttestation memory decryption, bytes[] memory signatures) internal view {
|
|
1219
|
+
require(euint256.unwrap(handle) == decryption.handle, HandleMismatch());
|
|
1220
|
+
require(uint256(decryption.value) == expected, UnexpectedDecryptedValue());
|
|
1221
|
+
require(inco.incoVerifier().isValidDecryptionAttestation(decryption, signatures), InvalidTEEAttestation());
|
|
1222
|
+
}
|
|
1197
1223
|
}
|
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
pragma solidity ^0.8;
|
|
7
7
|
|
|
8
8
|
import { IncoLightning } from "../IncoLightning.sol";
|
|
9
|
-
import { ebool, euint256, eaddress, ETypes, elist, IndexOutOfRange, InvalidRange, SliceOutOfRange, UnsupportedListType } from "../Types.sol";
|
|
9
|
+
import { ebool, euint256, eaddress, ETypes, elist, IndexOutOfRange, InvalidRange, SliceOutOfRange, UnsupportedListType, HandleMismatch, InvalidTEEAttestation, UnexpectedDecryptedValue } from "../Types.sol";
|
|
10
|
+
import { asBool } from "../shared/TypeUtils.sol";
|
|
10
11
|
import { DecryptionAttestation, ElementAttestationWithProof } from "../lightning-parts/DecryptionAttester.types.sol";
|
|
11
12
|
|
|
12
13
|
IncoLightning constant inco = IncoLightning(payable(0xDF3830489208461f72Df6E45D0e6cbF9DBB74fe1));
|
|
@@ -687,7 +688,8 @@ library e {
|
|
|
687
688
|
/// @dev costs the inco fee
|
|
688
689
|
/// @return The encrypted random value
|
|
689
690
|
function rand() internal returns (euint256) {
|
|
690
|
-
bytes32
|
|
691
|
+
bytes32 boundHandle = euint256.unwrap(asEuint256(0));
|
|
692
|
+
bytes32 result = _callWithFeeRetry(abi.encodeWithSelector(inco.eRandBounded.selector, boundHandle, ETypes.Uint256));
|
|
691
693
|
return euint256.wrap(result);
|
|
692
694
|
}
|
|
693
695
|
|
|
@@ -1194,4 +1196,28 @@ library e {
|
|
|
1194
1196
|
function verifyEListDecryption(elist elistHandle, ElementAttestationWithProof[] memory proofElements, bytes32 proof, bytes[] memory signatures) internal view returns (bool) {
|
|
1195
1197
|
return inco.incoVerifier().isValidEListDecryptionAttestation(elist.unwrap(elistHandle), proofElements, proof, signatures);
|
|
1196
1198
|
}
|
|
1199
|
+
|
|
1200
|
+
/// @notice Checks a decryption attestation for an encrypted bool against an expected plaintext value
|
|
1201
|
+
/// @param handle The encrypted handle
|
|
1202
|
+
/// @param expected The expected plaintext value
|
|
1203
|
+
/// @param decryption The decryption attestation to verify
|
|
1204
|
+
/// @param signatures The covalidator signatures for the attestation
|
|
1205
|
+
/// @dev Reverts if the handle doesn't match, the decrypted value doesn't match the expected value, or the attestation is invalid
|
|
1206
|
+
function requireEqual(ebool handle, bool expected, DecryptionAttestation memory decryption, bytes[] memory signatures) internal view {
|
|
1207
|
+
require(ebool.unwrap(handle) == decryption.handle, HandleMismatch());
|
|
1208
|
+
require(asBool(decryption.value) == expected, UnexpectedDecryptedValue());
|
|
1209
|
+
require(inco.incoVerifier().isValidDecryptionAttestation(decryption, signatures), InvalidTEEAttestation());
|
|
1210
|
+
}
|
|
1211
|
+
|
|
1212
|
+
/// @notice Checks a decryption attestation for an encrypted uint256 against an expected plaintext value
|
|
1213
|
+
/// @param handle The encrypted handle
|
|
1214
|
+
/// @param expected The expected plaintext value
|
|
1215
|
+
/// @param decryption The decryption attestation to verify
|
|
1216
|
+
/// @param signatures The covalidator signatures for the attestation
|
|
1217
|
+
/// @dev Reverts if the handle doesn't match, the decrypted value doesn't match the expected value, or the attestation is invalid
|
|
1218
|
+
function requireEqual(euint256 handle, uint256 expected, DecryptionAttestation memory decryption, bytes[] memory signatures) internal view {
|
|
1219
|
+
require(euint256.unwrap(handle) == decryption.handle, HandleMismatch());
|
|
1220
|
+
require(uint256(decryption.value) == expected, UnexpectedDecryptedValue());
|
|
1221
|
+
require(inco.incoVerifier().isValidDecryptionAttestation(decryption, signatures), InvalidTEEAttestation());
|
|
1222
|
+
}
|
|
1197
1223
|
}
|
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
pragma solidity ^0.8;
|
|
7
7
|
|
|
8
8
|
import { IncoLightning } from "../IncoLightning.sol";
|
|
9
|
-
import { ebool, euint256, eaddress, ETypes, elist, IndexOutOfRange, InvalidRange, SliceOutOfRange, UnsupportedListType } from "../Types.sol";
|
|
9
|
+
import { ebool, euint256, eaddress, ETypes, elist, IndexOutOfRange, InvalidRange, SliceOutOfRange, UnsupportedListType, HandleMismatch, InvalidTEEAttestation, UnexpectedDecryptedValue } from "../Types.sol";
|
|
10
|
+
import { asBool } from "../shared/TypeUtils.sol";
|
|
10
11
|
import { DecryptionAttestation, ElementAttestationWithProof } from "../lightning-parts/DecryptionAttester.types.sol";
|
|
11
12
|
|
|
12
13
|
IncoLightning constant inco = IncoLightning(payable(0xA2275E60cCEd081fFD7373593c44ebc30E6Efe66));
|
|
@@ -687,7 +688,8 @@ library e {
|
|
|
687
688
|
/// @dev costs the inco fee
|
|
688
689
|
/// @return The encrypted random value
|
|
689
690
|
function rand() internal returns (euint256) {
|
|
690
|
-
bytes32
|
|
691
|
+
bytes32 boundHandle = euint256.unwrap(asEuint256(0));
|
|
692
|
+
bytes32 result = _callWithFeeRetry(abi.encodeWithSelector(inco.eRandBounded.selector, boundHandle, ETypes.Uint256));
|
|
691
693
|
return euint256.wrap(result);
|
|
692
694
|
}
|
|
693
695
|
|
|
@@ -1194,4 +1196,28 @@ library e {
|
|
|
1194
1196
|
function verifyEListDecryption(elist elistHandle, ElementAttestationWithProof[] memory proofElements, bytes32 proof, bytes[] memory signatures) internal view returns (bool) {
|
|
1195
1197
|
return inco.incoVerifier().isValidEListDecryptionAttestation(elist.unwrap(elistHandle), proofElements, proof, signatures);
|
|
1196
1198
|
}
|
|
1199
|
+
|
|
1200
|
+
/// @notice Checks a decryption attestation for an encrypted bool against an expected plaintext value
|
|
1201
|
+
/// @param handle The encrypted handle
|
|
1202
|
+
/// @param expected The expected plaintext value
|
|
1203
|
+
/// @param decryption The decryption attestation to verify
|
|
1204
|
+
/// @param signatures The covalidator signatures for the attestation
|
|
1205
|
+
/// @dev Reverts if the handle doesn't match, the decrypted value doesn't match the expected value, or the attestation is invalid
|
|
1206
|
+
function requireEqual(ebool handle, bool expected, DecryptionAttestation memory decryption, bytes[] memory signatures) internal view {
|
|
1207
|
+
require(ebool.unwrap(handle) == decryption.handle, HandleMismatch());
|
|
1208
|
+
require(asBool(decryption.value) == expected, UnexpectedDecryptedValue());
|
|
1209
|
+
require(inco.incoVerifier().isValidDecryptionAttestation(decryption, signatures), InvalidTEEAttestation());
|
|
1210
|
+
}
|
|
1211
|
+
|
|
1212
|
+
/// @notice Checks a decryption attestation for an encrypted uint256 against an expected plaintext value
|
|
1213
|
+
/// @param handle The encrypted handle
|
|
1214
|
+
/// @param expected The expected plaintext value
|
|
1215
|
+
/// @param decryption The decryption attestation to verify
|
|
1216
|
+
/// @param signatures The covalidator signatures for the attestation
|
|
1217
|
+
/// @dev Reverts if the handle doesn't match, the decrypted value doesn't match the expected value, or the attestation is invalid
|
|
1218
|
+
function requireEqual(euint256 handle, uint256 expected, DecryptionAttestation memory decryption, bytes[] memory signatures) internal view {
|
|
1219
|
+
require(euint256.unwrap(handle) == decryption.handle, HandleMismatch());
|
|
1220
|
+
require(uint256(decryption.value) == expected, UnexpectedDecryptedValue());
|
|
1221
|
+
require(inco.incoVerifier().isValidDecryptionAttestation(decryption, signatures), InvalidTEEAttestation());
|
|
1222
|
+
}
|
|
1197
1223
|
}
|