@maci-protocol/domainobjs 0.0.0-ci.2653bc0
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/CHANGELOG.md +183 -0
- package/LICENSE +22 -0
- package/README.md +78 -0
- package/build/ts/ballot.d.ts +68 -0
- package/build/ts/ballot.d.ts.map +1 -0
- package/build/ts/ballot.js +120 -0
- package/build/ts/ballot.js.map +1 -0
- package/build/ts/commands/PCommand.d.ts +89 -0
- package/build/ts/commands/PCommand.d.ts.map +1 -0
- package/build/ts/commands/PCommand.js +171 -0
- package/build/ts/commands/PCommand.js.map +1 -0
- package/build/ts/commands/index.d.ts +3 -0
- package/build/ts/commands/index.d.ts.map +1 -0
- package/build/ts/commands/index.js +6 -0
- package/build/ts/commands/index.js.map +1 -0
- package/build/ts/commands/types.d.ts +21 -0
- package/build/ts/commands/types.d.ts.map +1 -0
- package/build/ts/commands/types.js +3 -0
- package/build/ts/commands/types.js.map +1 -0
- package/build/ts/constants.d.ts +6 -0
- package/build/ts/constants.d.ts.map +1 -0
- package/build/ts/constants.js +9 -0
- package/build/ts/constants.js.map +1 -0
- package/build/ts/index.d.ts +11 -0
- package/build/ts/index.d.ts.map +1 -0
- package/build/ts/index.js +26 -0
- package/build/ts/index.js.map +1 -0
- package/build/ts/keyPair.d.ts +49 -0
- package/build/ts/keyPair.d.ts.map +1 -0
- package/build/ts/keyPair.js +82 -0
- package/build/ts/keyPair.js.map +1 -0
- package/build/ts/message.d.ts +58 -0
- package/build/ts/message.d.ts.map +1 -0
- package/build/ts/message.js +78 -0
- package/build/ts/message.js.map +1 -0
- package/build/ts/privateKey.d.ts +56 -0
- package/build/ts/privateKey.d.ts.map +1 -0
- package/build/ts/privateKey.js +79 -0
- package/build/ts/privateKey.js.map +1 -0
- package/build/ts/publicKey.d.ts +89 -0
- package/build/ts/publicKey.d.ts.map +1 -0
- package/build/ts/publicKey.js +141 -0
- package/build/ts/publicKey.js.map +1 -0
- package/build/ts/stateLeaf.d.ts +83 -0
- package/build/ts/stateLeaf.d.ts.map +1 -0
- package/build/ts/stateLeaf.js +130 -0
- package/build/ts/stateLeaf.js.map +1 -0
- package/build/ts/types.d.ts +75 -0
- package/build/ts/types.d.ts.map +1 -0
- package/build/ts/types.js +3 -0
- package/build/ts/types.js.map +1 -0
- package/build/ts/verifyingKey.d.ts +57 -0
- package/build/ts/verifyingKey.d.ts.map +1 -0
- package/build/ts/verifyingKey.js +96 -0
- package/build/ts/verifyingKey.js.map +1 -0
- package/build/tsconfig.build.tsbuildinfo +1 -0
- package/package.json +55 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
+
|
|
6
|
+
## [3.0.0](https://github.com/privacy-scaling-explorations/maci/compare/v2.5.0...v3.0.0) (2025-03-28)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* voice credits per poll ([#1967](https://github.com/privacy-scaling-explorations/maci/issues/1967)) ([f59e9c3](https://github.com/privacy-scaling-explorations/maci/commit/f59e9c350133efb2fbbc37e5139addf5e34c55e6))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Miscellaneous
|
|
15
|
+
|
|
16
|
+
* **deps-dev:** bump @types/mocha from 10.0.8 to 10.0.10 ([a8b029a](https://github.com/privacy-scaling-explorations/maci/commit/a8b029a140b3bc81c639c26e049a766ce67b8886))
|
|
17
|
+
* **deps-dev:** bump @types/node from 20.17.19 to 22.13.9 ([aa7c356](https://github.com/privacy-scaling-explorations/maci/commit/aa7c356469592547f3d60c05077268267d7ea186))
|
|
18
|
+
* **deps-dev:** bump @types/node from 22.10.7 to 22.12.0 ([#2073](https://github.com/privacy-scaling-explorations/maci/issues/2073)) ([1dcb28e](https://github.com/privacy-scaling-explorations/maci/commit/1dcb28e33699ee91f9691c1073d4da0293e406c0))
|
|
19
|
+
* **deps-dev:** bump @types/node from 22.12.0 to 22.13.1 ([5f06af0](https://github.com/privacy-scaling-explorations/maci/commit/5f06af0180f522f552519529c07d2bb660fdd586))
|
|
20
|
+
* **deps-dev:** bump @types/node from 22.13.1 to 22.13.4 ([dba94f4](https://github.com/privacy-scaling-explorations/maci/commit/dba94f4fe6d405eaca655dfdc8ca01d57664b99b))
|
|
21
|
+
* **deps-dev:** bump @types/node from 22.13.9 to 22.13.10 ([#2241](https://github.com/privacy-scaling-explorations/maci/issues/2241)) ([3f50bb6](https://github.com/privacy-scaling-explorations/maci/commit/3f50bb65db4cd83b5ebe9d4fb1b7a6d650bb1c51))
|
|
22
|
+
* **deps-dev:** bump @types/node from 22.9.0 to 22.10.7 ([3e4a5ae](https://github.com/privacy-scaling-explorations/maci/commit/3e4a5ae43cc57d6ebaedeb5ce95ca6dd1c968ffe))
|
|
23
|
+
* **deps-dev:** bump mocha from 10.7.3 to 11.0.1 ([457a504](https://github.com/privacy-scaling-explorations/maci/commit/457a5048580a5460ad012b10486a65df0dacae0e))
|
|
24
|
+
* **deps-dev:** bump mocha from 10.8.2 to 11.1.0 ([f524a07](https://github.com/privacy-scaling-explorations/maci/commit/f524a07f5a3b1e94eaf6f230ecf16476f4c6810d))
|
|
25
|
+
* **deps-dev:** bump ts-mocha from 10.0.0 to 11.1.0 ([df84193](https://github.com/privacy-scaling-explorations/maci/commit/df84193a1ad0980523aba66f5b43b5a6cdd74307))
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
## [2.5.0](https://github.com/privacy-scaling-explorations/maci/compare/v2.4.0...v2.5.0) (2024-11-20)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
### Miscellaneous
|
|
33
|
+
|
|
34
|
+
* **deps-dev:** bump @types/node from 22.4.1 to 22.8.1 ([#1873](https://github.com/privacy-scaling-explorations/maci/issues/1873)) ([c1b9c0e](https://github.com/privacy-scaling-explorations/maci/commit/c1b9c0ed18eb3fae5e189dff952a8ab9dfb2f9b1))
|
|
35
|
+
* **deps-dev:** bump @types/node from 22.8.1 to 22.9.0 ([0e11e5d](https://github.com/privacy-scaling-explorations/maci/commit/0e11e5d668fed2e2168de56e87981b0edcca8cd9))
|
|
36
|
+
* **deps-dev:** bump nyc from 17.0.0 to 17.1.0 ([3dce47c](https://github.com/privacy-scaling-explorations/maci/commit/3dce47c8c2a016765ae68b48ebd38b36226b9709))
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
## [2.4.0](https://github.com/privacy-scaling-explorations/maci/compare/v2.3.0...v2.4.0) (2024-09-30)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
### Miscellaneous
|
|
44
|
+
|
|
45
|
+
* **deps-dev:** bump @types/mocha from 10.0.7 to 10.0.8 ([#1827](https://github.com/privacy-scaling-explorations/maci/issues/1827)) ([4deae8b](https://github.com/privacy-scaling-explorations/maci/commit/4deae8bb3a4ea5cf1b4ad16018186a593142adb8))
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
## [2.2.0](https://github.com/privacy-scaling-explorations/maci/compare/v2.1.0...v2.2.0) (2024-08-19)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
### Miscellaneous
|
|
53
|
+
|
|
54
|
+
* **deps-dev:** bump @types/node from 22.1.0 to 22.2.0 ([ac18985](https://github.com/privacy-scaling-explorations/maci/commit/ac189852bf6abb787736c474ad87927afaa5163c))
|
|
55
|
+
* **deps-dev:** bump @types/node from 22.2.0 to 22.4.1 ([#1779](https://github.com/privacy-scaling-explorations/maci/issues/1779)) ([4a929e0](https://github.com/privacy-scaling-explorations/maci/commit/4a929e0b9a5c4de5ac0345e742668a3400798867))
|
|
56
|
+
* **deps-dev:** bump mocha from 10.7.0 to 10.7.3 ([6ba908f](https://github.com/privacy-scaling-explorations/maci/commit/6ba908f5f78628aa6afe973b3d71ae54ff08c735))
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
## [2.0.0](https://github.com/privacy-scaling-explorations/maci/compare/v1.2.0...v2.0.0) (2024-08-06)
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
### ⚠ BREAKING CHANGES
|
|
64
|
+
|
|
65
|
+
* **topup:** No more topups
|
|
66
|
+
|
|
67
|
+
### Features
|
|
68
|
+
|
|
69
|
+
* export merge function and modify package version ([#1584](https://github.com/privacy-scaling-explorations/maci/issues/1584)) ([f6ae34a](https://github.com/privacy-scaling-explorations/maci/commit/f6ae34a3f9ea375cd5dac8f0ce8618e33509f8ad))
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
### Bug Fixes
|
|
73
|
+
|
|
74
|
+
* do not accept invalid maci keys ([9f9e858](https://github.com/privacy-scaling-explorations/maci/commit/9f9e858755a3e064f854675a678ef2fb18041fab))
|
|
75
|
+
* minor type issue for @zk-kit/eddsa-poseidon ([ee81309](https://github.com/privacy-scaling-explorations/maci/commit/ee8130924433a040a2d53b00b654f611b3b3e9c4))
|
|
76
|
+
* publish proof onchain ([e813174](https://github.com/privacy-scaling-explorations/maci/commit/e8131741b3fb5059572822c04cb61b1cbae9599d))
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
### Code Refactoring
|
|
80
|
+
|
|
81
|
+
* **topup:** remove the topup feature ([67711d4](https://github.com/privacy-scaling-explorations/maci/commit/67711d44058831302d4556f12d1972ffacede653))
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
### Miscellaneous
|
|
85
|
+
|
|
86
|
+
* bump to 1.2.2 ([e63278f](https://github.com/privacy-scaling-explorations/maci/commit/e63278f71937a1fa908ec8f4be2d43114701c134))
|
|
87
|
+
* **contracts:** add typedoc script for contracts package ([43459a0](https://github.com/privacy-scaling-explorations/maci/commit/43459a02301f102e80a709a0a722dd591e8e00ef))
|
|
88
|
+
* **deps-dev:** bump @types/mocha from 10.0.6 to 10.0.7 ([07c3480](https://github.com/privacy-scaling-explorations/maci/commit/07c3480efc40ad1d3f651b78cd7c3aaeee8d7f8a))
|
|
89
|
+
* **deps-dev:** bump @types/node from 20.11.20 to 20.11.24 ([c575eca](https://github.com/privacy-scaling-explorations/maci/commit/c575eca7c54c262764ce794a919f3b1d58d7d8e7))
|
|
90
|
+
* **deps-dev:** bump @types/node from 20.11.24 to 20.11.25 ([5eb49f9](https://github.com/privacy-scaling-explorations/maci/commit/5eb49f9090fc6db3a80ad2d63548d93430ff7645))
|
|
91
|
+
* **deps-dev:** bump @types/node from 20.11.25 to 20.11.28 ([81bebaa](https://github.com/privacy-scaling-explorations/maci/commit/81bebaa880cbc15b8c8445d412b9fc9d89580e67))
|
|
92
|
+
* **deps-dev:** bump @types/node from 20.11.28 to 20.11.30 ([5ef4420](https://github.com/privacy-scaling-explorations/maci/commit/5ef44209d16cd441067fb67201daa61cf968382d))
|
|
93
|
+
* **deps-dev:** bump @types/node from 20.11.30 to 20.12.2 ([e7c32d0](https://github.com/privacy-scaling-explorations/maci/commit/e7c32d0ddd506727f229d950239a116961bbe1a0))
|
|
94
|
+
* **deps-dev:** bump @types/node from 20.12.10 to 20.12.11 ([3019c66](https://github.com/privacy-scaling-explorations/maci/commit/3019c66eb70e54b376e9464417e073bd98d96b6a))
|
|
95
|
+
* **deps-dev:** bump @types/node from 20.12.11 to 20.12.12 ([bd0a0a5](https://github.com/privacy-scaling-explorations/maci/commit/bd0a0a5a1ec685542c2af4f6962186176d5453ba))
|
|
96
|
+
* **deps-dev:** bump @types/node from 20.12.2 to 20.12.5 ([588392f](https://github.com/privacy-scaling-explorations/maci/commit/588392f2f773addce0204f236fc26981ead1f7bb))
|
|
97
|
+
* **deps-dev:** bump @types/node from 20.12.5 to 20.12.7 ([f1b00de](https://github.com/privacy-scaling-explorations/maci/commit/f1b00deb29788e390dcecd5b1741339f96f06f73))
|
|
98
|
+
* **deps-dev:** bump @types/node from 20.12.7 to 20.12.10 ([cf5026a](https://github.com/privacy-scaling-explorations/maci/commit/cf5026a42a41c0078467fb477fdd51a2afb31e1f))
|
|
99
|
+
* **deps-dev:** bump @types/node from 20.14.10 to 20.14.11 ([01564c0](https://github.com/privacy-scaling-explorations/maci/commit/01564c0503379ca65ce90ea77fdc5ebcd9ae81c5))
|
|
100
|
+
* **deps-dev:** bump @types/node from 20.14.11 to 22.1.0 ([#1732](https://github.com/privacy-scaling-explorations/maci/issues/1732)) ([3c4b9d9](https://github.com/privacy-scaling-explorations/maci/commit/3c4b9d9c9eb7439c4ea9791e4388ff586530be50))
|
|
101
|
+
* **deps-dev:** bump @types/node from 20.14.2 to 20.14.8 ([636ac22](https://github.com/privacy-scaling-explorations/maci/commit/636ac22bd29d12e5af7f69c7dd639d0223595992))
|
|
102
|
+
* **deps-dev:** bump @types/node from 20.14.8 to 20.14.10 ([add0ce4](https://github.com/privacy-scaling-explorations/maci/commit/add0ce4e406fea4bfe2b839facc6a0a33b3fe3bf))
|
|
103
|
+
* **deps-dev:** bump mocha from 10.3.0 to 10.4.0 ([7bf5afe](https://github.com/privacy-scaling-explorations/maci/commit/7bf5afe954bcb6b34dbe7f109c9c7e8d5396f1b2))
|
|
104
|
+
* **deps-dev:** bump mocha from 10.4.0 to 10.5.0 ([e5c14cf](https://github.com/privacy-scaling-explorations/maci/commit/e5c14cf01e9b5beb6232e80345121dbb47190fd0))
|
|
105
|
+
* **deps-dev:** bump mocha from 10.5.0 to 10.6.0 ([6847bb3](https://github.com/privacy-scaling-explorations/maci/commit/6847bb374893672bf7e809fc80d124e2d874b784))
|
|
106
|
+
* **deps-dev:** bump mocha from 10.6.0 to 10.7.0 ([#1687](https://github.com/privacy-scaling-explorations/maci/issues/1687)) ([2cad35b](https://github.com/privacy-scaling-explorations/maci/commit/2cad35bab133af79f77ea9c19098d3561ba06f69))
|
|
107
|
+
* **deps-dev:** bump nyc from 15.1.0 to 17.0.0 ([c7f4414](https://github.com/privacy-scaling-explorations/maci/commit/c7f441417d7c7ec8019867801b77e7b5c07c2307))
|
|
108
|
+
* **dev-deps:** bump docusaurus packages to 3.4.0 ([b2c5568](https://github.com/privacy-scaling-explorations/maci/commit/b2c5568ea21d494075bc2bd8908820583e73a07f))
|
|
109
|
+
* **release:** publish 1.2.1 ([93564f8](https://github.com/privacy-scaling-explorations/maci/commit/93564f8a98baa0fee65db16e2e40209d9ac1b3ae))
|
|
110
|
+
* **release:** publish 2.0.0 ([04e647d](https://github.com/privacy-scaling-explorations/maci/commit/04e647d231df34952569ad6ff802e0b2333eb658))
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
## [1.2.0](https://github.com/privacy-scaling-explorations/maci/compare/v1.1.1...v1.2.0) (2024-02-23)
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
### Features
|
|
118
|
+
|
|
119
|
+
* update sidebar ([6206a1b](https://github.com/privacy-scaling-explorations/maci/commit/6206a1b8849108d78997e00b01c6e7f11efce124))
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
### Bug Fixes
|
|
123
|
+
|
|
124
|
+
* **circuits:** enforce use of stateIndex from message ([510e6ee](https://github.com/privacy-scaling-explorations/maci/commit/510e6ee365958e8c7f72cfca6cea75d15a89d28b))
|
|
125
|
+
* **publish:** ensure we publish the correct files ([bc42724](https://github.com/privacy-scaling-explorations/maci/commit/bc42724b34cf0c047c5692fbf477ed013a102aee))
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
### Code Refactoring
|
|
129
|
+
|
|
130
|
+
* **circuits:** fix ts types, improve docs ([a849486](https://github.com/privacy-scaling-explorations/maci/commit/a84948685d2e4be426cef50c5c608c107b5142b1))
|
|
131
|
+
* **crypto:** modify genPrivKey to generate a random seed vs a babyjubjub compatible value ([0f1e9ba](https://github.com/privacy-scaling-explorations/maci/commit/0f1e9bad81a872e67a09e6912beb48784cc19a4b))
|
|
132
|
+
* **crypto:** remove ffjavascript and implement utils functions locally ([0b2986f](https://github.com/privacy-scaling-explorations/maci/commit/0b2986fcaadbfce37ff9fc0007ddeae97573924e)), closes [#458](https://github.com/privacy-scaling-explorations/maci/issues/458)
|
|
133
|
+
* fix ESLint issues ([6c0ed97](https://github.com/privacy-scaling-explorations/maci/commit/6c0ed97c0976a81b5e5506699d550ec93a553cb8))
|
|
134
|
+
* **zk-kit-poseidon:** remove old circomlib dependencies in crypto ([0340f79](https://github.com/privacy-scaling-explorations/maci/commit/0340f7960a2214410d8885541ac542419a980a34))
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
### Miscellaneous
|
|
138
|
+
|
|
139
|
+
* add a badges to README.md ([888524b](https://github.com/privacy-scaling-explorations/maci/commit/888524baae82d56edbf0c794e587de174906c34c))
|
|
140
|
+
* add types check ([69f038f](https://github.com/privacy-scaling-explorations/maci/commit/69f038f55e6c740d43b8b5376db999bcf92de845))
|
|
141
|
+
* apply prettier ([8b905c0](https://github.com/privacy-scaling-explorations/maci/commit/8b905c0948d4a1f950653c6812067ec98ebfcbc8))
|
|
142
|
+
* bundle size optimizations ([18da49c](https://github.com/privacy-scaling-explorations/maci/commit/18da49c791e53350158659df8248d48af8e80f6d))
|
|
143
|
+
* **changelog:** add CHANGELOG of v1.1.1 ([f0c315a](https://github.com/privacy-scaling-explorations/maci/commit/f0c315a4c1b86f88839f2dbe4c4b9f59193f7be4))
|
|
144
|
+
* **circuits:** refactor and add tests for the circom circuits ([4d6419b](https://github.com/privacy-scaling-explorations/maci/commit/4d6419b4962af6e94929721a3008406b6bc29c1e))
|
|
145
|
+
* **cli:** optimize bundle size ([39268b2](https://github.com/privacy-scaling-explorations/maci/commit/39268b2ff8e0d27d062c6d3bc52a63ce8038ec5e))
|
|
146
|
+
* **cli:** reorganize e2e tests and add more tests for cli commands ([6000227](https://github.com/privacy-scaling-explorations/maci/commit/6000227231bee3917686b64685c14ca329fcf38b))
|
|
147
|
+
* **contract:** apply linter for deploy scripts and contracts ([9af9c04](https://github.com/privacy-scaling-explorations/maci/commit/9af9c0497a2491eaf89fbff475cf0f60bc04f59c))
|
|
148
|
+
* **coverage:** setup coverage for TS packages ([f4e6964](https://github.com/privacy-scaling-explorations/maci/commit/f4e6964b3e268e4d3f2819b85e6abf3e34bcb10e))
|
|
149
|
+
* **dependencies:** update project dependencies and remove redundant ones ([4c5ac27](https://github.com/privacy-scaling-explorations/maci/commit/4c5ac27767492c9867a6e2ab2acd6b10fe132847))
|
|
150
|
+
* **deps-dev:** bump @types/node from 18.19.6 to 20.10.8 ([6645120](https://github.com/privacy-scaling-explorations/maci/commit/664512038212d36d40799e8c4787847735bd7d82))
|
|
151
|
+
* **deps-dev:** bump @types/node from 20.10.8 to 20.11.0 ([805d253](https://github.com/privacy-scaling-explorations/maci/commit/805d2536a54478c51403362419ecad0b6ab736a7))
|
|
152
|
+
* **deps-dev:** bump @types/node from 20.11.0 to 20.11.2 ([45839e8](https://github.com/privacy-scaling-explorations/maci/commit/45839e8c2668ec56ea06221758605f88029ea8a1))
|
|
153
|
+
* **deps-dev:** bump @types/node from 20.11.10 to 20.11.16 ([8144919](https://github.com/privacy-scaling-explorations/maci/commit/8144919939f7d9a841eb6fce7182628cedbf8746))
|
|
154
|
+
* **deps-dev:** bump @types/node from 20.11.16 to 20.11.17 ([44de5db](https://github.com/privacy-scaling-explorations/maci/commit/44de5db0c25a5fdfd5c13c397f49edb7185bf1f5))
|
|
155
|
+
* **deps-dev:** bump @types/node from 20.11.17 to 20.11.19 ([8d86b32](https://github.com/privacy-scaling-explorations/maci/commit/8d86b32ef70b89f4239aad3903fd36937cf6a90f))
|
|
156
|
+
* **deps-dev:** bump @types/node from 20.11.2 to 20.11.5 ([7698ede](https://github.com/privacy-scaling-explorations/maci/commit/7698edef2b95bc017e54c1fc0d796ccc9da3de85))
|
|
157
|
+
* **deps-dev:** bump @types/node from 20.11.5 to 20.11.10 ([a2c445a](https://github.com/privacy-scaling-explorations/maci/commit/a2c445a295e792e421f6c1537b2b21f8a7648683))
|
|
158
|
+
* **deps-dev:** bump lerna from 6.6.2 to 8.0.2 ([4b150ad](https://github.com/privacy-scaling-explorations/maci/commit/4b150ade7c4fbaf88eb0e1f629cec6749377706d))
|
|
159
|
+
* **deps-dev:** bump mocha from 10.2.0 to 10.3.0 ([2b76e04](https://github.com/privacy-scaling-explorations/maci/commit/2b76e0445f5da5864a335352f66eac33c070ab29))
|
|
160
|
+
* **domainobjs:** apply linter rules and fixes ([6649ca6](https://github.com/privacy-scaling-explorations/maci/commit/6649ca6d2afc83cfec60008fa6314add1cd837cd))
|
|
161
|
+
* **domainobjs:** implement unit tests for the domainobjs package ([c19d1d3](https://github.com/privacy-scaling-explorations/maci/commit/c19d1d3b6652d306e5ae7f4083eb20c4832c1233))
|
|
162
|
+
* linter ([42ea4f0](https://github.com/privacy-scaling-explorations/maci/commit/42ea4f0ae8b342f6bd5ca5ac86f1bdd143978324))
|
|
163
|
+
* linter unification ([61a8bcd](https://github.com/privacy-scaling-explorations/maci/commit/61a8bcd915fd3e4b4da3c00d40704d892c02f51b))
|
|
164
|
+
* **publishing:** remove bash script for empty ballot roots contract ([025287c](https://github.com/privacy-scaling-explorations/maci/commit/025287c778547e0acb1582532f3412e022cca6fa))
|
|
165
|
+
* **release:** publish 1.1.2 ([10b3a85](https://github.com/privacy-scaling-explorations/maci/commit/10b3a85cc9b53c0fc1ccdf54221a48ec8d6efe0d))
|
|
166
|
+
* remove `gitHead` field from package.json ([d38ba71](https://github.com/privacy-scaling-explorations/maci/commit/d38ba71301469f350b3d80eab5bf94e779dda9cc))
|
|
167
|
+
* run prettier ([d09cd0e](https://github.com/privacy-scaling-explorations/maci/commit/d09cd0e01ac747245307ceec5343d9ed30d7a6f0))
|
|
168
|
+
* run prettier fix after bumping version ([e1f85a5](https://github.com/privacy-scaling-explorations/maci/commit/e1f85a53bbb72696b6998af5406748fd18df4701))
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
## [1.1.2](https://github.com/gurrpi/maci/compare/v1.1.1...v1.1.2) (2023-01-19)
|
|
173
|
+
|
|
174
|
+
### Miscellaneous
|
|
175
|
+
|
|
176
|
+
- add a badges to README.md ([888524b](https://github.com/gurrpi/maci/commit/888524baae82d56edbf0c794e587de174906c34c))
|
|
177
|
+
- **changelog:** add CHANGELOG of v1.1.1 ([ea1f0ca](https://github.com/gurrpi/maci/commit/ea1f0ca93f1618df0ba046f1f01b2abad57e0ee1))
|
|
178
|
+
|
|
179
|
+
## [1.1.1](https://github.com/gurrpi/maci/compare/v1.1.0...v1.1.1) (2022-12-03)
|
|
180
|
+
|
|
181
|
+
### Bug Fixes
|
|
182
|
+
|
|
183
|
+
- **maci:** upgraded minor version and fixed bug in testnet deployment ([5ef5ed8](https://github.com/gurrpi/maci/commit/5ef5ed842360277ac823c6919e171d0c51ff5702)), closes [#551](https://github.com/gurrpi/maci/issues/551) [#552](https://github.com/gurrpi/maci/issues/552)
|
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 Barry WhiteHat, Kendrick Tan, Kobi Gurkan, Kirill Goncharov
|
|
4
|
+
Cory Dickson, Han Jian, Chih-Cheng Liang, and Koh Wei Jie
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# maci-domainobjs
|
|
2
|
+
|
|
3
|
+
[![NPM Package][domainobjs-npm-badge]][domainobjs-npm-link]
|
|
4
|
+
[![Actions Status][domainobjs-actions-badge]][domainobjs-actions-link]
|
|
5
|
+
|
|
6
|
+
This module implements domain objects. A domain object is:
|
|
7
|
+
|
|
8
|
+
> a logical container of purely domain information, usually representing a
|
|
9
|
+
> logical entity in the problem domain space
|
|
10
|
+
|
|
11
|
+
https://wiki.c2.com/?DomainObject
|
|
12
|
+
|
|
13
|
+
In effect, domain objects are representations of objects shared between other
|
|
14
|
+
modules in this codebase. They also encapsulate helper functions which make it
|
|
15
|
+
easy to use them with said modules.
|
|
16
|
+
|
|
17
|
+
## `PrivKey`
|
|
18
|
+
|
|
19
|
+
A private key. Provides helper functions to do with passing it into a circuit
|
|
20
|
+
in the right format, serialisation and deserialisation, and deep copying.
|
|
21
|
+
|
|
22
|
+
This is a MACI private key, which is not to be confused with an Ethereum private key.
|
|
23
|
+
A serialized MACI private key is prefixed by 'macisk.'
|
|
24
|
+
A raw MACI private key can be thought as a point on the baby jubjub curve.
|
|
25
|
+
|
|
26
|
+
## `PubKey`
|
|
27
|
+
|
|
28
|
+
A public key. Provides helper functions to do with passing it into a contract
|
|
29
|
+
function or circuit in the right format, hashing, serialisation and
|
|
30
|
+
deserialisation, and deep copying.
|
|
31
|
+
|
|
32
|
+
This is a MACI public key, which is not to be confused with an Ethereum public key. A serialized MACI public key is prefixed by 'macipk.' A raw MACI public key can be thought as a pair of BigIntegers (x, y) representing a point on the baby jubjub curve.
|
|
33
|
+
|
|
34
|
+
## `Keypair`
|
|
35
|
+
|
|
36
|
+
Encapsulates a `PrivKey` and `PubKey`. Also provides `genEcdhSharedKey` which
|
|
37
|
+
generates an ECDH shared key from a public key and a private key.
|
|
38
|
+
|
|
39
|
+
This is a MACI keypair, which is not to be confused with an Ethereum keypair.
|
|
40
|
+
A MACI keypair is comprised of a MACI public key and a MACI private key
|
|
41
|
+
|
|
42
|
+
## `Command`
|
|
43
|
+
|
|
44
|
+
The `Command` domain object represents a request by a user to cast a vote
|
|
45
|
+
and/or change one's public key.
|
|
46
|
+
|
|
47
|
+
## `Message`
|
|
48
|
+
|
|
49
|
+
The `Message` domain object is an encrypted `Command` and signature. That is, a
|
|
50
|
+
`Message` is a `Ciphertext` (defined in `maci-crypto`)
|
|
51
|
+
which is the encrypted `Command` and its `Signature` (also defined in
|
|
52
|
+
`maci-crypto`). In other terms:
|
|
53
|
+
|
|
54
|
+
```
|
|
55
|
+
Message = Encrypt([Command, Signature], Key)
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## `Ballot`
|
|
59
|
+
|
|
60
|
+
Represents a User's votes in a Poll, as well as their next valid nonce.
|
|
61
|
+
|
|
62
|
+
## `StateLeaf`
|
|
63
|
+
|
|
64
|
+
Represents a leaf in the state tree, which maps public keys to voice credit
|
|
65
|
+
balances, as well as the timestamp at which it was inserted.
|
|
66
|
+
|
|
67
|
+
## `VerifyingKey`
|
|
68
|
+
|
|
69
|
+
Encapsulates a Groth16 zk-SNARK verifying key.
|
|
70
|
+
|
|
71
|
+
## `Proof`
|
|
72
|
+
|
|
73
|
+
Encapsulates a Groth16 zk-SNARK proof.
|
|
74
|
+
|
|
75
|
+
[domainobjs-npm-badge]: https://img.shields.io/npm/v/maci-domainobjs.svg
|
|
76
|
+
[domainobjs-npm-link]: https://www.npmjs.com/package/maci-domainobjs
|
|
77
|
+
[domainobjs-actions-badge]: https://github.com/privacy-scaling-explorations/maci/actions/workflows/domainobjs-build.yml/badge.svg
|
|
78
|
+
[domainobjs-actions-link]: https://github.com/privacy-scaling-explorations/maci/actions?query=workflow%3Adomainobjs
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { IJsonBallot } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* A Ballot represents a User's votes in a Poll, as well as their next valid
|
|
4
|
+
* nonce.
|
|
5
|
+
*/
|
|
6
|
+
export declare class Ballot {
|
|
7
|
+
votes: bigint[];
|
|
8
|
+
nonce: bigint;
|
|
9
|
+
voteOptionTreeDepth: number;
|
|
10
|
+
/**
|
|
11
|
+
* Create a new Ballot instance
|
|
12
|
+
* @param _numVoteOptions How many vote options are available in the poll
|
|
13
|
+
* @param _voteOptionTreeDepth The depth of the merkle tree holding the vote options
|
|
14
|
+
*/
|
|
15
|
+
constructor(_numVoteOptions: number, _voteOptionTreeDepth: number);
|
|
16
|
+
/**
|
|
17
|
+
* Generate an hash of this ballot
|
|
18
|
+
* @returns The hash of the ballot
|
|
19
|
+
*/
|
|
20
|
+
hash: () => bigint;
|
|
21
|
+
/**
|
|
22
|
+
* Convert in a format suitable for the circuit
|
|
23
|
+
* @returns the ballot as a BigInt array
|
|
24
|
+
*/
|
|
25
|
+
asCircuitInputs: () => bigint[];
|
|
26
|
+
/**
|
|
27
|
+
* Convert in a an array of bigints
|
|
28
|
+
* @notice this is the nonce and the root of the vote option tree
|
|
29
|
+
* @returns the ballot as a bigint array
|
|
30
|
+
*/
|
|
31
|
+
asArray: () => bigint[];
|
|
32
|
+
/**
|
|
33
|
+
* Create a deep clone of this Ballot
|
|
34
|
+
* @returns a copy of the ballot
|
|
35
|
+
*/
|
|
36
|
+
copy: () => Ballot;
|
|
37
|
+
/**
|
|
38
|
+
* Check if two ballots are equal (same votes and same nonce)
|
|
39
|
+
* @param b - The ballot to compare with
|
|
40
|
+
* @returns whether the two ballots are equal
|
|
41
|
+
*/
|
|
42
|
+
equals(b: Ballot): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Generate a random ballot
|
|
45
|
+
* @param numVoteOptions How many vote options are available
|
|
46
|
+
* @param voteOptionTreeDepth How deep is the merkle tree holding the vote options
|
|
47
|
+
* @returns a random Ballot
|
|
48
|
+
*/
|
|
49
|
+
static genRandomBallot(numVoteOptions: number, voteOptionTreeDepth: number): Ballot;
|
|
50
|
+
/**
|
|
51
|
+
* Generate a blank ballot
|
|
52
|
+
* @param numVoteOptions How many vote options are available
|
|
53
|
+
* @param voteOptionTreeDepth How deep is the merkle tree holding the vote options
|
|
54
|
+
* @returns a Blank Ballot object
|
|
55
|
+
*/
|
|
56
|
+
static genBlankBallot(numVoteOptions: number, voteOptionTreeDepth: number): Ballot;
|
|
57
|
+
/**
|
|
58
|
+
* Serialize to a JSON object
|
|
59
|
+
*/
|
|
60
|
+
toJSON(): IJsonBallot;
|
|
61
|
+
/**
|
|
62
|
+
* Deserialize into a Ballot instance
|
|
63
|
+
* @param json - the json representation
|
|
64
|
+
* @returns the deserialized object as a Ballot instance
|
|
65
|
+
*/
|
|
66
|
+
static fromJSON(json: IJsonBallot): Ballot;
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=ballot.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ballot.d.ts","sourceRoot":"","sources":["../../ts/ballot.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C;;;GAGG;AACH,qBAAa,MAAM;IACjB,KAAK,EAAE,MAAM,EAAE,CAAM;IAErB,KAAK,SAAa;IAElB,mBAAmB,EAAE,MAAM,CAAC;IAE5B;;;;OAIG;gBACS,eAAe,EAAE,MAAM,EAAE,oBAAoB,EAAE,MAAM;IASjE;;;OAGG;IACH,IAAI,QAAO,MAAM,CAGf;IAEF;;;OAGG;IACH,eAAe,QAAO,MAAM,EAAE,CAAmB;IAEjD;;;;OAIG;IACH,OAAO,QAAO,MAAM,EAAE,CAUpB;IAEF;;;OAGG;IACH,IAAI,QAAO,MAAM,CAMf;IAEF;;;;OAIG;IACH,MAAM,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO;IAK1B;;;;;OAKG;IACH,MAAM,CAAC,eAAe,CAAC,cAAc,EAAE,MAAM,EAAE,mBAAmB,EAAE,MAAM,GAAG,MAAM;IAMnF;;;;;OAKG;IACH,MAAM,CAAC,cAAc,CAAC,cAAc,EAAE,MAAM,EAAE,mBAAmB,EAAE,MAAM,GAAG,MAAM;IAKlF;;OAEG;IACH,MAAM,IAAI,WAAW;IAQrB;;;;OAIG;IACH,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,WAAW,GAAG,MAAM;CAM3C"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Ballot = void 0;
|
|
7
|
+
const crypto_1 = require("@maci-protocol/crypto");
|
|
8
|
+
const assert_1 = __importDefault(require("assert"));
|
|
9
|
+
/**
|
|
10
|
+
* A Ballot represents a User's votes in a Poll, as well as their next valid
|
|
11
|
+
* nonce.
|
|
12
|
+
*/
|
|
13
|
+
class Ballot {
|
|
14
|
+
/**
|
|
15
|
+
* Create a new Ballot instance
|
|
16
|
+
* @param _numVoteOptions How many vote options are available in the poll
|
|
17
|
+
* @param _voteOptionTreeDepth The depth of the merkle tree holding the vote options
|
|
18
|
+
*/
|
|
19
|
+
constructor(_numVoteOptions, _voteOptionTreeDepth) {
|
|
20
|
+
this.votes = [];
|
|
21
|
+
this.nonce = BigInt(0);
|
|
22
|
+
/**
|
|
23
|
+
* Generate an hash of this ballot
|
|
24
|
+
* @returns The hash of the ballot
|
|
25
|
+
*/
|
|
26
|
+
this.hash = () => {
|
|
27
|
+
const vals = this.asArray();
|
|
28
|
+
return (0, crypto_1.hashLeftRight)(vals[0], vals[1]);
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Convert in a format suitable for the circuit
|
|
32
|
+
* @returns the ballot as a BigInt array
|
|
33
|
+
*/
|
|
34
|
+
this.asCircuitInputs = () => this.asArray();
|
|
35
|
+
/**
|
|
36
|
+
* Convert in a an array of bigints
|
|
37
|
+
* @notice this is the nonce and the root of the vote option tree
|
|
38
|
+
* @returns the ballot as a bigint array
|
|
39
|
+
*/
|
|
40
|
+
this.asArray = () => {
|
|
41
|
+
const lastIndex = this.votes.length - 1;
|
|
42
|
+
const foundIndex = this.votes.findIndex((_, index) => this.votes[lastIndex - index] !== BigInt(0));
|
|
43
|
+
const lastIndexToInsert = foundIndex < 0 ? -1 : lastIndex - foundIndex;
|
|
44
|
+
const voTree = new crypto_1.IncrementalQuinTree(this.voteOptionTreeDepth, BigInt(0), 5, crypto_1.hash5);
|
|
45
|
+
for (let i = 0; i <= lastIndexToInsert; i += 1) {
|
|
46
|
+
voTree.insert(this.votes[i]);
|
|
47
|
+
}
|
|
48
|
+
return [this.nonce, voTree.root];
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Create a deep clone of this Ballot
|
|
52
|
+
* @returns a copy of the ballot
|
|
53
|
+
*/
|
|
54
|
+
this.copy = () => {
|
|
55
|
+
const b = new Ballot(this.votes.length, this.voteOptionTreeDepth);
|
|
56
|
+
b.votes = this.votes.map((x) => BigInt(x.toString()));
|
|
57
|
+
b.nonce = BigInt(this.nonce.toString());
|
|
58
|
+
return b;
|
|
59
|
+
};
|
|
60
|
+
this.voteOptionTreeDepth = _voteOptionTreeDepth;
|
|
61
|
+
(0, assert_1.default)(5 ** _voteOptionTreeDepth >= _numVoteOptions);
|
|
62
|
+
(0, assert_1.default)(_numVoteOptions >= 0);
|
|
63
|
+
for (let i = 0; i < _numVoteOptions; i += 1) {
|
|
64
|
+
this.votes.push(BigInt(0));
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Check if two ballots are equal (same votes and same nonce)
|
|
69
|
+
* @param b - The ballot to compare with
|
|
70
|
+
* @returns whether the two ballots are equal
|
|
71
|
+
*/
|
|
72
|
+
equals(b) {
|
|
73
|
+
const isEqualVotes = this.votes.every((vote, index) => vote === b.votes[index]);
|
|
74
|
+
return isEqualVotes ? b.nonce === this.nonce && this.votes.length === b.votes.length : false;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Generate a random ballot
|
|
78
|
+
* @param numVoteOptions How many vote options are available
|
|
79
|
+
* @param voteOptionTreeDepth How deep is the merkle tree holding the vote options
|
|
80
|
+
* @returns a random Ballot
|
|
81
|
+
*/
|
|
82
|
+
static genRandomBallot(numVoteOptions, voteOptionTreeDepth) {
|
|
83
|
+
const ballot = new Ballot(numVoteOptions, voteOptionTreeDepth);
|
|
84
|
+
ballot.nonce = (0, crypto_1.genRandomSalt)();
|
|
85
|
+
return ballot;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Generate a blank ballot
|
|
89
|
+
* @param numVoteOptions How many vote options are available
|
|
90
|
+
* @param voteOptionTreeDepth How deep is the merkle tree holding the vote options
|
|
91
|
+
* @returns a Blank Ballot object
|
|
92
|
+
*/
|
|
93
|
+
static genBlankBallot(numVoteOptions, voteOptionTreeDepth) {
|
|
94
|
+
const ballot = new Ballot(numVoteOptions, voteOptionTreeDepth);
|
|
95
|
+
return ballot;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Serialize to a JSON object
|
|
99
|
+
*/
|
|
100
|
+
toJSON() {
|
|
101
|
+
return {
|
|
102
|
+
votes: this.votes.map((x) => x.toString()),
|
|
103
|
+
nonce: this.nonce.toString(),
|
|
104
|
+
voteOptionTreeDepth: this.voteOptionTreeDepth.toString(),
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Deserialize into a Ballot instance
|
|
109
|
+
* @param json - the json representation
|
|
110
|
+
* @returns the deserialized object as a Ballot instance
|
|
111
|
+
*/
|
|
112
|
+
static fromJSON(json) {
|
|
113
|
+
const ballot = new Ballot(json.votes.length, Number.parseInt(json.voteOptionTreeDepth.toString(), 10));
|
|
114
|
+
ballot.votes = json.votes.map((x) => BigInt(x));
|
|
115
|
+
ballot.nonce = BigInt(json.nonce);
|
|
116
|
+
return ballot;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
exports.Ballot = Ballot;
|
|
120
|
+
//# sourceMappingURL=ballot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ballot.js","sourceRoot":"","sources":["../../ts/ballot.ts"],"names":[],"mappings":";;;;;;AAAA,kDAAiG;AAEjG,oDAA4B;AAI5B;;;GAGG;AACH,MAAa,MAAM;IAOjB;;;;OAIG;IACH,YAAY,eAAuB,EAAE,oBAA4B;QAXjE,UAAK,GAAa,EAAE,CAAC;QAErB,UAAK,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;QAkBlB;;;WAGG;QACH,SAAI,GAAG,GAAW,EAAE;YAClB,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;YAC5B,OAAO,IAAA,sBAAa,EAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QACzC,CAAC,CAAC;QAEF;;;WAGG;QACH,oBAAe,GAAG,GAAa,EAAE,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;QAEjD;;;;WAIG;QACH,YAAO,GAAG,GAAa,EAAE;YACvB,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;YACxC,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,KAAK,CAAC,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;YACnG,MAAM,iBAAiB,GAAG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B;QAC/B,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,mBAAmB,CAAC,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;QACvG,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;QAChD,MAAM,CAAC,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAClC,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAxHD,wBAwHC"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { type Signature, type EcdhSharedKey } from "@maci-protocol/crypto";
|
|
2
|
+
import type { IJsonPCommand } from "./types";
|
|
3
|
+
import type { PrivKey } from "../privateKey";
|
|
4
|
+
import { Message } from "../message";
|
|
5
|
+
import { PubKey } from "../publicKey";
|
|
6
|
+
export interface IDecryptMessage {
|
|
7
|
+
command: PCommand;
|
|
8
|
+
signature: Signature;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* @notice Unencrypted data whose fields include the user's public key, vote etc.
|
|
12
|
+
* This represents a Vote command.
|
|
13
|
+
*/
|
|
14
|
+
export declare class PCommand {
|
|
15
|
+
stateIndex: bigint;
|
|
16
|
+
newPubKey: PubKey;
|
|
17
|
+
voteOptionIndex: bigint;
|
|
18
|
+
newVoteWeight: bigint;
|
|
19
|
+
nonce: bigint;
|
|
20
|
+
pollId: bigint;
|
|
21
|
+
salt: bigint;
|
|
22
|
+
/**
|
|
23
|
+
* Create a new PCommand
|
|
24
|
+
* @param stateIndex the state index of the user
|
|
25
|
+
* @param newPubKey the new public key of the user
|
|
26
|
+
* @param voteOptionIndex the index of the vote option
|
|
27
|
+
* @param newVoteWeight the new vote weight of the user
|
|
28
|
+
* @param nonce the nonce of the message
|
|
29
|
+
* @param pollId the poll ID
|
|
30
|
+
* @param salt the salt of the message
|
|
31
|
+
*/
|
|
32
|
+
constructor(stateIndex: bigint, newPubKey: PubKey, voteOptionIndex: bigint, newVoteWeight: bigint, nonce: bigint, pollId: bigint, salt?: bigint);
|
|
33
|
+
/**
|
|
34
|
+
* Create a deep clone of this PCommand
|
|
35
|
+
* @returns a copy of the PCommand
|
|
36
|
+
*/
|
|
37
|
+
copy: <T extends PCommand>() => T;
|
|
38
|
+
/**
|
|
39
|
+
* @notice Returns this Command as an array. Note that 5 of the Command's fields
|
|
40
|
+
* are packed into a single 250-bit value. This allows Messages to be
|
|
41
|
+
* smaller and thereby save gas when the user publishes a message.
|
|
42
|
+
* @returns bigint[] - the command as an array
|
|
43
|
+
*/
|
|
44
|
+
asArray: () => bigint[];
|
|
45
|
+
asCircuitInputs: () => bigint[];
|
|
46
|
+
equals: (command: PCommand) => boolean;
|
|
47
|
+
hash: () => bigint;
|
|
48
|
+
/**
|
|
49
|
+
* @notice Signs this command and returns a Signature.
|
|
50
|
+
*/
|
|
51
|
+
sign: (privKey: PrivKey) => Signature;
|
|
52
|
+
/**
|
|
53
|
+
* @notice Returns true if the given signature is a correct signature of this
|
|
54
|
+
* command and signed by the private key associated with the given public
|
|
55
|
+
* key.
|
|
56
|
+
*/
|
|
57
|
+
verifySignature: (signature: Signature, pubKey: PubKey) => boolean;
|
|
58
|
+
/**
|
|
59
|
+
* @notice Encrypts this command along with a signature to produce a Message.
|
|
60
|
+
* To save gas, we can constrain the following values to 50 bits and pack
|
|
61
|
+
* them into a 250-bit value:
|
|
62
|
+
* 0. state index
|
|
63
|
+
* 3. vote option index
|
|
64
|
+
* 4. new vote weight
|
|
65
|
+
* 5. nonce
|
|
66
|
+
* 6. poll ID
|
|
67
|
+
*/
|
|
68
|
+
encrypt: (signature: Signature, sharedKey: EcdhSharedKey) => Message;
|
|
69
|
+
/**
|
|
70
|
+
* Decrypts a Message to produce a Command.
|
|
71
|
+
* @dev You can force decrypt the message by setting `force` to true.
|
|
72
|
+
* This is useful in case you don't want an invalid message to throw an error.
|
|
73
|
+
* @param message - the message to decrypt
|
|
74
|
+
* @param sharedKey - the shared key to use for decryption
|
|
75
|
+
* @param force - whether to force decryption or not
|
|
76
|
+
*/
|
|
77
|
+
static decrypt: (message: Message, sharedKey: EcdhSharedKey, force?: boolean) => IDecryptMessage;
|
|
78
|
+
/**
|
|
79
|
+
* Serialize into a JSON object
|
|
80
|
+
*/
|
|
81
|
+
toJSON(): IJsonPCommand;
|
|
82
|
+
/**
|
|
83
|
+
* Deserialize into a PCommand instance
|
|
84
|
+
* @param json
|
|
85
|
+
* @returns a PCommand instance
|
|
86
|
+
*/
|
|
87
|
+
static fromJSON(json: IJsonPCommand): PCommand;
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=PCommand.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PCommand.d.ts","sourceRoot":"","sources":["../../../ts/commands/PCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,KAAK,SAAS,EAEd,KAAK,aAAa,EAGnB,MAAM,uBAAuB,CAAC;AAI/B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAE7C,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,QAAQ,CAAC;IAClB,SAAS,EAAE,SAAS,CAAC;CACtB;AAED;;;GAGG;AACH,qBAAa,QAAQ;IACnB,UAAU,EAAE,MAAM,CAAC;IAEnB,SAAS,EAAE,MAAM,CAAC;IAElB,eAAe,EAAE,MAAM,CAAC;IAExB,aAAa,EAAE,MAAM,CAAC;IAEtB,KAAK,EAAE,MAAM,CAAC;IAEd,MAAM,EAAE,MAAM,CAAC;I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