@inco/lightning 0.1.31 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/manifest.yaml +125 -235
- package/package.json +2 -1
- package/src/DeployUtils.sol +43 -11
- package/src/IIncoLightning.sol +13 -0
- package/src/IncoLightning.gen.sol +15 -0
- package/src/IncoLightning.sol +5 -2
- package/src/{libs/incoLightning_0_1_23__830342853.sol → Lib.alphanet.sol} +3 -3
- package/src/libs/{incoLightning_0_1_22__761766708.sol → incoLightning_alphanet_v0_297966649.sol} +1 -1
- package/src/libs/{incoLightning_0_1_23__547622051.sol → incoLightning_junknet3_v0_495844717.sol} +1 -1
- package/src/lightning-parts/AccessControl/BaseAccessControlList.gen.sol +19 -0
- package/src/lightning-parts/AccessControl/BaseAccessControlList.sol +2 -1
- package/src/lightning-parts/DecryptionHandler.gen.sol +54 -0
- package/src/lightning-parts/DecryptionHandler.sol +7 -35
- package/src/lightning-parts/DecryptionHandler.types.sol +34 -0
- package/src/lightning-parts/EncryptedInput.gen.sol +13 -0
- package/src/lightning-parts/EncryptedInput.sol +3 -2
- package/src/lightning-parts/EncryptedOperations.gen.sol +59 -0
- package/src/lightning-parts/EncryptedOperations.sol +3 -1
- package/src/lightning-parts/TrivialEncryption.gen.sol +13 -0
- package/src/lightning-parts/TrivialEncryption.sol +2 -0
- package/src/lightning-parts/primitives/EventCounter.gen.sol +6 -0
- package/src/lightning-parts/primitives/EventCounter.sol +3 -1
- package/src/lightning-parts/primitives/HandleGeneration.gen.sol +19 -0
- package/src/lightning-parts/primitives/HandleGeneration.sol +2 -1
- package/src/lightning-parts/primitives/HandleMetadata.gen.sol +4 -0
- package/src/lightning-parts/primitives/SignatureVerifier.gen.sol +15 -0
- package/src/lightning-parts/primitives/SignatureVerifier.sol +2 -1
- package/src/test/AddTwo.sol +0 -2
- package/src/test/IncoTest.sol +3 -2
- package/src/version/Version.gen.sol +14 -0
- package/src/version/Version.sol +1 -1
- package/src/libs/incoLightning_0_1_24__266705097.sol +0 -389
- package/src/libs/incoLightning_0_1_25__861473222.sol +0 -389
- package/src/libs/incoLightning_0_1_25__986372984.sol +0 -389
- package/src/libs/incoLightning_0_1_26__18043964.sol +0 -389
- package/src/libs/incoLightning_0_1_26__444235330.sol +0 -389
- package/src/libs/incoLightning_0_1_27__125335042.sol +0 -389
- package/src/libs/incoLightning_0_1_27__558243565.sol +0 -389
- /package/src/libs/{incoLightning_0_1_29__863421733.sol → incoLightning_demonet_v0_863421733.sol} +0 -0
- /package/src/libs/{incoLightning_0_1_29__340846814.sol → incoLightning_devnet_v0_340846814.sol} +0 -0
- /package/src/libs/{incoLightning_0_1_29__183408998.sol → incoLightning_testnet_v0_183408998.sol} +0 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/// SPDX-License-Identifier: No License
|
|
2
|
+
pragma solidity ^0.8;
|
|
3
|
+
|
|
4
|
+
import { SenderNotAllowedForHandle } from "../../Types.sol";
|
|
5
|
+
|
|
6
|
+
interface IBaseAccessControlListGen {
|
|
7
|
+
/// @dev persistent
|
|
8
|
+
function allow(bytes32 handle, address account) external;
|
|
9
|
+
|
|
10
|
+
function allowTransient(bytes32 handle, address account) external;
|
|
11
|
+
|
|
12
|
+
function allowedTransient(bytes32 handle, address account) external view returns (bool);
|
|
13
|
+
|
|
14
|
+
function cleanTransientStorage() external;
|
|
15
|
+
|
|
16
|
+
function persistAllowed(bytes32 handle, address account) external view returns (bool);
|
|
17
|
+
|
|
18
|
+
function isAllowed(bytes32 handle, address account) external view returns (bool);
|
|
19
|
+
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
pragma solidity ^0.8;
|
|
3
3
|
|
|
4
4
|
import {SenderNotAllowedForHandle} from "../../Types.sol";
|
|
5
|
+
import {IBaseAccessControlListGen} from "./BaseAccessControlList.gen.sol";
|
|
5
6
|
|
|
6
7
|
contract AccessControlListStorage {
|
|
7
8
|
struct ACLStorage {
|
|
@@ -19,7 +20,7 @@ contract AccessControlListStorage {
|
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
// todo should add allowance events ?
|
|
22
|
-
contract BaseAccessControlList is AccessControlListStorage {
|
|
23
|
+
contract BaseAccessControlList is IBaseAccessControlListGen, AccessControlListStorage {
|
|
23
24
|
/// @dev persistent
|
|
24
25
|
function allow(bytes32 handle, address account) public {
|
|
25
26
|
require(
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/// SPDX-License-Identifier: No License
|
|
2
|
+
pragma solidity ^0.8;
|
|
3
|
+
|
|
4
|
+
import "./DecryptionHandler.types.sol";
|
|
5
|
+
import { BaseAccessControlList } from "./AccessControl/BaseAccessControlList.sol";
|
|
6
|
+
import { EIP712 } from "@openzeppelin/contracts/utils/cryptography/EIP712.sol";
|
|
7
|
+
import { EventCounter } from "./primitives/EventCounter.sol";
|
|
8
|
+
import { IDecryptionHandlerEip712CheckerGen } from "./DecryptionHandler.gen.sol";
|
|
9
|
+
import { SenderNotAllowedForHandle } from "../Types.sol";
|
|
10
|
+
import { SignatureVerifier } from "./primitives/SignatureVerifier.sol";
|
|
11
|
+
|
|
12
|
+
interface IDecryptionHandlerEip712CheckerGen {
|
|
13
|
+
function decryptionResultDigest(DecryptionResult memory result) external view returns (bytes32);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
interface IDecryptionHandlerGen {
|
|
17
|
+
/// @dev callback function MUST be of form `function name(bytes32 requestId, bytes32 result, bytes memory data)`
|
|
18
|
+
function requestDecryption(bytes4 callbackSelector, uint256 maxTimestamp, bytes32 handle, bytes memory data) external returns (uint256 requestId);
|
|
19
|
+
|
|
20
|
+
function fulfillRequest(DecryptionResult memory result, bytes memory signature) external;
|
|
21
|
+
|
|
22
|
+
function fulfillRequestsBatch(SignedDecryptionResult[] memory results) external;
|
|
23
|
+
|
|
24
|
+
/// @dev Get some pending requests.
|
|
25
|
+
/// @param offset A parameter for paginating through the whole set of pending requests.
|
|
26
|
+
/// Use zero for an initial query, then use the previous query's nextOffset to continue traversal.
|
|
27
|
+
/// @param maxRequests The maximum number of pending to return.
|
|
28
|
+
/// @param iterationBound The maximum number of non-pending requests to iterate over before returning.
|
|
29
|
+
/// @return nextOffset The next offset to use to continue to scan through the pending request set.
|
|
30
|
+
/// Returns the input offset if the whole set has been scanned. Can re-query with this offset
|
|
31
|
+
/// to see any new pending requests, or re-query with a zero offset to return the whole set again.
|
|
32
|
+
/// @return requests Some pending requests. May be fewer than requested, possibly zero. There may be
|
|
33
|
+
/// more requests available if the returned nextOffset is greater than the input offset.
|
|
34
|
+
function getPendingRequests(uint256 offset, uint256 maxRequests, uint256 iterationBound) external view returns (uint256 nextOffset, Request[] memory requests);
|
|
35
|
+
|
|
36
|
+
/// @param offset A parameter for paginating through the whole set of pending requests.
|
|
37
|
+
/// Use zero for an initial query, then use the previous query's nextOffset to continue traversal.
|
|
38
|
+
/// @param maxRequests The maximum number of pending to return.
|
|
39
|
+
/// @return nextOffset The next offset to use to continue to scan through the pending request set.
|
|
40
|
+
/// Returns the input offset if the whole set has been scanned. Can re-query with this offset
|
|
41
|
+
/// to see any new pending requests, or re-query with a zero offset to return the whole set again.
|
|
42
|
+
/// @return requests Some pending requests. May be fewer than requested, possibly zero. There may be
|
|
43
|
+
/// more requests available if the returned nextOffset is greater than the input offset.
|
|
44
|
+
function getPendingRequests(uint256 offset, uint256 maxRequests) external view returns (uint256 nextOffset, Request[] memory requests);
|
|
45
|
+
|
|
46
|
+
function getNextRequestId() external view returns (uint256);
|
|
47
|
+
|
|
48
|
+
function getLowWatermarkRequestId() external view returns (uint256);
|
|
49
|
+
|
|
50
|
+
/// @dev Advance the low watermark until we hit a pending request, the requestId counter, or iterationBound steps.
|
|
51
|
+
/// @param iterationBound The maximum number of requests to iterate over.
|
|
52
|
+
/// @notice This function is public so that we can externally drive the low watermark in extreme cases.
|
|
53
|
+
function advanceLowWatermark(uint256 iterationBound) external;
|
|
54
|
+
}
|
|
@@ -1,44 +1,15 @@
|
|
|
1
1
|
// SPDX-License-Identifier: No License
|
|
2
2
|
pragma solidity ^0.8;
|
|
3
3
|
|
|
4
|
-
import
|
|
4
|
+
import "./DecryptionHandler.gen.sol";
|
|
5
|
+
import "./DecryptionHandler.types.sol";
|
|
5
6
|
import {BaseAccessControlList} from "./AccessControl/BaseAccessControlList.sol";
|
|
6
7
|
import {EIP712} from "@openzeppelin/contracts/utils/cryptography/EIP712.sol";
|
|
7
8
|
import {EventCounter} from "./primitives/EventCounter.sol";
|
|
9
|
+
import {IDecryptionHandlerEip712CheckerGen} from "./DecryptionHandler.gen.sol";
|
|
10
|
+
import {SenderNotAllowedForHandle} from "../Types.sol";
|
|
8
11
|
import {SignatureVerifier} from "./primitives/SignatureVerifier.sol";
|
|
9
12
|
|
|
10
|
-
struct Request {
|
|
11
|
-
uint256 maxTimestamp;
|
|
12
|
-
address callbackContract;
|
|
13
|
-
bytes4 callbackSelector;
|
|
14
|
-
bool fulfilled;
|
|
15
|
-
bytes data;
|
|
16
|
-
// Adding at end of struct which should be unused state slot for version 0.2.0
|
|
17
|
-
bytes32 handle;
|
|
18
|
-
// This value is redundant for the contract but required for getPendingRequests, rather than duplicate this struct
|
|
19
|
-
// adding it here redundantly for now
|
|
20
|
-
uint256 requestId;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
struct DecryptionResult {
|
|
24
|
-
bytes32 abiEncodedResult;
|
|
25
|
-
uint256 requestId;
|
|
26
|
-
// Added in 0.2.0 to offer an integrity check
|
|
27
|
-
bytes32 handle;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
struct SignedDecryptionResult {
|
|
31
|
-
DecryptionResult result;
|
|
32
|
-
bytes signature;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
event DecryptionRequested(
|
|
36
|
-
uint256 indexed requestId,
|
|
37
|
-
bytes32 indexed handle,
|
|
38
|
-
uint256 maxTimestamp,
|
|
39
|
-
uint256 eventId
|
|
40
|
-
);
|
|
41
|
-
|
|
42
13
|
contract DecryptionHandlerStorage {
|
|
43
14
|
struct DecryptionStorage {
|
|
44
15
|
// The next request ID to assign. This and higher numbers have never been used,
|
|
@@ -65,7 +36,7 @@ contract DecryptionHandlerStorage {
|
|
|
65
36
|
}
|
|
66
37
|
}
|
|
67
38
|
|
|
68
|
-
abstract contract DecryptionHandlerEip712Checker is EIP712, SignatureVerifier {
|
|
39
|
+
abstract contract DecryptionHandlerEip712Checker is IDecryptionHandlerEip712CheckerGen, EIP712, SignatureVerifier {
|
|
69
40
|
bytes32 constant DecryptionResultStructHash =
|
|
70
41
|
keccak256(
|
|
71
42
|
"DecryptionResult(bytes32 abiEncodedResult,uint256 requestId)"
|
|
@@ -95,6 +66,7 @@ abstract contract DecryptionHandlerEip712Checker is EIP712, SignatureVerifier {
|
|
|
95
66
|
}
|
|
96
67
|
|
|
97
68
|
abstract contract DecryptionHandler is
|
|
69
|
+
IDecryptionHandlerGen,
|
|
98
70
|
BaseAccessControlList,
|
|
99
71
|
EventCounter,
|
|
100
72
|
DecryptionHandlerStorage,
|
|
@@ -280,7 +252,7 @@ abstract contract DecryptionHandler is
|
|
|
280
252
|
}
|
|
281
253
|
|
|
282
254
|
/**
|
|
283
|
-
|
|
255
|
+
|
|
284
256
|
* @param offset A parameter for paginating through the whole set of pending requests.
|
|
285
257
|
* Use zero for an initial query, then use the previous query's nextOffset to continue traversal.
|
|
286
258
|
* @param maxRequests The maximum number of pending to return.
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// SPDX-License-Identifier: No License
|
|
2
|
+
pragma solidity ^0.8;
|
|
3
|
+
|
|
4
|
+
struct Request {
|
|
5
|
+
uint256 maxTimestamp;
|
|
6
|
+
address callbackContract;
|
|
7
|
+
bytes4 callbackSelector;
|
|
8
|
+
bool fulfilled;
|
|
9
|
+
bytes data;
|
|
10
|
+
// Adding at end of struct which should be unused state slot for version 0.2.0
|
|
11
|
+
bytes32 handle;
|
|
12
|
+
// This value is redundant for the contract but required for getPendingRequests, rather than duplicate this struct
|
|
13
|
+
// adding it here redundantly for now
|
|
14
|
+
uint256 requestId;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
struct DecryptionResult {
|
|
18
|
+
bytes32 abiEncodedResult;
|
|
19
|
+
uint256 requestId;
|
|
20
|
+
// Added in 0.2.0 to offer an integrity check
|
|
21
|
+
bytes32 handle;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
struct SignedDecryptionResult {
|
|
25
|
+
DecryptionResult result;
|
|
26
|
+
bytes signature;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
event DecryptionRequested(
|
|
30
|
+
uint256 indexed requestId,
|
|
31
|
+
bytes32 indexed handle,
|
|
32
|
+
uint256 maxTimestamp,
|
|
33
|
+
uint256 eventId
|
|
34
|
+
);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/// SPDX-License-Identifier: No License
|
|
2
|
+
pragma solidity ^0.8;
|
|
3
|
+
|
|
4
|
+
import { BaseAccessControlList } from "./AccessControl/BaseAccessControlList.sol";
|
|
5
|
+
import { EventCounter } from "./primitives/EventCounter.sol";
|
|
6
|
+
import { HandleGeneration } from "./primitives/HandleGeneration.sol";
|
|
7
|
+
import { euint256, ebool, ETypes, EVM_HOST_CHAIN_PREFIX, HANDLE_VERSION, HANDLE_INDEX } from "../Types.sol";
|
|
8
|
+
|
|
9
|
+
interface IEncryptedInputGen {
|
|
10
|
+
function newEuint256(bytes memory ciphertext, address user) external returns (euint256 newValue);
|
|
11
|
+
|
|
12
|
+
function newEbool(bytes memory ciphertext, address user) external returns (ebool newValue);
|
|
13
|
+
}
|
|
@@ -3,11 +3,12 @@ pragma solidity ^0.8;
|
|
|
3
3
|
|
|
4
4
|
import {BaseAccessControlList} from "./AccessControl/BaseAccessControlList.sol";
|
|
5
5
|
import {EventCounter} from "./primitives/EventCounter.sol";
|
|
6
|
-
// import {console} from "forge-std/console.sol";
|
|
7
|
-
import {euint256, ebool, ETypes, EVM_HOST_CHAIN_PREFIX, HANDLE_VERSION, HANDLE_INDEX} from "../Types.sol";
|
|
8
6
|
import {HandleGeneration} from "./primitives/HandleGeneration.sol";
|
|
7
|
+
import {euint256, ebool, ETypes, EVM_HOST_CHAIN_PREFIX, HANDLE_VERSION, HANDLE_INDEX} from "../Types.sol";
|
|
8
|
+
import {IEncryptedInputGen} from "./EncryptedInput.gen.sol";
|
|
9
9
|
|
|
10
10
|
abstract contract EncryptedInput is
|
|
11
|
+
IEncryptedInputGen,
|
|
11
12
|
BaseAccessControlList,
|
|
12
13
|
EventCounter,
|
|
13
14
|
HandleGeneration
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/// SPDX-License-Identifier: No License
|
|
2
|
+
pragma solidity ^0.8;
|
|
3
|
+
|
|
4
|
+
import { euint256, ebool, EOps, SenderNotAllowedForHandle, ETypes, isTypeSupported } from "../Types.sol";
|
|
5
|
+
import { BaseAccessControlList } from "./AccessControl/BaseAccessControlList.sol";
|
|
6
|
+
import { EventCounter } from "./primitives/EventCounter.sol";
|
|
7
|
+
import { HandleGeneration } from "./primitives/HandleGeneration.sol";
|
|
8
|
+
|
|
9
|
+
interface IEncryptedOperationsGen {
|
|
10
|
+
function eAdd(euint256 lhs, euint256 rhs) external returns (euint256 result);
|
|
11
|
+
|
|
12
|
+
function eSub(euint256 lhs, euint256 rhs) external returns (euint256 result);
|
|
13
|
+
|
|
14
|
+
function eMul(euint256 lhs, euint256 rhs) external returns (euint256 result);
|
|
15
|
+
|
|
16
|
+
function eDiv(euint256 lhs, euint256 rhs) external returns (euint256 result);
|
|
17
|
+
|
|
18
|
+
function eRem(euint256 lhs, euint256 rhs) external returns (euint256 result);
|
|
19
|
+
|
|
20
|
+
function eBitAnd(bytes32 lhs, bytes32 rhs) external returns (bytes32 result);
|
|
21
|
+
|
|
22
|
+
function eBitOr(bytes32 lhs, bytes32 rhs) external returns (bytes32 result);
|
|
23
|
+
|
|
24
|
+
function eBitXor(bytes32 lhs, bytes32 rhs) external returns (bytes32 result);
|
|
25
|
+
|
|
26
|
+
function eShl(euint256 lhs, euint256 rhs) external returns (euint256 result);
|
|
27
|
+
|
|
28
|
+
function eShr(euint256 lhs, euint256 rhs) external returns (euint256 result);
|
|
29
|
+
|
|
30
|
+
function eRotl(euint256 lhs, euint256 rhs) external returns (euint256 result);
|
|
31
|
+
|
|
32
|
+
function eRotr(euint256 lhs, euint256 rhs) external returns (euint256 result);
|
|
33
|
+
|
|
34
|
+
function eEq(euint256 lhs, euint256 rhs) external returns (ebool result);
|
|
35
|
+
|
|
36
|
+
function eNe(euint256 lhs, euint256 rhs) external returns (ebool result);
|
|
37
|
+
|
|
38
|
+
function eGe(euint256 lhs, euint256 rhs) external returns (ebool result);
|
|
39
|
+
|
|
40
|
+
function eGt(euint256 lhs, euint256 rhs) external returns (ebool result);
|
|
41
|
+
|
|
42
|
+
function eLe(euint256 lhs, euint256 rhs) external returns (ebool result);
|
|
43
|
+
|
|
44
|
+
function eLt(euint256 lhs, euint256 rhs) external returns (ebool result);
|
|
45
|
+
|
|
46
|
+
function eMin(euint256 lhs, euint256 rhs) external returns (euint256 result);
|
|
47
|
+
|
|
48
|
+
function eMax(euint256 lhs, euint256 rhs) external returns (euint256 result);
|
|
49
|
+
|
|
50
|
+
function eNot(ebool operand) external returns (ebool result);
|
|
51
|
+
|
|
52
|
+
function eCast(bytes32 ct, ETypes toType) external returns (bytes32 result);
|
|
53
|
+
|
|
54
|
+
function eRand(ETypes randType) external returns (bytes32 result);
|
|
55
|
+
|
|
56
|
+
function eRandBounded(bytes32 upperBound, ETypes randType) external returns (bytes32 result);
|
|
57
|
+
|
|
58
|
+
function eIfThenElse(ebool control, bytes32 ifTrue, bytes32 ifFalse) external returns (bytes32 result);
|
|
59
|
+
}
|
|
@@ -5,8 +5,10 @@ import {euint256, ebool, EOps, SenderNotAllowedForHandle, ETypes, isTypeSupporte
|
|
|
5
5
|
import {BaseAccessControlList} from "./AccessControl/BaseAccessControlList.sol";
|
|
6
6
|
import {EventCounter} from "./primitives/EventCounter.sol";
|
|
7
7
|
import {HandleGeneration} from "./primitives/HandleGeneration.sol";
|
|
8
|
+
import {IEncryptedOperationsGen} from "./EncryptedOperations.gen.sol";
|
|
8
9
|
|
|
9
10
|
abstract contract EncryptedOperations is
|
|
11
|
+
IEncryptedOperationsGen,
|
|
10
12
|
BaseAccessControlList,
|
|
11
13
|
EventCounter,
|
|
12
14
|
HandleGeneration
|
|
@@ -290,7 +292,7 @@ abstract contract EncryptedOperations is
|
|
|
290
292
|
function eRem(
|
|
291
293
|
euint256 lhs,
|
|
292
294
|
euint256 rhs
|
|
293
|
-
) external checked(lhs, rhs) returns (euint256 result) {
|
|
295
|
+
) external virtual checked(lhs, rhs) returns (euint256 result) {
|
|
294
296
|
result = euint256.wrap(
|
|
295
297
|
createResultHandle(
|
|
296
298
|
EOps.Rem,
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/// SPDX-License-Identifier: No License
|
|
2
|
+
pragma solidity ^0.8;
|
|
3
|
+
|
|
4
|
+
import { EventCounter } from "./primitives/EventCounter.sol";
|
|
5
|
+
import { euint256, ebool, ETypes } from "../Types.sol";
|
|
6
|
+
import { BaseAccessControlList } from "./AccessControl/BaseAccessControlList.sol";
|
|
7
|
+
import { HandleGeneration } from "./primitives/HandleGeneration.sol";
|
|
8
|
+
|
|
9
|
+
interface ITrivialEncryptionGen {
|
|
10
|
+
function asEuint256(uint256 value) external returns (euint256 newEuint256);
|
|
11
|
+
|
|
12
|
+
function asEbool(bool value) external returns (ebool newEbool);
|
|
13
|
+
}
|
|
@@ -5,8 +5,10 @@ import {EventCounter} from "./primitives/EventCounter.sol";
|
|
|
5
5
|
import {euint256, ebool, ETypes} from "../Types.sol";
|
|
6
6
|
import {BaseAccessControlList} from "./AccessControl/BaseAccessControlList.sol";
|
|
7
7
|
import {HandleGeneration} from "./primitives/HandleGeneration.sol";
|
|
8
|
+
import {ITrivialEncryptionGen} from "./TrivialEncryption.gen.sol";
|
|
8
9
|
|
|
9
10
|
abstract contract TrivialEncryption is
|
|
11
|
+
ITrivialEncryptionGen,
|
|
10
12
|
BaseAccessControlList,
|
|
11
13
|
EventCounter,
|
|
12
14
|
HandleGeneration
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
// SPDX-License-Identifier: No License
|
|
2
2
|
pragma solidity ^0.8;
|
|
3
3
|
|
|
4
|
+
import {IEventCounterGen} from "./EventCounter.gen.sol";
|
|
5
|
+
|
|
4
6
|
contract EventCounterStorage {
|
|
5
7
|
struct Storage {
|
|
6
8
|
uint256 eventCounter;
|
|
@@ -21,7 +23,7 @@ contract EventCounterStorage {
|
|
|
21
23
|
}
|
|
22
24
|
}
|
|
23
25
|
|
|
24
|
-
contract EventCounter is EventCounterStorage {
|
|
26
|
+
contract EventCounter is IEventCounterGen, EventCounterStorage {
|
|
25
27
|
function getNewEventId() internal returns (uint256 newEventId) {
|
|
26
28
|
newEventId = getEventCounterStorage().eventCounter++;
|
|
27
29
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/// SPDX-License-Identifier: No License
|
|
2
|
+
pragma solidity ^0.8;
|
|
3
|
+
|
|
4
|
+
import { ETypes, EOps, EVM_HOST_CHAIN_PREFIX, HANDLE_INDEX } from "../../Types.sol";
|
|
5
|
+
import { HandleMetadata } from "./HandleMetadata.sol";
|
|
6
|
+
|
|
7
|
+
interface IHandleGenerationGen {
|
|
8
|
+
function getTrivialEncryptHandle(bytes32 plaintextBytes, ETypes handleType) external view returns (bytes32 generatedHandle);
|
|
9
|
+
|
|
10
|
+
function getInputHandle(bytes memory ciphertext, address user, address contractAddress, ETypes inputType) external view returns (bytes32 generatedHandle);
|
|
11
|
+
|
|
12
|
+
function getOpResultHandle(EOps op, ETypes returnType, bytes32 lhs, bytes32 rhs) external pure returns (bytes32 generatedHandle);
|
|
13
|
+
|
|
14
|
+
function getOpResultHandle(EOps op, ETypes returnType, uint256 counter, bytes32 upperBound) external pure returns (bytes32 generatedHandle);
|
|
15
|
+
|
|
16
|
+
function getOpResultHandle(EOps op, ETypes returnType, bytes32 value) external pure returns (bytes32 generatedHandle);
|
|
17
|
+
|
|
18
|
+
function getOpResultHandle(EOps op, ETypes returnType, bytes32 inputA, bytes32 inputB, bytes32 inputC) external pure returns (bytes32 generatedHandle);
|
|
19
|
+
}
|
|
@@ -3,8 +3,9 @@ pragma solidity ^0.8;
|
|
|
3
3
|
|
|
4
4
|
import {ETypes, EOps, EVM_HOST_CHAIN_PREFIX, HANDLE_INDEX} from "../../Types.sol";
|
|
5
5
|
import {HandleMetadata} from "./HandleMetadata.sol";
|
|
6
|
+
import {IHandleGenerationGen} from "./HandleGeneration.gen.sol";
|
|
6
7
|
|
|
7
|
-
contract HandleGeneration is HandleMetadata {
|
|
8
|
+
contract HandleGeneration is IHandleGenerationGen, HandleMetadata {
|
|
8
9
|
function getTrivialEncryptHandle(
|
|
9
10
|
bytes32 plaintextBytes,
|
|
10
11
|
ETypes handleType
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/// SPDX-License-Identifier: No License
|
|
2
|
+
pragma solidity ^0.8;
|
|
3
|
+
|
|
4
|
+
import { OwnableUpgradeable } from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
|
|
5
|
+
import { ECDSA } from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
|
|
6
|
+
|
|
7
|
+
interface ISignatureVerifierGen {
|
|
8
|
+
function addSigner(address signerAddress) external;
|
|
9
|
+
|
|
10
|
+
function removeSigner(address signerAddress) external;
|
|
11
|
+
|
|
12
|
+
function isSigner(address signerAddress) external view returns (bool);
|
|
13
|
+
|
|
14
|
+
function isValidSignature(bytes32 hash, bytes memory signature) external view returns (bool);
|
|
15
|
+
}
|
|
@@ -3,6 +3,7 @@ pragma solidity ^0.8;
|
|
|
3
3
|
|
|
4
4
|
import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
|
|
5
5
|
import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
|
|
6
|
+
import {ISignatureVerifierGen} from "./SignatureVerifier.gen.sol";
|
|
6
7
|
|
|
7
8
|
contract SignatureVerifierStorage {
|
|
8
9
|
struct StorageForSigVerifier {
|
|
@@ -26,7 +27,7 @@ contract SignatureVerifierStorage {
|
|
|
26
27
|
}
|
|
27
28
|
}
|
|
28
29
|
|
|
29
|
-
contract SignatureVerifier is OwnableUpgradeable, SignatureVerifierStorage {
|
|
30
|
+
contract SignatureVerifier is ISignatureVerifierGen, OwnableUpgradeable, SignatureVerifierStorage {
|
|
30
31
|
using ECDSA for bytes32;
|
|
31
32
|
|
|
32
33
|
error SignerNotFound(address signerAddress);
|
package/src/test/AddTwo.sol
CHANGED
|
@@ -24,8 +24,6 @@ contract AddTwo {
|
|
|
24
24
|
return inco.eAdd(a, inco.asEuint256(two));
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
// addTwoEOA is the equivalent of addTwo, but it allows an EOA to call it
|
|
28
|
-
// with an encrypted input.
|
|
29
27
|
function addTwoEOA(
|
|
30
28
|
bytes memory uint256EInput
|
|
31
29
|
) external returns (uint256, euint256) {
|
package/src/test/IncoTest.sol
CHANGED
|
@@ -27,10 +27,11 @@ contract IncoTest is MockOpHandler, DeployUtils {
|
|
|
27
27
|
vm.startPrank(testDeployer);
|
|
28
28
|
IncoLightning proxy = deployIncoLightningUsingConfig({
|
|
29
29
|
deployer: testDeployer,
|
|
30
|
-
|
|
30
|
+
// The highest precedent deployment
|
|
31
31
|
pepper: "testnet",
|
|
32
32
|
minorVersionForSalt: 1,
|
|
33
|
-
patchVersionForSalt: 29
|
|
33
|
+
patchVersionForSalt: 29,
|
|
34
|
+
includePreviewFeatures: false
|
|
34
35
|
});
|
|
35
36
|
proxy.transferOwnership(owner);
|
|
36
37
|
vm.stopPrank();
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/// SPDX-License-Identifier: No License
|
|
2
|
+
pragma solidity ^0.8;
|
|
3
|
+
|
|
4
|
+
import { Strings } from "@openzeppelin/contracts/utils/Strings.sol";
|
|
5
|
+
import { EIP712 } from "@openzeppelin/contracts/utils/cryptography/EIP712.sol";
|
|
6
|
+
import { ShortStrings, ShortString } from "@openzeppelin/contracts/utils/ShortStrings.sol";
|
|
7
|
+
|
|
8
|
+
interface IVersionGen {
|
|
9
|
+
function getVersionedName() external view returns (string memory);
|
|
10
|
+
|
|
11
|
+
function getVersion() external view returns (string memory);
|
|
12
|
+
|
|
13
|
+
function getName() external view returns (string memory);
|
|
14
|
+
}
|
package/src/version/Version.sol
CHANGED
|
@@ -13,7 +13,7 @@ contract Version is EIP712 {
|
|
|
13
13
|
uint8 public immutable minorVersion;
|
|
14
14
|
uint8 public immutable patchVersion;
|
|
15
15
|
bytes32 public immutable salt;
|
|
16
|
-
ShortString
|
|
16
|
+
ShortString internal immutable name;
|
|
17
17
|
|
|
18
18
|
constructor(
|
|
19
19
|
uint8 _majorVersion,
|