@crisp-e3/contracts 0.5.6 → 0.5.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.
@@ -53,6 +53,7 @@ contract CRISPProgram is IE3Program, Ownable {
53
53
  error MerkleRootAlreadySet();
54
54
  error InvalidTallyLength();
55
55
  error SlotIsEmpty();
56
+ error MerkleRootNotSet();
56
57
 
57
58
  // Events
58
59
  event InputPublished(uint256 indexed e3Id, bytes vote, uint256 index);
@@ -123,8 +124,7 @@ contract CRISPProgram is IE3Program, Ownable {
123
124
  if (!authorizedContracts[msg.sender] && msg.sender != owner()) revert CallerNotAuthorized();
124
125
 
125
126
  // We need to ensure that the CRISP admin set the merkle root of the census.
126
- // TODO: Uncomment this when we make the merkle root a public input of the circuit.
127
- // if (e3Data[e3Id].merkleRoot == 0) revert MerkleRootNotSet();
127
+ if (e3Data[e3Id].merkleRoot == 0) revert MerkleRootNotSet();
128
128
 
129
129
  if (data.length == 0) revert EmptyInputData();
130
130
 
@@ -135,12 +135,17 @@ contract CRISPProgram is IE3Program, Ownable {
135
135
  (uint40 voteIndex, bool isFirstVote) = _processVote(e3Id, slotAddress, voteBytes);
136
136
 
137
137
  // Set public inputs for the proof. Order must match Noir circuit.
138
- bytes32[] memory noirPublicInputs = new bytes32[](2 + vote.length);
138
+ bytes32[] memory noirPublicInputs = new bytes32[](4 + vote.length);
139
139
 
140
- noirPublicInputs[0] = bytes32(uint256(uint160(slotAddress)));
141
- noirPublicInputs[1] = bytes32(uint256(isFirstVote ? 1 : 0));
140
+ // Fetch E3 to get committee public key
141
+ E3 memory e3 = enclave.getE3(e3Id);
142
+
143
+ noirPublicInputs[0] = e3.committeePublicKey;
144
+ noirPublicInputs[1] = bytes32(e3Data[e3Id].merkleRoot);
145
+ noirPublicInputs[2] = bytes32(uint256(uint160(slotAddress)));
146
+ noirPublicInputs[3] = bytes32(uint256(isFirstVote ? 1 : 0));
142
147
  for (uint256 i = 0; i < vote.length; i++) {
143
- noirPublicInputs[i + 2] = vote[i];
148
+ noirPublicInputs[i + 4] = vote[i];
144
149
  }
145
150
 
146
151
  // Check if the ciphertext was encrypted correctly
@@ -7,85 +7,85 @@ pragma solidity >=0.8.21;
7
7
 
8
8
  uint256 constant N = 262144;
9
9
  uint256 constant LOG_N = 18;
10
- uint256 constant NUMBER_OF_PUBLIC_INPUTS = 2066;
11
- uint256 constant VK_HASH = 0x127b37c45dfb3a6a153382a3cf931c718810df54513b449af9ade62385eeefac;
10
+ uint256 constant NUMBER_OF_PUBLIC_INPUTS = 2068;
11
+ uint256 constant VK_HASH = 0x1ca8d8a2b64dc27e11e756a83b5efcf951b1dddf2ecb023022dcbf4ba1005de2;
12
12
  library HonkVerificationKey {
13
13
  function loadVerificationKey() internal pure returns (Honk.VerificationKey memory) {
14
14
  Honk.VerificationKey memory vk = Honk.VerificationKey({
15
15
  circuitSize: uint256(262144),
16
16
  logCircuitSize: uint256(18),
17
- publicInputsSize: uint256(2066),
17
+ publicInputsSize: uint256(2068),
18
18
  ql: Honk.G1Point({
19
- x: uint256(0x1a14a677dcf497132668b43dd6c2eba38ac0be2d8a55042e72ab0e431c1fca04),
20
- y: uint256(0x0e30a76f6ca16f79faa7f36c8541bac98823fce567367d5b05f6d1e1889d2dce)
19
+ x: uint256(0x0c3acef8966ceb2984e47121b763f16a862f3cdb33c24d4b03009a9f737408f6),
20
+ y: uint256(0x0da7bce94c82ecdbd4ae789e9753251fd8afc89d9605932b1154387a3d8c00e6)
21
21
  }),
22
22
  qr: Honk.G1Point({
23
- x: uint256(0x069b1a425a882deab8b2ab366567379d09dd9cc2430c896796c11e2e8be34fe4),
24
- y: uint256(0x2f4a270bd180719c0120936a6ca66c6097f378bb489db75e29e644716f6f9387)
23
+ x: uint256(0x2e41f2c832adad1d96df181c43ca52c717835470c7e471c087067197e33860d6),
24
+ y: uint256(0x25d16a68285523a3e9d8a42344a7489d493b8ddd51ed24b0c566651ca06eb8dc)
25
25
  }),
26
26
  qo: Honk.G1Point({
27
- x: uint256(0x24638b4ee6c5e15b721bbb29c486e913deb01588c13d0cb85da47c50c16a81e5),
28
- y: uint256(0x1bd194bdfc905dc9465a3fe4b697de6fd7d67ae421b7404b84e472c68e691e7b)
27
+ x: uint256(0x0c0e53fdc05955a112f7b1efaa77afb15271c8ee842163186bbca2a110a6deba),
28
+ y: uint256(0x05a9f03fe46a2347ef8aceb395dbc221cf4e180f63bd6e9de07cded19378fdb2)
29
29
  }),
30
30
  q4: Honk.G1Point({
31
- x: uint256(0x019d3ad6130f74a80db6a4f6480521fb87ea52247dd96de060ffa7bb04b32885),
32
- y: uint256(0x2fed009cd6974244ed643b1214943f8f48d9033e6236457ec9a601e0005ba444)
31
+ x: uint256(0x1e1cc841a9a3716e0689dca8bcc18f2b9e290bfeaef1f78c28cdcedb13f29d40),
32
+ y: uint256(0x12774484a5526ca36a7e91d0d53ec3e115321f609a662b5050ad378a024311e5)
33
33
  }),
34
34
  qm: Honk.G1Point({
35
- x: uint256(0x1aa0f6fd5c3d53ae9bc8c76ad7e015a7b3a131aee52255966082dd0584a2d867),
36
- y: uint256(0x292ea51ab60890143445fd667e86ce788e24d625225d24fe6eef31d2cb8763b4)
35
+ x: uint256(0x251c96f789fb3fc5258489bec45ec137c054966c8674132e27feeccf5a81cf25),
36
+ y: uint256(0x20491536be9bafbc08346c0a71a3ed3beffb13f2e9f092008230397a1c5fc98d)
37
37
  }),
38
38
  qc: Honk.G1Point({
39
- x: uint256(0x24cf8ec004d7a8a319a93ae7a62193e11e33cda3b072fee4cc92fbcf04e26c53),
40
- y: uint256(0x0acca02ae37ea0155238f82833cbc3727c9c10d74ae862a02b70edc2bbf53fec)
39
+ x: uint256(0x0936620bea178cd901115b75f458c8de74899315505e3e52852f668b6fd37674),
40
+ y: uint256(0x1ea7f29d26f0d4a3ecd04724b76fe410c7a30e6eb4d8e44f09c5beeaa5f78780)
41
41
  }),
42
42
  qLookup: Honk.G1Point({
43
- x: uint256(0x056cab9e0cc90d6187f1504470e987376fb9d964f5e69f79d3dc50a3aba8b070),
44
- y: uint256(0x2a0690805846bbbba0fe533d4ec11edc41678b77983bcba8f10a71ece5298fee)
43
+ x: uint256(0x21ed84b63d62aef10a8cd203641cd62f5a42825efd4807a47a4f5d006e44b6af),
44
+ y: uint256(0x306347f78166296722434632227c5ac52adfcdf24ee09169a6fb79d4258c7cca)
45
45
  }),
46
46
  qArith: Honk.G1Point({
47
- x: uint256(0x18850029d66fb7379caabfcb3d3b694c550a6413b84644f0d13b9e05554329b7),
48
- y: uint256(0x216fb14305fc176ea326c69925161a0024e25d53909f3fd0c09871be5f94f8a0)
47
+ x: uint256(0x053507710ff715cf9363741dc46cc5d686fdd09012e3ccf83a38e3f79f491bb0),
48
+ y: uint256(0x0d004c2714d1630398938e93adc23622cb4ae4ca78141a68fb9e365295650cde)
49
49
  }),
50
50
  qDeltaRange: Honk.G1Point({
51
- x: uint256(0x1faf3b8674c17daf3e0f63e7c9356cacb82450ef207412dcf21922e73850f746),
52
- y: uint256(0x07b754988b169db012bc034513ac4ee42746fe1bf233dc531af97d5bc2d0db0c)
51
+ x: uint256(0x0ddde3ce2b24613aed779dde885daa094fb9087cba224838118a08fa197139db),
52
+ y: uint256(0x0030cdcf467265124848353360e5e29839ebd846b687a512f99ae7f8a2a54490)
53
53
  }),
54
54
  qElliptic: Honk.G1Point({
55
- x: uint256(0x04788fb295f478b04078cab13188d28645677fda3a09ec788387afce8f2b5804),
56
- y: uint256(0x29194accd4f5315943071685ff9c2b02480c0bff1c21915b16dd54ec561019fb)
55
+ x: uint256(0x0214eea9bd774ccbaea3cd9753e77adb6af9bfc2c5ef210160d6af8520204de9),
56
+ y: uint256(0x0ac1443dca135c5ddc9a1c38a4323d54a554867a0db1b82b752f9416b6eb8301)
57
57
  }),
58
58
  qMemory: Honk.G1Point({
59
- x: uint256(0x0bf2ec6066d37230ae861b2473bf67d5ea2fff4fe3b1ff276c71c0edab34c040),
60
- y: uint256(0x230bbf4647507639fa136c8112d8682c34686c7d62fee9899fd8a456dc19c71b)
59
+ x: uint256(0x1cb6ea41a55bb0a307ebbbc130d80e6039a971ac4664ed84a2968b8bf2ebbf49),
60
+ y: uint256(0x0047bc403498ca5f6ed5c9d15827dcd65dae3030a28002112e1d789680eaac2e)
61
61
  }),
62
62
  qNnf: Honk.G1Point({
63
- x: uint256(0x27b6e6deb48b8f1510b8bc376c0d0998166587549833fc86d6cc9eef0ed465c5),
64
- y: uint256(0x072563066ec76ae4137df6971684a2904be8f2fef972f1f8ac9407bf41c044f6)
63
+ x: uint256(0x2c45a53bef969d29924c1585f468d78c3f81a9a2026a37029e4651b8099f61b2),
64
+ y: uint256(0x1ff421b8b79665b7ad9c598f4143d155db08e0120f2a8bdd93fae19c5c8caca8)
65
65
  }),
66
66
  qPoseidon2External: Honk.G1Point({
67
- x: uint256(0x0412d71f1f86606512556c6d48194094f6f15e108cffeb5171ac5deafcf21ba5),
68
- y: uint256(0x0d92c1ab9f5838fa6bda23289f6baab5abb7fafd2505b05412be72c98eed5784)
67
+ x: uint256(0x29a806a3d3deae47f9de89d35a3200f2f66c4b78bab19c0dfb5fe8348f669582),
68
+ y: uint256(0x0dc3b792592ccdde2d18bae94cca0e8d499814c70e8bfaeaa63dd902ea7ad008)
69
69
  }),
70
70
  qPoseidon2Internal: Honk.G1Point({
71
- x: uint256(0x03a37c8f14f04a0c47b55fc372681424912f79c3ae565a2afce81587846e00c5),
72
- y: uint256(0x0dfb3edabbbd97745fea4c569bc99dd450bad935f50610a36639cae94acddf56)
71
+ x: uint256(0x05024f6de65a4dcced2738308dbda5326cbaafad2981f8b67526eb0eb1cce144),
72
+ y: uint256(0x07ec05f2076b4369362030c2c7acbef7efca4eea33e2b13c8a5b92b02a8e34c3)
73
73
  }),
74
74
  s1: Honk.G1Point({
75
- x: uint256(0x22d479c6eca52747dcca3a59269018e74cb9dbd7a7bf4c0f3cd380d022896fea),
76
- y: uint256(0x0c3961f035d12e248dfa9f22f8ab9c6343c6c636d56ac5180334381e03f96c11)
75
+ x: uint256(0x01e80e00cc438bef1c0311d8e860d214f1f4f8c030cb97110c64fdb2dbb24f51),
76
+ y: uint256(0x17441e3965eacb1bedc71d9983aeb0558222c093f142e597fc66a0b7e9973907)
77
77
  }),
78
78
  s2: Honk.G1Point({
79
- x: uint256(0x0c5ca053933191ff3aad8b265619f6a4fe97650125d1c33d3af5513c18e3f48e),
80
- y: uint256(0x095932332027f209dc52666412aedb31121ee12d0f6ee50870d1cf8c7662b2a0)
79
+ x: uint256(0x0d4e58d4f2698d73f7d0980c9e07a20d0587292bbc97212f9f85a786e03847bc),
80
+ y: uint256(0x27d389ca0c65494fab3c321aafe3f289ad39b778b76b524fa396c6b51004f812)
81
81
  }),
82
82
  s3: Honk.G1Point({
83
- x: uint256(0x25b689112c3e1dd78e43260f40c2c6e6316b16f58fdf665ac727f9b7d423cdb7),
84
- y: uint256(0x2c9974d76ea25589eef8f777bceca914c3d7d145c5fba75413cf30120621fb86)
83
+ x: uint256(0x27e70f21603a4902a769ea6822a6c06d0715a9f39795fe18fdb6327bf41abca0),
84
+ y: uint256(0x1fedc45c7c852a9ebcb12ad5aa0a6df0c8f9576bed8a6d51ba8187b8936d4bd5)
85
85
  }),
86
86
  s4: Honk.G1Point({
87
- x: uint256(0x22ee739f9fb4fdcb29a7ed18db916919795d688ab94175ce5acb46348b0d8809),
88
- y: uint256(0x021d5b6eb780aa2015158d6039437c956079b61f8fc2c97352303458ce6f91ba)
87
+ x: uint256(0x1ff580dc873878337c5f7697ceb402342ce1b821c37d766f97cedd93b63d0359),
88
+ y: uint256(0x196d7d19376846c104f0ef472a6ed732fd243e356908ba33f6c68901ffe8ce13)
89
89
  }),
90
90
  t1: Honk.G1Point({
91
91
  x: uint256(0x1f16b037f0b4c96ea2a30a118a44e139881c0db8a4d6c9fde7db5c1c1738e61f),
@@ -104,28 +104,28 @@ library HonkVerificationKey {
104
104
  y: uint256(0x2d7e8c1ecb92e2490049b50efc811df63f1ca97e58d5e82852dbec0c29715d71)
105
105
  }),
106
106
  id1: Honk.G1Point({
107
- x: uint256(0x01b858b61eaf5d54df5361d88c410ea379acb66cff9b2280dfa9e2ec57609ed1),
108
- y: uint256(0x2f764a892dc8a7efc8f9e58b4778aa8b0b94a979a7d6231ee26311a20623d2d2)
107
+ x: uint256(0x0fc864a6c1236d620b1c09c9278c95610758a8f5fea80f681fd1587c9406ecbf),
108
+ y: uint256(0x077911571c3508dbc02c65c15ae1cb3af33b2b69fe73f460925f5c5f906fb51e)
109
109
  }),
110
110
  id2: Honk.G1Point({
111
- x: uint256(0x0ee58f929bb58de7d3e780126fcfac0943adab83776166c10b7626d2a0d04695),
112
- y: uint256(0x1ead787a8fbc072a941301774d04a4a590036e9db96de8432732592156a44f1a)
111
+ x: uint256(0x23760b478cf3aaefe6782ad269e6bed4dbad373b85cf73685b5eb77ec9498bcf),
112
+ y: uint256(0x12b6be9b4f5b3cce944a695ad7517218ffb6648ec1a74d4bd028b053a565de67)
113
113
  }),
114
114
  id3: Honk.G1Point({
115
- x: uint256(0x28628c4f0e01831a2406331bc0901948f2f2bc22200b2ce26d92558502cd3b96),
116
- y: uint256(0x16d113fc0d0188deb7bcc2148bf2066003d5d2f6b7490201570d2ba5aa9b38ea)
115
+ x: uint256(0x144205f099b5c04c0a4a51e30bf20bd5fff8a82be5eac9a059961db089cb34dc),
116
+ y: uint256(0x256a6fdb5a8a8a5dfb285dcaeefb4bf590f58900fb648ba715e465cd3f745918)
117
117
  }),
118
118
  id4: Honk.G1Point({
119
- x: uint256(0x282448418450184e943367153db43c02bd17640d2a40ed1861833b63f0cef798),
120
- y: uint256(0x2dc5b559853ab1d7bf820f393e913fe435ccf95f84f9d8740d5f99bfcc3e3cea)
119
+ x: uint256(0x1e1ea32eea4d1afcee4572ecca811099f54e90fcf09b4037f8505248cb65f2c6),
120
+ y: uint256(0x10df7dee70bc3946d428fe27811eedbe58a9a9565c9b734268e646b30aed50b8)
121
121
  }),
122
122
  lagrangeFirst: Honk.G1Point({
123
123
  x: uint256(0x0000000000000000000000000000000000000000000000000000000000000001),
124
124
  y: uint256(0x0000000000000000000000000000000000000000000000000000000000000002)
125
125
  }),
126
126
  lagrangeLast: Honk.G1Point({
127
- x: uint256(0x29b5224a64e89595783b8ed5c7d047e4d8a337cbf836ee2be2f20d7d47ce95b2),
128
- y: uint256(0x13396543d3d0ccf426d918fd2199d9507eafa2a505f0cce2d958231b29af1e66)
127
+ x: uint256(0x2e8854320df8d7e2bc104a691285ebb73e6a6aeb5834d8818ddfb90779ef7b4a),
128
+ y: uint256(0x2a1a85f62dd5371e29e46b650f9b995e91b864d6bebd1bcb0604635f5a5c4270)
129
129
  })
130
130
  });
131
131
  return vk;
@@ -11,11 +11,16 @@ import { IDecryptionVerifier } from "@enclave-e3/contracts/contracts/interfaces/
11
11
 
12
12
  contract MockEnclave {
13
13
  bytes public plaintextOutput;
14
+ bytes32 public committeePublicKey;
14
15
 
15
16
  function setPlaintextOutput(bytes memory plaintext) external {
16
17
  plaintextOutput = plaintext;
17
18
  }
18
19
 
20
+ function setCommitteePublicKey(bytes32 publicKeyHash) external {
21
+ committeePublicKey = publicKeyHash;
22
+ }
23
+
19
24
  function getE3(uint256 e3Id) external view returns (E3 memory) {
20
25
  return
21
26
  E3({
@@ -30,7 +35,7 @@ contract MockEnclave {
30
35
  e3ProgramParams: bytes(""),
31
36
  customParams: bytes(""),
32
37
  decryptionVerifier: IDecryptionVerifier(address(0)),
33
- committeePublicKey: bytes32(0),
38
+ committeePublicKey: committeePublicKey,
34
39
  ciphertextOutput: bytes32(0),
35
40
  plaintextOutput: plaintextOutput
36
41
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crisp-e3/contracts",
3
- "version": "0.5.6",
3
+ "version": "0.5.7",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "contracts",
@@ -59,8 +59,8 @@
59
59
  "typechain": "^8.3.0",
60
60
  "typescript": "5.8.3",
61
61
  "viem": "2.30.6",
62
- "@crisp-e3/sdk": "^0.5.6",
63
- "@crisp-e3/zk-inputs": "^0.5.6"
62
+ "@crisp-e3/zk-inputs": "^0.5.7",
63
+ "@crisp-e3/sdk": "^0.5.7"
64
64
  },
65
65
  "scripts": {
66
66
  "compile": "hardhat compile",