@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.
- package/contracts/CRISPProgram.sol +6 -20
- package/contracts/CRISPVerifier.sol +57 -57
- package/package.json +3 -3
|
@@ -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 =
|
|
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[](
|
|
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
|
-
|
|
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 (
|
|
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
|
-
|
|
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 =
|
|
11
|
-
uint256 constant VK_HASH =
|
|
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(
|
|
17
|
+
publicInputsSize: uint256(24),
|
|
18
18
|
ql: Honk.G1Point({
|
|
19
|
-
x: uint256(
|
|
20
|
-
y: uint256(
|
|
19
|
+
x: uint256(0x234faa9054de61d5d3d8fcd4ef8da9eea97a0ce55e726d3b661477953c4a2251),
|
|
20
|
+
y: uint256(0x2af662ee06d2565688e865a012e0eb31e8ef519568fd5f36d793db868c06014c)
|
|
21
21
|
}),
|
|
22
22
|
qr: Honk.G1Point({
|
|
23
|
-
x: uint256(
|
|
24
|
-
y: uint256(
|
|
23
|
+
x: uint256(0x1d26b28d1460c0aded9fc8d8e60240ffc1307399032de105684237ca0b3d8b2c),
|
|
24
|
+
y: uint256(0x007836bcebafb4f2826a9568bdfc09ab40cc1e45fd0033cc52c437bcdfcdc106)
|
|
25
25
|
}),
|
|
26
26
|
qo: Honk.G1Point({
|
|
27
|
-
x: uint256(
|
|
28
|
-
y: uint256(
|
|
27
|
+
x: uint256(0x270fc953cc356ce24afe388466b9face4f44e8bf34aece7d400f866a60760ca7),
|
|
28
|
+
y: uint256(0x120ceb2eb686a23b375971abdcb803f3c76ac2970092a8122e6f549c7e2cbe27)
|
|
29
29
|
}),
|
|
30
30
|
q4: Honk.G1Point({
|
|
31
|
-
x: uint256(
|
|
32
|
-
y: uint256(
|
|
31
|
+
x: uint256(0x09c27b010f18d47a875b4130a71e9414eff97027829cae3cc482d4beb1875c7b),
|
|
32
|
+
y: uint256(0x1875cc2dc5e537161fe454acbd1ce32e1240ada2d2618ce80b8481c206266ab0)
|
|
33
33
|
}),
|
|
34
34
|
qm: Honk.G1Point({
|
|
35
|
-
x: uint256(
|
|
36
|
-
y: uint256(
|
|
35
|
+
x: uint256(0x1c5987d7d41b2436961f70bcb06cc20ff10d59d6f9b2c7b28ea5180b4e15da1b),
|
|
36
|
+
y: uint256(0x18816198ba37696350121c3cfa66abefa8d6e95b867be08e85cc64d29f9d3469)
|
|
37
37
|
}),
|
|
38
38
|
qc: Honk.G1Point({
|
|
39
|
-
x: uint256(
|
|
40
|
-
y: uint256(
|
|
39
|
+
x: uint256(0x25f9f44ede97ba190b3dd793e16d74e063a47f323c6e983da6f9ab5db6beb63e),
|
|
40
|
+
y: uint256(0x1929f7a9d4a4a25ae32077714b299dccd62bac12f77da179704e3e96b422413b)
|
|
41
41
|
}),
|
|
42
42
|
qLookup: Honk.G1Point({
|
|
43
|
-
x: uint256(
|
|
44
|
-
y: uint256(
|
|
43
|
+
x: uint256(0x131342f1f7ba8c1218b01824d28190937da03bf8dea49d4d699c9a268871ea0b),
|
|
44
|
+
y: uint256(0x24bcefad8c9004741c53b103f782698c451cd5b7221b3817b3529cf1188278f3)
|
|
45
45
|
}),
|
|
46
46
|
qArith: Honk.G1Point({
|
|
47
|
-
x: uint256(
|
|
48
|
-
y: uint256(
|
|
47
|
+
x: uint256(0x2def7e188d2e52391dafd0925a06bc62de391a4b9bde443396bf561abf9c7ed4),
|
|
48
|
+
y: uint256(0x13a5a4401e3fa95d12bb1511f3836ba02cd42ca963d2a65227eb054fee5b56f2)
|
|
49
49
|
}),
|
|
50
50
|
qDeltaRange: Honk.G1Point({
|
|
51
|
-
x: uint256(
|
|
52
|
-
y: uint256(
|
|
51
|
+
x: uint256(0x1f6899527408847834b3fffc57906066244d532194aca24616ac5bc799fefc4d),
|
|
52
|
+
y: uint256(0x101c4d2ec7504ddca07f96bb8c622883452ff4fcfc3f0bf285d7b634ba14ec31)
|
|
53
53
|
}),
|
|
54
54
|
qElliptic: Honk.G1Point({
|
|
55
|
-
x: uint256(
|
|
56
|
-
y: uint256(
|
|
55
|
+
x: uint256(0x304c3aa07720dd601b93139c0c73c92ff98822bef32c92a1a3180d398aec5350),
|
|
56
|
+
y: uint256(0x0e17e55c50c8864b38040cddcc6b66f2127150658559a413d0e18704a4ca9ecd)
|
|
57
57
|
}),
|
|
58
58
|
qMemory: Honk.G1Point({
|
|
59
|
-
x: uint256(
|
|
60
|
-
y: uint256(
|
|
59
|
+
x: uint256(0x0808e64714fd19ba05ec0a47bbbee6619e6b39885fa6f6ff4d3e2866f8445423),
|
|
60
|
+
y: uint256(0x00eccd76054d02841b7474edc58580b9b48848fe1c81ac201d480a9814996dbf)
|
|
61
61
|
}),
|
|
62
62
|
qNnf: Honk.G1Point({
|
|
63
|
-
x: uint256(
|
|
64
|
-
y: uint256(
|
|
63
|
+
x: uint256(0x0482a321762ae984d3abf9fb79cb9ae9a88f642c28ab2e6c8340938549a915b4),
|
|
64
|
+
y: uint256(0x154f88d62e30be611aa186b60c7ef4a24bfb6ec54fdbe10872ebc962c79266c0)
|
|
65
65
|
}),
|
|
66
66
|
qPoseidon2External: Honk.G1Point({
|
|
67
|
-
x: uint256(
|
|
68
|
-
y: uint256(
|
|
67
|
+
x: uint256(0x190c7aa9c5916f96733c4e60c392fe92d977b896e1c087a27db64664b1923367),
|
|
68
|
+
y: uint256(0x2f98f87ac92ed3a4f0055098cad62aab7b9a2c4bd4383b37022aa323c6ea0d7a)
|
|
69
69
|
}),
|
|
70
70
|
qPoseidon2Internal: Honk.G1Point({
|
|
71
|
-
x: uint256(
|
|
72
|
-
y: uint256(
|
|
71
|
+
x: uint256(0x2e9374229e687460b00565dbd78637a12cdbd026211e59662f3ccbaba095cace),
|
|
72
|
+
y: uint256(0x2fd8240ed5842471405822c80b9a3c82e3f80fa07359f364264ac256e0756599)
|
|
73
73
|
}),
|
|
74
74
|
s1: Honk.G1Point({
|
|
75
|
-
x: uint256(
|
|
76
|
-
y: uint256(
|
|
75
|
+
x: uint256(0x01da6b0ff7e4247d584adfa0ee1c8a8f0f44ad0010d39f4a520d836192202856),
|
|
76
|
+
y: uint256(0x2eaf9744557a3b300d73fed4080e74b894296d179bcb75dd32fea66e63a02e5a)
|
|
77
77
|
}),
|
|
78
78
|
s2: Honk.G1Point({
|
|
79
|
-
x: uint256(
|
|
80
|
-
y: uint256(
|
|
79
|
+
x: uint256(0x2322e09796c58d9acfa91dcc0c4491663a901c6ce98e4855dd59f273d6b9abd2),
|
|
80
|
+
y: uint256(0x0f6d5cef8233cffdf200f1acf0b6db5526a6517eee8946f2c813b64a1627edaa)
|
|
81
81
|
}),
|
|
82
82
|
s3: Honk.G1Point({
|
|
83
|
-
x: uint256(
|
|
84
|
-
y: uint256(
|
|
83
|
+
x: uint256(0x227f46a481e3ee5cae6e9a935678ecaf85e497d8e9e3001b0d896869b4b618ae),
|
|
84
|
+
y: uint256(0x11108d549d670d953c712e9db06d38b49be83be4aace3bf51a20bbdb33f8bee9)
|
|
85
85
|
}),
|
|
86
86
|
s4: Honk.G1Point({
|
|
87
|
-
x: uint256(
|
|
88
|
-
y: uint256(
|
|
87
|
+
x: uint256(0x24859c2a41c9988e6b5699ea8fc920349ffe506399867de7731da1dd9054c30d),
|
|
88
|
+
y: uint256(0x1be6e6049fb1228ab9b3e1a87bcd102e1b758ba59f39b4bb354b1d44a32dc89f)
|
|
89
89
|
}),
|
|
90
90
|
t1: Honk.G1Point({
|
|
91
|
-
x: uint256(
|
|
92
|
-
y: uint256(
|
|
91
|
+
x: uint256(0x099e3bd5a0a00ab7fe18040105b9b395b5d8b7b4a63b05df652b0d10ef146d26),
|
|
92
|
+
y: uint256(0x0015b8d2515d76e2ccec99dcd194592129af3a637f5a622a32440f860d1e2a7f)
|
|
93
93
|
}),
|
|
94
94
|
t2: Honk.G1Point({
|
|
95
|
-
x: uint256(
|
|
96
|
-
y: uint256(
|
|
95
|
+
x: uint256(0x1b917517920bad3d8bc01c9595092a222b888108dc25d1aa450e0b4bc212c37e),
|
|
96
|
+
y: uint256(0x305e8992b148eedb22e6e992077a84482141c7ebe42000a1d58ccb74381f6d19)
|
|
97
97
|
}),
|
|
98
98
|
t3: Honk.G1Point({
|
|
99
|
-
x: uint256(
|
|
100
|
-
y: uint256(
|
|
99
|
+
x: uint256(0x061f64497996e8915722501e9e367938ed8da2375186b518c7345c60b1134b2d),
|
|
100
|
+
y: uint256(0x1b84d38339321f405ebaf6a2f830842ad3d7cb59792e11c0d2691f317fd50e6e)
|
|
101
101
|
}),
|
|
102
102
|
t4: Honk.G1Point({
|
|
103
|
-
x: uint256(
|
|
104
|
-
y: uint256(
|
|
103
|
+
x: uint256(0x043d063b130adfb37342af45d0155a28edd1a7e46c840d9c943fdf45521c64ce),
|
|
104
|
+
y: uint256(0x261522c4089330646aff96736194949330952ae74c573d1686d9cb4a00733854)
|
|
105
105
|
}),
|
|
106
106
|
id1: Honk.G1Point({
|
|
107
|
-
x: uint256(
|
|
108
|
-
y: uint256(
|
|
107
|
+
x: uint256(0x1609f3a69b11fceba44d010b8bcd36034b5264f4665c3b9d7d964693ae3f4c2e),
|
|
108
|
+
y: uint256(0x08aefcb1e6c05704d7f19526175dee32bf6db7f3780ca8e9f460727bacede468)
|
|
109
109
|
}),
|
|
110
110
|
id2: Honk.G1Point({
|
|
111
|
-
x: uint256(
|
|
112
|
-
y: uint256(
|
|
111
|
+
x: uint256(0x004e940ec86e291f968f5e1e703e8a61b39fb6d60bbbed3e72a58f230ac6c38b),
|
|
112
|
+
y: uint256(0x0ebbcea20f7ab33512246d748c0c0f8ac6b3084205cf358ab62fa4b1c83bc9d6)
|
|
113
113
|
}),
|
|
114
114
|
id3: Honk.G1Point({
|
|
115
|
-
x: uint256(
|
|
116
|
-
y: uint256(
|
|
115
|
+
x: uint256(0x216055263eda3960804d6fc3d8fb45cfb282d92f44fa31e0e42bad8656eb7131),
|
|
116
|
+
y: uint256(0x059053bf915da4d1b013b070779e1cc3de3baca4f984bfc901b23ad26d72af03)
|
|
117
117
|
}),
|
|
118
118
|
id4: Honk.G1Point({
|
|
119
|
-
x: uint256(
|
|
120
|
-
y: uint256(
|
|
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(
|
|
128
|
-
y: uint256(
|
|
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.
|
|
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.
|
|
63
|
-
"@crisp-e3/zk-inputs": "^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",
|