@iexec-nox/nox-protocol-contracts 0.1.0-beta.6 → 0.1.0-beta.7

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/README.md CHANGED
@@ -55,6 +55,14 @@ The default network is a local EDR simulation. For external networks, configure
55
55
  pnpm run deploy
56
56
  ```
57
57
 
58
+ ## Verify
59
+
60
+ Verify deployed contracts on Etherscan. Requires `ETHERSCAN_API_KEY`
61
+
62
+ ```bash
63
+ pnpm run verify arbitrumSepolia --network arbitrumSepolia
64
+ ```
65
+
58
66
  ## Configuration notes
59
67
 
60
68
  - Create2 salt is defined in [config/config.ts](config/config.ts).
@@ -19,6 +19,7 @@ interface INoxCompute {
19
19
  error InvalidProof(bytes proof, string reason);
20
20
  error UnsupportedType();
21
21
  error IncompatibleTypes();
22
+ error NotPubliclyDecryptable(bytes32 handle);
22
23
 
23
24
  /// Emitted when admin role is granted
24
25
  event Allowed(address indexed sender, address indexed account, bytes32 indexed handle);
@@ -268,19 +269,30 @@ interface INoxCompute {
268
269
  function plaintextToEncrypted(bytes32 value, TEEType teeType) external returns (bytes32);
269
270
 
270
271
  /**
271
- * @notice Validates a handle proof for a given owner and type.
272
+ * @notice Validates an input handle proof for a given owner and type.
272
273
  * @param handle handle to validate
273
274
  * @param owner owner of the provided handle
274
275
  * @param proof proof data
275
276
  * @param teeType expected handle type
276
277
  */
277
- function validateProof(
278
+ function validateInputProof(
278
279
  bytes32 handle,
279
280
  address owner,
280
281
  bytes calldata proof,
281
282
  TEEType teeType
282
283
  ) external;
283
284
 
285
+ /**
286
+ * @notice Validates a decryption proof issued by the gateway for a publicly decryptable handle.
287
+ * @param handle Handle to decrypt
288
+ * @param decryptionProof Serialized decryption proof (signature + decrypted value)
289
+ * @return The decrypted value (variable length)
290
+ */
291
+ function validateDecryptionProof(
292
+ bytes32 handle,
293
+ bytes calldata decryptionProof
294
+ ) external view returns (bytes memory);
295
+
284
296
  /**
285
297
  * @notice Performs an addition between two encrypted values without overflow check.
286
298
  * @param leftHandOperand Left-hand side operand handle
@@ -29,11 +29,11 @@ library Nox {
29
29
  }
30
30
  // Arbitrum Sepolia or its fork
31
31
  if (block.chainid == 421614) {
32
- return 0x5633472D35E18464CA24Ab974954fB3b1B122eA6;
32
+ return 0xE4622fbFCd0bDd482775bBf5b3e72382C0D99208;
33
33
  }
34
34
  // Local development chain
35
35
  if (block.chainid == 31337) {
36
- return 0x9cF45FFE48126380cFCC40215a1d6D7fffbffb05;
36
+ return 0x9bdef3F9fEc61eE7cDfE84BDE8398595c6E0b22d;
37
37
  }
38
38
  revert("Nox: Unsupported chain");
39
39
  }
@@ -169,7 +169,7 @@ library Nox {
169
169
  bytes calldata handleProof
170
170
  ) internal returns (ebool) {
171
171
  bytes32 handle = externalEbool.unwrap(externalHandle);
172
- _noxComputeContract().validateProof(handle, msg.sender, handleProof, TEEType.Bool);
172
+ _noxComputeContract().validateInputProof(handle, msg.sender, handleProof, TEEType.Bool);
173
173
  return ebool.wrap(handle);
174
174
  }
175
175
 
@@ -178,7 +178,7 @@ library Nox {
178
178
  bytes calldata handleProof
179
179
  ) internal returns (eaddress) {
180
180
  bytes32 handle = externalEaddress.unwrap(externalHandle);
181
- _noxComputeContract().validateProof(handle, msg.sender, handleProof, TEEType.Address);
181
+ _noxComputeContract().validateInputProof(handle, msg.sender, handleProof, TEEType.Address);
182
182
  return eaddress.wrap(handle);
183
183
  }
184
184
 
@@ -187,7 +187,7 @@ library Nox {
187
187
  bytes calldata handleProof
188
188
  ) internal returns (euint16) {
189
189
  bytes32 handle = externalEuint16.unwrap(externalHandle);
190
- _noxComputeContract().validateProof(handle, msg.sender, handleProof, TEEType.Uint16);
190
+ _noxComputeContract().validateInputProof(handle, msg.sender, handleProof, TEEType.Uint16);
191
191
  return euint16.wrap(handle);
192
192
  }
193
193
 
@@ -196,7 +196,7 @@ library Nox {
196
196
  bytes calldata handleProof
197
197
  ) internal returns (euint256) {
198
198
  bytes32 handle = externalEuint256.unwrap(externalHandle);
199
- _noxComputeContract().validateProof(handle, msg.sender, handleProof, TEEType.Uint256);
199
+ _noxComputeContract().validateInputProof(handle, msg.sender, handleProof, TEEType.Uint256);
200
200
  return euint256.wrap(handle);
201
201
  }
202
202
 
@@ -205,7 +205,7 @@ library Nox {
205
205
  bytes calldata handleProof
206
206
  ) internal returns (eint16) {
207
207
  bytes32 handle = externalEint16.unwrap(externalHandle);
208
- _noxComputeContract().validateProof(handle, msg.sender, handleProof, TEEType.Int16);
208
+ _noxComputeContract().validateInputProof(handle, msg.sender, handleProof, TEEType.Int16);
209
209
  return eint16.wrap(handle);
210
210
  }
211
211
 
@@ -214,7 +214,7 @@ library Nox {
214
214
  bytes calldata handleProof
215
215
  ) internal returns (eint256) {
216
216
  bytes32 handle = externalEint256.unwrap(externalHandle);
217
- _noxComputeContract().validateProof(handle, msg.sender, handleProof, TEEType.Int256);
217
+ _noxComputeContract().validateInputProof(handle, msg.sender, handleProof, TEEType.Int256);
218
218
  return eint256.wrap(handle);
219
219
  }
220
220
 
@@ -896,6 +896,86 @@ library Nox {
896
896
  return _noxComputeContract().isPubliclyDecryptable(eint256.unwrap(handle));
897
897
  }
898
898
 
899
+ // ============ Public decryption proof verification ============
900
+
901
+ /**
902
+ * @dev Verifies a decryption proof and returns the decrypted boolean value.
903
+ */
904
+ function publicDecrypt(ebool handle, bytes calldata decryptionProof) internal returns (bool) {
905
+ bytes memory result = _noxComputeContract().validateDecryptionProof(
906
+ ebool.unwrap(handle),
907
+ decryptionProof
908
+ );
909
+ return abi.decode(result, (bool));
910
+ }
911
+
912
+ /**
913
+ * @dev Verifies a decryption proof and returns the decrypted address value.
914
+ */
915
+ function publicDecrypt(
916
+ eaddress handle,
917
+ bytes calldata decryptionProof
918
+ ) internal returns (address) {
919
+ bytes memory result = _noxComputeContract().validateDecryptionProof(
920
+ eaddress.unwrap(handle),
921
+ decryptionProof
922
+ );
923
+ return abi.decode(result, (address));
924
+ }
925
+
926
+ /**
927
+ * @dev Verifies a decryption proof and returns the decrypted uint16 value.
928
+ */
929
+ function publicDecrypt(
930
+ euint16 handle,
931
+ bytes calldata decryptionProof
932
+ ) internal returns (uint16) {
933
+ bytes memory result = _noxComputeContract().validateDecryptionProof(
934
+ euint16.unwrap(handle),
935
+ decryptionProof
936
+ );
937
+ return abi.decode(result, (uint16));
938
+ }
939
+
940
+ /**
941
+ * @dev Verifies a decryption proof and returns the decrypted uint256 value.
942
+ */
943
+ function publicDecrypt(
944
+ euint256 handle,
945
+ bytes calldata decryptionProof
946
+ ) internal returns (uint256) {
947
+ bytes memory result = _noxComputeContract().validateDecryptionProof(
948
+ euint256.unwrap(handle),
949
+ decryptionProof
950
+ );
951
+ return abi.decode(result, (uint256));
952
+ }
953
+
954
+ /**
955
+ * @dev Verifies a decryption proof and returns the decrypted int16 value.
956
+ */
957
+ function publicDecrypt(eint16 handle, bytes calldata decryptionProof) internal returns (int16) {
958
+ bytes memory result = _noxComputeContract().validateDecryptionProof(
959
+ eint16.unwrap(handle),
960
+ decryptionProof
961
+ );
962
+ return abi.decode(result, (int16));
963
+ }
964
+
965
+ /**
966
+ * @dev Verifies a decryption proof and returns the decrypted int256 value.
967
+ */
968
+ function publicDecrypt(
969
+ eint256 handle,
970
+ bytes calldata decryptionProof
971
+ ) internal returns (int256) {
972
+ bytes memory result = _noxComputeContract().validateDecryptionProof(
973
+ eint256.unwrap(handle),
974
+ decryptionProof
975
+ );
976
+ return abi.decode(result, (int256));
977
+ }
978
+
899
979
  // ============ Private helpers ============
900
980
 
901
981
  function _assertInitialized(bytes32 handle) private pure {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iexec-nox/nox-protocol-contracts",
3
- "version": "0.1.0-beta.6",
3
+ "version": "0.1.0-beta.7",
4
4
  "description": "Nox protocol smart contracts",
5
5
  "keywords": [
6
6
  "Nox",
@@ -26,6 +26,7 @@
26
26
  "set-gateway": "pnpm hardhat run scripts/set-gateway.ts",
27
27
  "set-kms-public-key": "pnpm hardhat run scripts/set-kms-public-key.ts",
28
28
  "upgrade": "pnpm hardhat run scripts/upgrade.ts",
29
+ "verify": "pnpm hardhat ignition verify",
29
30
  "format": "pnpm prettier --write .",
30
31
  "format:check": "pnpm prettier --check ."
31
32
  },
@@ -35,16 +36,16 @@
35
36
  ]
36
37
  },
37
38
  "dependencies": {
38
- "@openzeppelin/contracts": "^5.4.0",
39
- "@openzeppelin/contracts-upgradeable": "^5.4.0",
39
+ "@openzeppelin/contracts": "^5.6.1",
40
+ "@openzeppelin/contracts-upgradeable": "^5.6.1",
40
41
  "encrypted-types": "^0.0.4"
41
42
  },
42
43
  "devDependencies": {
43
- "@nomicfoundation/hardhat-ignition": "^3.0.8",
44
+ "@nomicfoundation/hardhat-ignition": "^3.0.9",
44
45
  "@nomicfoundation/hardhat-toolbox-viem": "^5.0.2",
45
46
  "@types/node": "^22.19.13",
46
47
  "forge-std": "github:foundry-rs/forge-std#v1.9.4",
47
- "hardhat": "^3.1.10",
48
+ "hardhat": "^3.1.11",
48
49
  "husky": "^9.1.7",
49
50
  "lint-staged": "^16.3.1",
50
51
  "prettier": "^3.8.1",