@crisp-e3/contracts 0.14.0 → 0.16.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.
@@ -12,6 +12,7 @@ import { IDecryptionVerifier } from "@interfold/contracts/contracts/interfaces/I
12
12
  import { IPkVerifier } from "@interfold/contracts/contracts/interfaces/IPkVerifier.sol";
13
13
 
14
14
  contract MockInterfold {
15
+ bytes32 public constant ENCRYPTION_SCHEME_ID = keccak256("fhe.rs:BFV");
15
16
  bytes public plaintextOutput;
16
17
  bytes32 public committeePublicKey;
17
18
 
@@ -20,15 +21,25 @@ contract MockInterfold {
20
21
  mapping(uint256 => E3) public e3s;
21
22
 
22
23
  function request(address program) external {
24
+ _request(program, 2);
25
+ }
26
+
27
+ /// @notice Request an E3 with a caller-supplied option count, so tests can
28
+ /// cover tallies with more than two options.
29
+ function requestWithOptions(address program, uint256 numOptions) external {
30
+ _request(program, numOptions);
31
+ }
32
+
33
+ function _request(address program, uint256 numOptions) internal {
23
34
  e3s[nextE3Id] = E3({
24
35
  seed: 0,
25
36
  committeeSize: IInterfold.CommitteeSize.Minimum,
26
37
  requestBlock: 0,
27
38
  inputWindow: [uint256(0), uint256(0)],
28
- encryptionSchemeId: bytes32(0),
39
+ encryptionSchemeId: ENCRYPTION_SCHEME_ID,
29
40
  e3Program: IE3Program(address(0)),
30
41
  paramSet: 0, // Insecure512
31
- customParams: abi.encode(address(0), nextE3Id, 2, 0, 0),
42
+ customParams: abi.encode(address(0), nextE3Id, numOptions, 0, 0, 0),
32
43
  decryptionVerifier: IDecryptionVerifier(address(0)),
33
44
  pkVerifier: IPkVerifier(address(0)),
34
45
  committeePublicKey: committeePublicKey,
@@ -38,7 +49,7 @@ contract MockInterfold {
38
49
  ciphertextCommitment: bytes32(0)
39
50
  });
40
51
 
41
- IE3Program(program).validate(nextE3Id, 0, bytes(""), bytes(""), abi.encode(address(0), nextE3Id, 2, 0, 0));
52
+ IE3Program(program).validate(nextE3Id, 0, bytes(""), bytes(""), abi.encode(address(0), nextE3Id, numOptions, 0, 0, 0));
42
53
 
43
54
  nextE3Id++;
44
55
  }
@@ -62,10 +73,10 @@ contract MockInterfold {
62
73
  committeeSize: IInterfold.CommitteeSize.Minimum,
63
74
  requestBlock: 0,
64
75
  inputWindow: [uint256(0), block.timestamp + 100],
65
- encryptionSchemeId: bytes32(0),
76
+ encryptionSchemeId: ENCRYPTION_SCHEME_ID,
66
77
  e3Program: IE3Program(address(0)),
67
78
  paramSet: 0, // Insecure512
68
- customParams: abi.encode(address(0), 0, 2, 0, 0),
79
+ customParams: abi.encode(address(0), 0, 2, 0, 0, 0),
69
80
  decryptionVerifier: IDecryptionVerifier(address(0)),
70
81
  pkVerifier: IPkVerifier(address(0)),
71
82
  committeePublicKey: committeePublicKey,
@@ -8,7 +8,19 @@ pragma solidity ^0.8.27;
8
8
  import { IRiscZeroVerifier, Receipt } from "risc0/IRiscZeroVerifier.sol";
9
9
 
10
10
  contract MockRISC0Verifier is IRiscZeroVerifier {
11
- function verify(bytes calldata seal, bytes32 imageId, bytes32 journalDigest) public view override {}
11
+ bytes32 public expectedJournalDigest;
12
+
13
+ error UnexpectedJournalDigest(bytes32 actual, bytes32 expected);
14
+
15
+ function setExpectedJournalDigest(bytes32 journalDigest) external {
16
+ expectedJournalDigest = journalDigest;
17
+ }
18
+
19
+ function verify(bytes calldata, bytes32, bytes32 journalDigest) public view override {
20
+ if (expectedJournalDigest != bytes32(0) && journalDigest != expectedJournalDigest) {
21
+ revert UnexpectedJournalDigest(journalDigest, expectedJournalDigest);
22
+ }
23
+ }
12
24
 
13
25
  function verifyIntegrity(Receipt calldata receipt) external view override {}
14
26
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crisp-e3/contracts",
3
- "version": "0.14.0",
3
+ "version": "0.16.0",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "contracts",
@@ -31,7 +31,7 @@
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
- "@interfold/contracts": "0.4.0"
34
+ "@interfold/contracts": "0.6.0"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@nomicfoundation/hardhat-keystore": "3.0.3",
@@ -53,8 +53,8 @@
53
53
  "typechain": "^8.3.0",
54
54
  "typescript": "5.8.3",
55
55
  "viem": "2.30.6",
56
- "@crisp-e3/zk-inputs": "^0.14.0",
57
- "@crisp-e3/sdk": "^0.14.0"
56
+ "@crisp-e3/sdk": "^0.16.0",
57
+ "@crisp-e3/zk-inputs": "^0.16.0"
58
58
  },
59
59
  "scripts": {
60
60
  "compile": "hardhat compile",