@iexec-nox/nox-protocol-contracts 0.1.0-beta.8 → 0.1.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/LICENSE +157 -201
- package/README.md +110 -33
- package/contracts/interfaces/INoxCompute.sol +9 -7
- package/contracts/interfaces/LICENSE +22 -0
- package/contracts/sdk/LICENSE +22 -0
- package/contracts/sdk/Nox.sol +412 -217
- package/contracts/shared/HandleUtils.sol +35 -0
- package/contracts/shared/LICENSE +22 -0
- package/contracts/shared/TypeUtils.sol +16 -18
- package/package.json +18 -14
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity ^0.8.27;
|
|
3
|
+
|
|
4
|
+
import {TEEType} from "./TypeUtils.sol";
|
|
5
|
+
|
|
6
|
+
library HandleUtils {
|
|
7
|
+
/// @dev Bit 0 of the attrs byte. When set, the handle is guaranteed unique on-chain.
|
|
8
|
+
bytes1 internal constant ATTR_IS_UNIQUE_HANDLE = 0x01;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @notice Checks if a handle is a public handle (isUniqueHandle bit == 0).
|
|
12
|
+
* A public handle wraps a plaintext value known on-chain, has no ACL,
|
|
13
|
+
* and is accessible by everyone.
|
|
14
|
+
* @param handle The handle to check
|
|
15
|
+
* @return True if the handle is a public handle
|
|
16
|
+
*/
|
|
17
|
+
function isPublicHandle(bytes32 handle) internal pure returns (bool) {
|
|
18
|
+
return (handle[6] & ATTR_IS_UNIQUE_HANDLE) == 0;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @notice Returns the zero handle for the given TEE type on the current chain.
|
|
23
|
+
* The zero handle represents the default zero value for a given type and is a public handle.
|
|
24
|
+
* It follows the standard handle format but with a zeroed pre-handle:
|
|
25
|
+
* [0]=version(0x00) [1-4]=chainId [5]=teeType [6]=attrs(0x00) [7-31]=0x00..00
|
|
26
|
+
* @param teeType The TEE type to encode
|
|
27
|
+
* @return The typed null handle
|
|
28
|
+
*/
|
|
29
|
+
function zeroHandle(TEEType teeType) internal view returns (bytes32) {
|
|
30
|
+
return
|
|
31
|
+
// [0]=version is implicitly 0x00
|
|
32
|
+
(bytes32(bytes4(uint32(block.chainid))) >> (1 * 8)) |
|
|
33
|
+
(bytes32(bytes1(uint8(teeType))) >> (5 * 8));
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
-----------
|
|
3
|
+
|
|
4
|
+
Copyright (c) 2026 iExec
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in
|
|
14
|
+
all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
21
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
22
|
+
IN THE SOFTWARE.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
// SPDX-License-Identifier:
|
|
2
|
-
pragma solidity ^0.8.
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity ^0.8.27;
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* @notice Enum values MUST NOT be reordered or removed once deployed.
|
|
@@ -113,11 +113,9 @@ enum TEEType {
|
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
error NonArithmeticType();
|
|
116
|
+
error UnsupportedArithmeticType();
|
|
116
117
|
|
|
117
118
|
library TypeUtils {
|
|
118
|
-
/// @dev Bit 0 of the attrs byte. When set, the handle is guaranteed unique on-chain.
|
|
119
|
-
bytes1 internal constant ATTR_IS_UNIQ_HANDLE = 0x01;
|
|
120
|
-
|
|
121
119
|
/**
|
|
122
120
|
* @notice Extracts the TEE type from a handle.
|
|
123
121
|
* The type is stored at byte position 5 in the handle.
|
|
@@ -128,25 +126,25 @@ library TypeUtils {
|
|
|
128
126
|
return TEEType(uint8(handle[5]));
|
|
129
127
|
}
|
|
130
128
|
|
|
131
|
-
/**
|
|
132
|
-
* @notice Checks if a handle is a public handle (isUniqHandle bit == 0).
|
|
133
|
-
* A public handle wraps a plaintext value known on-chain, has no ACL,
|
|
134
|
-
* and is accessible by everyone.
|
|
135
|
-
* @param handle The handle to check
|
|
136
|
-
* @return True if the handle is a public handle
|
|
137
|
-
*/
|
|
138
|
-
function isPublicHandle(bytes32 handle) internal pure returns (bool) {
|
|
139
|
-
return (handle[6] & ATTR_IS_UNIQ_HANDLE) == 0;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
129
|
/**
|
|
143
130
|
* @notice Validates that a TEE type is supported for arithmetic operations.
|
|
144
|
-
* Only
|
|
145
|
-
*
|
|
131
|
+
* Only the following arithmetic types are supported:
|
|
132
|
+
* - uint16
|
|
133
|
+
* - uint256
|
|
134
|
+
* - int16
|
|
135
|
+
* - int256
|
|
146
136
|
* @param teeType The TEE type to validate
|
|
137
|
+
* @dev Reverts with NonArithmeticType when the type is not an arithmetic type.
|
|
138
|
+
* @dev Reverts with UnsupportedArithmeticType when the type is not supported.
|
|
147
139
|
*/
|
|
148
140
|
function validateArithmeticType(TEEType teeType) internal pure {
|
|
149
141
|
uint8 t = uint8(teeType);
|
|
150
142
|
require(t >= uint8(TEEType.Uint8) && t <= uint8(TEEType.Int256), NonArithmeticType());
|
|
143
|
+
bool supportedType =
|
|
144
|
+
teeType == TEEType.Uint16 ||
|
|
145
|
+
teeType == TEEType.Uint256 ||
|
|
146
|
+
teeType == TEEType.Int16 ||
|
|
147
|
+
teeType == TEEType.Int256;
|
|
148
|
+
require(supportedType, UnsupportedArithmeticType());
|
|
151
149
|
}
|
|
152
150
|
}
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@iexec-nox/nox-protocol-contracts",
|
|
3
|
-
"version": "0.1.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "Nox protocol smart contracts",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Nox",
|
|
7
7
|
"Confidential DeFi",
|
|
8
8
|
"cDeFi"
|
|
9
9
|
],
|
|
10
|
-
"license": "
|
|
11
|
-
"packageManager": "pnpm@10.
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"packageManager": "pnpm@10.33.0",
|
|
12
12
|
"type": "module",
|
|
13
13
|
"files": [
|
|
14
14
|
"/contracts/interfaces/",
|
|
@@ -20,13 +20,14 @@
|
|
|
20
20
|
"clean": "pnpm hardhat clean",
|
|
21
21
|
"build": "pnpm hardhat build",
|
|
22
22
|
"test": "pnpm hardhat test",
|
|
23
|
+
"test:gas": "pnpm hardhat test solidity --gas-stats",
|
|
23
24
|
"coverage": "pnpm hardhat test solidity --coverage",
|
|
24
25
|
"deploy": "pnpm hardhat run scripts/deploy.ts",
|
|
25
26
|
"deploy:production": "pnpm hardhat run scripts/deploy.ts --build-profile production",
|
|
26
27
|
"set-gateway": "pnpm hardhat run scripts/set-gateway.ts",
|
|
27
28
|
"set-kms-public-key": "pnpm hardhat run scripts/set-kms-public-key.ts",
|
|
28
|
-
"upgrade": "
|
|
29
|
-
"upgrade:production": "
|
|
29
|
+
"upgrade": "bash scripts/upgrade.sh",
|
|
30
|
+
"upgrade:production": "bash scripts/upgrade.sh --build-profile production",
|
|
30
31
|
"verify": "pnpm hardhat ignition verify",
|
|
31
32
|
"format": "pnpm prettier --write .",
|
|
32
33
|
"format:check": "pnpm prettier --check ."
|
|
@@ -42,17 +43,20 @@
|
|
|
42
43
|
"encrypted-types": "^0.0.4"
|
|
43
44
|
},
|
|
44
45
|
"devDependencies": {
|
|
45
|
-
"@nomicfoundation/hardhat-
|
|
46
|
-
"@nomicfoundation/hardhat-
|
|
47
|
-
"@
|
|
48
|
-
"
|
|
49
|
-
"
|
|
46
|
+
"@nomicfoundation/hardhat-ethers": "^4.0.6",
|
|
47
|
+
"@nomicfoundation/hardhat-ignition": "^3.1.0",
|
|
48
|
+
"@nomicfoundation/hardhat-toolbox-viem": "^5.0.3",
|
|
49
|
+
"@openzeppelin/hardhat-upgrades": "4.0.0-alpha.0",
|
|
50
|
+
"@types/node": "^25.5.0",
|
|
51
|
+
"ethers": "^6.16.0",
|
|
52
|
+
"forge-std": "github:foundry-rs/forge-std#v1.15.0",
|
|
53
|
+
"hardhat": "^3.2.0",
|
|
50
54
|
"husky": "^9.1.7",
|
|
51
|
-
"lint-staged": "^16.
|
|
55
|
+
"lint-staged": "^16.4.0",
|
|
52
56
|
"prettier": "^3.8.1",
|
|
53
|
-
"prettier-plugin-solidity": "^2.
|
|
54
|
-
"typescript": "^
|
|
55
|
-
"viem": "^2.
|
|
57
|
+
"prettier-plugin-solidity": "^2.3.1",
|
|
58
|
+
"typescript": "^6.0.2",
|
|
59
|
+
"viem": "^2.47.6"
|
|
56
60
|
},
|
|
57
61
|
"homepage": "https://github.com/iExec-Nox/nox-protocol-contracts#readme",
|
|
58
62
|
"repository": {
|