@crisp-e3/contracts 0.0.1-test
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.md +165 -0
- package/README.md +21 -0
- package/contracts/CRISPInputValidator.sol +107 -0
- package/contracts/CRISPInputValidatorFactory.sol +28 -0
- package/contracts/CRISPProgram.sol +151 -0
- package/contracts/CRISPVerifier.sol +1886 -0
- package/contracts/ImageID.sol +26 -0
- package/contracts/Mocks/MockCRISPInputValidator.sol +35 -0
- package/contracts/Mocks/MockRISC0Verifier.sol +18 -0
- package/contracts/Mocks/RiscZeroGroth16Verifier.sol +16 -0
- package/package.json +72 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// Copyright 2024 RISC Zero, Inc.
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
14
|
+
//
|
|
15
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
16
|
+
|
|
17
|
+
// This file is automatically generated
|
|
18
|
+
|
|
19
|
+
pragma solidity ^0.8.20;
|
|
20
|
+
|
|
21
|
+
library ImageID {
|
|
22
|
+
bytes32 public constant PROGRAM_ID =
|
|
23
|
+
bytes32(
|
|
24
|
+
0x23734b77b0f76e85623a88d7a82f24c34c94834f2501964ea123b7a2027013a2
|
|
25
|
+
);
|
|
26
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// SPDX-License-Identifier: LGPL-3.0-only
|
|
2
|
+
//
|
|
3
|
+
// This file is provided WITHOUT ANY WARRANTY;
|
|
4
|
+
// without even the implied warranty of MERCHANTABILITY
|
|
5
|
+
// or FITNESS FOR A PARTICULAR PURPOSE.
|
|
6
|
+
pragma solidity >=0.8.27;
|
|
7
|
+
|
|
8
|
+
import {IInputValidator} from "@enclave-e3/contracts/contracts/interfaces/IInputValidator.sol";
|
|
9
|
+
import {IBasePolicy} from "@excubiae/contracts/interfaces/IBasePolicy.sol";
|
|
10
|
+
import {Clone} from "@excubiae/contracts/proxy/Clone.sol";
|
|
11
|
+
import {IVerifier} from "../CRISPVerifier.sol";
|
|
12
|
+
|
|
13
|
+
/// @title MockCRISPInputValidator.
|
|
14
|
+
/// @notice Mock Enclave Input Validator
|
|
15
|
+
contract MockCRISPInputValidator is IInputValidator, Clone {
|
|
16
|
+
/// @notice The error emitted when the input data is empty.
|
|
17
|
+
error EmptyInputData();
|
|
18
|
+
|
|
19
|
+
/// @notice Initializes the contract with appended bytes data for configuration.
|
|
20
|
+
function _initialize() internal virtual override(Clone) {
|
|
21
|
+
super._initialize();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/// @notice Validates input
|
|
25
|
+
/// @param sender The account that is submitting the input.
|
|
26
|
+
/// @param data The input to be verified.
|
|
27
|
+
/// @return input The decoded, policy-approved application payload.
|
|
28
|
+
function validate(address sender, bytes memory data) external returns (bytes memory input) {
|
|
29
|
+
if (data.length == 0) revert EmptyInputData();
|
|
30
|
+
|
|
31
|
+
(,,bytes memory vote,) = abi.decode(data, (bytes, bytes32[], bytes, address));
|
|
32
|
+
|
|
33
|
+
input = vote;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// SPDX-License-Identifier: LGPL-3.0-only
|
|
2
|
+
//
|
|
3
|
+
// This file is provided WITHOUT ANY WARRANTY;
|
|
4
|
+
// without even the implied warranty of MERCHANTABILITY
|
|
5
|
+
// or FITNESS FOR A PARTICULAR PURPOSE.
|
|
6
|
+
pragma solidity ^0.8.27;
|
|
7
|
+
|
|
8
|
+
import {IRiscZeroVerifier, Receipt} from "risc0/IRiscZeroVerifier.sol";
|
|
9
|
+
|
|
10
|
+
contract MockRISC0Verifier is IRiscZeroVerifier {
|
|
11
|
+
function verify(
|
|
12
|
+
bytes calldata seal,
|
|
13
|
+
bytes32 imageId,
|
|
14
|
+
bytes32 journalDigest
|
|
15
|
+
) public view override {}
|
|
16
|
+
|
|
17
|
+
function verifyIntegrity(Receipt calldata receipt) external view override {}
|
|
18
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// SPDX-License-Identifier: LGPL-3.0-only
|
|
2
|
+
//
|
|
3
|
+
// This file is provided WITHOUT ANY WARRANTY;
|
|
4
|
+
// without even the implied warranty of MERCHANTABILITY
|
|
5
|
+
// or FITNESS FOR A PARTICULAR PURPOSE.
|
|
6
|
+
pragma solidity >=0.8.27;
|
|
7
|
+
|
|
8
|
+
import {RiscZeroGroth16Verifier as RiscZero} from "risc0/groth16/RiscZeroGroth16Verifier.sol";
|
|
9
|
+
import {ControlID} from "risc0/groth16/ControlID.sol";
|
|
10
|
+
|
|
11
|
+
contract RiscZeroGroth16Verifier is RiscZero {
|
|
12
|
+
constructor() RiscZero(
|
|
13
|
+
ControlID.CONTROL_ROOT,
|
|
14
|
+
ControlID.BN254_CONTROL_ID
|
|
15
|
+
) {}
|
|
16
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@crisp-e3/contracts",
|
|
3
|
+
"version": "0.0.1-test",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"files": [
|
|
6
|
+
"contracts",
|
|
7
|
+
"dist"
|
|
8
|
+
],
|
|
9
|
+
"exports": {
|
|
10
|
+
"./contracts/*": "./contracts/*",
|
|
11
|
+
"./types": {
|
|
12
|
+
"import": {
|
|
13
|
+
"types": "./dist/types/index.d.ts",
|
|
14
|
+
"default": "./dist/types/index.js"
|
|
15
|
+
},
|
|
16
|
+
"require": {
|
|
17
|
+
"types": "./dist/types/index.d.ts",
|
|
18
|
+
"default": "./dist/types/index.js"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"author": {
|
|
23
|
+
"name": "gnosisguild",
|
|
24
|
+
"url": "https://github.com/gnosisguild"
|
|
25
|
+
},
|
|
26
|
+
"publishConfig": {
|
|
27
|
+
"access": "public"
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@excubiae/contracts": "^0.4.0",
|
|
31
|
+
"@zk-kit/lean-imt.sol": "2.0.0",
|
|
32
|
+
"poseidon-solidity": "^0.0.5",
|
|
33
|
+
"solady": "^0.1.13",
|
|
34
|
+
"@enclave-e3/contracts": "0.1.5"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@nomicfoundation/hardhat-ethers": "4",
|
|
38
|
+
"@nomicfoundation/hardhat-ethers-chai-matchers": "^3.0.0",
|
|
39
|
+
"@nomicfoundation/hardhat-network-helpers": "3",
|
|
40
|
+
"@nomicfoundation/hardhat-toolbox": "^5.0.0",
|
|
41
|
+
"@nomicfoundation/hardhat-toolbox-mocha-ethers": "3.0.0",
|
|
42
|
+
"@nomicfoundation/hardhat-typechain": "3",
|
|
43
|
+
"@nomicfoundation/hardhat-verify": "^3.0.1",
|
|
44
|
+
"@openzeppelin/contracts": "^5.0.2",
|
|
45
|
+
"@typechain/ethers-v6": "^0.5.0",
|
|
46
|
+
"@typechain/hardhat": "^9.0.0",
|
|
47
|
+
"@types/chai": "^4.2.0",
|
|
48
|
+
"@types/mocha": ">=9.1.0",
|
|
49
|
+
"@types/node": "^22.18.0",
|
|
50
|
+
"dotenv": "^16.4.5",
|
|
51
|
+
"ethers": "^6.15.0",
|
|
52
|
+
"forge-std": "github:foundry-rs/forge-std#v1.9.4",
|
|
53
|
+
"hardhat": "^3.0.1",
|
|
54
|
+
"hardhat-deploy": "^0.12.4",
|
|
55
|
+
"hardhat-gas-reporter": "^1.0.8",
|
|
56
|
+
"solidity-coverage": "^0.8.1",
|
|
57
|
+
"ts-node": "^10.9.2",
|
|
58
|
+
"typechain": "^8.3.0",
|
|
59
|
+
"typescript": "5.8.3",
|
|
60
|
+
"viem": "2.30.6"
|
|
61
|
+
},
|
|
62
|
+
"scripts": {
|
|
63
|
+
"compile": "hardhat compile",
|
|
64
|
+
"ciphernode:add": "hardhat ciphernode:admin-add",
|
|
65
|
+
"clean:deployments": "hardhat utils:clean-deployments",
|
|
66
|
+
"deploy:contracts": "hardhat run deploy/deploy.ts",
|
|
67
|
+
"deploy:contracts:full": "export DEPLOY_ENCLAVE=true && pnpm deploy:contracts",
|
|
68
|
+
"deploy:contracts:full:mock": "export DEPLOY_ENCLAVE=true && export USE_MOCK_VERIFIER=true && export USE_MOCK_INPUT_VALIDATOR=true && pnpm deploy:contracts",
|
|
69
|
+
"test": "hardhat test tests/crisp.contracts.test.ts --network localhost",
|
|
70
|
+
"verify": "hardhat run deploy/verify.ts"
|
|
71
|
+
}
|
|
72
|
+
}
|