@maci-protocol/website 0.0.0-ci.1e276ed

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.
Files changed (415) hide show
  1. package/.eslintrc.js +157 -0
  2. package/CHANGELOG.md +566 -0
  3. package/LICENSE +22 -0
  4. package/README.md +58 -0
  5. package/babel.config.js +3 -0
  6. package/blog/2021-10-12-maci-v1.md +100 -0
  7. package/blog/2022-09-22-maci-v1-technical-introduction.md +180 -0
  8. package/blog/2023-01-18-maci-v1.1.1.md +121 -0
  9. package/blog/2024-01-18-roadmap.md +106 -0
  10. package/blog/2024-02-28-maci-v1.2.0.md +121 -0
  11. package/blog/2024-04-10-roadmap-q2.md +96 -0
  12. package/blog/2024-05-08-ethdam.md +169 -0
  13. package/blog/2024-05-22-the-origins-of-maci.md +38 -0
  14. package/blog/2024-05-28-upcoming-grants.md +85 -0
  15. package/blog/2024-06-17-understanding-maci.md +63 -0
  16. package/blog/2024-06-21-deciphering-maci.md +48 -0
  17. package/blog/2024-06-28-revolusioning-public-goods-funding.md +32 -0
  18. package/blog/2024-07-23-q2-review.md +72 -0
  19. package/blog/2024-07-30-roadmap-q3.md +61 -0
  20. package/blog/2024-08-10-maci-v2.md +102 -0
  21. package/blog/2024-08-29-anonymous-poll-joining.md +47 -0
  22. package/blog/2024-10-29-q3-review.md +63 -0
  23. package/blog/2024-11-20-maci-platform.md +93 -0
  24. package/blog/2024-12-01-maci-getting-started.md +294 -0
  25. package/blog/2025-03-21-roadmap-2025.md +112 -0
  26. package/blog/assets/MACI_Bob_SignUp_1.png +0 -0
  27. package/blog/assets/MACI_Bob_SignUp_2.png +0 -0
  28. package/blog/assets/MACI_Complex_Message.png +0 -0
  29. package/blog/assets/MACI_Contracts.png +0 -0
  30. package/blog/assets/MACI_Sign_Up.png +0 -0
  31. package/blog/assets/MACI_Simple_Message.png +0 -0
  32. package/blog/assets/MACI_Verifier_1.png +0 -0
  33. package/blog/authors.yml +5 -0
  34. package/docusaurus.config.ts +213 -0
  35. package/package.json +65 -0
  36. package/src/components/ActionCard/index.tsx +30 -0
  37. package/src/components/ActionCard/styles.module.css +96 -0
  38. package/src/components/HomepageFeatures/index.tsx +91 -0
  39. package/src/components/HomepageFeatures/styles.module.css +17 -0
  40. package/src/components/ProjectCard/index.tsx +74 -0
  41. package/src/components/ProjectCard/styles.module.css +77 -0
  42. package/src/components/ProjectList/index.tsx +218 -0
  43. package/src/components/ProjectList/styles.module.css +180 -0
  44. package/src/content/projects.json +294 -0
  45. package/src/css/card.module.css +130 -0
  46. package/src/css/custom.css +91 -0
  47. package/src/icons/IconDiscord.tsx +16 -0
  48. package/src/icons/IconGithub.tsx +16 -0
  49. package/src/icons/IconWebsite.tsx +16 -0
  50. package/src/pages/blogs.tsx +58 -0
  51. package/src/pages/index.module.css +152 -0
  52. package/src/pages/index.tsx +66 -0
  53. package/src/pages/projects.tsx +44 -0
  54. package/src/pages/roadmap.md +150 -0
  55. package/src/pages/typedoc.tsx +11 -0
  56. package/src/plugins/blog-plugin/index.ts +86 -0
  57. package/src/react-app-env.d.ts +1 -0
  58. package/src/scripts/setupSolidityDocs.ts +67 -0
  59. package/src/scripts/setupTypedoc.ts +112 -0
  60. package/src/scripts/utils.ts +115 -0
  61. package/src/utils/getProjectsByFilter.ts +40 -0
  62. package/static/.nojekyll +0 -0
  63. package/static/audit_reports/20210922_Hashcloak_audit_report.pdf +0 -0
  64. package/static/audit_reports/202220930_Hashcloak_audit_report.pdf +0 -0
  65. package/static/audit_reports/20240223_PSE_Audit_audit_report.pdf +0 -0
  66. package/static/audit_reports/20240731_PSE_Audit_audit_report.pdf +0 -0
  67. package/static/fonts/DM_Sans.woff2 +0 -0
  68. package/static/fonts/Share_Tech_Mono.woff2 +0 -0
  69. package/static/img/box.png +0 -0
  70. package/static/img/box_dark.png +0 -0
  71. package/static/img/chain.png +0 -0
  72. package/static/img/chain_dark.png +0 -0
  73. package/static/img/chart.png +0 -0
  74. package/static/img/chart_dark.png +0 -0
  75. package/static/img/circuits/MACI-Circuits.excalidraw +39652 -0
  76. package/static/img/circuits/calculateTotal.svg +21 -0
  77. package/static/img/circuits/ecdh.svg +21 -0
  78. package/static/img/circuits/messageToCommand.svg +21 -0
  79. package/static/img/circuits/messageValidator.svg +21 -0
  80. package/static/img/circuits/poseidonHasher13.svg +21 -0
  81. package/static/img/circuits/privToPubkey.svg +21 -0
  82. package/static/img/circuits/processMessages.svg +21 -0
  83. package/static/img/circuits/processMessagesInputHasher.svg +21 -0
  84. package/static/img/circuits/processMessages_2_0.svg +21 -0
  85. package/static/img/circuits/processOne.svg +21 -0
  86. package/static/img/circuits/processTopup.svg +21 -0
  87. package/static/img/circuits/processingAfterPollEnds.svg +21 -0
  88. package/static/img/circuits/quinBatchLeavesExists.svg +21 -0
  89. package/static/img/circuits/quinCheckRoot.svg +21 -0
  90. package/static/img/circuits/quinGeneratePathIndices.svg +21 -0
  91. package/static/img/circuits/quinSelector.svg +21 -0
  92. package/static/img/circuits/resultsCommitmentVerifier.svg +21 -0
  93. package/static/img/circuits/splicer.svg +21 -0
  94. package/static/img/circuits/tallyInputHasher.svg +21 -0
  95. package/static/img/circuits/tallyVotes.svg +21 -0
  96. package/static/img/circuits/unpackElement.svg +21 -0
  97. package/static/img/circuits/verifySignature.svg +21 -0
  98. package/static/img/completingAPoll.svg +4 -0
  99. package/static/img/contracts.svg +16 -0
  100. package/static/img/coordinatorComponents.svg +21 -0
  101. package/static/img/favicon.ico +0 -0
  102. package/static/img/generateProofs.svg +4 -0
  103. package/static/img/hero.svg +9 -0
  104. package/static/img/maci-card.png +0 -0
  105. package/static/img/maci-rpgf-design.jpg +0 -0
  106. package/static/img/messageProcessingLocal.svg +21 -0
  107. package/static/img/offlineProcessing.svg +21 -0
  108. package/static/img/pse-logo-round.png +0 -0
  109. package/static/img/relayer-diagram.png +0 -0
  110. package/static/img/tallyCommitments.svg +4 -0
  111. package/static/img/voteTallyingLocal.svg +21 -0
  112. package/tsconfig.json +34 -0
  113. package/versioned_docs/version-v0.x/circuits.md +22 -0
  114. package/versioned_docs/version-v0.x/contract.md +186 -0
  115. package/versioned_docs/version-v0.x/faq.md +67 -0
  116. package/versioned_docs/version-v0.x/introduction.md +119 -0
  117. package/versioned_docs/version-v0.x/quadratic-vote-tallying-circuit.md +138 -0
  118. package/versioned_docs/version-v0.x/state-root-transition-circuit.md +230 -0
  119. package/versioned_docs/version-v1.2/audit.md +160 -0
  120. package/versioned_docs/version-v1.2/ci-pipeline.md +38 -0
  121. package/versioned_docs/version-v1.2/circuits.md +508 -0
  122. package/versioned_docs/version-v1.2/cli.md +689 -0
  123. package/versioned_docs/version-v1.2/contracts.md +445 -0
  124. package/versioned_docs/version-v1.2/contributing/code-of-conduct.md +91 -0
  125. package/versioned_docs/version-v1.2/contributing/contributing.md +129 -0
  126. package/versioned_docs/version-v1.2/coordinator-processing.md +46 -0
  127. package/versioned_docs/version-v1.2/deployment.md +122 -0
  128. package/versioned_docs/version-v1.2/installation.md +175 -0
  129. package/versioned_docs/version-v1.2/integrating.md +200 -0
  130. package/versioned_docs/version-v1.2/introduction.md +94 -0
  131. package/versioned_docs/version-v1.2/key-change.md +182 -0
  132. package/versioned_docs/version-v1.2/overview.md +47 -0
  133. package/versioned_docs/version-v1.2/poll-types.md +68 -0
  134. package/versioned_docs/version-v1.2/primitives.md +216 -0
  135. package/versioned_docs/version-v1.2/project-ideas.md +14 -0
  136. package/versioned_docs/version-v1.2/purpose.md +62 -0
  137. package/versioned_docs/version-v1.2/solidity-docs/MACI.md +345 -0
  138. package/versioned_docs/version-v1.2/solidity-docs/MessageProcessor.md +266 -0
  139. package/versioned_docs/version-v1.2/solidity-docs/MessageProcessorFactory.md +26 -0
  140. package/versioned_docs/version-v1.2/solidity-docs/Poll.md +381 -0
  141. package/versioned_docs/version-v1.2/solidity-docs/PollFactory.md +50 -0
  142. package/versioned_docs/version-v1.2/solidity-docs/SignUpToken.md +27 -0
  143. package/versioned_docs/version-v1.2/solidity-docs/Subsidy.md +218 -0
  144. package/versioned_docs/version-v1.2/solidity-docs/SubsidyFactory.md +27 -0
  145. package/versioned_docs/version-v1.2/solidity-docs/Tally.md +311 -0
  146. package/versioned_docs/version-v1.2/solidity-docs/TallyFactory.md +27 -0
  147. package/versioned_docs/version-v1.2/solidity-docs/TallyNonQv.md +296 -0
  148. package/versioned_docs/version-v1.2/solidity-docs/TallyNonQvFactory.md +27 -0
  149. package/versioned_docs/version-v1.2/solidity-docs/TopupCredit.md +61 -0
  150. package/versioned_docs/version-v1.2/solidity-docs/VkRegistry.md +457 -0
  151. package/versioned_docs/version-v1.2/solidity-docs/benchmarks/HasherBenchmarks.md +44 -0
  152. package/versioned_docs/version-v1.2/solidity-docs/crypto/Hasher.md +125 -0
  153. package/versioned_docs/version-v1.2/solidity-docs/crypto/IVerifier.md +11 -0
  154. package/versioned_docs/version-v1.2/solidity-docs/crypto/MockVerifier.md +17 -0
  155. package/versioned_docs/version-v1.2/solidity-docs/crypto/Pairing.md +85 -0
  156. package/versioned_docs/version-v1.2/solidity-docs/crypto/PoseidonT3.md +9 -0
  157. package/versioned_docs/version-v1.2/solidity-docs/crypto/PoseidonT4.md +9 -0
  158. package/versioned_docs/version-v1.2/solidity-docs/crypto/PoseidonT5.md +9 -0
  159. package/versioned_docs/version-v1.2/solidity-docs/crypto/PoseidonT6.md +9 -0
  160. package/versioned_docs/version-v1.2/solidity-docs/crypto/SnarkCommon.md +16 -0
  161. package/versioned_docs/version-v1.2/solidity-docs/crypto/SnarkConstants.md +40 -0
  162. package/versioned_docs/version-v1.2/solidity-docs/crypto/Verifier.md +61 -0
  163. package/versioned_docs/version-v1.2/solidity-docs/gatekeepers/EASGatekeeper.md +121 -0
  164. package/versioned_docs/version-v1.2/solidity-docs/gatekeepers/FreeForAllSignUpGatekeeper.md +40 -0
  165. package/versioned_docs/version-v1.2/solidity-docs/gatekeepers/SignUpGatekeeper.md +26 -0
  166. package/versioned_docs/version-v1.2/solidity-docs/gatekeepers/SignUpTokenGatekeeper.md +93 -0
  167. package/versioned_docs/version-v1.2/solidity-docs/gatekeepers/hatsGatekeepers/HatsGatekeeperBase.md +79 -0
  168. package/versioned_docs/version-v1.2/solidity-docs/gatekeepers/hatsGatekeepers/HatsGatekeeperMultiple.md +48 -0
  169. package/versioned_docs/version-v1.2/solidity-docs/gatekeepers/hatsGatekeepers/HatsGatekeeperSingle.md +42 -0
  170. package/versioned_docs/version-v1.2/solidity-docs/index.md +4 -0
  171. package/versioned_docs/version-v1.2/solidity-docs/initialVoiceCreditProxy/ConstantInitialVoiceCreditProxy.md +40 -0
  172. package/versioned_docs/version-v1.2/solidity-docs/initialVoiceCreditProxy/InitialVoiceCreditProxy.md +26 -0
  173. package/versioned_docs/version-v1.2/solidity-docs/interfaces/IEAS.md +40 -0
  174. package/versioned_docs/version-v1.2/solidity-docs/interfaces/IHats.md +103 -0
  175. package/versioned_docs/version-v1.2/solidity-docs/interfaces/IMPFactory.md +26 -0
  176. package/versioned_docs/version-v1.2/solidity-docs/interfaces/IMessageProcessor.md +31 -0
  177. package/versioned_docs/version-v1.2/solidity-docs/interfaces/IPoll.md +217 -0
  178. package/versioned_docs/version-v1.2/solidity-docs/interfaces/IPollFactory.md +29 -0
  179. package/versioned_docs/version-v1.2/solidity-docs/interfaces/ITallyFactory.md +28 -0
  180. package/versioned_docs/version-v1.2/solidity-docs/interfaces/ITallySubsidyFactory.md +27 -0
  181. package/versioned_docs/version-v1.2/solidity-docs/interfaces/IVerifier.md +25 -0
  182. package/versioned_docs/version-v1.2/solidity-docs/interfaces/IVkRegistry.md +70 -0
  183. package/versioned_docs/version-v1.2/solidity-docs/mocks/MockHatsProtocol.md +133 -0
  184. package/versioned_docs/version-v1.2/solidity-docs/trees/AccQueue.md +464 -0
  185. package/versioned_docs/version-v1.2/solidity-docs/trees/AccQueueBinary.md +60 -0
  186. package/versioned_docs/version-v1.2/solidity-docs/trees/AccQueueBinary0.md +40 -0
  187. package/versioned_docs/version-v1.2/solidity-docs/trees/AccQueueBinaryMaci.md +34 -0
  188. package/versioned_docs/version-v1.2/solidity-docs/trees/AccQueueQuinary.md +75 -0
  189. package/versioned_docs/version-v1.2/solidity-docs/trees/AccQueueQuinary0.md +40 -0
  190. package/versioned_docs/version-v1.2/solidity-docs/trees/AccQueueQuinaryBlankSl.md +40 -0
  191. package/versioned_docs/version-v1.2/solidity-docs/trees/AccQueueQuinaryMaci.md +40 -0
  192. package/versioned_docs/version-v1.2/solidity-docs/trees/EmptyBallotRoots.md +13 -0
  193. package/versioned_docs/version-v1.2/solidity-docs/utilities/CommonUtilities.md +25 -0
  194. package/versioned_docs/version-v1.2/solidity-docs/utilities/DomainObjs.md +40 -0
  195. package/versioned_docs/version-v1.2/solidity-docs/utilities/Params.md +36 -0
  196. package/versioned_docs/version-v1.2/solidity-docs/utilities/Utilities.md +79 -0
  197. package/versioned_docs/version-v1.2/spec.md +944 -0
  198. package/versioned_docs/version-v1.2/testing-in-detail.md +209 -0
  199. package/versioned_docs/version-v1.2/testing.md +472 -0
  200. package/versioned_docs/version-v1.2/topup.md +43 -0
  201. package/versioned_docs/version-v1.2/troubleshooting.md +51 -0
  202. package/versioned_docs/version-v1.2/trusted-setup.md +76 -0
  203. package/versioned_docs/version-v1.2/typedoc/cli/.nojekyll +1 -0
  204. package/versioned_docs/version-v1.2/typedoc/cli/index.md +15 -0
  205. package/versioned_docs/version-v1.2/typedoc/cli/interfaces/AirdropArgs.md +89 -0
  206. package/versioned_docs/version-v1.2/typedoc/cli/interfaces/DeployArgs.md +154 -0
  207. package/versioned_docs/version-v1.2/typedoc/cli/interfaces/DeployPollArgs.md +154 -0
  208. package/versioned_docs/version-v1.2/typedoc/cli/interfaces/DeployedContracts.md +130 -0
  209. package/versioned_docs/version-v1.2/typedoc/cli/interfaces/GenLocalStateArgs.md +168 -0
  210. package/versioned_docs/version-v1.2/typedoc/cli/interfaces/GenProofsArgs.md +388 -0
  211. package/versioned_docs/version-v1.2/typedoc/cli/interfaces/IGenKeypairArgs.md +37 -0
  212. package/versioned_docs/version-v1.2/typedoc/cli/interfaces/IRegisteredUserArgs.md +63 -0
  213. package/versioned_docs/version-v1.2/typedoc/cli/interfaces/MergeMessagesArgs.md +76 -0
  214. package/versioned_docs/version-v1.2/typedoc/cli/interfaces/MergeSignupsArgs.md +76 -0
  215. package/versioned_docs/version-v1.2/typedoc/cli/interfaces/PollContracts.md +53 -0
  216. package/versioned_docs/version-v1.2/typedoc/cli/interfaces/ProveOnChainArgs.md +128 -0
  217. package/versioned_docs/version-v1.2/typedoc/cli/interfaces/PublishArgs.md +154 -0
  218. package/versioned_docs/version-v1.2/typedoc/cli/interfaces/SignupArgs.md +89 -0
  219. package/versioned_docs/version-v1.2/typedoc/cli/interfaces/SubsidyData.md +73 -0
  220. package/versioned_docs/version-v1.2/typedoc/cli/interfaces/TallyData.md +166 -0
  221. package/versioned_docs/version-v1.2/typedoc/cli/interfaces/TopupArgs.md +89 -0
  222. package/versioned_docs/version-v1.2/typedoc/cli/interfaces/VerifyArgs.md +128 -0
  223. package/versioned_docs/version-v1.2/typedoc/cli/modules.md +556 -0
  224. package/versioned_docs/version-v1.2/typedoc/core/.nojekyll +1 -0
  225. package/versioned_docs/version-v1.2/typedoc/core/classes/MaciState.md +295 -0
  226. package/versioned_docs/version-v1.2/typedoc/core/classes/Poll.md +1098 -0
  227. package/versioned_docs/version-v1.2/typedoc/core/index.md +110 -0
  228. package/versioned_docs/version-v1.2/typedoc/core/interfaces/BatchSizes.md +50 -0
  229. package/versioned_docs/version-v1.2/typedoc/core/interfaces/IJsonMaciState.md +77 -0
  230. package/versioned_docs/version-v1.2/typedoc/core/interfaces/IProcessMessagesCircuitInputs.md +242 -0
  231. package/versioned_docs/version-v1.2/typedoc/core/interfaces/ISubsidyCircuitInputs.md +198 -0
  232. package/versioned_docs/version-v1.2/typedoc/core/interfaces/ITallyCircuitInputs.md +231 -0
  233. package/versioned_docs/version-v1.2/typedoc/core/interfaces/MaxValues.md +37 -0
  234. package/versioned_docs/version-v1.2/typedoc/core/interfaces/TreeDepths.md +63 -0
  235. package/versioned_docs/version-v1.2/typedoc/core/modules.md +289 -0
  236. package/versioned_docs/version-v1.2/typedoc/crypto/.nojekyll +1 -0
  237. package/versioned_docs/version-v1.2/typedoc/crypto/classes/AccQueue.md +770 -0
  238. package/versioned_docs/version-v1.2/typedoc/crypto/classes/G1Point.md +115 -0
  239. package/versioned_docs/version-v1.2/typedoc/crypto/classes/G2Point.md +140 -0
  240. package/versioned_docs/version-v1.2/typedoc/crypto/classes/IncrementalQuinTree.md +470 -0
  241. package/versioned_docs/version-v1.2/typedoc/crypto/index.md +44 -0
  242. package/versioned_docs/version-v1.2/typedoc/crypto/interfaces/Keypair.md +33 -0
  243. package/versioned_docs/version-v1.2/typedoc/crypto/interfaces/PoseidonFuncs.md +115 -0
  244. package/versioned_docs/version-v1.2/typedoc/crypto/interfaces/Queue.md +33 -0
  245. package/versioned_docs/version-v1.2/typedoc/crypto/interfaces/Signature.md +37 -0
  246. package/versioned_docs/version-v1.2/typedoc/crypto/modules.md +913 -0
  247. package/versioned_docs/version-v1.2/typedoc/domainobjs/.nojekyll +1 -0
  248. package/versioned_docs/version-v1.2/typedoc/domainobjs/classes/Ballot.md +274 -0
  249. package/versioned_docs/version-v1.2/typedoc/domainobjs/classes/Keypair.md +181 -0
  250. package/versioned_docs/version-v1.2/typedoc/domainobjs/classes/Message.md +244 -0
  251. package/versioned_docs/version-v1.2/typedoc/domainobjs/classes/PCommand.md +409 -0
  252. package/versioned_docs/version-v1.2/typedoc/domainobjs/classes/PrivKey.md +206 -0
  253. package/versioned_docs/version-v1.2/typedoc/domainobjs/classes/PubKey.md +289 -0
  254. package/versioned_docs/version-v1.2/typedoc/domainobjs/classes/StateLeaf.md +340 -0
  255. package/versioned_docs/version-v1.2/typedoc/domainobjs/classes/TCommand.md +200 -0
  256. package/versioned_docs/version-v1.2/typedoc/domainobjs/classes/VerifyingKey.md +240 -0
  257. package/versioned_docs/version-v1.2/typedoc/domainobjs/index.md +81 -0
  258. package/versioned_docs/version-v1.2/typedoc/domainobjs/interfaces/ICommand.md +104 -0
  259. package/versioned_docs/version-v1.2/typedoc/domainobjs/interfaces/IG1ContractParams.md +31 -0
  260. package/versioned_docs/version-v1.2/typedoc/domainobjs/interfaces/IG2ContractParams.md +31 -0
  261. package/versioned_docs/version-v1.2/typedoc/domainobjs/interfaces/IJsonBallot.md +42 -0
  262. package/versioned_docs/version-v1.2/typedoc/domainobjs/interfaces/IJsonCommand.md +32 -0
  263. package/versioned_docs/version-v1.2/typedoc/domainobjs/interfaces/IJsonKeyPair.md +31 -0
  264. package/versioned_docs/version-v1.2/typedoc/domainobjs/interfaces/IJsonPCommand.md +111 -0
  265. package/versioned_docs/version-v1.2/typedoc/domainobjs/interfaces/IJsonStateLeaf.md +42 -0
  266. package/versioned_docs/version-v1.2/typedoc/domainobjs/interfaces/IJsonTCommand.md +67 -0
  267. package/versioned_docs/version-v1.2/typedoc/domainobjs/interfaces/IMessageContractParams.md +31 -0
  268. package/versioned_docs/version-v1.2/typedoc/domainobjs/interfaces/IStateLeaf.md +39 -0
  269. package/versioned_docs/version-v1.2/typedoc/domainobjs/interfaces/IStateLeafContractParams.md +42 -0
  270. package/versioned_docs/version-v1.2/typedoc/domainobjs/interfaces/IVkContractParams.md +64 -0
  271. package/versioned_docs/version-v1.2/typedoc/domainobjs/interfaces/IVkObjectParams.md +108 -0
  272. package/versioned_docs/version-v1.2/typedoc/domainobjs/interfaces/Proof.md +46 -0
  273. package/versioned_docs/version-v1.2/typedoc/domainobjs/interfaces/VoteOptionTreeLeaf.md +24 -0
  274. package/versioned_docs/version-v1.2/typedoc/domainobjs/modules.md +110 -0
  275. package/versioned_docs/version-v1.2/typedoc/index.md +4 -0
  276. package/versioned_docs/version-v1.2/versioning.md +94 -0
  277. package/versioned_docs/version-v1.2/workflow.md +142 -0
  278. package/versioned_docs/version-v2.x/case-studies.md +35 -0
  279. package/versioned_docs/version-v2.x/contributing/_category_.json +4 -0
  280. package/versioned_docs/version-v2.x/contributing/code-of-conduct.md +92 -0
  281. package/versioned_docs/version-v2.x/contributing/contributing.md +149 -0
  282. package/versioned_docs/version-v2.x/contributing/project-ideas.md +78 -0
  283. package/versioned_docs/version-v2.x/core-concepts/_category_.json +4 -0
  284. package/versioned_docs/version-v2.x/core-concepts/ballot.md +19 -0
  285. package/versioned_docs/version-v2.x/core-concepts/coordinator-processing.md +46 -0
  286. package/versioned_docs/version-v2.x/core-concepts/hashing-and-encryption.md +45 -0
  287. package/versioned_docs/version-v2.x/core-concepts/key-change.md +179 -0
  288. package/versioned_docs/version-v2.x/core-concepts/maci-keys.md +84 -0
  289. package/versioned_docs/version-v2.x/core-concepts/maci-messages.md +44 -0
  290. package/versioned_docs/version-v2.x/core-concepts/merkle-trees.md +23 -0
  291. package/versioned_docs/version-v2.x/core-concepts/poll-types.md +106 -0
  292. package/versioned_docs/version-v2.x/core-concepts/spec.md +883 -0
  293. package/versioned_docs/version-v2.x/core-concepts/state-leaf.md +42 -0
  294. package/versioned_docs/version-v2.x/core-concepts/workflow.md +142 -0
  295. package/versioned_docs/version-v2.x/getting-started.md +313 -0
  296. package/versioned_docs/version-v2.x/guides/_category_.json +4 -0
  297. package/versioned_docs/version-v2.x/guides/compile-circuits.md +163 -0
  298. package/versioned_docs/version-v2.x/guides/frontend.md +99 -0
  299. package/versioned_docs/version-v2.x/guides/integrating.md +73 -0
  300. package/versioned_docs/version-v2.x/guides/maciWrapper.md +173 -0
  301. package/versioned_docs/version-v2.x/guides/subgraph.md +79 -0
  302. package/versioned_docs/version-v2.x/guides/testing/_category_.json +4 -0
  303. package/versioned_docs/version-v2.x/guides/testing/testing-in-detail.md +203 -0
  304. package/versioned_docs/version-v2.x/guides/testing/testing.md +163 -0
  305. package/versioned_docs/version-v2.x/guides/troubleshooting.md +161 -0
  306. package/versioned_docs/version-v2.x/introduction.md +146 -0
  307. package/versioned_docs/version-v2.x/processes/_category_.json +4 -0
  308. package/versioned_docs/version-v2.x/processes/ci-pipeline.md +38 -0
  309. package/versioned_docs/version-v2.x/processes/versioning.md +94 -0
  310. package/versioned_docs/version-v2.x/resources.md +33 -0
  311. package/versioned_docs/version-v2.x/security/_category_.json +4 -0
  312. package/versioned_docs/version-v2.x/security/audit.md +167 -0
  313. package/versioned_docs/version-v2.x/security/trusted-setup.md +166 -0
  314. package/versioned_docs/version-v2.x/supported-networks/_category_.json +4 -0
  315. package/versioned_docs/version-v2.x/supported-networks/deployed-contracts.md +1108 -0
  316. package/versioned_docs/version-v2.x/supported-networks/supported-networks.md +47 -0
  317. package/versioned_docs/version-v2.x/technical-references/_category_.json +4 -0
  318. package/versioned_docs/version-v2.x/technical-references/smart-contracts/AccQueue.md +21 -0
  319. package/versioned_docs/version-v2.x/technical-references/smart-contracts/Gatekeepers.md +40 -0
  320. package/versioned_docs/version-v2.x/technical-references/smart-contracts/MACI.md +152 -0
  321. package/versioned_docs/version-v2.x/technical-references/smart-contracts/MessageProcessor.md +13 -0
  322. package/versioned_docs/version-v2.x/technical-references/smart-contracts/Params.md +32 -0
  323. package/versioned_docs/version-v2.x/technical-references/smart-contracts/Poll.md +104 -0
  324. package/versioned_docs/version-v2.x/technical-references/smart-contracts/PollFactory.md +43 -0
  325. package/versioned_docs/version-v2.x/technical-references/smart-contracts/Tally.md +45 -0
  326. package/versioned_docs/version-v2.x/technical-references/smart-contracts/VkRegistry.md +57 -0
  327. package/versioned_docs/version-v2.x/technical-references/smart-contracts/VoiceCreditProxy.md +18 -0
  328. package/versioned_docs/version-v2.x/technical-references/smart-contracts/_category_.json +8 -0
  329. package/versioned_docs/version-v2.x/technical-references/technical-references.md +47 -0
  330. package/versioned_docs/version-v2.x/technical-references/typescript-code/_category_.json +4 -0
  331. package/versioned_docs/version-v2.x/technical-references/typescript-code/cli.md +699 -0
  332. package/versioned_docs/version-v2.x/technical-references/zk-snark-circuits/_category_.json +4 -0
  333. package/versioned_docs/version-v2.x/technical-references/zk-snark-circuits/processMessages.md +107 -0
  334. package/versioned_docs/version-v2.x/technical-references/zk-snark-circuits/setup.md +101 -0
  335. package/versioned_docs/version-v2.x/technical-references/zk-snark-circuits/tallyVotes.md +79 -0
  336. package/versioned_docs/version-v2.x/technical-references/zk-snark-circuits/utilities.md +131 -0
  337. package/versioned_docs/version-v2.x/technical-references/zk-snark-circuits/zk-snark-circuits.md +37 -0
  338. package/versioned_docs/version-v2.x/use-cases/_category_.json +4 -0
  339. package/versioned_docs/version-v2.x/use-cases/governance.md +18 -0
  340. package/versioned_docs/version-v2.x/use-cases/polling.md +10 -0
  341. package/versioned_docs/version-v2.x/use-cases/public-goods.md +65 -0
  342. package/versioned_docs/version-v3.x/case-studies.md +35 -0
  343. package/versioned_docs/version-v3.x/contributing/_category_.json +4 -0
  344. package/versioned_docs/version-v3.x/contributing/code-of-conduct.md +92 -0
  345. package/versioned_docs/version-v3.x/contributing/contributing.md +149 -0
  346. package/versioned_docs/version-v3.x/contributing/project-ideas.md +78 -0
  347. package/versioned_docs/version-v3.x/core-concepts/_category_.json +4 -0
  348. package/versioned_docs/version-v3.x/core-concepts/ballot.md +19 -0
  349. package/versioned_docs/version-v3.x/core-concepts/coordinator-processing.md +46 -0
  350. package/versioned_docs/version-v3.x/core-concepts/coordinator-service.md +16 -0
  351. package/versioned_docs/version-v3.x/core-concepts/hashing-and-encryption.md +45 -0
  352. package/versioned_docs/version-v3.x/core-concepts/key-change.md +179 -0
  353. package/versioned_docs/version-v3.x/core-concepts/maci-keys.md +84 -0
  354. package/versioned_docs/version-v3.x/core-concepts/maci-messages.md +44 -0
  355. package/versioned_docs/version-v3.x/core-concepts/merkle-trees.md +16 -0
  356. package/versioned_docs/version-v3.x/core-concepts/offchain-voting.md +14 -0
  357. package/versioned_docs/version-v3.x/core-concepts/poll-types.md +58 -0
  358. package/versioned_docs/version-v3.x/core-concepts/polls.md +81 -0
  359. package/versioned_docs/version-v3.x/core-concepts/spec.md +883 -0
  360. package/versioned_docs/version-v3.x/core-concepts/state-leaf.md +42 -0
  361. package/versioned_docs/version-v3.x/core-concepts/workflow.md +149 -0
  362. package/versioned_docs/version-v3.x/guides/_category_.json +4 -0
  363. package/versioned_docs/version-v3.x/guides/compile-circuits.md +175 -0
  364. package/versioned_docs/version-v3.x/guides/integrating.md +137 -0
  365. package/versioned_docs/version-v3.x/guides/subgraph.md +79 -0
  366. package/versioned_docs/version-v3.x/guides/testing/_category_.json +4 -0
  367. package/versioned_docs/version-v3.x/guides/testing/testing-in-detail.md +191 -0
  368. package/versioned_docs/version-v3.x/guides/testing/testing-introduction.md +158 -0
  369. package/versioned_docs/version-v3.x/guides/troubleshooting.md +161 -0
  370. package/versioned_docs/version-v3.x/introduction.md +153 -0
  371. package/versioned_docs/version-v3.x/processes/_category_.json +4 -0
  372. package/versioned_docs/version-v3.x/processes/ci-pipeline.md +38 -0
  373. package/versioned_docs/version-v3.x/processes/versioning.md +94 -0
  374. package/versioned_docs/version-v3.x/quick-start.md +318 -0
  375. package/versioned_docs/version-v3.x/resources.md +33 -0
  376. package/versioned_docs/version-v3.x/security/_category_.json +4 -0
  377. package/versioned_docs/version-v3.x/security/audit.md +167 -0
  378. package/versioned_docs/version-v3.x/security/trusted-setup.md +172 -0
  379. package/versioned_docs/version-v3.x/supported-networks/_category_.json +4 -0
  380. package/versioned_docs/version-v3.x/supported-networks/deployed-contracts.md +112 -0
  381. package/versioned_docs/version-v3.x/supported-networks/supported-networks.md +53 -0
  382. package/versioned_docs/version-v3.x/technical-references/_category_.json +4 -0
  383. package/versioned_docs/version-v3.x/technical-references/coordinator-service/_category_.json +8 -0
  384. package/versioned_docs/version-v3.x/technical-references/coordinator-service/index.md +10 -0
  385. package/versioned_docs/version-v3.x/technical-references/coordinator-service/installation.md +43 -0
  386. package/versioned_docs/version-v3.x/technical-references/offchain-relayer/_category_.json +8 -0
  387. package/versioned_docs/version-v3.x/technical-references/offchain-relayer/index.md +51 -0
  388. package/versioned_docs/version-v3.x/technical-references/offchain-relayer/installation.md +109 -0
  389. package/versioned_docs/version-v3.x/technical-references/smart-contracts/MACI.md +160 -0
  390. package/versioned_docs/version-v3.x/technical-references/smart-contracts/MessageProcessor.md +13 -0
  391. package/versioned_docs/version-v3.x/technical-references/smart-contracts/Params.md +33 -0
  392. package/versioned_docs/version-v3.x/technical-references/smart-contracts/Policies.md +39 -0
  393. package/versioned_docs/version-v3.x/technical-references/smart-contracts/Poll.md +170 -0
  394. package/versioned_docs/version-v3.x/technical-references/smart-contracts/PollFactory.md +33 -0
  395. package/versioned_docs/version-v3.x/technical-references/smart-contracts/Tally.md +43 -0
  396. package/versioned_docs/version-v3.x/technical-references/smart-contracts/VkRegistry.md +62 -0
  397. package/versioned_docs/version-v3.x/technical-references/smart-contracts/VoiceCreditProxy.md +18 -0
  398. package/versioned_docs/version-v3.x/technical-references/smart-contracts/_category_.json +8 -0
  399. package/versioned_docs/version-v3.x/technical-references/technical-references.md +48 -0
  400. package/versioned_docs/version-v3.x/technical-references/zk-snark-circuits/_category_.json +4 -0
  401. package/versioned_docs/version-v3.x/technical-references/zk-snark-circuits/joinPoll.md +53 -0
  402. package/versioned_docs/version-v3.x/technical-references/zk-snark-circuits/processMessages.md +106 -0
  403. package/versioned_docs/version-v3.x/technical-references/zk-snark-circuits/setup.md +96 -0
  404. package/versioned_docs/version-v3.x/technical-references/zk-snark-circuits/tallyVotes.md +79 -0
  405. package/versioned_docs/version-v3.x/technical-references/zk-snark-circuits/utilities.md +131 -0
  406. package/versioned_docs/version-v3.x/technical-references/zk-snark-circuits/zk-snark-circuits.md +42 -0
  407. package/versioned_docs/version-v3.x/use-cases/_category_.json +4 -0
  408. package/versioned_docs/version-v3.x/use-cases/governance.md +18 -0
  409. package/versioned_docs/version-v3.x/use-cases/polling.md +10 -0
  410. package/versioned_docs/version-v3.x/use-cases/public-goods.md +65 -0
  411. package/versioned_sidebars/version-v0.x-sidebars.json +8 -0
  412. package/versioned_sidebars/version-v1.2-sidebars.json +8 -0
  413. package/versioned_sidebars/version-v2.x-sidebars.json +8 -0
  414. package/versioned_sidebars/version-v3.x-sidebars.json +8 -0
  415. package/versions.json +1 -0
@@ -0,0 +1,445 @@
1
+ ---
2
+ title: MACI Smart Contracts
3
+ description: MACI is composed of multiple smart contracts, which together with the zk-SNARK circuits, can be used to carry out on-chain voting
4
+ sidebar_label: Smart Contracts
5
+ sidebar_position: 8
6
+ ---
7
+
8
+ # Smart Contracts
9
+
10
+ MACI is composed of multiple smart contracts, which together with the zk-SNARK circuits, can be used to carry out on-chain voting.
11
+
12
+ The main contracts are presented and explained below.
13
+
14
+ ![contracts](/img/contracts.svg)
15
+
16
+ ## MACI.sol
17
+
18
+ `MACI.sol` is the core contract of the project, as it provides the base layer for user signups and Polls to be created.
19
+
20
+ The constructor shown below accepts several arguments:
21
+
22
+ - `PollFactory` address
23
+ - `MessageProcessorFactory` address
24
+ - `TallyFactory` address
25
+ - `SubsidyFactory` address
26
+ - `SignUpGatekeeper` address
27
+ - `InitialVoiceCreditProxy` address
28
+ - `TopupCredit` address
29
+ - The depth of the state tree
30
+
31
+ ```javascript
32
+ constructor(
33
+ IPollFactory _pollFactory,
34
+ IMessageProcessorFactory _messageProcessorFactory,
35
+ ITallySubsidyFactory _tallyFactory,
36
+ ITallySubsidyFactory _subsidyFactory,
37
+ SignUpGatekeeper _signUpGatekeeper,
38
+ InitialVoiceCreditProxy _initialVoiceCreditProxy,
39
+ TopupCredit _topupCredit,
40
+ uint8 _stateTreeDepth
41
+ ) payable {
42
+ // Deploy the state AccQueue
43
+ stateAq = new AccQueueQuinaryBlankSl(STATE_TREE_SUBDEPTH);
44
+ stateAq.enqueue(BLANK_STATE_LEAF_HASH);
45
+
46
+ // because we add a blank leaf we need to count one signup
47
+ // so we don't allow max + 1
48
+ unchecked {
49
+ numSignUps++;
50
+ }
51
+
52
+ pollFactory = _pollFactory;
53
+ messageProcessorFactory = _messageProcessorFactory;
54
+ tallyFactory = _tallyFactory;
55
+ subsidyFactory = _subsidyFactory;
56
+ topupCredit = _topupCredit;
57
+ signUpGatekeeper = _signUpGatekeeper;
58
+ initialVoiceCreditProxy = _initialVoiceCreditProxy;
59
+ stateTreeDepth = _stateTreeDepth;
60
+
61
+ // Verify linked poseidon libraries
62
+ if (hash2([uint256(1), uint256(1)]) == 0) revert PoseidonHashLibrariesNotLinked();
63
+ }
64
+
65
+ ```
66
+
67
+ Upon deployment, the contract will deploy a new `AccQueueQuinaryBlankSl` contract using the `STATE_TREE_SUBDEPTH`. By default, this is defined as `uint8 internal constant STATE_TREE_SUBDEPTH = 2;`.
68
+
69
+ Should this be changed, it will be necessary to amend the `contracts/ts/genEmptyBallotRootsContract.ts` file to reflect the change. The first action on this deployed contract, is to enqueue (add) an empty hash (defined as `6769006970205099520508948723718471724660867171122235270773600567925038008762`).
70
+
71
+ After this, the contracts will be stored to state, and then the contract will perform a simple sanity check to ensure that the Poseidon hash libraries were linked successfully.
72
+
73
+ Next, we have the `signUp` function, which allows users to `signUp`, as long as they pass the conditions set in the `SignUpGatekeeper` contract. This contract can use any mean necessary to gatekeep access to MACI's polls. For instance, only wallets with a specific ERC721 token can be allowed to sign up.
74
+
75
+ This function does the following:
76
+
77
+ - checks that the maximum number of signups has not been reached. As of now, this will be $5 ** 10 - 1$ due to circuit limitations.
78
+ - ensure the subtrees have not been merged already, to prevent a DoS on the coordinator full tree merge
79
+ - checks that the provided public key is a valid baby-jubjub point
80
+ - increases signups counter
81
+ - registers the user using the sign up gatekeeper contract. It is important that whichever gatekeeper is used, this reverts if a user tries to sign up twice or the conditions are not met (i.e returning false is not enough)
82
+ - calls the voice credit proxy to retrieve the number of allocated voice credits allocated to this voter
83
+ - hashes the voice credits alongside the user's MACI public key and the current time
84
+ - enqueues this hashed data into the `stateAq` contract
85
+
86
+ ```javascript
87
+ function signUp(
88
+ PubKey memory _pubKey,
89
+ bytes memory _signUpGatekeeperData,
90
+ bytes memory _initialVoiceCreditProxyData
91
+ ) public virtual {
92
+ // prevent new signups until we merge the roots (possible DoS)
93
+ if (subtreesMerged) revert SignupTemporaryBlocked();
94
+
95
+ // ensure we do not have more signups than what the circuits support
96
+ if (numSignUps >= uint256(TREE_ARITY) ** uint256(stateTreeDepth)) revert TooManySignups();
97
+
98
+ if (_pubKey.x >= SNARK_SCALAR_FIELD || _pubKey.y >= SNARK_SCALAR_FIELD) {
99
+ revert MaciPubKeyLargerThanSnarkFieldSize();
100
+ }
101
+
102
+ // Increment the number of signups
103
+ // cannot overflow with realistic STATE_TREE_DEPTH
104
+ // values as numSignUps < 5 ** STATE_TREE_DEPTH -1
105
+ unchecked {
106
+ numSignUps++;
107
+ }
108
+
109
+ // Register the user via the sign-up gatekeeper. This function should
110
+ // throw if the user has already registered or if ineligible to do so.
111
+ signUpGatekeeper.register(msg.sender, _signUpGatekeeperData);
112
+
113
+ // Get the user's voice credit balance.
114
+ uint256 voiceCreditBalance = initialVoiceCreditProxy.getVoiceCredits(msg.sender, _initialVoiceCreditProxyData);
115
+
116
+ uint256 timestamp = block.timestamp;
117
+ // Create a state leaf and enqueue it.
118
+ uint256 stateLeaf = hashStateLeaf(StateLeaf(_pubKey, voiceCreditBalance, timestamp));
119
+ uint256 stateIndex = stateAq.enqueue(stateLeaf);
120
+
121
+ emit SignUp(stateIndex, _pubKey.x, _pubKey.y, voiceCreditBalance, timestamp);
122
+ }
123
+ ```
124
+
125
+ Once everything has been setup, polls can be deployed using the `deployPoll` function. It should be noted that currently, after the first poll is deployed, in order to deploy a new one, the state tree must have been merged (and this can be triggered by Poll contracts using `Poll.mergeMaciStateAqSubRoots` and `Poll.mergeMaciStateAq`)
126
+
127
+ ```javascript
128
+ function deployPoll(
129
+ uint256 _duration,
130
+ TreeDepths memory _treeDepths,
131
+ PubKey memory _coordinatorPubKey,
132
+ address _verifier,
133
+ address _vkRegistry,
134
+ bool useSubsidy
135
+ ) public virtual onlyOwner returns (PollContracts memory pollAddr) {
136
+ // cache the poll to a local variable so we can increment it
137
+ uint256 pollId = nextPollId;
138
+
139
+ // Increment the poll ID for the next poll
140
+ // 2 ** 256 polls available
141
+ unchecked {
142
+ nextPollId++;
143
+ }
144
+
145
+ if (pollId > 0) {
146
+ if (!stateAq.treeMerged()) revert PreviousPollNotCompleted(pollId);
147
+ }
148
+
149
+ MaxValues memory maxValues = MaxValues({
150
+ maxMessages: uint256(TREE_ARITY) ** _treeDepths.messageTreeDepth,
151
+ maxVoteOptions: uint256(TREE_ARITY) ** _treeDepths.voteOptionTreeDepth
152
+ });
153
+
154
+ address _owner = owner();
155
+
156
+ address p = pollFactory.deploy(
157
+ _duration,
158
+ maxValues,
159
+ _treeDepths,
160
+ _coordinatorPubKey,
161
+ address(this),
162
+ topupCredit,
163
+ _owner
164
+ );
165
+
166
+ address mp = messageProcessorFactory.deploy(_verifier, _vkRegistry, p, _owner);
167
+ address tally = tallyFactory.deploy(_verifier, _vkRegistry, p, mp, _owner);
168
+
169
+ address subsidy;
170
+ if (useSubsidy) {
171
+ subsidy = subsidyFactory.deploy(_verifier, _vkRegistry, p, mp, _owner);
172
+ }
173
+
174
+ polls[pollId] = p;
175
+
176
+ // store the addresses in a struct so they can be returned
177
+ pollAddr = PollContracts({ poll: p, messageProcessor: mp, tally: tally, subsidy: subsidy });
178
+
179
+ emit DeployPoll(pollId, _coordinatorPubKey.x, _coordinatorPubKey.y, pollAddr);
180
+ }
181
+ ```
182
+
183
+ :::info
184
+ Please be advised that the number of signups in the MACI contract (number of leaves in the merkle tree holding MACI's state) considers the initial zero leaf as one signup. For this reason, when accounting for the real users signed up to MACI, you should subtract one from the value returned from the `numSignUps` function.
185
+ :::
186
+
187
+ ## Poll.sol
188
+
189
+ This contract allows users to submit their votes.
190
+
191
+ The main functions of the contract are as follows:
192
+
193
+ - `topup` - This function accepts two parameters, a `stateIndex`, and an `amount`. It can only be called before the voting deadline.
194
+ After checking whether the deadline has passed or not, it will validate that the contract has not reached the maximum number of messages, if the checks passes, it will increase the number of messages by 1.
195
+ It will then try to transfer the amount of `topUpCredit` tokens.
196
+ Finally, it will create a new Message object that will be hashed and enqueued in the `messageAq` contract. This messageAq contract is reserved for this one poll only and will only contain its messages.
197
+ - `publishMessage` - This function allows anyone to publish a message, and it accepts the message object as well as an ephemeral public key. This key together with the coordinator public key will be used to generate a shared ECDH key that will encrypt the message.
198
+ Before saving the message, the function will check that the voting deadline has not passed, as well as the max number of messages was not reached.
199
+ - `publisMessageBatch` - This function allows to submit a batch of messages, and it accepts an array of messages with their corresponding public keys used in the encryption step. It will call the `publishMessage` function for each message in the array.
200
+
201
+ The `mergeMaciStateAqSubRoots` function can be called by the contract admin after the voting deadline and looks like the following:
202
+
203
+ ```javascript
204
+ function mergeMaciStateAqSubRoots(uint256 _numSrQueueOps, uint256 _pollId) public onlyOwner isAfterVotingDeadline {
205
+ // This function cannot be called after the stateAq was merged
206
+ if (stateAqMerged) revert StateAqAlreadyMerged();
207
+
208
+ // merge subroots
209
+ extContracts.maci.mergeStateAqSubRoots(_numSrQueueOps, _pollId);
210
+
211
+ emit MergeMaciStateAqSubRoots(_numSrQueueOps);
212
+ }
213
+ ```
214
+
215
+ If the subtrees have not been merged on the MACI contract's `stateAq`, then it will merge it by calling `mergeStateAqSubroots`. It accepts two parameters:
216
+
217
+ - `_numSrQueueOps` - the number of operations required
218
+ - `_pollId` - the id of the poll
219
+
220
+ After merging the subroots, a coordinator's job is to merge the main state root, using `mergeMaciStateAq`:
221
+
222
+ ```javascript
223
+ function mergeMaciStateAq(uint256 _pollId) public onlyOwner isAfterVotingDeadline {
224
+ // This function can only be called once per Poll after the voting
225
+ // deadline
226
+ if (stateAqMerged) revert StateAqAlreadyMerged();
227
+
228
+ // set merged to true so it cannot be called again
229
+ stateAqMerged = true;
230
+
231
+ // the subtrees must have been merged first
232
+ if (!extContracts.maci.stateAq().subTreesMerged()) revert StateAqSubtreesNeedMerge();
233
+
234
+ mergedStateRoot = extContracts.maci.mergeStateAq(_pollId);
235
+
236
+ // Set currentSbCommitment
237
+ uint256[3] memory sb;
238
+ sb[0] = mergedStateRoot;
239
+ sb[1] = emptyBallotRoots[treeDepths.voteOptionTreeDepth - 1];
240
+ sb[2] = uint256(0);
241
+
242
+ currentSbCommitment = hash3(sb);
243
+
244
+ numSignups = extContracts.maci.numSignUps();
245
+ emit MergeMaciStateAq(mergedStateRoot, numSignups);
246
+ }
247
+ ```
248
+
249
+ This function only accepts one parameter, and can be called by the owner only, after the voting deadline. The parameter is the pollId for which we want to perform the operation. This function can only be called once per poll, and it will check that the sub trees have been merged on MACI's AccQueue contract. Finally it will merge the whole AccQueue to generate the state root, and store the current commitment comprised of:
250
+
251
+ the Poseidon hash of the merkle root, an empty ballot root stored in the emptyBallotRoots mapping (shown below), and a zero.
252
+
253
+ ```javascript
254
+ emptyBallotRoots[0] = uint256(6579820437991406069687396372962263845395426835385368878767605633903648955255);
255
+ emptyBallotRoots[1] = uint256(9105453741665960449792281626882014222103501499246287334255160659262747058842);
256
+ emptyBallotRoots[2] = uint256(14830222164980158319423900821611648302565544940504586015002280367515043751869);
257
+ emptyBallotRoots[3] = uint256(12031563002271722465187541954825013132282571927669361737331626664787916495335);
258
+ emptyBallotRoots[4] = uint256(5204612805325639173251450278876337947880680931527922506745154187077640790699);
259
+ ```
260
+
261
+ It will also store the number of signups at this current block, as well as the merkle root of the state tree.
262
+
263
+ Now, the coordinator can also perform similar operations to merge the message tree.
264
+
265
+ - `mergeMessageAqSubRoots` - merges the Poll's messages tree subroot
266
+ - `mergeMessageAq` - merges the Poll's messages tree
267
+
268
+ ## PollFactory.sol
269
+
270
+ `PollFactory` is a smart contract that is used to deploy new Polls. This is used by MACI inside the `deployPoll` function.
271
+
272
+ ```ts
273
+ function deploy(
274
+ uint256 _duration,
275
+ MaxValues calldata _maxValues,
276
+ TreeDepths calldata _treeDepths,
277
+ PubKey calldata _coordinatorPubKey,
278
+ address _maci,
279
+ TopupCredit _topupCredit,
280
+ address _pollOwner
281
+ ) public virtual returns (address pollAddr) {
282
+ /// @notice Validate _maxValues
283
+ /// maxVoteOptions must be less than 2 ** 50 due to circuit limitations;
284
+ /// it will be packed as a 50-bit value along with other values as one
285
+ /// of the inputs (aka packedVal)
286
+ if (_maxValues.maxVoteOptions >= (2 ** 50)) {
287
+ revert InvalidMaxValues();
288
+ }
289
+
290
+ /// @notice deploy a new AccQueue contract to store messages
291
+ AccQueue messageAq = new AccQueueQuinaryMaci(_treeDepths.messageTreeSubDepth);
292
+
293
+ /// @notice the smart contracts that a Poll would interact with
294
+ ExtContracts memory extContracts = ExtContracts({
295
+ maci: IMACI(_maci),
296
+ messageAq: messageAq,
297
+ topupCredit: _topupCredit
298
+ });
299
+
300
+ // deploy the poll
301
+ Poll poll = new Poll(_duration, _maxValues, _treeDepths, _coordinatorPubKey, extContracts);
302
+
303
+ // Make the Poll contract own the messageAq contract, so only it can
304
+ // run enqueue/merge
305
+ messageAq.transferOwnership(address(poll));
306
+
307
+ // init Poll
308
+ poll.init();
309
+
310
+ poll.transferOwnership(_pollOwner);
311
+
312
+ pollAddr = address(poll);
313
+ }
314
+ ```
315
+
316
+ Upon deployment, the following will happen:
317
+
318
+ - ownership of the `messageAq` contract is transferred to the deployed poll contract
319
+ - ownership of the new `Poll` contract is transferred to the poll owner, which in `MACI` is set as the owner of `MACI`.
320
+
321
+ ## MessageProcessor
322
+
323
+ This contract is used to prepare parameters for the zk-SNARK circuits as well as for verifying proofs. It should be deployed alongside `MACI` and ownership assigned to the coordinator.
324
+ It will process messages in batches, and after all batches have been processed, the `sbCommitment` can then be used for the `Tally` and `Subsidy` contracts.
325
+
326
+ ## Tally
327
+
328
+ :::info
329
+ The `Tally` contract is present also in a non quadratic voting fashion, and is slightly smaller due to not having the `verifyPerVOSpentVoiceCredits` function. This is not required because with normal (non quadratic) voting, each vote by a user is not the square root of the voice credits spent.
330
+ :::
331
+
332
+ The `Tally` contract is used by the coordinator to submit commitments to the tally results via the `tallyVotes` function. This is done in batches and the final commitment can be used by the users to verify the validity of the results.
333
+
334
+ Below are the functions which users can use to verify the results:
335
+
336
+ - `verifySpentVoiceCredits`
337
+ - `verifyPerVOSpentVoiceCredits`
338
+ - `verifyTallyResult`
339
+
340
+ ## Subsidy (optional)
341
+
342
+ The subsidy contract can be used by the coordinator to post proofs of valid subsidy calculations, as well as users to verify that the subsidy calculations were performed correctly.
343
+
344
+ ## SignUpToken (optional)
345
+
346
+ This contract can be used by the `SignUpGateKeeper` to determine whether a user is allowed to register. The default contract provided with MACI is a simple ERC721 token. Coordinators can use this contract to mint a token for each of the participants in the voting process, and gatekeep access to a round by using a `SignUpTokenGatekeeper` contract.
347
+
348
+ ## SignUpGatekeeper
349
+
350
+ MACI requires a signup gatekeeper to ensure that only designed users register. It is up to MACI's deployer how they wish to allow sign-ups, therefore they can implement their own GateKeeper. The repository comes with different options:
351
+
352
+ - `FreeForAllGatekeeper` - This allows anyone to signup on MACI.
353
+ - `SignUpTokenGatekeeper` - This makes use of a ERC721 token to gatekeep the signup function.
354
+ - `EASGatekeeper` - This allows gatekeeping signups to only users who have a specific EAS attestation.
355
+
356
+ An abstract contract to inherit from is also provided, with two function signatures as shown below:
357
+
358
+ ```ts
359
+ abstract contract SignUpGatekeeper {
360
+ function setMaciInstance(MACI _maci) public virtual {}
361
+ function register(address _user, bytes memory _data) public virtual {}
362
+ }
363
+ ```
364
+
365
+ The MACI contract will need to call the `SignUpGatekeeper.register` function inside the `MACI.signUp` function.
366
+
367
+ ## VoiceCreditProxy
368
+
369
+ The VoiceCreditProxy contract is used to assign voice credits to users. Whichever implementation should the MACI deployers use, this must implement a view function that returns the balance for a user, such as the one below:
370
+
371
+ ```javascript
372
+ function getVoiceCredits(address _user, bytes memory _data) public virtual view returns (uint256) {}
373
+ ```
374
+
375
+ The repository comes with a simple implementation called `InitialVoiceCreditProxy` which assigns a fixed amount of voice credits to each user.
376
+
377
+ ## Hasher
378
+
379
+ This contract exposes methods to hash different number of parameters with the Poseidon hash function.
380
+
381
+ ## VkRegistry
382
+
383
+ The VkRegistry is a contract that holds the verifying keys for the zk-SNARK circuits. It holds three different sets of keys:
384
+
385
+ - `processVks` - The keys for the processMessages circuit
386
+ - `tallyVks` - The keys for the tallyVotes circuit
387
+ - `subsidyVk` - The keys for the subsidy circuit
388
+
389
+ Each circuit will have a signature which is its compile-time constants represented as a uint256.
390
+
391
+ ## Params
392
+
393
+ A contract holding three structs:
394
+
395
+ ```c
396
+ /// @notice A struct holding the depths of the merkle trees
397
+ struct TreeDepths {
398
+ uint8 intStateTreeDepth;
399
+ uint8 messageTreeSubDepth;
400
+ uint8 messageTreeDepth;
401
+ uint8 voteOptionTreeDepth;
402
+ }
403
+
404
+ /// @notice A struct holding the max values for the poll
405
+ struct MaxValues {
406
+ uint256 maxMessages;
407
+ uint256 maxVoteOptions;
408
+ }
409
+
410
+ /// @notice A struct holding the external contracts
411
+ /// that are to be passed to a Poll contract on
412
+ /// deployment
413
+ struct ExtContracts {
414
+ IMACI maci;
415
+ AccQueue messageAq;
416
+ TopupCredit topupCredit;
417
+ }
418
+ ```
419
+
420
+ Struct parameters are used to avoid stack too deep errors in the other contracts.
421
+
422
+ ## AccQueue
423
+
424
+ The AccQueue contract represents a Merkle Tree where each leaf insertion only updates a subtree. To obtain the main tree root, the subtrees must be merged together by the contract owner. This requires at least two operations, a `mergeSubRoots` and a `merge`.
425
+
426
+ The contract can be initialized to work as a traditional Merkle Tree (2 leaves per node) or a Quinary Tree (5 leaves per node). This can be achieved by passing either two or five as parameter to the constructor (`_hashLength`). Any other values should not be accepted.
427
+
428
+ Below are presented the most important functions of the smart contract:
429
+
430
+ - `enqueue` - Allows to add a leaf to the queue for the current subtree. Only one parameter is accepted and that is the leaf to insert.
431
+ - `insertSubTree` - Admin only function which allows to insert a full subtree (batch enqueue)
432
+ - `mergeSubRoots` - Allows the contract owner to merge all of the subtrees to form the shortest possible tree. The argument `_numSrQueueOps` can be used to perform the operation in multiple transactions (as this might trigger the block gas limit).
433
+ - `merge` - Allows the contract admin to form a main tree with the desired depth. The depth must fit all of the leaves.
434
+
435
+ ## EmptyBallotRoots
436
+
437
+ This contract contains the roots of Ballot trees of five leaf configurations.
438
+
439
+ ```javascript
440
+ emptyBallotRoots[0] = uint256(6579820437991406069687396372962263845395426835385368878767605633903648955255);
441
+ emptyBallotRoots[1] = uint256(9105453741665960449792281626882014222103501499246287334255160659262747058842);
442
+ emptyBallotRoots[2] = uint256(14830222164980158319423900821611648302565544940504586015002280367515043751869);
443
+ emptyBallotRoots[3] = uint256(12031563002271722465187541954825013132282571927669361737331626664787916495335);
444
+ emptyBallotRoots[4] = uint256(5204612805325639173251450278876337947880680931527922506745154187077640790699);
445
+ ```
@@ -0,0 +1,91 @@
1
+ ---
2
+ title: MACI Contributor Code of Conduct
3
+ description: The Contributor Covenant Code of Conduct for MACI
4
+ sidebar_label: Code of Conduct
5
+ ---
6
+
7
+ # Contributor Covenant Code of Conduct
8
+
9
+ Please see our guide on [contributing to MACI](/docs/contributing).
10
+
11
+ ## Our Pledge
12
+
13
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
14
+
15
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
16
+
17
+ ## Our Standards
18
+
19
+ Examples of behavior that contributes to a positive environment for our community include:
20
+
21
+ - Demonstrating empathy and kindness toward other people
22
+ - Being respectful of differing opinions, viewpoints, and experiences
23
+ - Giving and gracefully accepting constructive feedback
24
+ - Accepting responsibility and apologizing to those affected by our mistakes,
25
+ and learning from the experience
26
+ - Focusing on what is best not just for us as individuals, but for the
27
+ overall community
28
+
29
+ Examples of unacceptable behavior include:
30
+
31
+ - The use of sexualized language or imagery, and sexual attention or
32
+ advances of any kind
33
+ - Trolling, insulting or derogatory comments, and personal or political attacks
34
+ - Public or private harassment
35
+ - Publishing others' private information, such as a physical or email
36
+ address, without their explicit permission
37
+ - Other conduct which could reasonably be considered inappropriate in a
38
+ professional setting
39
+
40
+ ## Enforcement Responsibilities
41
+
42
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
43
+
44
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
49
+
50
+ ## Enforcement
51
+
52
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement.
53
+ All complaints will be reviewed and investigated promptly and fairly.
54
+
55
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
56
+
57
+ ## Enforcement Guidelines
58
+
59
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
60
+
61
+ ### 1. Correction
62
+
63
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
64
+
65
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
66
+
67
+ ### 2. Warning
68
+
69
+ **Community Impact**: A violation through a single incident or series of actions.
70
+
71
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
72
+
73
+ ### 3. Temporary Ban
74
+
75
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
76
+
77
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
78
+
79
+ ### 4. Permanent Ban
80
+
81
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
82
+
83
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
84
+
85
+ ## Attribution
86
+
87
+ This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org/), version 2.0, [available here](https://www.contributor-covenant.org/version/2/0/code_of_conduct.html).
88
+
89
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
90
+
91
+ For answers to common questions about this code of conduct, see [the FAQ](https://www.contributor-covenant.org/faq). [Translations are available here](https://www.contributor-covenant.org/translations).
@@ -0,0 +1,129 @@
1
+ ---
2
+ title: Contributing to MACI
3
+ description: Instructions on how to contribute to MACI
4
+ sidebar_label: Contributing
5
+ sidebar_position: 21
6
+ ---
7
+
8
+ # Contributing
9
+
10
+ 🎉 Thank you for being interested in contributing to MACI! 🎉
11
+
12
+ Feel welcome and read the following sections in order to know how to ask questions and how to work on something.
13
+
14
+ All members of our community are expected to follow our [Code of Conduct](/docs/contributing/code-of-conduct). Please make sure you are welcoming and friendly in all of our spaces.
15
+
16
+ We're really glad you're reading this, because we need volunteer developers to help this project come to fruition. There is a lot we want to achieve, and this can only be made possible thanks to your support. 👏
17
+
18
+ ## Issues
19
+
20
+ The best way to contribute to our projects is by opening a [new issue](https://github.com/privacy-scaling-explorations/maci/issues) or tackling one of the issues listed [here](https://github.com/privacy-scaling-explorations/maci/contribute).
21
+
22
+ ## Pull Requests
23
+
24
+ Pull requests are great if you want to add a feature or fix a bug. Here's a quick guide:
25
+
26
+ 1. Ensure there is an issue tracking your work.
27
+
28
+ 2. Fork the repo.
29
+
30
+ 3. Run the tests. We only take pull requests with passing tests.
31
+
32
+ 4. Add a test for your change. Only refactoring and documentation changes require no new tests.
33
+
34
+ 5. Make sure to check out the [Style Guide](#style-guide) and ensure that your code complies with the rules.
35
+
36
+ 6. Make sure you read our [GitHub processes](https://github.com/privacy-scaling-explorations/maci/discussions/847) documentation.
37
+
38
+ 7. Make the test pass.
39
+
40
+ 8. Commit your changes. Please make sure your forked `dev` branch is synched as well feature/fix branch and there are no "temp" commits (like wip, fix typo/lint/types and etc). We recommend to squash the feature/fix branch commits before creating PR. You can use this command for it:
41
+
42
+ ```bash
43
+ git reset $(git merge-base dev $(git rev-parse --abbrev-ref HEAD))
44
+ ```
45
+
46
+ 9. Push to your fork and submit a pull request on our `dev` branch. Please provide us with some explanation of why you made the changes you made. For new features make sure to explain a standard use case to us.
47
+
48
+ 10. Link any issues that the PR is addressing as described in our processes documentation.
49
+
50
+ ## CI (Github Actions) Tests
51
+
52
+ We use GitHub Actions to test each PR before it is merged.
53
+
54
+ When you submit your PR (or later change that code), a CI build will automatically be kicked off. A note will be added to the PR, and will indicate the current status of the build.
55
+
56
+ Please refer to our [testing guide](/docs/testing) for more details on how we run tests across the monorepo.
57
+
58
+ ## Style Guide
59
+
60
+ ### Code rules
61
+
62
+ We always use ESLint and Prettier. To check that your code follows the rules, simply run the pnpm script `pnpm run lint` and `pnpm run prettier`. When committing, `eslint` is run automatically, so you will be required to fix any error before being able to push a commit. We highly recommend to tackle warnings as well.
63
+
64
+ ### Commits rules
65
+
66
+ For commits it is recommended to use [Conventional Commits](https://www.conventionalcommits.org). You may install the [commitizen](https://commitizen-tools.github.io/commitizen/) tool to help you with this.
67
+
68
+ Each commit message consists of a **header**, a **body** and a **footer**. The **header** has a special format that includes a **type**, a **scope** and a **subject**:
69
+
70
+ ```
71
+ <type>(<scope>): <subject>
72
+ <BLANK LINE>
73
+ <body>
74
+ <BLANK LINE>
75
+ <footer>
76
+ ```
77
+
78
+ The **header** is mandatory and the **scope** of the header must contain the name of the component you are working on.
79
+
80
+ #### Type
81
+
82
+ The type must be one of the following:
83
+
84
+ - feat: A new feature
85
+ - fix: A bug fix
86
+ - docs: Documentation only changes
87
+ - style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
88
+ - refactor: A code change that neither fixes a bug nor adds a feature (improvements of the code structure)
89
+ - perf: A code change that improves the performance
90
+ - test: Adding missing or correcting existing tests
91
+ - build: Changes that affect the build system or external dependencies (example scopes: gulp, npm)
92
+ - ci: Changes to CI configuration files and scripts (example scopes: travis, circle)
93
+ - chore: Other changes that don't modify src or test files
94
+ - revert: Reverts a previous commit
95
+
96
+ #### Scope
97
+
98
+ The scope should be the name of the feature or package modified (as perceived by the person reading the changelog generated from commit messages).
99
+
100
+ #### Subject
101
+
102
+ The subject contains a succinct description of the change:
103
+
104
+ - Use the imperative, present tense: "change" not "changed" nor "changes"
105
+ - Don't capitalize the first letter
106
+ - No dot (.) at the end
107
+
108
+ #### Body
109
+
110
+ Just as in the subject, use the imperative, present tense: "change" not "changed" nor "changes". The body should include the motivation for the change and contrast this with previous behavior.
111
+
112
+ ### Branch rules
113
+
114
+ - Branches should generally be created off of the base branch (`dev` )
115
+ - Avoid long descriptive names for long-lived branches
116
+ - Use kebab-case (no CamelCase)
117
+ - Use grouping tokens (words) at the beginning of your branch names (in a similar way to the `type` of commit)
118
+ - Define and use short lead tokens to differentiate branches in a way that is meaningful to your workflow
119
+ - Use slashes to separate parts of your branch names
120
+ - Remove branch after merge if it is not important
121
+
122
+ Examples:
123
+
124
+ ```bash
125
+ git branch -b docs/readme
126
+ git branch -b test/a-feature
127
+ git branch -b feat/sidebar
128
+ git branch -b fix/b-feature
129
+ ```