@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
|
-
|
|
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[](
|
|
138
|
+
bytes32[] memory noirPublicInputs = new bytes32[](4 + vote.length);
|
|
139
139
|
|
|
140
|
-
|
|
141
|
-
|
|
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 +
|
|
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 =
|
|
11
|
-
uint256 constant VK_HASH =
|
|
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(
|
|
17
|
+
publicInputsSize: uint256(2068),
|
|
18
18
|
ql: Honk.G1Point({
|
|
19
|
-
x: uint256(
|
|
20
|
-
y: uint256(
|
|
19
|
+
x: uint256(0x0c3acef8966ceb2984e47121b763f16a862f3cdb33c24d4b03009a9f737408f6),
|
|
20
|
+
y: uint256(0x0da7bce94c82ecdbd4ae789e9753251fd8afc89d9605932b1154387a3d8c00e6)
|
|
21
21
|
}),
|
|
22
22
|
qr: Honk.G1Point({
|
|
23
|
-
x: uint256(
|
|
24
|
-
y: uint256(
|
|
23
|
+
x: uint256(0x2e41f2c832adad1d96df181c43ca52c717835470c7e471c087067197e33860d6),
|
|
24
|
+
y: uint256(0x25d16a68285523a3e9d8a42344a7489d493b8ddd51ed24b0c566651ca06eb8dc)
|
|
25
25
|
}),
|
|
26
26
|
qo: Honk.G1Point({
|
|
27
|
-
x: uint256(
|
|
28
|
-
y: uint256(
|
|
27
|
+
x: uint256(0x0c0e53fdc05955a112f7b1efaa77afb15271c8ee842163186bbca2a110a6deba),
|
|
28
|
+
y: uint256(0x05a9f03fe46a2347ef8aceb395dbc221cf4e180f63bd6e9de07cded19378fdb2)
|
|
29
29
|
}),
|
|
30
30
|
q4: Honk.G1Point({
|
|
31
|
-
x: uint256(
|
|
32
|
-
y: uint256(
|
|
31
|
+
x: uint256(0x1e1cc841a9a3716e0689dca8bcc18f2b9e290bfeaef1f78c28cdcedb13f29d40),
|
|
32
|
+
y: uint256(0x12774484a5526ca36a7e91d0d53ec3e115321f609a662b5050ad378a024311e5)
|
|
33
33
|
}),
|
|
34
34
|
qm: Honk.G1Point({
|
|
35
|
-
x: uint256(
|
|
36
|
-
y: uint256(
|
|
35
|
+
x: uint256(0x251c96f789fb3fc5258489bec45ec137c054966c8674132e27feeccf5a81cf25),
|
|
36
|
+
y: uint256(0x20491536be9bafbc08346c0a71a3ed3beffb13f2e9f092008230397a1c5fc98d)
|
|
37
37
|
}),
|
|
38
38
|
qc: Honk.G1Point({
|
|
39
|
-
x: uint256(
|
|
40
|
-
y: uint256(
|
|
39
|
+
x: uint256(0x0936620bea178cd901115b75f458c8de74899315505e3e52852f668b6fd37674),
|
|
40
|
+
y: uint256(0x1ea7f29d26f0d4a3ecd04724b76fe410c7a30e6eb4d8e44f09c5beeaa5f78780)
|
|
41
41
|
}),
|
|
42
42
|
qLookup: Honk.G1Point({
|
|
43
|
-
x: uint256(
|
|
44
|
-
y: uint256(
|
|
43
|
+
x: uint256(0x21ed84b63d62aef10a8cd203641cd62f5a42825efd4807a47a4f5d006e44b6af),
|
|
44
|
+
y: uint256(0x306347f78166296722434632227c5ac52adfcdf24ee09169a6fb79d4258c7cca)
|
|
45
45
|
}),
|
|
46
46
|
qArith: Honk.G1Point({
|
|
47
|
-
x: uint256(
|
|
48
|
-
y: uint256(
|
|
47
|
+
x: uint256(0x053507710ff715cf9363741dc46cc5d686fdd09012e3ccf83a38e3f79f491bb0),
|
|
48
|
+
y: uint256(0x0d004c2714d1630398938e93adc23622cb4ae4ca78141a68fb9e365295650cde)
|
|
49
49
|
}),
|
|
50
50
|
qDeltaRange: Honk.G1Point({
|
|
51
|
-
x: uint256(
|
|
52
|
-
y: uint256(
|
|
51
|
+
x: uint256(0x0ddde3ce2b24613aed779dde885daa094fb9087cba224838118a08fa197139db),
|
|
52
|
+
y: uint256(0x0030cdcf467265124848353360e5e29839ebd846b687a512f99ae7f8a2a54490)
|
|
53
53
|
}),
|
|
54
54
|
qElliptic: Honk.G1Point({
|
|
55
|
-
x: uint256(
|
|
56
|
-
y: uint256(
|
|
55
|
+
x: uint256(0x0214eea9bd774ccbaea3cd9753e77adb6af9bfc2c5ef210160d6af8520204de9),
|
|
56
|
+
y: uint256(0x0ac1443dca135c5ddc9a1c38a4323d54a554867a0db1b82b752f9416b6eb8301)
|
|
57
57
|
}),
|
|
58
58
|
qMemory: Honk.G1Point({
|
|
59
|
-
x: uint256(
|
|
60
|
-
y: uint256(
|
|
59
|
+
x: uint256(0x1cb6ea41a55bb0a307ebbbc130d80e6039a971ac4664ed84a2968b8bf2ebbf49),
|
|
60
|
+
y: uint256(0x0047bc403498ca5f6ed5c9d15827dcd65dae3030a28002112e1d789680eaac2e)
|
|
61
61
|
}),
|
|
62
62
|
qNnf: Honk.G1Point({
|
|
63
|
-
x: uint256(
|
|
64
|
-
y: uint256(
|
|
63
|
+
x: uint256(0x2c45a53bef969d29924c1585f468d78c3f81a9a2026a37029e4651b8099f61b2),
|
|
64
|
+
y: uint256(0x1ff421b8b79665b7ad9c598f4143d155db08e0120f2a8bdd93fae19c5c8caca8)
|
|
65
65
|
}),
|
|
66
66
|
qPoseidon2External: Honk.G1Point({
|
|
67
|
-
x: uint256(
|
|
68
|
-
y: uint256(
|
|
67
|
+
x: uint256(0x29a806a3d3deae47f9de89d35a3200f2f66c4b78bab19c0dfb5fe8348f669582),
|
|
68
|
+
y: uint256(0x0dc3b792592ccdde2d18bae94cca0e8d499814c70e8bfaeaa63dd902ea7ad008)
|
|
69
69
|
}),
|
|
70
70
|
qPoseidon2Internal: Honk.G1Point({
|
|
71
|
-
x: uint256(
|
|
72
|
-
y: uint256(
|
|
71
|
+
x: uint256(0x05024f6de65a4dcced2738308dbda5326cbaafad2981f8b67526eb0eb1cce144),
|
|
72
|
+
y: uint256(0x07ec05f2076b4369362030c2c7acbef7efca4eea33e2b13c8a5b92b02a8e34c3)
|
|
73
73
|
}),
|
|
74
74
|
s1: Honk.G1Point({
|
|
75
|
-
x: uint256(
|
|
76
|
-
y: uint256(
|
|
75
|
+
x: uint256(0x01e80e00cc438bef1c0311d8e860d214f1f4f8c030cb97110c64fdb2dbb24f51),
|
|
76
|
+
y: uint256(0x17441e3965eacb1bedc71d9983aeb0558222c093f142e597fc66a0b7e9973907)
|
|
77
77
|
}),
|
|
78
78
|
s2: Honk.G1Point({
|
|
79
|
-
x: uint256(
|
|
80
|
-
y: uint256(
|
|
79
|
+
x: uint256(0x0d4e58d4f2698d73f7d0980c9e07a20d0587292bbc97212f9f85a786e03847bc),
|
|
80
|
+
y: uint256(0x27d389ca0c65494fab3c321aafe3f289ad39b778b76b524fa396c6b51004f812)
|
|
81
81
|
}),
|
|
82
82
|
s3: Honk.G1Point({
|
|
83
|
-
x: uint256(
|
|
84
|
-
y: uint256(
|
|
83
|
+
x: uint256(0x27e70f21603a4902a769ea6822a6c06d0715a9f39795fe18fdb6327bf41abca0),
|
|
84
|
+
y: uint256(0x1fedc45c7c852a9ebcb12ad5aa0a6df0c8f9576bed8a6d51ba8187b8936d4bd5)
|
|
85
85
|
}),
|
|
86
86
|
s4: Honk.G1Point({
|
|
87
|
-
x: uint256(
|
|
88
|
-
y: uint256(
|
|
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(
|
|
108
|
-
y: uint256(
|
|
107
|
+
x: uint256(0x0fc864a6c1236d620b1c09c9278c95610758a8f5fea80f681fd1587c9406ecbf),
|
|
108
|
+
y: uint256(0x077911571c3508dbc02c65c15ae1cb3af33b2b69fe73f460925f5c5f906fb51e)
|
|
109
109
|
}),
|
|
110
110
|
id2: Honk.G1Point({
|
|
111
|
-
x: uint256(
|
|
112
|
-
y: uint256(
|
|
111
|
+
x: uint256(0x23760b478cf3aaefe6782ad269e6bed4dbad373b85cf73685b5eb77ec9498bcf),
|
|
112
|
+
y: uint256(0x12b6be9b4f5b3cce944a695ad7517218ffb6648ec1a74d4bd028b053a565de67)
|
|
113
113
|
}),
|
|
114
114
|
id3: Honk.G1Point({
|
|
115
|
-
x: uint256(
|
|
116
|
-
y: uint256(
|
|
115
|
+
x: uint256(0x144205f099b5c04c0a4a51e30bf20bd5fff8a82be5eac9a059961db089cb34dc),
|
|
116
|
+
y: uint256(0x256a6fdb5a8a8a5dfb285dcaeefb4bf590f58900fb648ba715e465cd3f745918)
|
|
117
117
|
}),
|
|
118
118
|
id4: Honk.G1Point({
|
|
119
|
-
x: uint256(
|
|
120
|
-
y: uint256(
|
|
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(
|
|
128
|
-
y: uint256(
|
|
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:
|
|
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.
|
|
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/
|
|
63
|
-
"@crisp-e3/
|
|
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",
|