@crisp-e3/contracts 0.6.0 → 0.7.1

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.
@@ -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
  /// @notice The zero-knowledge verification key hash for the CRISP program.
45
- bytes32 public constant ZK_VK_HASH = 0xfbb1352f018828a2e0989e3010af055b6217b60462066ae0ce06209e22ffa8c2;
45
+ bytes32 public constant ZK_VK_HASH = 0x2e53e3285d47eebd65eb932cf6a57ecaa5e43f90b1673165715c92b78e493a9c;
46
46
 
47
47
  // State variables
48
48
  IEnclave public enclave;
@@ -181,7 +181,7 @@ contract CRISPProgram is IE3Program, Ownable {
181
181
  (uint40 voteIndex, bytes32 previousEncryptedVoteCommitment) = _processVote(e3Id, slotAddress, encryptedVoteCommitment);
182
182
 
183
183
  // Set the public inputs for the proof. Order must match Noir circuit.
184
- bytes32[] memory noirPublicInputs = new bytes32[](39);
184
+ bytes32[] memory noirPublicInputs = new bytes32[](8);
185
185
  noirPublicInputs[0] = previousEncryptedVoteCommitment;
186
186
  noirPublicInputs[1] = bytes32(e3Data[e3Id].merkleRoot);
187
187
  noirPublicInputs[2] = bytes32(uint256(uint160(slotAddress)));
@@ -189,10 +189,7 @@ contract CRISPProgram is IE3Program, Ownable {
189
189
  noirPublicInputs[4] = bytes32(e3Data[e3Id].numOptions);
190
190
  noirPublicInputs[5] = encryptedVoteCommitment;
191
191
  noirPublicInputs[6] = e3.committeePublicKey;
192
- // Insert ZK_VK_HASH as 32 separate bytes (each as bytes32), matching proof format
193
- for (uint256 i = 0; i < 32; i++) {
194
- noirPublicInputs[7 + i] = bytes32(uint256(uint8(zkKeyHash[i])));
195
- }
192
+ noirPublicInputs[7] = zkKeyHash;
196
193
 
197
194
  // Check if the ciphertext was encrypted correctly
198
195
  if (!honkVerifier.verify(noirProof, noirPublicInputs)) {
@@ -243,21 +240,10 @@ contract CRISPProgram is IE3Program, Ownable {
243
240
  /// @notice Get the slot index for a given E3 ID and slot address
244
241
  /// @param e3Id The E3 program ID
245
242
  /// @param slotAddress The slot address
246
- /// @return The slot index
247
- function getSlotIndex(uint256 e3Id, address slotAddress) external view returns (uint40) {
243
+ /// @return The slot index, or -1 if the slot is empty
244
+ function getSlotIndex(uint256 e3Id, address slotAddress) external view returns (int40) {
248
245
  uint40 storedIndexPlusOne = e3Data[e3Id].voteSlots[slotAddress];
249
- if (storedIndexPlusOne == 0) {
250
- revert SlotIsEmpty();
251
- }
252
- return storedIndexPlusOne - 1;
253
- }
254
-
255
- /// @notice Check if a slot is empty for a given E3 ID and slot address
256
- /// @param e3Id The E3 program ID
257
- /// @param slotAddress The slot address
258
- /// @return Whether the slot is empty or not
259
- function isSlotEmptyByAddress(uint256 e3Id, address slotAddress) external view returns (bool) {
260
- return e3Data[e3Id].voteSlots[slotAddress] == 0;
246
+ return int40(storedIndexPlusOne) - 1;
261
247
  }
262
248
 
263
249
  /// @inheritdoc IE3Program
@@ -7,125 +7,125 @@ pragma solidity >=0.8.21;
7
7
 
8
8
  uint256 constant N = 2097152;
9
9
  uint256 constant LOG_N = 21;
10
- uint256 constant NUMBER_OF_PUBLIC_INPUTS = 55;
11
- uint256 constant VK_HASH = 0x0ea01fb8e0ba32adb2d0ab6391f3bccb82eaf1ea55adcf5b033ea180190f11bc;
10
+ uint256 constant NUMBER_OF_PUBLIC_INPUTS = 24;
11
+ uint256 constant VK_HASH = 0x0359288034fa67d6452fb3ad06256357a05a13751a860cb9aefa1e6537bf741c;
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(2097152),
16
16
  logCircuitSize: uint256(21),
17
- publicInputsSize: uint256(55),
17
+ publicInputsSize: uint256(24),
18
18
  ql: Honk.G1Point({
19
- x: uint256(0x0b49cca46309009bcfb42f7e72925f6b8b5f102e6b6ab8825dae8a96fe3cba34),
20
- y: uint256(0x1e4d119e1991788b257fd6c8b9d701c6b4fb80dc24e6bb34489e2aa679e4369b)
19
+ x: uint256(0x234faa9054de61d5d3d8fcd4ef8da9eea97a0ce55e726d3b661477953c4a2251),
20
+ y: uint256(0x2af662ee06d2565688e865a012e0eb31e8ef519568fd5f36d793db868c06014c)
21
21
  }),
22
22
  qr: Honk.G1Point({
23
- x: uint256(0x23fcf389d77e9fb6e9f257b2a577311a62703d7746e077b8c4efe6a40bcadc1a),
24
- y: uint256(0x257e7923fabec927d96159f14fcede129348203152597db67c4ec0fe392d3038)
23
+ x: uint256(0x1d26b28d1460c0aded9fc8d8e60240ffc1307399032de105684237ca0b3d8b2c),
24
+ y: uint256(0x007836bcebafb4f2826a9568bdfc09ab40cc1e45fd0033cc52c437bcdfcdc106)
25
25
  }),
26
26
  qo: Honk.G1Point({
27
- x: uint256(0x125a3d99a31fa1f16585dfa287e82903828bb535c4b67895869f26d30b34a19b),
28
- y: uint256(0x1a76e12e46934a8183e4d3983c40a12aa645054d272c5492aa48f933b216c957)
27
+ x: uint256(0x270fc953cc356ce24afe388466b9face4f44e8bf34aece7d400f866a60760ca7),
28
+ y: uint256(0x120ceb2eb686a23b375971abdcb803f3c76ac2970092a8122e6f549c7e2cbe27)
29
29
  }),
30
30
  q4: Honk.G1Point({
31
- x: uint256(0x02717f10da28d42bd2096b5501b44c5e29a9d88ee76ad6b0e48b6d2b68dacf7d),
32
- y: uint256(0x16e4f684dddc45d91078cef3af321dc5db6ba7ea9fc527a800a0e20e5ffbd9f3)
31
+ x: uint256(0x09c27b010f18d47a875b4130a71e9414eff97027829cae3cc482d4beb1875c7b),
32
+ y: uint256(0x1875cc2dc5e537161fe454acbd1ce32e1240ada2d2618ce80b8481c206266ab0)
33
33
  }),
34
34
  qm: Honk.G1Point({
35
- x: uint256(0x0fdda6f7325628ba94b4ae2e823a1d5a1dfe18fbd1c875850ff4d7e6e2bb738a),
36
- y: uint256(0x1fcedd6727ab1f287d0a2c2e68ef08319e00352719055e9fb40a4292282e167f)
35
+ x: uint256(0x1c5987d7d41b2436961f70bcb06cc20ff10d59d6f9b2c7b28ea5180b4e15da1b),
36
+ y: uint256(0x18816198ba37696350121c3cfa66abefa8d6e95b867be08e85cc64d29f9d3469)
37
37
  }),
38
38
  qc: Honk.G1Point({
39
- x: uint256(0x06422053a8c6503244e00acc1e275c3b86a2bd7139ae666d909453b766797de2),
40
- y: uint256(0x000033f450d6a78d5841b7027366c1f40bf240dc5fbaf3a01e14aa5f047bb36c)
39
+ x: uint256(0x25f9f44ede97ba190b3dd793e16d74e063a47f323c6e983da6f9ab5db6beb63e),
40
+ y: uint256(0x1929f7a9d4a4a25ae32077714b299dccd62bac12f77da179704e3e96b422413b)
41
41
  }),
42
42
  qLookup: Honk.G1Point({
43
- x: uint256(0x285cd2008c8e9d282963405be4ac4f7733be06e27d5706a518a5902d712cae6c),
44
- y: uint256(0x2efd1ebb7f3ed30e0c96ae4d42b15d9e6cd18d906f198a67fb3cbb64c62b3cb5)
43
+ x: uint256(0x131342f1f7ba8c1218b01824d28190937da03bf8dea49d4d699c9a268871ea0b),
44
+ y: uint256(0x24bcefad8c9004741c53b103f782698c451cd5b7221b3817b3529cf1188278f3)
45
45
  }),
46
46
  qArith: Honk.G1Point({
47
- x: uint256(0x0afc885f2b56f40755a8f66743425b589f8ac283920e112dc4725a503ed69e14),
48
- y: uint256(0x0fc111111f23cb77fb579532a4c393fafc412a223f76743c98567d08a2ce8450)
47
+ x: uint256(0x2def7e188d2e52391dafd0925a06bc62de391a4b9bde443396bf561abf9c7ed4),
48
+ y: uint256(0x13a5a4401e3fa95d12bb1511f3836ba02cd42ca963d2a65227eb054fee5b56f2)
49
49
  }),
50
50
  qDeltaRange: Honk.G1Point({
51
- x: uint256(0x1968df000ac48429eb10b056a0a6dd3d1da8332b5de3724ab87547c3371ffc42),
52
- y: uint256(0x18e9cb336ca060c58b7f6051d792fc40c0b488fd9672807e10cf10eab7cacb7a)
51
+ x: uint256(0x1f6899527408847834b3fffc57906066244d532194aca24616ac5bc799fefc4d),
52
+ y: uint256(0x101c4d2ec7504ddca07f96bb8c622883452ff4fcfc3f0bf285d7b634ba14ec31)
53
53
  }),
54
54
  qElliptic: Honk.G1Point({
55
- x: uint256(0x177d1a59fab0f5281dfd02b19aa00eb945c77f91c5bd6112b8e857db9dc6b798),
56
- y: uint256(0x11b2038670e6e114f87b1d472a31cea6390f5de495febdf47237a806969fae04)
55
+ x: uint256(0x304c3aa07720dd601b93139c0c73c92ff98822bef32c92a1a3180d398aec5350),
56
+ y: uint256(0x0e17e55c50c8864b38040cddcc6b66f2127150658559a413d0e18704a4ca9ecd)
57
57
  }),
58
58
  qMemory: Honk.G1Point({
59
- x: uint256(0x02b0cec1f1b948b9e689b5b172eb85c8cd7b901c142e07df3fde5b9d74ca7414),
60
- y: uint256(0x2d84255bc631bcb170192dd095b8785369495061366530ba5c843e7a97240be9)
59
+ x: uint256(0x0808e64714fd19ba05ec0a47bbbee6619e6b39885fa6f6ff4d3e2866f8445423),
60
+ y: uint256(0x00eccd76054d02841b7474edc58580b9b48848fe1c81ac201d480a9814996dbf)
61
61
  }),
62
62
  qNnf: Honk.G1Point({
63
- x: uint256(0x053c8110bdde783ecb8ec60d71f1bd85a3bc8b43e1fe443c321a44d5692cdfc8),
64
- y: uint256(0x177969870de5b24725a64587e0cf2258988960674a6ccc722133edb3fb6768aa)
63
+ x: uint256(0x0482a321762ae984d3abf9fb79cb9ae9a88f642c28ab2e6c8340938549a915b4),
64
+ y: uint256(0x154f88d62e30be611aa186b60c7ef4a24bfb6ec54fdbe10872ebc962c79266c0)
65
65
  }),
66
66
  qPoseidon2External: Honk.G1Point({
67
- x: uint256(0x087716c4e6b28e30afa0a4b0cf49a1ee4643709464ef89e708481e9fbcb3acf4),
68
- y: uint256(0x081caf798962ce0724f2880fccebc8c2ee75ee6d0ea87d308fa91a97e4587afb)
67
+ x: uint256(0x190c7aa9c5916f96733c4e60c392fe92d977b896e1c087a27db64664b1923367),
68
+ y: uint256(0x2f98f87ac92ed3a4f0055098cad62aab7b9a2c4bd4383b37022aa323c6ea0d7a)
69
69
  }),
70
70
  qPoseidon2Internal: Honk.G1Point({
71
- x: uint256(0x1f7ab7d4ad925b2c31233ea29ba4debac639158de845f734d3d4340f84d72937),
72
- y: uint256(0x2d228dbe4b4eb9baf6d62068cb766b7fb3b44a1a3cbde58a5c40c69ff6e176d8)
71
+ x: uint256(0x2e9374229e687460b00565dbd78637a12cdbd026211e59662f3ccbaba095cace),
72
+ y: uint256(0x2fd8240ed5842471405822c80b9a3c82e3f80fa07359f364264ac256e0756599)
73
73
  }),
74
74
  s1: Honk.G1Point({
75
- x: uint256(0x2bd432c0b486d1b9a75870a420e02622eeec72f59615c9532a22c2d946f8dc03),
76
- y: uint256(0x1037cf6462b36a560256ea2c03306634ed4d87e76ea81052083700fbb1a5f8d4)
75
+ x: uint256(0x01da6b0ff7e4247d584adfa0ee1c8a8f0f44ad0010d39f4a520d836192202856),
76
+ y: uint256(0x2eaf9744557a3b300d73fed4080e74b894296d179bcb75dd32fea66e63a02e5a)
77
77
  }),
78
78
  s2: Honk.G1Point({
79
- x: uint256(0x1359c3633ccf1c39969812967b170b2592f88dbec76079f0779c4ae17f79c432),
80
- y: uint256(0x0e696f759fc6cd345418c89c3737d237bd2685d59b1843a884b2436f2a67fb97)
79
+ x: uint256(0x2322e09796c58d9acfa91dcc0c4491663a901c6ce98e4855dd59f273d6b9abd2),
80
+ y: uint256(0x0f6d5cef8233cffdf200f1acf0b6db5526a6517eee8946f2c813b64a1627edaa)
81
81
  }),
82
82
  s3: Honk.G1Point({
83
- x: uint256(0x2201b7d5413f027286a8ecebfb33c3fdac7974d241e428f2ab549bcb6b1ec379),
84
- y: uint256(0x1327e17ebdcc90f8233b838e4836974e68812dde890018ce5e59ba0bed8d4eb1)
83
+ x: uint256(0x227f46a481e3ee5cae6e9a935678ecaf85e497d8e9e3001b0d896869b4b618ae),
84
+ y: uint256(0x11108d549d670d953c712e9db06d38b49be83be4aace3bf51a20bbdb33f8bee9)
85
85
  }),
86
86
  s4: Honk.G1Point({
87
- x: uint256(0x2983325004b0f8ebfda26f1425a3fa7c780c9619a0a57b6026cebc3241233bb3),
88
- y: uint256(0x21e0b11f18c587feb26a1b0984af1b928df573b57f6e1e7430892d02eebdaf56)
87
+ x: uint256(0x24859c2a41c9988e6b5699ea8fc920349ffe506399867de7731da1dd9054c30d),
88
+ y: uint256(0x1be6e6049fb1228ab9b3e1a87bcd102e1b758ba59f39b4bb354b1d44a32dc89f)
89
89
  }),
90
90
  t1: Honk.G1Point({
91
- x: uint256(0x0bed9c3687f3524dbbb6410842f20eb0d87d1915348d97dd74ce9df8681fb03c),
92
- y: uint256(0x061cf87194c9b570a8d060c9dfed139083f2aedc80da0d97d390d72f5cc75579)
91
+ x: uint256(0x099e3bd5a0a00ab7fe18040105b9b395b5d8b7b4a63b05df652b0d10ef146d26),
92
+ y: uint256(0x0015b8d2515d76e2ccec99dcd194592129af3a637f5a622a32440f860d1e2a7f)
93
93
  }),
94
94
  t2: Honk.G1Point({
95
- x: uint256(0x0441aaeda5bb8ccbef2c72be215aacd45db72650f5a9855820447b241f57c887),
96
- y: uint256(0x27e4f80d4673c2dc9bc21386edf443e8f74d4cff7b89fb2c34c0bcca5008d9d8)
95
+ x: uint256(0x1b917517920bad3d8bc01c9595092a222b888108dc25d1aa450e0b4bc212c37e),
96
+ y: uint256(0x305e8992b148eedb22e6e992077a84482141c7ebe42000a1d58ccb74381f6d19)
97
97
  }),
98
98
  t3: Honk.G1Point({
99
- x: uint256(0x17161957b5bea1c4b6cd7dd7a0b530aae4907cffac5801fff85ba8e4c3fa3f2f),
100
- y: uint256(0x14669badaf49b0e6aaa983ac2a20378e7c5ac3b4141284ca01124c3dd33589f7)
99
+ x: uint256(0x061f64497996e8915722501e9e367938ed8da2375186b518c7345c60b1134b2d),
100
+ y: uint256(0x1b84d38339321f405ebaf6a2f830842ad3d7cb59792e11c0d2691f317fd50e6e)
101
101
  }),
102
102
  t4: Honk.G1Point({
103
- x: uint256(0x1e10d6c8482b99a03f78a2028bb33719c19bc62fa08e1d548059b139388532e6),
104
- y: uint256(0x0139852d1968d8a0c11ba44db1553094224570b77f987b01a73781e265365cea)
103
+ x: uint256(0x043d063b130adfb37342af45d0155a28edd1a7e46c840d9c943fdf45521c64ce),
104
+ y: uint256(0x261522c4089330646aff96736194949330952ae74c573d1686d9cb4a00733854)
105
105
  }),
106
106
  id1: Honk.G1Point({
107
- x: uint256(0x298881ca881438995e404581a83530c3d88dfa93485a6f29a882cdd2670e9593),
108
- y: uint256(0x2cfd5e44e0a6979145879de24261c18defe4c22e7a7a23b20b002030e675c643)
107
+ x: uint256(0x1609f3a69b11fceba44d010b8bcd36034b5264f4665c3b9d7d964693ae3f4c2e),
108
+ y: uint256(0x08aefcb1e6c05704d7f19526175dee32bf6db7f3780ca8e9f460727bacede468)
109
109
  }),
110
110
  id2: Honk.G1Point({
111
- x: uint256(0x02c16723d917f17d181a59379615e683306841760032f394cdb0b4f2903c0af7),
112
- y: uint256(0x08d4e6f0f5f23b5431a424bd364a33e83009d3dce3214c92c22e033adb02f09c)
111
+ x: uint256(0x004e940ec86e291f968f5e1e703e8a61b39fb6d60bbbed3e72a58f230ac6c38b),
112
+ y: uint256(0x0ebbcea20f7ab33512246d748c0c0f8ac6b3084205cf358ab62fa4b1c83bc9d6)
113
113
  }),
114
114
  id3: Honk.G1Point({
115
- x: uint256(0x21dc5e14e79ab4bf1244065498cc521f001630dee5a631a0ace7cc03c12afc0c),
116
- y: uint256(0x1fc77a1fc605ba6548e353b93411784ef9f79b966b676273acf37519b88a451f)
115
+ x: uint256(0x216055263eda3960804d6fc3d8fb45cfb282d92f44fa31e0e42bad8656eb7131),
116
+ y: uint256(0x059053bf915da4d1b013b070779e1cc3de3baca4f984bfc901b23ad26d72af03)
117
117
  }),
118
118
  id4: Honk.G1Point({
119
- x: uint256(0x246bd4706d80d364c95e550e7e12816e13cf5736985becd309eab4503a6a5dec),
120
- y: uint256(0x1453ed9448d07a67232a466d416620e9cb8438cc6c54225cb12acbde33d0a2a9)
119
+ x: uint256(0x2c4cc79d180f4b4ecf1afc7dc189f5e753df807f80c976640e2ab7b52c26b74e),
120
+ y: uint256(0x2e7ce37a25ad2465d6443f27b3092a5b7f1b35286959a78256ae0f1f3cea8783)
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(0x12541b65d3fa0ed265d6fa8823d60b50e7e245797410c733a497fe858346b8fd),
128
- y: uint256(0x237bf222dbadaeb345852f0bf7e93c87f7bbf30b85cacbd349d95c0f76c4e318)
127
+ x: uint256(0x2fcf4fb13521bea1bbe36d383297ec557a79c6fc506433f08590bb3ca6107c19),
128
+ y: uint256(0x0e638803c967dd3ac316ddddcfa548c998e833cba8219f3e6a11a4352ef5aa47)
129
129
  })
130
130
  });
131
131
  return vk;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crisp-e3/contracts",
3
- "version": "0.6.0",
3
+ "version": "0.7.1",
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.6.0",
63
- "@crisp-e3/zk-inputs": "^0.6.0"
62
+ "@crisp-e3/sdk": "^0.7.1",
63
+ "@crisp-e3/zk-inputs": "^0.7.1"
64
64
  },
65
65
  "scripts": {
66
66
  "compile": "hardhat compile",