@crisp-e3/contracts 0.10.0 → 0.11.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/README.md CHANGED
@@ -29,28 +29,29 @@ Local deploy is driven by **`../../crisp.dev.env`** (see
29
29
  `CRISP_PROOF_AGGREGATION_ENABLED=true`
30
30
  - `pnpm dev:up` → `scripts/crisp_deploy.sh` — sets `ENABLE_ZK_VERIFICATION` from the same file
31
31
 
32
- ### CRISP-only deploy (Enclave already deployed)
32
+ ### CRISP-only deploy (Interfold already deployed)
33
33
 
34
34
  ```bash
35
35
  pnpm deploy:contracts # production RISC0 verifier
36
- pnpm deploy:contracts:full # also deploy Enclave stack (no ZK unless ENABLE_ZK_VERIFICATION=true)
36
+ pnpm deploy:contracts:full # also deploy Interfold stack (no ZK unless ENABLE_ZK_VERIFICATION=true)
37
37
  ```
38
38
 
39
39
  ## CRISP Program
40
40
 
41
- This is the main logic of CRISP - an enclave program for secure voting.
41
+ This is the main logic of CRISP - an interfold program for secure voting.
42
42
 
43
43
  It exposes two main functions:
44
44
 
45
- - `validate` - that is called when a new E3 instance is requested on Enclave (`Enclave.request`).
46
- - `verify` - that is called when the ciphertext output is published on Enclave
47
- (`Enclave.publishCiphertextOutput`). This function ensures that the ciphertext output is valid.
45
+ - `validate` - that is called when a new E3 instance is requested on Interfold
46
+ (`Interfold.request`).
47
+ - `verify` - that is called when the ciphertext output is published on Interfold
48
+ (`Interfold.publishCiphertextOutput`). This function ensures that the ciphertext output is valid.
48
49
  CRISP uses Risc0 as the compute provider for running the FHE program, thus the proof will be a
49
50
  Risc0 proof.
50
51
  - `validateInput` - validate the input data that is submitted to the E3 instance. It is called by
51
- the Enclave contract when a new input is published (`Enclave.publishInput`). In CRISP, the data
52
- providers (the ones submitting the inputs) are the voters, and the input submitted is the vote
53
- itself. The logic checks that gating conditions are satisfied and that the ciphertext is
52
+ the Interfold contract when a new input is published (`Interfold.publishInput`). In CRISP, the
53
+ data providers (the ones submitting the inputs) are the voters, and the input submitted is the
54
+ vote itself. The logic checks that gating conditions are satisfied and that the ciphertext is
54
55
  constructed correctly using
55
- [Greco](https://github.com/gnosisguild/enclave/tree/main/circuits/crates/libs/greco). See the
56
+ [Greco](https://github.com/gnosisguild/interfold/tree/main/circuits/crates/libs/greco). See the
56
57
  Greco [paper](https://eprint.iacr.org/2024/594).
@@ -7,9 +7,9 @@ pragma solidity >=0.8.27;
7
7
 
8
8
  import { IRiscZeroVerifier } from "risc0/IRiscZeroVerifier.sol";
9
9
  import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";
10
- import { IE3Program } from "@enclave-e3/contracts/contracts/interfaces/IE3Program.sol";
11
- import { IEnclave } from "@enclave-e3/contracts/contracts/interfaces/IEnclave.sol";
12
- import { E3 } from "@enclave-e3/contracts/contracts/interfaces/IE3.sol";
10
+ import { IE3Program } from "@interfold/contracts/contracts/interfaces/IE3Program.sol";
11
+ import { IInterfold } from "@interfold/contracts/contracts/interfaces/IInterfold.sol";
12
+ import { E3 } from "@interfold/contracts/contracts/interfaces/IE3.sol";
13
13
  import { LazyIMTData, InternalLazyIMT } from "@zk-kit/lazy-imt.sol/InternalLazyIMT.sol";
14
14
  import { HonkVerifier } from "./CRISPVerifier.sol";
15
15
 
@@ -42,7 +42,7 @@ contract CRISPProgram is IE3Program, Ownable {
42
42
  /// @notice Maximum number of bits allocated for vote counts in the plaintext output per option.
43
43
  uint256 constant MAX_VOTE_BITS = 50;
44
44
  // State variables
45
- IEnclave public enclave;
45
+ IInterfold public interfold;
46
46
  IRiscZeroVerifier public risc0Verifier;
47
47
  bytes32 public imageId;
48
48
  HonkVerifier private immutable honkVerifier;
@@ -53,7 +53,7 @@ contract CRISPProgram is IE3Program, Ownable {
53
53
  // Errors
54
54
  error CallerNotAuthorized();
55
55
  error E3AlreadyInitialized();
56
- error EnclaveAddressZero();
56
+ error InterfoldAddressZero();
57
57
  error Risc0VerifierAddressZero();
58
58
  error InvalidHonkVerifier();
59
59
  error EmptyInputData();
@@ -72,16 +72,16 @@ contract CRISPProgram is IE3Program, Ownable {
72
72
  event InputPublished(uint256 indexed e3Id, bytes encryptedVote, uint256 index);
73
73
 
74
74
  /// @notice Initialize the contract, binding it to a specified RISC Zero verifier.
75
- /// @param _enclave The enclave address
75
+ /// @param _interfold The interfold address
76
76
  /// @param _risc0Verifier The RISC Zero verifier address
77
77
  /// @param _honkVerifier The honk verifier address
78
78
  /// @param _imageId The image ID for the guest program
79
- constructor(IEnclave _enclave, IRiscZeroVerifier _risc0Verifier, HonkVerifier _honkVerifier, bytes32 _imageId) Ownable(msg.sender) {
80
- if (address(_enclave) == address(0)) revert EnclaveAddressZero();
79
+ constructor(IInterfold _interfold, IRiscZeroVerifier _risc0Verifier, HonkVerifier _honkVerifier, bytes32 _imageId) Ownable(msg.sender) {
80
+ if (address(_interfold) == address(0)) revert InterfoldAddressZero();
81
81
  if (address(_risc0Verifier) == address(0)) revert Risc0VerifierAddressZero();
82
82
  if (address(_honkVerifier) == address(0)) revert InvalidHonkVerifier();
83
83
 
84
- enclave = _enclave;
84
+ interfold = _interfold;
85
85
  risc0Verifier = _risc0Verifier;
86
86
  honkVerifier = _honkVerifier;
87
87
  imageId = _imageId;
@@ -125,7 +125,7 @@ contract CRISPProgram is IE3Program, Ownable {
125
125
  bytes calldata,
126
126
  bytes calldata customParams
127
127
  ) external returns (bytes32) {
128
- if (msg.sender != address(enclave) && msg.sender != owner()) revert CallerNotAuthorized();
128
+ if (msg.sender != address(interfold) && msg.sender != owner()) revert CallerNotAuthorized();
129
129
  if (e3Data[e3Id].paramsHash != bytes32(0)) revert E3AlreadyInitialized();
130
130
 
131
131
  // decode custom params to get the number of options
@@ -147,11 +147,11 @@ contract CRISPProgram is IE3Program, Ownable {
147
147
 
148
148
  /// @inheritdoc IE3Program
149
149
  function publishInput(uint256 e3Id, bytes memory data) external {
150
- E3 memory e3 = enclave.getE3(e3Id);
150
+ E3 memory e3 = interfold.getE3(e3Id);
151
151
 
152
152
  // check that we are in the correct stage
153
- IEnclave.E3Stage stage = enclave.getE3Stage(e3Id);
154
- if (stage != IEnclave.E3Stage.KeyPublished) {
153
+ IInterfold.E3Stage stage = interfold.getE3Stage(e3Id);
154
+ if (stage != IInterfold.E3Stage.KeyPublished) {
155
155
  revert KeyNotPublished(e3Id);
156
156
  }
157
157
 
@@ -199,7 +199,7 @@ contract CRISPProgram is IE3Program, Ownable {
199
199
  /// @param e3Id The E3 program ID
200
200
  /// @return votes - an array of vote counts for each option
201
201
  function decodeTally(uint256 e3Id) public view returns (uint256[] memory votes) {
202
- E3 memory e3 = enclave.getE3(e3Id);
202
+ E3 memory e3 = interfold.getE3(e3Id);
203
203
 
204
204
  uint256 numOptions = e3Data[e3Id].numOptions;
205
205
 
@@ -5,13 +5,13 @@
5
5
  // or FITNESS FOR A PARTICULAR PURPOSE.
6
6
  pragma solidity >=0.8.27;
7
7
 
8
- import { E3 } from "@enclave-e3/contracts/contracts/interfaces/IE3.sol";
9
- import { IEnclave } from "@enclave-e3/contracts/contracts/interfaces/IEnclave.sol";
10
- import { IE3Program } from "@enclave-e3/contracts/contracts/interfaces/IE3Program.sol";
11
- import { IDecryptionVerifier } from "@enclave-e3/contracts/contracts/interfaces/IDecryptionVerifier.sol";
12
- import { IPkVerifier } from "@enclave-e3/contracts/contracts/interfaces/IPkVerifier.sol";
8
+ import { E3 } from "@interfold/contracts/contracts/interfaces/IE3.sol";
9
+ import { IInterfold } from "@interfold/contracts/contracts/interfaces/IInterfold.sol";
10
+ import { IE3Program } from "@interfold/contracts/contracts/interfaces/IE3Program.sol";
11
+ import { IDecryptionVerifier } from "@interfold/contracts/contracts/interfaces/IDecryptionVerifier.sol";
12
+ import { IPkVerifier } from "@interfold/contracts/contracts/interfaces/IPkVerifier.sol";
13
13
 
14
- contract MockEnclave {
14
+ contract MockInterfold {
15
15
  bytes public plaintextOutput;
16
16
  bytes32 public committeePublicKey;
17
17
 
@@ -22,7 +22,7 @@ contract MockEnclave {
22
22
  function request(address program) external {
23
23
  e3s[nextE3Id] = E3({
24
24
  seed: 0,
25
- committeeSize: IEnclave.CommitteeSize.Micro,
25
+ committeeSize: IInterfold.CommitteeSize.Minimum,
26
26
  requestBlock: 0,
27
27
  inputWindow: [uint256(0), uint256(0)],
28
28
  encryptionSchemeId: bytes32(0),
@@ -51,15 +51,15 @@ contract MockEnclave {
51
51
  committeePublicKey = publicKeyHash;
52
52
  }
53
53
 
54
- function getE3Stage(uint256) external view returns (IEnclave.E3Stage) {
55
- return IEnclave.E3Stage.KeyPublished;
54
+ function getE3Stage(uint256) external view returns (IInterfold.E3Stage) {
55
+ return IInterfold.E3Stage.KeyPublished;
56
56
  }
57
57
 
58
58
  function getE3(uint256) external view returns (E3 memory) {
59
59
  return
60
60
  E3({
61
61
  seed: 0,
62
- committeeSize: IEnclave.CommitteeSize.Micro,
62
+ committeeSize: IInterfold.CommitteeSize.Minimum,
63
63
  requestBlock: 0,
64
64
  inputWindow: [uint256(0), block.timestamp + 100],
65
65
  encryptionSchemeId: bytes32(0),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crisp-e3/contracts",
3
- "version": "0.10.0",
3
+ "version": "0.11.0",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "contracts",
@@ -31,19 +31,12 @@
31
31
  "@zk-kit/lazy-imt.sol": "2.0.0-beta.12",
32
32
  "poseidon-solidity": "^0.0.5",
33
33
  "solady": "^0.1.13",
34
- "@enclave-e3/contracts": "0.1.15"
34
+ "@interfold/contracts": "0.3.0"
35
35
  },
36
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
37
  "@nomicfoundation/hardhat-toolbox-mocha-ethers": "3.0.0",
42
- "@nomicfoundation/hardhat-typechain": "3",
43
- "@nomicfoundation/hardhat-verify": "^3.0.1",
44
38
  "@openzeppelin/contracts": "^5.0.2",
45
39
  "@typechain/ethers-v6": "^0.5.0",
46
- "@typechain/hardhat": "^9.0.0",
47
40
  "@types/chai": "^4.2.0",
48
41
  "@types/mocha": ">=9.1.0",
49
42
  "@types/node": "^22.18.0",
@@ -51,7 +44,7 @@
51
44
  "dotenv": "^16.4.5",
52
45
  "ethers": "^6.15.0",
53
46
  "forge-std": "github:foundry-rs/forge-std#v1.9.4",
54
- "hardhat": "^3.0.1",
47
+ "hardhat": "3.0.11",
55
48
  "hardhat-deploy": "^0.12.4",
56
49
  "hardhat-gas-reporter": "^1.0.8",
57
50
  "solidity-coverage": "^0.8.1",
@@ -59,8 +52,8 @@
59
52
  "typechain": "^8.3.0",
60
53
  "typescript": "5.8.3",
61
54
  "viem": "2.30.6",
62
- "@crisp-e3/sdk": "^0.10.0",
63
- "@crisp-e3/zk-inputs": "^0.10.0"
55
+ "@crisp-e3/zk-inputs": "^0.11.0",
56
+ "@crisp-e3/sdk": "^0.11.0"
64
57
  },
65
58
  "scripts": {
66
59
  "compile": "hardhat compile",
@@ -70,8 +63,8 @@
70
63
  "clean:deployments": "hardhat utils:clean-deployments",
71
64
  "deploy:contracts": "hardhat run deploy/deploy.ts",
72
65
  "deploy:contracts:mock": "export USE_MOCKS=true PRINT_ENV_VARS=true && pnpm deploy:contracts",
73
- "deploy:contracts:full": "export DEPLOY_ENCLAVE=true && pnpm deploy:contracts",
74
- "deploy:contracts:full:mock": "export DEPLOY_ENCLAVE=true USE_MOCKS=true PRINT_ENV_VARS=true && pnpm deploy:contracts",
66
+ "deploy:contracts:full": "export DEPLOY_INTERFOLD=true && pnpm deploy:contracts",
67
+ "deploy:contracts:full:mock": "export DEPLOY_INTERFOLD=true USE_MOCKS=true PRINT_ENV_VARS=true && pnpm deploy:contracts",
75
68
  "test": "hardhat test mocha",
76
69
  "verify": "hardhat run deploy/verify.ts",
77
70
  "updateSubmissionWindow": "hardhat ciphernode:window"