Compare commits

..

355 Commits

Author SHA1 Message Date
cedoor
281f00ebd5 chore: v3.10.0
Former-commit-id: 63e7e7a7937b84be9122d060b7ec3bf73b182703
2023-05-15 16:13:43 +01:00
Cedoor
f2575f2bec Merge pull request #324 from semaphore-protocol/feat/is-member
New function to check if a member exists

Former-commit-id: e783465dc2
2023-05-15 15:50:18 +01:00
cedoor
3bfc7ce2bc style(data): format code with prettier
Former-commit-id: 2b430dace0
2023-05-15 15:43:50 +01:00
cedoor
ef88c9c84c feat(data): create function to check if a member exists
re #321


Former-commit-id: 9d7076acc7
2023-05-15 15:35:53 +01:00
Cedoor
6580b6620f Merge pull request #322 from semaphore-protocol/feat/init-members
New class parameter to add members

Former-commit-id: 5915ea082b
2023-05-15 12:59:46 +01:00
cedoor
42d33e2af7 feat(group): add new class parameter to add members
re #319


Former-commit-id: ed015ccc83
2023-05-15 12:46:44 +01:00
Cedoor
594c612318 Merge pull request #316 from semaphore-protocol/docs/update-readme-data-package
Update readme file in data package

Former-commit-id: 0ee1fa2b72
2023-05-02 09:46:50 +01:00
vplasencia
fbfa92023d docs(data): update readme file
Former-commit-id: 594daba6cc
2023-05-01 20:58:00 +02:00
cedoor
caed0aecc1 test(data): add test for new function
Former-commit-id: 0cb0ef3514
2023-04-28 12:32:30 +01:00
cedoor
7bcc44c645 chore: v3.9.0
Former-commit-id: 900da9cef5
2023-04-28 12:27:48 +01:00
Cedoor
0ac390eaf0 Merge pull request #315 from semaphore-protocol/feat/subgraph
Sepolia subgraph & supported networks

Former-commit-id: f50a16054b
2023-04-28 11:33:57 +01:00
cedoor
5db4c61c28 feat(data): provide function to get supported networks
re #314


Former-commit-id: 5e033556fb
2023-04-27 16:04:20 +01:00
cedoor
37dc17d880 feat(data): add sepolia subgraph support
Former-commit-id: 92a6a7a354
2023-04-27 16:03:54 +01:00
cedoor
a04057f861 chore: v3.8.0
Former-commit-id: 736bddbd83
2023-04-26 15:34:48 +01:00
Cedoor
29e8f5852f Merge pull request #312 from semaphore-protocol/feat/nullifier-hash
New function to calculate nullifier hash

Former-commit-id: 946ac8333c
2023-04-26 15:20:20 +01:00
Cedoor
26c76f453e Merge pull request #313 from 0xdeenz/main
chore: add Block Qualified to list of projects
Former-commit-id: 37951ff29e
2023-04-26 12:43:24 +01:00
cedoor
9a1a1e7853 docs: update package docs links
Former-commit-id: 8ff372ef35
2023-04-26 12:37:09 +01:00
cedoor
f583caa243 ci(github): add semaphore js cname
Former-commit-id: 9a24d36c0b
2023-04-26 12:25:20 +01:00
0xdeenz
b399b923ab chore: add Block Qualified to list of projects
Former-commit-id: dc7e0a1d0b
2023-04-25 20:04:37 +02:00
Cedoor
65e5d29dcd docs(proof): update README.md
Former-commit-id: 3f1432c8b9
2023-04-22 17:28:06 +01:00
cedoor
ba9782139e feat(proof): add function to calculate nullifier hash
Former-commit-id: 6cc2b6af1c
2023-04-22 17:23:52 +01:00
Cedoor
edef368976 Merge pull request #311 from semaphore-protocol/ref/cli
Update get-proofs description

Former-commit-id: 10024bced9
2023-04-22 10:42:14 +01:00
vplasencia
77fddc9b16 docs(cli): update the description of get-proofs command in the readme file
Former-commit-id: d151998013
2023-04-22 09:26:21 +02:00
vplasencia
69b2b8fd7b refactor(cli): update get-proofs description
Former-commit-id: eb63447166
2023-04-22 09:19:54 +02:00
cedoor
aba7d51f86 chore: v3.7.0
Former-commit-id: 22f33a8f26
2023-04-20 11:28:32 +01:00
Cedoor
32d1b47964 Merge pull request #310 from semaphore-protocol/docs/cli
Update the Readme file to add the new CLI commands

Former-commit-id: faf7ff9c18
2023-04-20 11:20:02 +01:00
vplasencia
cb3ff0fcb8 docs(cli): update the readme file to add the new commands
Former-commit-id: e7ceb37503
2023-04-20 10:15:51 +02:00
Cedoor
4d4338d3bc Merge pull request #309 from semaphore-protocol/chore/community-projects
Semaphore projects

Former-commit-id: f0574c4c40
2023-04-19 12:21:20 +01:00
cedoor
536410457e chore: add some projects
Former-commit-id: 3ee4cebd35
2023-04-19 12:08:58 +01:00
Cedoor
7469086a2a docs: add section for semaphore projects
Former-commit-id: 37bbdb4dc0
2023-04-19 12:06:29 +01:00
cedoor
3496aa6478 chore: update issue template to add projects
Former-commit-id: 10909c63c4
2023-04-19 11:28:16 +01:00
cedoor
60d5110905 chore: create json for community projects
Former-commit-id: b98bdb3a1d
2023-04-19 11:27:49 +01:00
Cedoor
0da64796ea Merge pull request #306 from vimwitch/bump-poseidon-lite
chore: bump poseidon-lite minor version
Former-commit-id: 617bb364ae
2023-04-19 10:43:56 +02:00
Chance
41ab36d24c chore: bump poseidon-lite minor version
Former-commit-id: 9f9ec7054b
2023-04-19 00:47:13 -05:00
vplasencia
6bcd77fe5b chore: vv3.6.0
Former-commit-id: c52f0036da
2023-04-11 19:49:21 +02:00
vplasencia
4a221a43c7 refactor(cli): copy the contents of the .env.example file to a new .env file
Former-commit-id: 74c2ed1b3a
2023-04-11 14:01:28 +02:00
vplasencia
37465288a7 refactor(cli): set the monorepo-ethers template as default when creating a project
Former-commit-id: 27ba252565
2023-04-11 13:48:59 +02:00
vplasencia
c38b3c5255 chore: v3.6.0-beta.4
Former-commit-id: aabad74de7
2023-04-11 11:43:15 +02:00
vplasencia
dba7a6ca85 chore: v3.6.0-beta.3
Former-commit-id: e17737d894
2023-04-07 19:36:36 +02:00
vplasencia
468a3314e3 fix(cli): update package.json file in monorepos with correct package names
Former-commit-id: c4f3565546
2023-04-07 19:10:11 +02:00
vplasencia
a80b1136cd chore: v3.6.0-beta.2
Former-commit-id: fe8a48be0d
2023-04-07 17:37:11 +02:00
vplasencia
44328f1893 chore(cli): create a script to remove unnecessary files in monorepo templates
Former-commit-id: 02658c0780
2023-04-07 17:28:18 +02:00
vplasencia
a0c1c27c35 refactor(cli): add the next-env.d.ts file to gitignore
Former-commit-id: 02d1395828
2023-04-07 14:12:53 +02:00
vplasencia
f6be176df9 chore: v3.6.0-beta.1
Former-commit-id: 6b9c9c1f28
2023-04-07 12:02:14 +02:00
vplasencia
1a2eb3e18d chore(cli): decompress and then remove the files.tgz file after downloading a template
Former-commit-id: 2467291010
2023-04-07 09:15:52 +02:00
vplasencia
44b25995e0 fix(cli): add gitignore file
Former-commit-id: bd897a6d97
2023-04-06 19:58:23 +02:00
cedoor
f1b3368529 fix(data): check if groups exist before adding members
Former-commit-id: 6e453ff32a
2023-04-06 18:36:05 +01:00
cedoor
5c64b09f51 chore(cli): create prepublish script to compress files
Former-commit-id: 206106ad66
2023-04-06 17:38:56 +01:00
vplasencia
fd08c3f2e7 chore: v3.6.0-beta.0
Former-commit-id: 4996ec1d9f
2023-04-06 15:28:09 +02:00
vplasencia
01fa043b4d chore: add files field in the package.json file in monorepo-ethers and monorepo-subgraph templates
Former-commit-id: 6f381019ff
2023-04-06 14:35:42 +02:00
vplasencia
c10b57e3cf fix(cli): add solhint file in monorepo-ethers and monorepo-subgraph templates
Former-commit-id: 7d4871f858
2023-04-06 14:19:59 +02:00
vplasencia
9a7e053f64 chore: v3.6.0-1
Former-commit-id: 83762718e9
2023-04-05 18:12:31 +02:00
vplasencia
2e6b2d678a chore: remove private from package.json file in templates
Former-commit-id: 36f9b56241
2023-04-05 18:09:04 +02:00
Vivian Plasencia
cf1c039545 Merge pull request #304 from semaphore-protocol/fix/proof-event
Correct `ProofVerified` event parameters

Former-commit-id: 4ec0ba5baa
2023-04-05 17:46:34 +02:00
Vivian Plasencia
0a496e5375 Merge pull request #303 from semaphore-protocol/milestone/semaphore-cli-templates
Add new templates and commands in the CLI

Former-commit-id: 81435b1b7b
2023-04-05 17:45:47 +02:00
cedoor
ff6835d1db chore(data): update subgraph url and contract addresses
re #304


Former-commit-id: db2820e687
2023-04-05 16:04:48 +01:00
cedoor
b350cd4b66 style(contracts): format code with prettier
Former-commit-id: 41a88132c4
2023-04-05 12:37:58 +01:00
cedoor
f4508c4db5 chore(contracts): fresh semaphore contracts deployment
re #298


Former-commit-id: 8a9c42bace
2023-04-05 12:35:11 +01:00
cedoor
2df42d49c0 fix(contracts): set correct ProofVerifier event parameters
fix #297


Former-commit-id: 84813c519a
2023-04-05 11:20:16 +01:00
cedoor
fea6b8446c chore(cli): update monorepo templates semaphore deps
Former-commit-id: 045a2a2c54
2023-04-04 17:07:56 +01:00
cedoor
322051bd3a chore(cli): make monorepo cli templates private
Former-commit-id: 0a3654bfbe
2023-04-04 16:58:32 +01:00
cedoor
6ae1249618 fix: limit some npm scripts to public packages
Former-commit-id: 94bbf40e96
2023-04-04 16:57:56 +01:00
cedoor
8528e9e758 refactor(cli): update template apps' names
Former-commit-id: 58de92a335
2023-04-04 16:36:19 +01:00
vplasencia
9bea6143a6 refactor(cli): change cli template names
Former-commit-id: 84c1dfa486
2023-04-04 16:23:34 +01:00
vplasencia
3b59bf6117 refactor(cli-template-monorepo-subgraph): rename cli hardhat-nextjs-semaphoresubgraph template
Former-commit-id: ee6e1c156d
2023-04-04 16:23:34 +01:00
vplasencia
cecdcc3fb1 refactor(cli-template-monorepo-ethers): rename cli hardhat-nextjs-semaphoreethers template package
Former-commit-id: 1c0d119e60
2023-04-04 16:23:34 +01:00
vplasencia
f57c2b4397 refactor(cli-template-contracts-hardhat): rename the cli hardhat template package
Former-commit-id: e38b040641
2023-04-04 16:23:26 +01:00
vplasencia
47f3651bc5 feat(cli): add inquirer to select a template when creating a project
Former-commit-id: 4d1a637093
2023-04-04 16:22:47 +01:00
vplasencia
8006983643 refactor: ignore .next and public folders
Former-commit-id: 6afb098709
2023-04-04 16:22:22 +01:00
vplasencia
3a7f18652f style: format code with prettier
Former-commit-id: 8475666016
2023-04-04 16:22:22 +01:00
vplasencia
c7a4cf7121 refactor(cli-template-monorepo-subgraph): add yarn.lock file
Former-commit-id: b363ce3955
2023-04-04 16:22:10 +01:00
vplasencia
66aa482b07 refactor(cli-template-monorepo-ethers): remove unused code
Former-commit-id: fcaac9f2e3
2023-04-04 16:20:47 +01:00
vplasencia
b89ed0ebb7 refactor(cli-template-hardhat-nextjs-semaphoresubgraph): remove unused import statement
Former-commit-id: 5dbbdd1b2c
2023-04-04 16:20:19 +01:00
vplasencia
4cf00f33d0 refactor(cli-template-hardhat-nextjs-semaphoresubgraph): remove unused code
Former-commit-id: e5cf466a5f
2023-04-04 16:20:19 +01:00
vplasencia
a3309ab707 feat(cli-template-hardhat-nextjs-semaphoresubgraph): add hardhat-nextjs-semaphoresubgraph template
Former-commit-id: 58310b5e67
2023-04-04 16:20:19 +01:00
vplasencia
30449c4fe7 refactor(cli-template-hardhat-nextjs-semaphoreethers): update package names
Former-commit-id: eb997a8488
2023-04-04 16:20:19 +01:00
vplasencia
6b1f1a8c31 refactor(cli-template-hardhat-nextjs-semaphoreethers): add access public in package.json file
Former-commit-id: abfff13099
2023-04-04 16:20:19 +01:00
vplasencia
70c53b6203 feat(cli-template-hardhat-nextjs-semaphoreethers): add the hardhat-nextjs-semaphoreethers template
Former-commit-id: 53d878ce47
2023-04-04 16:20:19 +01:00
vplasencia
3313be7f38 style(cli): add total of elements in the output of get-groups get-members and get-proofs commands
Former-commit-id: 1b2f6b89fa
2023-04-04 16:20:19 +01:00
vplasencia
240fee73b4 style(cli): change output text of get-proofs command
Former-commit-id: 30f82d917b
2023-04-04 16:20:19 +01:00
vplasencia
7e85c1ddda fix(cli-template-hardhat): set the correct env file path
Former-commit-id: d9b0afbf31
2023-04-04 16:20:19 +01:00
vplasencia
18d724b166 perf(cli): optimize get-proofs command
Former-commit-id: 0b060f97ec
2023-04-04 16:20:19 +01:00
vplasencia
f97a233798 perf(cli): optimize get-members command
Former-commit-id: bb0b58e3f1
2023-04-04 16:20:19 +01:00
vplasencia
e146f3e84e refactor(cli): organize get group ids logic
Former-commit-id: 93e4a5d00b
2023-04-04 16:20:17 +01:00
cedoor
81fba57259 chore(cli): add types packages
re #189


Former-commit-id: 150a4c236b
2023-04-04 16:18:43 +01:00
vplasencia
07515c5068 feat(cli): add checks for template integrity
Former-commit-id: 14e39a101c
2023-04-04 16:18:40 +01:00
vplasencia
ad812f778b refactor(cli): organize inquirer prompts
Former-commit-id: d8ab9092ea
2023-04-04 16:18:00 +01:00
vplasencia
70727203fd feat(cli): split the get-group command to make it easier to query group data
Former-commit-id: 0cbbd9b28f
2023-04-04 16:18:00 +01:00
cedoor
b93acc884b chore: v3.5.0
Former-commit-id: 64a2e010f1
2023-03-31 13:14:48 +01:00
Cedoor
c9e565a445 Merge pull request #295 from semaphore-protocol/feat/identity-getter
New identity secret attribute and getter

Former-commit-id: 2af0af9a22
2023-03-31 12:53:30 +01:00
cedoor
6cea8c5dcc feat(identity): add new identity secret attribute and getter
re #294


Former-commit-id: 99ea3a15bc
2023-03-31 12:20:49 +01:00
Cedoor
5bd7cd93f7 Merge pull request #293 from semaphore-protocol/fix/semaphore-ethers
Correct nullifier hash parameter

Former-commit-id: 1118452cd4
2023-03-28 14:00:04 +01:00
cedoor
da1b4f6d8f fix(data): set correct nullifier hash parameter
Former-commit-id: d36a79e7ab
2023-03-28 12:52:46 +01:00
Cedoor
124f627d39 Merge pull request #292 from mmqxyz/patch-1
docs: fix small typos in Pairing.sol
Former-commit-id: 53963f7cd4
2023-03-28 11:01:50 +01:00
mmqxyz
199dca2a3b fix small typos in Pairing.sol
Former-commit-id: 9aa18b2fff
2023-03-28 11:32:29 +02:00
Cedoor
51accfc939 Merge pull request #291 from semaphore-protocol/docs/heyauthn-readme
Add new author

Former-commit-id: c77451857c
2023-03-24 10:16:47 +00:00
vplasencia
1696294881 style(heyauthn): format code with prettier
Former-commit-id: 220b34dade
2023-03-24 09:39:29 +01:00
vplasencia
c85b758120 docs(heyauthn): add new author
Former-commit-id: a31259011d
2023-03-24 09:28:38 +01:00
cedoor
12fd0f7a80 chore: v3.4.0
Former-commit-id: 254218b1e5
2023-03-21 19:41:10 +00:00
cedoor
78da99055d feat(cli): add support for arbitrum goerli
Former-commit-id: 7c4a2a1022
2023-03-21 19:40:40 +00:00
cedoor
77e4770b53 docs: add heyauthn docs link
Former-commit-id: ff692f1507
2023-03-21 19:35:50 +00:00
cedoor
799afc82f4 docs: add heyauthn package to readme
Former-commit-id: 79103bbbb0
2023-03-21 19:31:49 +00:00
cedoor
46fe2fc8f8 chore: v3.3.0
Former-commit-id: af89f3a0a1
2023-03-21 19:28:09 +00:00
cedoor
7bb9554388 style(heyauthn): format code with prettier
Former-commit-id: 587e3045c8
2023-03-21 19:22:22 +00:00
Cedoor
d88a71ec4d Merge pull request #285 from semaphore-protocol/feat/heyauthn
New HeyAuthn package

Former-commit-id: b497be753e
2023-03-21 19:17:11 +00:00
cedoor
2afc4ce1de style(cli): format code
Former-commit-id: 22ee1e0109
2023-03-21 11:36:42 +00:00
Cedoor
64f7b24c53 Merge pull request #281 from semaphore-protocol/feat/cli-sepolia-network
Add support for Sepolia network in the CLI

Former-commit-id: 889fe89162
2023-03-21 11:19:44 +00:00
Cedoor
88ba0af2d2 Merge pull request #282 from semaphore-protocol/chore/arbitrum-goerli
Semaphore support for Arbitrum Goerli network

Former-commit-id: 0a6061c9c5
2023-03-21 11:05:31 +00:00
vplasencia
c2e8ba6856 fix(cli): add admin in get-group when using SemaphoreEthers
Former-commit-id: 4641735932
2023-03-21 01:15:07 +01:00
cedoor
f9a8d68641 docs(heyauthn): add authors to readme file
re #284


Former-commit-id: 53637009b1
2023-03-20 16:37:55 +00:00
cedoor
df84100c22 feat(heyauthn): create heyauthn package
re #284


Former-commit-id: f67c1f07d7
2023-03-20 16:29:26 +00:00
cedoor
b962339203 feat(data): add support for arbitrum goerli network
re #275


Former-commit-id: 0571bbcdaa
2023-03-20 12:42:52 +00:00
Cedoor
073f5a5772 Merge pull request #283 from semaphore-protocol/feat/cli-template-hardhat
Add new version of cli-template-hardhat

Former-commit-id: e44ca7d447
2023-03-20 12:18:09 +00:00
vplasencia
b26f74a453 feat(cli-template-hardhat): add new version of cli-template-hardhat
Former-commit-id: 4133ae12c3
2023-03-20 12:36:12 +01:00
vplasencia
e9cac671f2 refactor(cli): remove unnecessary code in get-group command
Former-commit-id: 716a20cb7c
2023-03-17 23:11:40 +01:00
vplasencia
ecf8dcafb1 refactor(cli): remove unused code
Former-commit-id: 4ecf293cd4
2023-03-17 22:59:41 +01:00
vplasencia
f90c99193a refactor(cli): organize get-groups command code
Former-commit-id: eefffca9f4
2023-03-17 22:55:40 +01:00
vplasencia
a826708320 feat(cli): update get-group command to use sepolia
Former-commit-id: 4ddf75b378
2023-03-17 22:41:11 +01:00
cedoor
43370202a7 style(contracts): format code with prettier
Former-commit-id: ef393e9c03
2023-03-17 18:07:53 +00:00
cedoor
a4d1180d26 chore(contracts): deploy semaphore on arbitrum goerli network
re #275


Former-commit-id: e34ce9c61a
2023-03-17 18:01:40 +00:00
vplasencia
5c42f9e09c feat(cli): add support for sepolia network in the cli
Former-commit-id: 63666f6a9c
2023-03-17 14:27:58 +01:00
Cedoor
c8362e373b Merge pull request #280 from dbrans/patch-1
Comment typo in Pairing.sol

Former-commit-id: 032702b245
2023-03-17 10:53:27 +00:00
Derek Brans
06765f2f88 Fix typo in Pairing.sol
Former-commit-id: 0810ffbe0f
2023-03-16 19:15:42 -05:00
Cedoor
f26c84445e Merge pull request #279 from semaphore-protocol/chore/default-network
New default network (Sepolia)

Former-commit-id: 6c644522f0
2023-03-16 10:42:46 +00:00
cedoor
61a2d6adc2 test(data): update tests for semaphore ethers class
re #277


Former-commit-id: 8988f478c9
2023-03-15 19:04:23 +00:00
cedoor
eddd6b3dd5 chore(data): change default network
re #277


Former-commit-id: 49221b6ba7
2023-03-15 18:56:49 +00:00
cedoor
fa561f8f00 chore(cli): update command description
Former-commit-id: a4f9e47957
2023-03-15 18:55:34 +00:00
cedoor
c1842eefc3 chore: v3.2.3
Former-commit-id: 59d2d1367c
2023-03-13 22:52:08 +00:00
Cedoor
320187ff89 Merge pull request #276 from semaphore-protocol/fix/bundle-poseidon
JS bundles with Poseidon functions

Former-commit-id: e135b1d8fa
2023-03-13 22:51:20 +00:00
cedoor
abbf1a1d30 chore: update lockfile
Former-commit-id: 982ee86208
2023-03-13 22:41:37 +00:00
cedoor
59269b067d build: bundle poseidon-lite functions with rollup
Former-commit-id: 797e62dd28
2023-03-13 22:32:23 +00:00
cedoor
21bd9fe540 ci: update auto-assign workflow name
Former-commit-id: 6a3079bf52
2023-03-13 19:35:41 +00:00
Cedoor
f60a4c02f1 Merge pull request #274 from semaphore-protocol/chore/husky
New Husky script to check commit messages' format

Former-commit-id: e00dc8eca8
2023-03-13 19:30:46 +00:00
cedoor
d012310ae1 chore: add husky script to check commit message format
re #263


Former-commit-id: 77552b0da3
2023-03-13 19:26:40 +00:00
Cedoor
f01cb91472 chore: update github token
Former-commit-id: d33d306478
2023-03-13 19:25:17 +00:00
cedoor
31e6954aff style: format code with prettier
Former-commit-id: 0137d6e759
2023-03-13 18:36:01 +00:00
Cedoor
7518d938d1 Merge pull request #273 from semaphore-protocol/chore/auto-assign-action
New Github workflow to assign PRs

Former-commit-id: f777603fba
2023-03-13 18:31:43 +00:00
Cedoor
083d8a03a4 chore: update team name
Former-commit-id: 07244fc6bc
2023-03-13 18:30:56 +00:00
Cedoor
16c9e90ae4 chore: set org devs as reviewers
Former-commit-id: b9db0663ec
2023-03-13 18:18:50 +00:00
Cedoor
1fe2745594 chore: add github workflow to auto assign PRs
Former-commit-id: 0c6df193e4
2023-03-13 16:57:52 +00:00
cedoor
18d4b740ca chore: v3.2.2
Former-commit-id: 5ea3b7e6ef
2023-03-13 11:52:02 +00:00
Cedoor
8392173370 Merge pull request #272 from semaphore-protocol/fix/data-ethers
Correct check for group existence

Former-commit-id: 46c2ad2c7a
2023-03-13 11:50:59 +00:00
cedoor
26490304e4 fix(data): set correct check for group existence
Former-commit-id: 7b938935ca
2023-03-13 11:40:23 +00:00
cedoor
1878ce2320 chore: v3.2.1
Former-commit-id: 5cc6877d15
2023-03-11 21:41:08 +00:00
cedoor
98aed04bd9 chore(contracts): include Semaphore.sol contract in npm files
Former-commit-id: d227ee1907
2023-03-11 21:40:38 +00:00
cedoor
5a0585cec2 chore: add refactor type to changelog
Former-commit-id: 4f7af880a9
2023-03-10 13:09:10 +00:00
cedoor
1a51263e5c chore: v3.2.0
Former-commit-id: 33d814fe6d
2023-03-10 11:19:52 +00:00
cedoor
4d7a976f06 chore(cli): remove unused ts paths
Former-commit-id: 915b95dfc6
2023-03-10 11:10:25 +00:00
cedoor
fe07103ff2 chore(cli-template-hardhat): add supported networks to hardhat
Former-commit-id: 0780751954
2023-03-10 11:03:17 +00:00
Cedoor
aa230345fb Merge pull request #270 from semaphore-protocol/chore/optimism-goerli
Semaphore support for Optimism Goerli network

Former-commit-id: 6344cf4954
2023-03-10 10:55:47 +00:00
Cedoor
d5c24c0f9c Merge pull request #269 from semaphore-protocol/chore/mumbai
Semaphore support for Mumbai network

Former-commit-id: e002b24f2a
2023-03-10 10:55:19 +00:00
Cedoor
c1752dcb2e Merge pull request #271 from vimwitch/poseidon-lite-upgrade
Poseidon lite upgrade

Former-commit-id: 21f2287570
2023-03-09 20:35:49 +00:00
Chance
b00ff99e5e chore: bump poseidon-lite version
Former-commit-id: 1a27d0b28b
2023-03-09 14:05:48 -06:00
cedoor
00e3c4a7f5 feat(data): add support for optimism goerli network
re #234


Former-commit-id: 3722b154bf
2023-03-09 18:21:44 +00:00
cedoor
0176a67e3a style(contracts): format code with prettier
Former-commit-id: d9f888ab70
2023-03-09 18:03:09 +00:00
cedoor
4fa9f41483 chore(contracts): deploy semaphore on optimism goerli network
re #234


Former-commit-id: 55a48a27d1
2023-03-09 18:02:16 +00:00
cedoor
64b9ef28e8 chore(contracts): update hardhat etherscan plugin
Former-commit-id: 4241be137a
2023-03-09 18:01:03 +00:00
cedoor
d7ce540f88 style(contracts): format code with prettier
Former-commit-id: 2e5e00ae55
2023-03-09 15:33:26 +00:00
cedoor
3411f55403 feat(data): add support for mumbai network
re #233


Former-commit-id: 6b498912df
2023-03-09 15:19:34 +00:00
cedoor
1bc492c39d chore(contracts): deploy semaphore on mumbai network
re #233


Former-commit-id: c98889632e
2023-03-09 14:28:35 +00:00
Cedoor
6197a03734 Merge pull request #268 from semaphore-protocol/chore/sepolia
Semaphore on Sepolia network

Former-commit-id: eceec87727
2023-03-09 11:40:03 +00:00
cedoor
6369fdfa71 style(contracts): format code with prettier
Former-commit-id: 1013516ba2
2023-03-09 11:39:51 +00:00
cedoor
48f779cd90 chore(contracts): deploy semaphore on sepolia network
re #183


Former-commit-id: a296541c6d
2023-03-09 11:28:17 +00:00
Cedoor
3ff6709a7b Merge pull request #267 from 0xdeenz/main
refactor(contracts): change Semaphore__InvalidProof to InvalidProof

Former-commit-id: 4fab94e058
2023-03-09 10:25:38 +00:00
0xdeenz
90bb4ccfa0 refactor(contracts): change Semaphore__InvalidProof to InvalidProof
Makes Pairing.sol errors more generic for greater reusability

fix #266


Former-commit-id: dc39c4ca44
2023-03-08 23:27:08 +01:00
Cedoor
5f29690641 Merge pull request #264 from semaphore-protocol/feat/data-package
New `@semaphore-protocol/data` package

Former-commit-id: 86e186cdc0
2023-03-08 21:30:33 +00:00
cedoor
2665a440fa build: add topological option to yarn workspaces cmd
Former-commit-id: b09e27477f
2023-03-08 21:18:38 +00:00
Cedoor
cf31913d27 docs: fix md syntax
Former-commit-id: 2b732f335c
2023-03-08 21:15:12 +00:00
cedoor
103a676455 docs(data): add await to usage functions
Former-commit-id: cce29363f9
2023-03-08 21:12:19 +00:00
cedoor
9aa5bc5840 fix(cli): set correct data class name
Former-commit-id: 180977841d
2023-03-08 21:11:49 +00:00
cedoor
894bc87952 docs(data): update readme file
re #256


Former-commit-id: a798acbe80
2023-03-08 20:57:32 +00:00
cedoor
cd4bd6ad91 chore(cli): sen new data package
Former-commit-id: bc165cd6e4
2023-03-08 20:32:02 +00:00
cedoor
dca7b67677 fix(data): add request header
Former-commit-id: 56e652a507
2023-03-08 20:31:40 +00:00
cedoor
60d698f6ee test(data): mock ethers tests
re #256


Former-commit-id: 9942b92f13
2023-03-07 18:24:25 +00:00
cedoor
f05e654f95 build(data): update rollup configuration
re #256


Former-commit-id: 9d27c3ac54
2023-03-06 22:14:28 +00:00
cedoor
9a4fe6ba64 chore: remove types folder from prettier ignore file
Former-commit-id: 925cc64d73
2023-03-06 17:44:44 +00:00
cedoor
c8d472a286 feat(data): create new data package
This new package allows devs to fetch on-chain data by using a Semaphore subgraph or the Ethers
library.

BREAKING CHANGE: The code of the old `@semaphore-protocol/subgraph` package has been moved to the
`@semaphore-protocol/data` package.

re #256


Former-commit-id: fc2f648acc
2023-03-06 17:43:42 +00:00
Cedoor
c9711b9007 Merge pull request #262 from vimwitch/identity-entropy
feat(identity): use sha512 to extract more entropy from message

Former-commit-id: 95e4a4e672
2023-03-05 21:07:39 +00:00
cedoor
8afcac50c2 chore(subgraph): remove subgraph package
re #256


Former-commit-id: b040c421ea
2023-03-05 20:12:46 +00:00
Chance
75c1c1373c chore: run prettier
Former-commit-id: d5d01142b1
2023-03-04 15:12:31 -06:00
Chance
2318628ca2 feat(identity): use sha512 to extract more entropy from message
Former-commit-id: ed63519423
2023-03-04 15:02:40 -06:00
Cedoor
2603600716 Merge pull request #261 from vimwitch/json-prepend-0x
feat(identity): prepend hex strings with 0x

Former-commit-id: 5a99792b68
2023-03-04 21:00:45 +00:00
Chance
3f0f1e006c feat(identity): prepend hex strings with 0x
Former-commit-id: 3c359e9a57
2023-03-04 14:47:03 -06:00
cedoor
2a4f2455d7 refactor(hardhat): update readme and set correct task name
Former-commit-id: 25e2442090
2023-03-01 19:35:57 +00:00
cedoor
0ea221d9ea Merge pull request #257 from shiyingt/feat/deploy-verifier-hardhat
add hardhat task to deploy SemaphoreVerifier.sol

Former-commit-id: 76146ed728
2023-03-01 20:20:59 +01:00
shiyingt
437674f3bc add hardhat task to deploy verifier
Former-commit-id: 934e4b2c06
2023-02-27 23:43:33 +08:00
shiyingt
4202186c0b revert all changes
Former-commit-id: b51f1d7820
2023-02-27 23:29:28 +08:00
cedoor
383e818833 docs(hardhat): update readme description
Former-commit-id: 865421a001
2023-02-23 11:54:04 +01:00
shiyingt
74014a42b5 run prettier write and eslint
Former-commit-id: 2ddbc51679
2023-02-22 22:39:10 +08:00
cedoor
e875fa4aa3 chore: update discord links
Former-commit-id: bd06422ef5
2023-02-22 13:22:46 +01:00
shiyingt
186dae79d2 fix hardhat task
Former-commit-id: 6987686426
2023-02-21 23:08:58 +08:00
shiyingt
195d545a95 fix hardhat task
Former-commit-id: 3105a0c095
2023-02-21 23:02:51 +08:00
cedoor
84245b9b1f Merge pull request #255 from semaphore-protocol/chore/bump-version
New NPM scripts to bump versions and publish NPM packages

Former-commit-id: 1bb2982f7d
2023-02-20 16:42:47 +01:00
cedoor
461e91f53b style: format code with prettier
Former-commit-id: 5c402f3ba2
2023-02-20 14:40:10 +01:00
cedoor
2893feca3c chore: add new scripts to bump versions & publish npm pkgs
re #254


Former-commit-id: 257080e478
2023-02-20 14:31:42 +01:00
cedoor
4be2973761 chore: update lockfile
re #254


Former-commit-id: 0b1519ea57
2023-02-20 12:46:15 +01:00
cedoor
01a30fd8af chore: add new workspace package
re #254


Former-commit-id: 9ef675f120
2023-02-20 12:44:36 +01:00
cedoor
a70c1b001c chore(yarn): add yarn plugin for versioning
re #254


Former-commit-id: a5df125378
2023-02-20 12:07:38 +01:00
shiyingt
30ed65d569 add hardhat task to deploy semaphore verifier only
Former-commit-id: 972790d158
2023-02-19 09:48:19 +08:00
cedoor
04a6649f2f Merge pull request #253 from semaphore-protocol/chore/release
Yarn patch to change `changelogithub` output

Former-commit-id: d2b959718c
2023-02-16 19:13:35 +01:00
cedoor
a337021d8d chore(release): create yarn patch to update changelogithub format
re #252


Former-commit-id: 739af09a5d
2023-02-16 18:41:15 +01:00
cedoor
4cd3863d03 docs(subgraph): update readme file
Former-commit-id: 6e036c0887
2023-02-15 22:00:03 +01:00
cedoor
c88639659d chore: update lockfile
Former-commit-id: 4f49736591
2023-02-15 20:57:45 +01:00
cedoor
0ca17d078b chore(semaphore): v3.1.0
Former-commit-id: 243c505d87
2023-02-15 20:47:23 +01:00
cedoor
f171506891 ci(release): add new workflow for automatic releases
Former-commit-id: a4fcb36fe0
2023-02-15 20:40:50 +01:00
cedoor
e085ecd0df test(subgraph): ignore some lines
Former-commit-id: 381c8668e4
2023-02-15 20:37:09 +01:00
cedoor
b744ee1e7b Merge pull request #250 from semaphore-protocol/refactor/cli-inquirer
Add inquirer in get-groups and get-group commands

Former-commit-id: 04ac6c2649
2023-02-15 20:18:15 +01:00
vplasencia
8d51a6689d refactor(cli): change some inquirer messages
Former-commit-id: 48ec4ba361
2023-02-15 12:29:32 -05:00
cedoor
7bec0a4e42 Merge pull request #251 from semaphore-protocol/feat/subgraph-improvements
Subgraph library improvements

Former-commit-id: 1d6f59229b
2023-02-15 18:16:11 +01:00
Saleel
71ed4d605d chore: add test for querying subgraph with filters
Former-commit-id: 11f061e586
2023-02-15 22:24:56 +05:30
Saleel
810a5358c0 chore: add tests for initalizing subgraph library with URL
Former-commit-id: 667929b09d
2023-02-15 22:05:56 +05:30
Saleel
636a9156b4 feat: add option to specify subgraph URL in subgraph library
Former-commit-id: fc4db2c8a1
2023-02-15 21:43:53 +05:30
Saleel
a679d047fa feat: add query filters to subgraph library
Former-commit-id: bc8f3495b6
2023-02-15 21:39:11 +05:30
vplasencia
6d3e685284 refactor(cli): add inquirer in get-group command
Former-commit-id: 68702bb5e4
2023-02-14 20:45:29 -05:00
vplasencia
3bfcf67b9d refactor(cli): add inquirer in get-groups command
Former-commit-id: f7fb159562
2023-02-14 16:41:00 -05:00
vplasencia
e16dbe663e refactor(cli): change project name message
Former-commit-id: 1aaaae0635
2023-02-14 16:30:14 -05:00
cedoor
0aca50ea34 Merge pull request #248 from semaphore-protocol/refactor/cli
Add node conventions and display an error for excess arguments in commands

Former-commit-id: 5604eff98d
2023-02-08 17:07:31 +01:00
vplasencia
54a6abdd2b refactor(cli): add node conventions and display an error for excess arguments in commands
Former-commit-id: 878ff0524e
2023-02-08 10:58:22 -05:00
cedoor
de32db6d2d Merge pull request #247 from semaphore-protocol/feature/cli-integrate-inquirer
Integrate Inquirer.js in create command in the CLI

Former-commit-id: 519b518c21
2023-02-08 16:32:46 +01:00
vplasencia
d43f9278e0 refactor(cli): remove projectDir variable
Former-commit-id: f7c1ca6e7e
2023-02-08 10:24:48 -05:00
vplasencia
f3d8c4ee75 feat(cli): integrate inquirer in create command
Former-commit-id: 7f63cc567e
2023-02-08 00:16:57 -05:00
cedoor
60fedc4e90 Merge pull request #244 from semaphore-protocol/feature/cli-check-latest-version
Check for latest version

Former-commit-id: dc969e0f55
2023-02-06 20:17:46 +01:00
cedoor
34d5743fa4 refactor(cli): move code to function to check latest version
re #188


Former-commit-id: fb0c016447
2023-02-06 20:06:16 +01:00
vplasencia
6810fcb5bb feat(cli): add check for latest version
Former-commit-id: ed81202bbd
2023-02-06 10:09:18 -05:00
cedoor
0bdf064614 Merge pull request #241 from semaphore-protocol/feature/group-id
Group class `id` attribute

Former-commit-id: cd3fa0c82c
2023-02-06 14:27:14 +01:00
cedoor
7c4d2c2007 feat(group): add id attribute to group class
re #240


Former-commit-id: 202fcc399c
2023-02-06 12:23:51 +01:00
cedoor
1bb57ca607 chore: update lockfile
Former-commit-id: b45c4f3510
2023-01-26 22:59:08 +01:00
cedoor
44860d70b9 chore: v3.0.0
Former-commit-id: 439a357173
2023-01-26 22:52:52 +01:00
cedoor
d286a8f1e8 Merge pull request #213 from semaphore-protocol/dev
Semaphore v3

Former-commit-id: 39a40f5f3b
2023-01-26 22:49:35 +01:00
cedoor
729ba41afd Merge pull request #236 from semaphore-protocol/vplasencia-patch-1
Change a comment

Former-commit-id: d27513d3f0
2023-01-26 11:47:04 +01:00
Vivian Plasencia
972fde32a7 Update group.ts
Former-commit-id: 5eb168c2ef
2023-01-25 21:55:17 -05:00
cedoor
c3d9e23e2a docs(contracts): update readme file
Former-commit-id: 9d12d3b050
2023-01-24 11:26:58 +01:00
cedoor
5fd7435c6d Merge pull request #232 from semaphore-protocol/refactor/proof
Proof generation/verification refactoring

Former-commit-id: f272aa26e9
2023-01-24 11:07:26 +01:00
cedoor
07888687a0 chore: update lockfile
Former-commit-id: 6b24210be1
2023-01-24 11:00:42 +01:00
cedoor
54c3a54597 chore: v3.0.0-beta.8
Former-commit-id: 8c952e9558
2023-01-24 10:38:47 +01:00
cedoor
81dba510c3 refactor(cli): update cli template tests
re #230


Former-commit-id: 5c027eef70
2023-01-24 10:37:32 +01:00
cedoor
343cdabe9c refactor(contracts): update contract tests
re #230


Former-commit-id: 1b654977b0
2023-01-23 20:29:08 +01:00
cedoor
fe6fbc1a0d refactor(proof): pack snarkjs proof
re #230


Former-commit-id: 8d68c09068
2023-01-23 20:27:56 +01:00
cedoor
f854492709 Merge pull request #231 from semaphore-protocol/feat/arbitrum-subgraph
Arbitrum subgraph

Former-commit-id: 4139c3e146
2023-01-23 17:08:48 +01:00
cedoor
30af236547 feat(subgraph): add arbitrum subgraph
re #229


Former-commit-id: 22fb9ebb87
2023-01-23 16:22:59 +01:00
cedoor
d65b4aae47 style: format code with prettier
Former-commit-id: 45d5815d95
2023-01-23 15:45:03 +01:00
cedoor
245fb2cba8 chore(contracts): deploy contracts on arbitrum
Former-commit-id: ea86ae0a3d
2023-01-23 15:41:15 +01:00
cedoor
f469ccc36a Merge pull request #228 from semaphore-protocol/refactor/bytes32-greeting
`bytes32` greeting

Former-commit-id: 5b2944105c
2023-01-19 12:12:12 +01:00
cedoor
8ee1bd9c1b Merge pull request #226 from semaphore-protocol/chore/fixed-dependencies
No version range for `snarkjs` and `poseidon-lite` dependencies

Former-commit-id: 5c03b72d37
2023-01-19 12:10:03 +01:00
cedoor
348a4327d7 refactor(cli): update greeting type to bytes32
Former-commit-id: c0ec1b5ecf
2023-01-18 20:06:48 +01:00
cedoor
faffde79f0 chore: update lockfile
re #225


Former-commit-id: 95e4a743b2
2023-01-17 15:29:05 +01:00
cedoor
89a83c7b6b chore: make snarkjs and poseidon-lite versions fixed
re #225


Former-commit-id: 59f1f624f2
2023-01-17 15:13:41 +01:00
cedoor
f36e8c1536 Merge pull request #223 from semaphore-protocol/fix/add-ts-suppress-error-comment
Fix/add ts suppress error comment

Former-commit-id: bdfc8d68a2
2023-01-11 18:34:32 +01:00
vplasencia
46ed508de8 Add TypeScript suppress error comment
Former-commit-id: 07728848f2
2023-01-11 12:12:48 -05:00
cedoor
821cdb7fd3 chore: update lockfile
Former-commit-id: 3bcec50e19
2023-01-09 17:18:17 +01:00
cedoor
dd2df7ab06 chore: v3.0.0-beta.7
Former-commit-id: ab1115c77a
2023-01-09 17:14:50 +01:00
cedoor
71fdabe65c Merge pull request #220 from semaphore-protocol/refactor/cli-init
Semaphore `create` command

Former-commit-id: a411b041b8
2023-01-09 17:03:22 +01:00
cedoor
cce6c31461 refactor(cli): replace init command with create
Former-commit-id: 72859d9b98
2023-01-09 11:05:54 +01:00
aguzmant103
f1aced7ee3 docs: adding GitPOAP link
Former-commit-id: f7e87c4442
2023-01-05 20:06:10 -06:00
cedoor
bd8b06bb7b docs(hardhat): update readme usage section
Former-commit-id: 20fa45c8f3
2023-01-05 17:44:46 +01:00
cedoor
9f692e57e8 chore: v3.0.0-beta.6
Former-commit-id: 1df18f81f7
2023-01-04 19:16:42 +01:00
cedoor
32aabf81d2 fix(subgraph): set correct goerli subgraph url
Former-commit-id: ce5c30b816
2023-01-04 19:08:52 +01:00
cedoor
a72a57ef63 style(subgraph): format code with prettier
Former-commit-id: 469e2a1310
2023-01-04 19:08:32 +01:00
cedoor
4e5b4495a3 chore: update lockfile
Former-commit-id: 1d4e7c509e
2023-01-04 18:56:23 +01:00
cedoor
578d426d1a chore(cli): v3.0.0-beta.5
Former-commit-id: 9a2db4b3bf
2023-01-04 18:52:16 +01:00
cedoor
362b025fac chore(hardhat): v3.0.0-beta.5
Former-commit-id: 23ec6dc55c
2023-01-04 18:48:54 +01:00
cedoor
84aa8d0eac chore(subgraph): v3.0.0-beta.5
Former-commit-id: ca1485bea8
2023-01-04 18:12:06 +01:00
cedoor
6592a62f25 chore(proof): v3.0.0-beta.5
Former-commit-id: e097a86875
2023-01-04 18:09:22 +01:00
cedoor
a59a2af50b chore(contracts): v3.0.0-beta.5
Former-commit-id: 268ef49ec5
2023-01-04 18:09:03 +01:00
cedoor
1e68ed1fec chore(group): v3.0.0-beta.5
Former-commit-id: 3ca1f59472
2023-01-04 18:08:14 +01:00
cedoor
2abd068cf8 chore(identity): v3.0.0-beta.5
Former-commit-id: 7f9978eb4f
2023-01-04 18:07:49 +01:00
cedoor
8b746ff2bc style(contracts): format code with prettier
Former-commit-id: ef9f927cbd
2023-01-04 13:27:15 +01:00
cedoor
23d9786e16 chore(contracts): deploy contracts on goerli
Former-commit-id: 2f14cc9fa9
2023-01-04 13:21:57 +01:00
cedoor
3b20402476 refactor(contracts): update function to verify contracts
Former-commit-id: cd65440f2c
2023-01-04 13:20:54 +01:00
cedoor
91bcc66c17 chore(cli): add arbitrum network to cli hardhat template
Former-commit-id: 3cdf7daa0f
2023-01-04 12:42:11 +01:00
cedoor
bcf9dad496 docs: update readme description
Former-commit-id: 64e47907b9
2023-01-04 11:03:33 +01:00
cedoor
29195519fb chore(cli): v0.5.0
Former-commit-id: bd30127759
2023-01-03 20:37:44 +01:00
cedoor
17efdb38af refactor(cli): add more info to init command
Former-commit-id: 3d559a6491
2023-01-03 20:36:11 +01:00
cedoor
8713e2b339 chore(cli): add files to be included in the package
re #216


Former-commit-id: 51a9d17520
2023-01-03 20:35:16 +01:00
cedoor
ef69356dca docs(proof): update readme file
Former-commit-id: 55add650f9
2022-12-23 11:08:49 +01:00
cedoor
252b866daa docs(readme): update badge & package list
Former-commit-id: d03f15c263
2022-12-23 10:58:07 +01:00
cedoor
5627f6eae7 chore: update lockfile
Former-commit-id: fead45b069
2022-12-23 10:24:07 +01:00
cedoor
45ef560324 chore(contracts): update zk-kit dependency
Former-commit-id: 9e186f3da9
2022-12-23 10:19:34 +01:00
cedoor
ee80aa172e fix(contracts): set a nullifier hashes mapping for each poll
fix #211


Former-commit-id: 681128f468
2022-12-22 18:22:45 +01:00
cedoor
c0f106edb6 Merge pull request #210 from semaphore-protocol/refactor/general
General refactoring and additional documentation to contracts

Former-commit-id: 2f1fbd8411
2022-12-22 18:20:45 +01:00
cedoor
3aea38cc9b docs(contracts): update contract comments
Former-commit-id: 4c32f4f610
2022-12-22 15:49:08 +01:00
cedoor
c6fe15cf13 refactor(contracts): remove unused contract error
Former-commit-id: 2dd0737e2c
2022-12-22 15:15:33 +01:00
cedoor
6e948d63dc refactor(contracts): make some event parameteres indexed
Former-commit-id: cd4aeab0a6
2022-12-22 13:09:02 +01:00
cedoor
c2bd4df1d9 refactor(contracts): rename merkle trees' mapping
Former-commit-id: b1ce54f0b9
2022-12-22 13:07:21 +01:00
cedoor
06e3063c3e refactor(contracts): get merkle tree depth only once
Former-commit-id: 76d8e81b65
2022-12-22 13:06:29 +01:00
cedoor
cb52b3db20 Merge pull request #197 from semaphore-protocol/fix/zero-values
Generate zeroValue based on groupId

Former-commit-id: 5726c9896a
2022-12-20 11:56:06 +01:00
cedoor
88781ea466 style(contracts): format code with prettier
Former-commit-id: 218867747b
2022-12-20 11:51:26 +01:00
cedoor
2c47ad9f28 Merge branch 'dev' into fix/zero-values
Former-commit-id: a2e31b78d3
2022-12-20 11:44:26 +01:00
cedoor
228ebd941a Merge pull request #206 from semaphore-protocol/fix/group-existence
Tree depth to check group existence

Former-commit-id: f7367b63d0
2022-12-20 11:39:27 +01:00
cedoor
71f31f0910 Merge pull request #204 from semaphore-protocol/docs/circuit-tree-depth
Update circuits' nLevels comment

Former-commit-id: a30261c373
2022-12-20 11:38:28 +01:00
cedoor
7cf8eb11a1 Merge pull request #205 from semaphore-protocol/fix/members-loop
Increase size of iterator variable

Former-commit-id: 93c7445619
2022-12-20 11:37:37 +01:00
cedoor
6bbe45fb33 Merge pull request #208 from semaphore-protocol/fix/root-duration
New function to update merkle tree duration

Former-commit-id: 81ef86757e
2022-12-20 11:36:41 +01:00
cedoor
7b4e03c7fd style(contracts): format code with prettier
Former-commit-id: dabdfc036b
2022-12-19 13:43:09 +01:00
cedoor
8e0dd30ccc fix(contracts): add function to update merkle tree duration
This bug was found by Veridise during their audit of Semaphore.

fix #200


Former-commit-id: 70d7276928
2022-12-19 13:35:01 +01:00
cedoor
0661320c2a fix(contracts): use tree depth to check group existence
This bug was found by Veridise during their audit of Semaphore.

fix #202


Former-commit-id: 6458614a76
2022-12-19 13:02:16 +01:00
cedoor
b419344297 fix(contracts): increase size of members iterator variable
This bug was found by Veridise during their audit of Semaphore.

fix #201


Former-commit-id: 1c5ccb8af5
2022-12-19 12:51:09 +01:00
cedoor
fc636b732d docs(circuits): update nLevels comment
This issue was opened by Veridise during their audit of Semaphore.

re #203


Former-commit-id: f67d803b1b
2022-12-19 12:27:08 +01:00
cedoor
5ac1cad96c Merge pull request #199 from semaphore-protocol/fix/whistleblowing-entities
Editors can be associated with multiple entities

Former-commit-id: 6b876c1606
2022-12-19 11:57:20 +01:00
cedoor
33a6a3601e fix(contracts): associate editor with many entities
This bug was found by Veridise during their audit of Semaphore.

fix #198


Former-commit-id: 2f414484ed
2022-12-17 14:32:12 +01:00
cedoor
2dc8be161c Merge pull request #195 from semaphore-protocol/chore/hardhat-chai-matchers
Migrate from hardhat-waffle to hardhat-chai-matchers

Former-commit-id: f392afbefa
2022-12-17 13:00:25 +01:00
cedoor
a9dae718d3 Merge pull request #194 from semaphore-protocol/refactor/snark-identities
New hash function to generate identity secrets

Former-commit-id: 8c51b9e707
2022-12-17 12:59:04 +01:00
cedoor
f3ca0ce3d8 fix(contracts): generate zeroValue based on groupId
This bug was found by Veridise during their audit of Semaphore.


Former-commit-id: a6d3e0719f
2022-12-16 16:23:13 +01:00
cedoor
310b1a8dcd chore(contracts): migrate to hardhat-chai-matchers
Former-commit-id: 0d3e3c8459
2022-12-16 14:46:24 +01:00
cedoor
3c3d374c54 style(identity): format code with prettier
Former-commit-id: 62c048f964
2022-12-16 13:57:21 +01:00
cedoor
c6247ace3b refactor(identity): update hash function to generate identity secrets
Former-commit-id: d46c9306e6
2022-12-16 13:50:44 +01:00
cedoor
1e9d56d3da docs(readme): update badges urls
Former-commit-id: 9ea07a8b1b
2022-12-16 12:38:45 +01:00
cedoor
a52a3bee1b chore(contracts): update incremental-merkle-tree.sol dependency
Former-commit-id: f67c5c0fe4
2022-12-16 12:36:21 +01:00
cedoor
e91bc74ab0 Merge pull request #191 from semaphore-protocol/feat/semaphore-cli
Semaphore CLI

Former-commit-id: 85af25af58
2022-12-16 11:45:03 +01:00
cedoor
2594c4e1c2 chore(cli): v0.4.0
Former-commit-id: d4b3ff5f74
2022-12-16 11:41:37 +01:00
cedoor
a199b01a50 fix(cli): add check for network option
Former-commit-id: ee27d5a056
2022-12-16 11:41:02 +01:00
cedoor
c97a0cbbb5 style: format code
Former-commit-id: 1a60f28320
2022-12-15 14:14:00 +01:00
cedoor
04fd0a3d91 chore: add files to ignore for eslint and prettier
Former-commit-id: c1d4511c77
2022-12-15 14:13:34 +01:00
cedoor
3fb849f076 build(cli): add subgraph package ts path
Former-commit-id: fb00f0cf4a
2022-12-15 14:03:57 +01:00
cedoor
b3c83bac8b chore(cli): move dependency
Former-commit-id: 53e395d0d6
2022-12-15 13:57:56 +01:00
cedoor
00c302aefc docs(cli): update readme long description
Former-commit-id: a6511d2978
2022-12-15 13:43:02 +01:00
cedoor
feee90e69d chore(cli): v.0.3.0
Former-commit-id: dc9340a70f
2022-12-15 13:38:13 +01:00
cedoor
ca87f3601d docs(cli): update usage section
Former-commit-id: 65bf4f0366
2022-12-15 13:37:07 +01:00
cedoor
a3abb810a9 refactor(cli): add more info to init command
Former-commit-id: 0e9ae15156
2022-12-15 13:35:34 +01:00
cedoor
5d19919474 docs(cli): update description and readme file
Former-commit-id: 1450d78f5c
2022-12-15 13:34:57 +01:00
cedoor
5c66f16a5b feat(cli): create init command
Former-commit-id: 4241fb97d5
2022-12-14 20:24:55 +01:00
cedoor
4b2f9e4492 feat(cli): create new cli template
Former-commit-id: 621f3ab4e6
2022-12-14 17:01:37 +01:00
cedoor
b593d1a0e9 refactor(cli): set common error syntax
Former-commit-id: ff8c73b31b
2022-12-12 15:20:27 +01:00
cedoor
d3b206ec3a refactor(cli): set error messages
Former-commit-id: d5a599c7d5
2022-12-12 14:57:16 +01:00
cedoor
adadacb218 chore(cli): v0.1.0
Former-commit-id: 8d80ba2614
2022-12-12 13:03:43 +01:00
cedoor
b7411bfcb7 feat(cli): create get-groups command
Former-commit-id: 110942071a
2022-12-12 13:02:24 +01:00
cedoor
3feeb7f9fd feat(cli): create get-group command
Former-commit-id: 190fdaff22
2022-12-09 18:34:14 +01:00
cedoor
05125c11d9 chore(cli): add cli package and basic setup
Former-commit-id: d124b48903
2022-12-08 20:45:45 +01:00
cedoor
3188d3dbff Merge pull request #180 from semaphore-protocol/refactor/group-id
No SNARK restrictions for Group IDs

Former-commit-id: 27320f1723
2022-11-28 15:52:49 +01:00
cedoor
04f57db7f0 refactor(contracts): remove snark field check for group id values
Former-commit-id: c15145da2c
2022-11-28 15:31:04 +01:00
cedoor
066f38c471 chore: add license to contracts package
Former-commit-id: 0f24c01ff1
2022-11-23 13:04:38 +01:00
cedoor
37e8784471 docs(circuits): add readme file
Former-commit-id: 9cd0144734
2022-11-23 13:03:46 +01:00
cedoor
889cf1890a Merge pull request #173 from semaphore-protocol/chore/poseidon-lite
New Poseidon library

Former-commit-id: 8081766843
2022-11-23 12:00:17 +01:00
cedoor
1a4a7f36e0 chore: replace circomlibjs with poseidon-lite
Former-commit-id: df6ce176cb
2022-11-23 11:32:48 +01:00
cedoor
3d6c24a51b Merge pull request #170 from semaphore-protocol/refactor/normalize-signals
New hash function to normalize signal & external nullifier

Former-commit-id: 23fb94fd65
2022-11-22 15:25:07 +01:00
cedoor
781922436e refactor: create hash function to normalize snark signals
Former-commit-id: 7f872bcd92
2022-11-22 15:12:29 +01:00
cedoor
277a790e36 Merge pull request #168 from semaphore-protocol/refactor/hardcode-verification-keys
Hardcoded snark verification keys

Former-commit-id: 901531b062
2022-11-21 13:32:46 +01:00
cedoor
d880925604 refactor(proof): move zk verification keys to the code
Former-commit-id: 26d1c5153e
2022-11-21 13:16:56 +01:00
cedoor
5466178f40 Merge pull request #167 from semaphore-protocol/fix/merkle-root-creation-dates
Merkle roots for any tree update

Former-commit-id: 583311fc03
2022-11-20 19:58:22 +01:00
cedoor
6cc4dc07bb Merge pull request #166 from semaphore-protocol/refactor/semaphore-verifier
One Verifier to rule them all

Former-commit-id: 7061785fa0
2022-11-20 19:54:53 +01:00
cedoor
98a35c0a37 fix(contracts): save merkle roots after updates or removal of members
Former-commit-id: be4165afa5
2022-11-18 20:04:39 +01:00
cedoor
bfeb24791d chore(contracts): fix lint warnings
Former-commit-id: 22c7ec8bb3
2022-11-18 19:28:49 +01:00
cedoor
37e2614ac7 style: format code with prettier
Former-commit-id: 6f73de2daf
2022-11-18 17:42:02 +01:00
cedoor
84bb9c89a4 chore: add folder to ignore
Former-commit-id: 975aba3d7a
2022-11-18 17:41:38 +01:00
cedoor
a4aaf7f7ec fix: download snark artifacts in the right folder
Former-commit-id: ecd586a757
2022-11-18 16:36:13 +01:00
cedoor
b92a6e1c7a refactor(proof): update snark artifacts path
Former-commit-id: ec7f605551
2022-11-18 16:35:32 +01:00
cedoor
3afae28e06 refactor: remove unused solidity interface
Former-commit-id: 4f964c9d7f
2022-11-18 16:35:02 +01:00
cedoor
63cddf3da2 chore: add contracts files to ignore
Former-commit-id: eecc8fe97f
2022-11-18 16:34:38 +01:00
cedoor
499ec1cbeb refactor(contracts): replace old verifiers with a single semaphore verifier
Former-commit-id: 56ecb4a2a7
2022-11-18 16:33:58 +01:00
cedoor
fb1ffee89d ci: replace snark-artifacts folder for each download
Former-commit-id: 92d70e1050
2022-11-18 16:18:50 +01:00
cedoor
f7bc7900e0 ci: add env variables to workflows
Former-commit-id: 2ec07b4b99
2022-11-18 16:13:51 +01:00
cedoor
bc14210bc7 chore: add env var to download all snark artifacts
Former-commit-id: 8f269ecafc
2022-11-18 16:13:25 +01:00
cedoor
aabad94a81 Merge pull request #164 from semaphore-protocol/refactor/extension-contracts
Remove modifiers from proof verification functions

Former-commit-id: ba149545f2
2022-11-09 15:34:23 +01:00
cedoor
eeac211c01 refactor(contracts): remove modifier from proof verification functions
Former-commit-id: 99a358ca12
2022-11-09 15:13:12 +01:00
cedoor
6e0236e9bc Merge pull request #163 from semaphore-protocol/refactor/merkle-tree-attributes
Public `merkleTree` attribute and new method name

Former-commit-id: cf9f804651
2022-11-09 12:43:24 +01:00
cedoor
a9f8379545 refactor(groups): make attribute public and update method name
Former-commit-id: 822561a015
2022-11-09 12:29:58 +01:00
262 changed files with 9633 additions and 5466 deletions

View File

@@ -1,5 +1,6 @@
DEFAULT_NETWORK=hardhat
TREE_DEPTH=20
ALL_SNARK_ARTIFACTS=true
REPORT_GAS=false
BACKEND_PRIVATE_KEY=
INFURA_API_KEY=

View File

@@ -9,7 +9,9 @@ coverage
coverage.json
# hardhat
artifacts
cache
typechain-types
# types
types
@@ -30,3 +32,6 @@ docs
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# packages
cli-template-*

View File

@@ -13,6 +13,7 @@ A brief description of your project. In what way have you used Semaphore?
**Other info**
- Name
- Tagline
- Icon
**Links**

14
.github/workflows/auto-assign.yml vendored Normal file
View File

@@ -0,0 +1,14 @@
name: auto-assign
on:
pull_request:
types: [opened]
jobs:
run:
runs-on: ubuntu-latest
steps:
- uses: wow-actions/auto-assign@v3
with:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
reviewers: org/core-devs

View File

@@ -41,5 +41,6 @@ jobs:
with:
build_dir: docs
jekyll: false
fqdn: js.semaphore.appliedzkp.org
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -5,6 +5,10 @@ on:
branches:
- main
env:
TREE_DEPTH: 20
ALL_SNARK_ARTIFACTS: false
jobs:
style:
runs-on: ubuntu-latest

View File

@@ -3,6 +3,10 @@ name: pull-requests
on:
pull_request:
env:
TREE_DEPTH: 20
ALL_SNARK_ARTIFACTS: false
jobs:
style:
runs-on: ubuntu-latest

43
.github/workflows/release.yml vendored Normal file
View File

@@ -0,0 +1,43 @@
name: release
permissions:
contents: write
on:
push:
tags:
- "v*"
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 16.x
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn config get cacheFolder)"
- name: Restore yarn cache
uses: actions/cache@v3
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install dependencies
run: yarn
- run: yarn version:release
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

4
.gitignore vendored
View File

@@ -70,6 +70,10 @@ docs/*
# Hardhat
artifacts
cache
typechain-types
packages/contracts/deployed-contracts/undefined.json
packages/contracts/deployed-contracts/hardhat.json
packages/contracts/deployed-contracts/localhost.json
# Stores VSCode versions used for testing VSCode extensions
.vscode-test

4
.husky/commit-msg Executable file
View File

@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
npx --no-install commitlint --edit $1

View File

@@ -9,10 +9,12 @@ coverage
coverage.json
# hardhat
artifacts
cache
# types
types
typechain-types
packages/contracts/deployed-contracts/undefined.json
packages/contracts/deployed-contracts/hardhat.json
packages/contracts/deployed-contracts/localhost.json
# circuits
circuits
@@ -39,3 +41,7 @@ yarn-error.log*
# other
snark-artifacts
# Next.js
.next/
public

View File

@@ -0,0 +1,23 @@
diff --git a/dist/shared/changelogithub.821fab93.mjs b/dist/shared/changelogithub.821fab93.mjs
index 5fc2100867613c20f7827eac8715a5fc28bdc39e..97bd8dff878b81c63d2220e496904f6f3933589a 100644
--- a/dist/shared/changelogithub.821fab93.mjs
+++ b/dist/shared/changelogithub.821fab93.mjs
@@ -181,7 +181,7 @@ function formatLine(commit, options) {
function formatTitle(name, options) {
if (!options.emoji)
name = name.replace(emojisRE, "");
- return `###    ${name.trim()}`;
+ return `##    ${name.trim()}`;
}
function formatSection(commits, sectionName, options) {
if (!commits.length)
@@ -198,7 +198,8 @@ function formatSection(commits, sectionName, options) {
Object.keys(scopes).sort().forEach((scope) => {
let padding = "";
let prefix = "";
- const scopeText = `**${options.scopeMap[scope] || scope}**`;
+ const url = `https://github.com/${options.github}/tree/main/packages/${scope}`
+ const scopeText = `[**@${options.github.split("/")[0]}/${options.scopeMap[scope] || scope}**](${url})`
if (scope && useScopeGroup) {
lines.push(`- ${scopeText}:`);
padding = " ";

View File

@@ -0,0 +1 @@
87de4f440a77841135f97a187e09140c6d4e6ae2

View File

@@ -1,8 +1,11 @@
nodeLinker: node-modules
checksumBehavior: update
nodeLinker: node-modules
plugins:
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
spec: "@yarnpkg/plugin-workspace-tools"
- path: .yarn/plugins/@yarnpkg/plugin-version.cjs
spec: "@yarnpkg/plugin-version"
yarnPath: .yarn/releases/yarn-3.2.1.cjs

198
README.md
View File

@@ -17,7 +17,7 @@
<img alt="Github license" src="https://img.shields.io/github/license/semaphore-protocol/semaphore.svg?style=flat-square">
</a>
<a href="https://github.com/semaphore-protocol/semaphore/actions?query=workflow%3Aproduction">
<img alt="GitHub Workflow test" src="https://img.shields.io/github/workflow/status/semaphore-protocol/semaphore/production?label=test&style=flat-square&logo=github">
<img alt="GitHub Workflow test" src="https://img.shields.io/github/actions/workflow/status/semaphore-protocol/semaphore/production.yml?branch=main&label=test&style=flat-square&logo=github">
</a>
<a href="https://coveralls.io/github/semaphore-protocol/semaphore">
<img alt="Coveralls" src="https://img.shields.io/coveralls/github/semaphore-protocol/semaphore?style=flat-square&logo=coveralls">
@@ -32,6 +32,10 @@
<img alt="Code style prettier" src="https://img.shields.io/badge/code%20style-prettier-f8bc45?style=flat-square&logo=prettier">
</a>
<img alt="Repository top language" src="https://img.shields.io/github/languages/top/semaphore-protocol/semaphore?style=flat-square">
<a href="https://www.gitpoap.io/gh/semaphore-protocol/semaphore" target="_blank">
<img src="https://public-api.gitpoap.io/v1/repo/semaphore-protocol/semaphore/badge">
</a>
</p>
<div align="center">
@@ -48,7 +52,7 @@
🔎 Issues
</a>
<span>&nbsp;&nbsp;|&nbsp;&nbsp;</span>
<a href="https://discord.gg/6mSdGHnstH">
<a href="https://semaphore.appliedzkp.org/discord">
🗣️ Chat &amp; Support
</a>
</h4>
@@ -57,11 +61,7 @@
| Semaphore is a protocol, designed to be a simple and generic privacy layer for Ethereum DApps. Using zero knowledge, Ethereum users can prove their membership of a group and send signals such as votes or endorsements without revealing their original identity. |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
The core of the Semaphore protocol is in the [circuit logic](/packages/circuits/scheme.png). However Semaphore also provides [Solidity contracts](/packages/contracts) (NPM: `@semaphore-protocol/contracts`) and JavaScript libraries to make the steps for offchain proof creation and onchain verification easier. To learn more about Semaphore visit [semaphore.appliedzkp.org](https://semaphore.appliedzkp.org).
You can find Semaphore V1 on [`version/1.0.0`](https://github.com/semaphore-protocol/semaphore/tree/version/1.0.0).
---
The core of the Semaphore protocol is in the [circuit logic](/packages/circuits/scheme.png). However Semaphore also provides [Solidity contracts](/packages/contracts) and JavaScript libraries to make the steps for offchain proof creation and onchain verification easier. To learn more about Semaphore visit [semaphore.appliedzkp.org](https://semaphore.appliedzkp.org).
## 📦 Packages
@@ -94,7 +94,7 @@ You can find Semaphore V1 on [`version/1.0.0`](https://github.com/semaphore-prot
<a href="/packages/identity">
@semaphore-protocol/identity
</a>
<a href="https://semaphore-protocol.github.io/semaphore/identity">
<a href="https://js.semaphore.appliedzkp.org/identity">
(docs)
</a>
</td>
@@ -116,7 +116,7 @@ You can find Semaphore V1 on [`version/1.0.0`](https://github.com/semaphore-prot
<a href="/packages/group">
@semaphore-protocol/group
</a>
<a href="https://semaphore-protocol.github.io/semaphore/group">
<a href="https://js.semaphore.appliedzkp.org/group">
(docs)
</a>
</td>
@@ -138,7 +138,7 @@ You can find Semaphore V1 on [`version/1.0.0`](https://github.com/semaphore-prot
<a href="/packages/proof">
@semaphore-protocol/proof
</a>
<a href="https://semaphore-protocol.github.io/semaphore/proof">
<a href="https://js.semaphore.appliedzkp.org/proof">
(docs)
</a>
</td>
@@ -157,23 +157,23 @@ You can find Semaphore V1 on [`version/1.0.0`](https://github.com/semaphore-prot
</tr>
<tr>
<td>
<a href="/packages/subgraph">
@semaphore-protocol/subgraph
<a href="/packages/data">
@semaphore-protocol/data
</a>
<a href="https://semaphore-protocol.github.io/semaphore/subgraph">
<a href="https://js.semaphore.appliedzkp.org/data">
(docs)
</a>
</td>
<td>
<!-- NPM version -->
<a href="https://npmjs.org/package/@semaphore-protocol/subgraph">
<img src="https://img.shields.io/npm/v/@semaphore-protocol/subgraph.svg?style=flat-square" alt="NPM version" />
<a href="https://npmjs.org/package/@semaphore-protocol/data">
<img src="https://img.shields.io/npm/v/@semaphore-protocol/data.svg?style=flat-square" alt="NPM version" />
</a>
</td>
<td>
<!-- Downloads -->
<a href="https://npmjs.org/package/@semaphore-protocol/subgraph">
<img src="https://img.shields.io/npm/dm/@semaphore-protocol/subgraph.svg?style=flat-square" alt="Downloads" />
<a href="https://npmjs.org/package/@semaphore-protocol/data">
<img src="https://img.shields.io/npm/dm/@semaphore-protocol/data.svg?style=flat-square" alt="Downloads" />
</a>
</td>
</tr>
@@ -196,8 +196,172 @@ You can find Semaphore V1 on [`version/1.0.0`](https://github.com/semaphore-prot
</a>
</td>
</tr>
<tr>
<td>
<a href="/packages/cli">
@semaphore-protocol/cli
</a>
</td>
<td>
<!-- NPM version -->
<a href="https://npmjs.org/package/@semaphore-protocol/cli">
<img src="https://img.shields.io/npm/v/@semaphore-protocol/cli.svg?style=flat-square" alt="NPM version" />
</a>
</td>
<td>
<!-- Downloads -->
<a href="https://npmjs.org/package/@semaphore-protocol/cli">
<img src="https://img.shields.io/npm/dm/@semaphore-protocol/cli.svg?style=flat-square" alt="Downloads" />
</a>
</td>
</tr>
<tr>
<td>
<a href="/packages/heyauthn">
@semaphore-protocol/heyauthn
</a>
<a href="https://js.semaphore.appliedzkp.org/heyauthn">
(docs)
</a>
</td>
<td>
<!-- NPM version -->
<a href="https://npmjs.org/package/@semaphore-protocol/heyauthn">
<img src="https://img.shields.io/npm/v/@semaphore-protocol/heyauthn.svg?style=flat-square" alt="NPM version" />
</a>
</td>
<td>
<!-- Downloads -->
<a href="https://npmjs.org/package/@semaphore-protocol/heyauthn">
<img src="https://img.shields.io/npm/dm/@semaphore-protocol/heyauthn.svg?style=flat-square" alt="Downloads" />
</a>
</td>
</tr>
<tbody>
</table>
## 💡 Projects
The following are some of the internal and external projects that use Semaphore. If you want to include your project, open an [issue](https://github.com/semaphore-protocol/semaphore/issues/new?assignees=&labels=documentation++%F0%9F%93%96&template=----project.md&title=) or create a PR by adding the project information to the `projects.json` file.
<table>
<th>Project</th>
<th>Description</th>
<th>Links</th>
<tbody>
<tr>
<td>
<a href="https://explorer.semaphore.appliedzkp.org">
Semaphore Explorer
</a>
</td>
<td>
Semaphore explorer for on-chain groups.
</td>
<td>
<a href="https://github.com/semaphore-protocol/explorer">
Github
</a>|
<a href="https://semaphore.appliedzkp.org/discord">
Discord
</a>
</td>
</tr>
<tr>
<td>
<a href="https://discord.com/api/oauth2/authorize?client_id=1082429985496772628&permissions=1024&scope=bot">
Semaphore Discord Bot
</a>
</td>
<td>
A Discord bot for Semaphore.
</td>
<td>
<a href="https://github.com/semaphore-protocol/discord-bot">
Github
</a>|
<a href="https://semaphore.appliedzkp.org/discord">
Discord
</a>
</td>
</tr>
<tr>
<td>
<a href="https://developer.unirep.io">
Unirep
</a>
</td>
<td>
Private and nonrepudiable reputation system based on ZKP.
</td>
<td>
<a href="https://github.com/Unirep">
Github
</a>|
<a href="https://discord.gg/VzMMDJmYc5">
Discord
</a>
</td>
</tr>
<tr>
<td>
<a href="https://zk-proof-of-humanity.vercel.app">
ZK Proof of Humanity
</a>
</td>
<td>
A project to allows humans, registered in Proof of Humanity, to prove their humanity without doxing.
</td>
<td>
<a href="https://github.com/elmol/zk-proof-of-humanity">
Github
</a>
</td>
</tr>
<tr>
<td>
Plurality
</td>
<td>
An Identity Lego Building Block for dapp creators that lets them identify their users without</br> using any third-party KYC provider or other middlemen, whilst preserving the privacy of users.
</td>
<td>
<a href="https://github.com/Web3-Plurality">
Github
</a>
</td>
</tr>
<tr>
<td>
<a href="https://zerotherapy.vercel.app">
ZeroTherapy
</a>
</td>
<td>
AMA privacy application built with Semaphore.
</td>
<td>
<a href="https://github.com/Pushpit07/ZeroTherapy">
Github
</a>
</td>
</tr>
<tr>
<td>
<a href="https://bq2.netlify.app/">
Block Qualified
</a>
</td>
<td>
On-chain and privacy preserving education platform built on Semaphore.
</td>
<td>
<a href="https://github.com/0xdeenz/bq2">
Github
</a>
</td>
</tr>
<tbody>
</table>
## 🛠 Install

View File

@@ -0,0 +1,7 @@
{
"types": {
"feat": { "title": "🚀 Features" },
"fix": { "title": "🐞 Bug Fixes" },
"refactor": { "title": "♻️ Refactoring" }
}
}

View File

@@ -7,19 +7,23 @@
"bugs": "https://github.com/semaphore-protocol/semaphore/issues",
"private": true,
"scripts": {
"build:libraries": "yarn workspaces foreach run build",
"build:libraries": "yarn workspaces foreach -t --no-private run build",
"compile:contracts": "yarn workspace contracts compile",
"download:snark-artifacts": "ts-node scripts/download-snark-artifacts.ts",
"download:snark-artifacts": "rimraf snark-artifacts && ts-node scripts/download-snark-artifacts.ts",
"remove:template-files": "ts-node scripts/remove-template-files.ts",
"test": "yarn test:libraries && yarn test:contracts",
"test:libraries": "jest --coverage",
"test:contracts": "yarn workspace contracts test:coverage",
"lint": "eslint . --ext .js,.ts && yarn workspace contracts lint",
"prettier": "prettier -c .",
"prettier:write": "prettier -w .",
"docs": "yarn workspaces foreach run docs",
"docs": "yarn workspaces foreach --no-private run docs",
"version:bump": "yarn workspaces foreach --no-private version -d ${0} && yarn version apply --all && git commit -am \"chore: v${0}\" && git tag v${0}",
"version:publish": "yarn build:libraries && yarn remove:template-files && yarn workspaces foreach --no-private npm publish --tolerate-republish --access public",
"version:release": "changelogithub",
"commit": "cz",
"precommit": "lint-staged",
"postinstall": "yarn download:snark-artifacts"
"postinstall": "yarn download:snark-artifacts && husky install"
},
"keywords": [
"ethereum",
@@ -35,7 +39,8 @@
"monorepo"
],
"workspaces": [
"packages/*"
"packages/*",
"packages/contracts/contracts"
],
"packageManager": "yarn@3.2.1",
"devDependencies": {
@@ -53,7 +58,7 @@
"@typescript-eslint/eslint-plugin": "^5.9.1",
"@typescript-eslint/parser": "^5.9.1",
"babel-jest": "^27.4.6",
"circomlibjs": "^0.0.8",
"changelogithub": "0.12.7",
"commitizen": "^4.2.4",
"cz-conventional-changelog": "^3.3.0",
"dotenv": "^16.0.2",
@@ -63,6 +68,7 @@
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-import": "^2.25.2",
"eslint-plugin-jest": "^25.7.0",
"husky": "^8.0.3",
"jest": "^27.4.1",
"jest-config": "^27.4.7",
"lint-staged": "^12.1.7",
@@ -71,11 +77,14 @@
"rollup": "^2.64.0",
"ts-node": "^10.4.0",
"tslib": "^2.3.1",
"typescript": "^4.5.4"
"typescript": "^4.7.0"
},
"config": {
"commitizen": {
"path": "./node_modules/cz-conventional-changelog"
}
},
"resolutions": {
"changelogithub@0.12.7": "patch:changelogithub@npm:0.12.7#.yarn/patches/changelogithub-npm-0.12.7-72f348805d.patch"
}
}

View File

@@ -0,0 +1,37 @@
<p align="center">
<h1 align="center">
Semaphore circuits
</h1>
<p align="center">Semaphore circuits to create and verify zero-knowledge proofs.</p>
</p>
<p align="center">
<a href="https://github.com/semaphore-protocol">
<img src="https://img.shields.io/badge/project-Semaphore-blue.svg?style=flat-square">
</a>
<a href="https://github.com/semaphore-protocol/semaphore/blob/main/LICENSE">
<img alt="Github license" src="https://img.shields.io/github/license/semaphore-protocol/semaphore.svg?style=flat-square">
</a>
</p>
<div align="center">
<h4>
<a href="https://github.com/semaphore-protocol/semaphore/blob/main/CONTRIBUTING.md">
👥 Contributing
</a>
<span>&nbsp;&nbsp;|&nbsp;&nbsp;</span>
<a href="https://github.com/semaphore-protocol/semaphore/blob/main/CODE_OF_CONDUCT.md">
🤝 Code of conduct
</a>
<span>&nbsp;&nbsp;|&nbsp;&nbsp;</span>
<a href="https://github.com/semaphore-protocol/semaphore/contribute">
🔎 Issues
</a>
<span>&nbsp;&nbsp;|&nbsp;&nbsp;</span>
<a href="https://semaphore.appliedzkp.org/discord">
🗣️ Chat &amp; Support
</a>
</h4>
</div>
To learn more about circuits visit [semaphore.appliedzkp.org](https://semaphore.appliedzkp.org/docs/technical-reference/circuits).

View File

@@ -43,7 +43,7 @@ template CalculateNullifierHash() {
out <== poseidon.out;
}
// nLevels must be < 32.
// The current Semaphore smart contracts require nLevels <= 32 and nLevels >= 16.
template Semaphore(nLevels) {
signal input identityNullifier;
signal input identityTrapdoor;

View File

@@ -0,0 +1,4 @@
INFURA_API_KEY=
ETHEREUM_PRIVATE_KEY=
REPORT_GAS=false
COINMARKETCAP_API_KEY=

View File

@@ -0,0 +1,10 @@
node_modules
.env
coverage
coverage.json
typechain
typechain-types
# Hardhat files
cache
artifacts

View File

@@ -0,0 +1,54 @@
# Semaphore Hardhat template
This project demonstrates a basic Semaphore use case. It comes with a sample contract, a test for that contract and a sample task that deploys that contract.
## Usage
### Compile
```bash
yarn compile
```
### Testing
```bash
yarn test
```
You can also generate a test coverage report:
```bash
yarn test:coverage
```
Or a test gas report:
```bash
yarn test:report-gas
```
### Deploy
1. Copy the `.env.example` file as `.env`.
```bash
cp .env.example .env
```
2. Add your environment variables.
> **Note**
> You should at least set a valid Ethereum URL (e.g. Infura) and a private key with some ethers.
3. And deploy your contract.
```bash
yarn deploy --semaphore <semaphore-address> --group <group-id> --network goerli
```
> **Note**
> Check the Semaphore contract addresses [here](https://semaphore.appliedzkp.org/docs/deployed-contracts#semaphore).
> **Warning**
> The group id is a number!

View File

@@ -0,0 +1,30 @@
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "@semaphore-protocol/contracts/interfaces/ISemaphore.sol";
contract Feedback {
ISemaphore public semaphore;
uint256 public groupId;
constructor(address semaphoreAddress, uint256 _groupId) {
semaphore = ISemaphore(semaphoreAddress);
groupId = _groupId;
semaphore.createGroup(groupId, 20, address(this));
}
function joinGroup(uint256 identityCommitment) external {
semaphore.addMember(groupId, identityCommitment);
}
function sendFeedback(
uint256 feedback,
uint256 merkleTreeRoot,
uint256 nullifierHash,
uint256[8] calldata proof
) external {
semaphore.verifyProof(groupId, merkleTreeRoot, feedback, nullifierHash, groupId, proof);
}
}

View File

@@ -0,0 +1,77 @@
import "@nomiclabs/hardhat-ethers"
import "@nomicfoundation/hardhat-chai-matchers"
import "@semaphore-protocol/hardhat"
import "@typechain/hardhat"
import { config as dotenvConfig } from "dotenv"
import "hardhat-gas-reporter"
import { HardhatUserConfig } from "hardhat/config"
import { NetworksUserConfig } from "hardhat/types"
import "solidity-coverage"
import { config } from "./package.json"
import "./tasks/deploy"
dotenvConfig()
function getNetworks(): NetworksUserConfig {
if (!process.env.INFURA_API_KEY || !process.env.ETHEREUM_PRIVATE_KEY) {
return {}
}
const accounts = [`0x${process.env.ETHEREUM_PRIVATE_KEY}`]
const infuraApiKey = process.env.INFURA_API_KEY
return {
goerli: {
url: `https://goerli.infura.io/v3/${infuraApiKey}`,
chainId: 5,
accounts
},
sepolia: {
url: `https://sepolia.infura.io/v3/${infuraApiKey}`,
chainId: 11155111,
accounts
},
mumbai: {
url: `https://polygon-mumbai.infura.io/v3/${infuraApiKey}`,
chainId: 80001,
accounts
},
"optimism-goerli": {
url: `https://optimism-goerli.infura.io/v3/${infuraApiKey}`,
chainId: 420,
accounts
},
arbitrum: {
url: `https://arbitrum-mainnet.infura.io/v3/${infuraApiKey}`,
chainId: 42161,
accounts
}
}
}
const hardhatConfig: HardhatUserConfig = {
solidity: config.solidity,
paths: {
sources: config.paths.contracts,
tests: config.paths.tests,
cache: config.paths.cache,
artifacts: config.paths.build.contracts
},
networks: {
hardhat: {
chainId: 1337
},
...getNetworks()
},
gasReporter: {
currency: "USD",
enabled: process.env.REPORT_GAS === "true",
coinmarketcap: process.env.COINMARKETCAP_API_KEY
},
typechain: {
outDir: config.paths.build.typechain,
target: "ethers-v5"
}
}
export default hardhatConfig

View File

@@ -0,0 +1,78 @@
{
"name": "@semaphore-protocol/cli-template-contracts-hardhat",
"version": "3.10.0",
"description": "Semaphore Hardhat template.",
"license": "Unlicense",
"files": [
"files.tgz",
"contracts/",
"scripts/",
"tasks/",
"test/",
".env.example",
"hardhat.config.ts",
"tsconfig.json",
"README.md"
],
"publishConfig": {
"access": "public"
},
"scripts": {
"dev": "hardhat node & yarn compile && yarn deploy --network localhost",
"compile": "hardhat compile",
"download:snark-artifacts": "hardhat run scripts/download-snark-artifacts.ts",
"deploy": "yarn compile && hardhat deploy",
"test": "hardhat run scripts/download-snark-artifacts.ts && hardhat test",
"test:report-gas": "REPORT_GAS=true hardhat test",
"test:coverage": "hardhat coverage",
"typechain": "hardhat typechain",
"prepublish": "tar -czf files.tgz .gitignore"
},
"devDependencies": {
"@ethersproject/abi": "^5.4.7",
"@ethersproject/providers": "^5.4.7",
"@nomicfoundation/hardhat-chai-matchers": "^1.0.0",
"@nomicfoundation/hardhat-network-helpers": "^1.0.0",
"@nomicfoundation/hardhat-toolbox": "^2.0.0",
"@nomiclabs/hardhat-ethers": "^2.0.0",
"@nomiclabs/hardhat-etherscan": "^3.0.0",
"@semaphore-protocol/group": "3.10.0",
"@semaphore-protocol/hardhat": "3.10.0",
"@semaphore-protocol/identity": "3.10.0",
"@semaphore-protocol/proof": "3.10.0",
"@typechain/ethers-v5": "^10.1.0",
"@typechain/hardhat": "^6.1.2",
"@types/chai": "^4.2.0",
"@types/download": "^8.0.1",
"@types/mocha": "^9.1.0",
"@types/node": ">=12.0.0",
"chai": "^4.2.0",
"dotenv": "^16.0.3",
"download": "^8.0.0",
"ethers": "^5.4.7",
"hardhat": "^2.11.0",
"hardhat-gas-reporter": "^1.0.8",
"solidity-coverage": "^0.8.1",
"ts-node": ">=8.0.0",
"typechain": "^8.1.0",
"typescript": ">=4.5.0"
},
"dependencies": {
"@semaphore-protocol/contracts": "3.10.0"
},
"config": {
"solidity": {
"version": "0.8.4"
},
"paths": {
"contracts": "./contracts",
"tests": "./test",
"cache": "./cache",
"build": {
"snark-artifacts": "./build/snark-artifacts",
"contracts": "./build/contracts",
"typechain": "./build/typechain"
}
}
}
}

View File

@@ -0,0 +1,24 @@
import download from "download"
import fs from "fs"
import { config } from "../package.json"
async function main() {
const snarkArtifactsPath = config.paths.build["snark-artifacts"]
const url = `http://www.trusted-setup-pse.org/semaphore/${20}`
if (!fs.existsSync(snarkArtifactsPath)) {
fs.mkdirSync(snarkArtifactsPath, { recursive: true })
}
if (!fs.existsSync(`${snarkArtifactsPath}/semaphore.zkey`)) {
await download(`${url}/semaphore.wasm`, snarkArtifactsPath)
await download(`${url}/semaphore.zkey`, snarkArtifactsPath)
}
}
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error)
process.exit(1)
})

View File

@@ -0,0 +1,31 @@
import { task, types } from "hardhat/config"
task("deploy", "Deploy a Feedback contract")
.addOptionalParam("semaphore", "Semaphore contract address", undefined, types.string)
.addOptionalParam("group", "Group id", "42", types.string)
.addOptionalParam("logs", "Print the logs", true, types.boolean)
.setAction(async ({ logs, semaphore: semaphoreAddress, group: groupId }, { ethers, run }) => {
if (!semaphoreAddress) {
const { semaphore } = await run("deploy:semaphore", {
logs
})
semaphoreAddress = semaphore.address
}
if (!groupId) {
groupId = process.env.GROUP_ID
}
const FeedbackFactory = await ethers.getContractFactory("Feedback")
const feedbackContract = await FeedbackFactory.deploy(semaphoreAddress, groupId)
await feedbackContract.deployed()
if (logs) {
console.info(`Feedback contract has been deployed to: ${feedbackContract.address}`)
}
return feedbackContract
})

View File

@@ -0,0 +1,69 @@
import { Group } from "@semaphore-protocol/group"
import { Identity } from "@semaphore-protocol/identity"
import { generateProof } from "@semaphore-protocol/proof"
import { expect } from "chai"
import { formatBytes32String } from "ethers/lib/utils"
import { run } from "hardhat"
// @ts-ignore: typechain folder will be generated after contracts compilation
import { Feedback } from "../build/typechain"
import { config } from "../package.json"
describe("Feedback", () => {
let feedbackContract: Feedback
let semaphoreContract: string
const groupId = "42"
const group = new Group(groupId)
const users: Identity[] = []
before(async () => {
const { semaphore } = await run("deploy:semaphore", {
logs: false
})
feedbackContract = await run("deploy", { logs: false, group: groupId, semaphore: semaphore.address })
semaphoreContract = semaphore
users.push(new Identity())
users.push(new Identity())
})
describe("# joinGroup", () => {
it("Should allow users to join the group", async () => {
for await (const [i, user] of users.entries()) {
const transaction = feedbackContract.joinGroup(user.commitment)
group.addMember(user.commitment)
await expect(transaction)
.to.emit(semaphoreContract, "MemberAdded")
.withArgs(groupId, i, user.commitment, group.root)
}
})
})
describe("# sendFeedback", () => {
const wasmFilePath = `${config.paths.build["snark-artifacts"]}/semaphore.wasm`
const zkeyFilePath = `${config.paths.build["snark-artifacts"]}/semaphore.zkey`
it("Should allow users to send feedback anonymously", async () => {
const feedback = formatBytes32String("Hello World")
const fullProof = await generateProof(users[1], group, groupId, feedback, {
wasmFilePath,
zkeyFilePath
})
const transaction = feedbackContract.sendFeedback(
feedback,
fullProof.merkleTreeRoot,
fullProof.nullifierHash,
fullProof.proof
)
await expect(transaction)
.to.emit(semaphoreContract, "ProofVerified")
.withArgs(groupId, fullProof.merkleTreeRoot, fullProof.nullifierHash, groupId, fullProof.signal)
})
})
})

View File

@@ -0,0 +1,15 @@
{
"compilerOptions": {
"moduleResolution": "Node",
"noImplicitAny": true,
"resolveJsonModule": true,
"target": "ES2018",
"module": "CommonJS",
"strict": true,
"esModuleInterop": true,
"outDir": "dist",
"typeRoots": ["node_modules/@types", "types"]
},
"include": ["scripts/**/*", "tasks/**/*", "test/**/*", "build/typechain/**/*", "types/**/*"],
"files": ["./hardhat.config.ts"]
}

View File

@@ -0,0 +1,13 @@
#root = true
[*]
indent_style = space
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
max_line_length = 120
indent_size = 4
[*.md]
trim_trailing_whitespace = false

View File

@@ -0,0 +1,10 @@
DEFAULT_NETWORK=localhost
INFURA_API_KEY=
ETHEREUM_PRIVATE_KEY=ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
FEEDBACK_CONTRACT_ADDRESS=0x5fc8d32690cc91d4c39d9d3abcbd16989f875707
SEMAPHORE_CONTRACT_ADDRESS=0xdc64a140aa3e981100a9beca4e685f962f0cf6c9
OPENZEPPELIN_AUTOTASK_WEBHOOK=
GROUP_ID=42
REPORT_GAS=false
COINMARKETCAP_API_KEY=
ETHERSCAN_API_KEY=

View File

@@ -0,0 +1,45 @@
# dependencies
node_modules
package-lock.json
yarn.lock
.yarn
# testing
coverage
coverage.json
# docs
docs
# types
types
# production
dist
build
cache
contract-artifacts
# misc
.DS_Store
*.pem
# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Next.js
.next/
out/
# The Graph
generated
# Auto Generated PWA files
**/public/sw.js
**/public/workbox-*.js
**/public/worker-*.js
**/public/sw.js.map
**/public/workbox-*.js.map
**/public/worker-*.js.map

View File

@@ -0,0 +1,36 @@
{
"root": true,
"env": {
"es6": true
},
"extends": ["airbnb-base", "airbnb-typescript/base", "prettier"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module",
"project": ["./**/tsconfig.json"]
},
"plugins": ["@typescript-eslint"],
"rules": {
"no-underscore-dangle": "off",
"no-alert": "off",
"no-nested-ternary": "off",
"import/no-extraneous-dependencies": "off",
"import/extensions": "off",
"import/no-relative-packages": "off",
"no-await-in-loop": "off",
"no-bitwise": "off",
"no-restricted-syntax": "off",
"no-console": ["warn", { "allow": ["info", "warn", "error"] }],
"@typescript-eslint/lines-between-class-members": "off",
"no-param-reassign": "off",
"@typescript-eslint/naming-convention": [
"error",
{
"selector": "variable",
"format": ["camelCase", "PascalCase", "UPPER_CASE", "snake_case"],
"leadingUnderscore": "allow"
}
]
}
}

View File

@@ -0,0 +1,122 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# IDE
.vscode
.idea
# Cargo
target
# Testing
coverage
coverage.json
*.lcov
# Dependency directories
node_modules/
# TypeScript cache
*.tsbuildinfo
# Output of 'npm pack'
*.tgz
# Optional eslint cache
.eslintcache
# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/
# Yarn Integrity file
.yarn-integrity
# Generate output
dist
build
cache
# Next.js
.next/
out/
# vercel
.vercel
# typescript
next-env.d.ts
# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local
# Optional npm cache directory
.npm
*.DS_Store
# yarn v3
.pnp.*
.pnp.js
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
# The Graph
generated
# Auto Generated PWA files
**/public/sw.js
**/public/workbox-*.js
**/public/worker-*.js
**/public/sw.js.map
**/public/workbox-*.js.map
**/public/worker-*.js.map
#amplify-do-not-edit-begin
amplify/\#current-cloud-backend
amplify/.config/local-*
amplify/logs
amplify/mock-data
amplify/mock-api-resources
amplify/backend/amplify-meta.json
amplify/backend/.temp
build/
dist/
node_modules/
aws-exports.js
awsconfiguration.json
amplifyconfiguration.json
amplifyconfiguration.dart
amplify-build-config.json
amplify-gradle-config.json
amplifytools.xcconfig
.secret-*
**.sample
#amplify-do-not-edit-end
# Others
files.tgz

View File

@@ -0,0 +1,45 @@
# dependencies
node_modules
package-lock.json
yarn.lock
.yarn
# testing
coverage
coverage.json
# docs
docs
# production
dist
build
cache
contract-artifacts
# github
.github/ISSUE_TEMPLATE
# misc
.DS_Store
*.pem
# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Next.js
.next/
out/
# The Graph
generated
# Auto Generated PWA files
**/public/sw.js
**/public/workbox-*.js
**/public/worker-*.js
**/public/sw.js.map
**/public/workbox-*.js.map
**/public/worker-*.js.map

View File

@@ -0,0 +1,5 @@
{
"semi": false,
"arrowParens": "always",
"trailingComma": "none"
}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
b3cadff6efb37a12712d12c2553ec703dbcaa4dd

View File

@@ -0,0 +1,9 @@
checksumBehavior: update
nodeLinker: node-modules
plugins:
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
spec: "@yarnpkg/plugin-workspace-tools"
yarnPath: .yarn/releases/yarn-3.2.1.cjs

View File

@@ -0,0 +1,59 @@
# Semaphore Hardhat + Next.js + SemaphoreEthers template
This project is a complete application that demonstrates a basic Semaphore use case. It comes with a sample contract, a test for that contract and a sample task that deploys that contract. It also contains a frontend to play around with the contract.
## 📜 Usage
Copy the `.env.example` file as `.env`:
```bash
cp .env.example .env
```
and add your environment variables or run the app in a local network.
### Local server
You can start your app locally with:
```bash
yarn dev
```
### Deploy the contract
1. Go to the `apps/contracts` directory and deploy your contract:
```bash
yarn deploy --semaphore <semaphore-address> --group <group-id> --network arbitrum-goerli
```
2. Update your `.env` file with your new contract address, the group id and the semaphore contract address.
3. Copy your contract artifacts from `apps/contracts/build/contracts/contracts` folder to `apps/web-app/contract-artifacts` folders manually. Or run `yarn copy:contract-artifacts` in the project root to do it automatically.
> **Note**
> Check the Semaphore contract addresses [here](https://semaphore.appliedzkp.org/docs/deployed-contracts).
> **Warning**
> The group id is a number!
### Code quality and formatting
Run [ESLint](https://eslint.org/) to analyze the code and catch bugs:
```bash
yarn lint
```
Run [Prettier](https://prettier.io/) to check formatting rules:
```bash
yarn prettier
```
or to automatically format the code:
```bash
yarn prettier:write
```

View File

@@ -0,0 +1,3 @@
{
"extends": "solhint:default"
}

View File

@@ -0,0 +1,30 @@
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "@semaphore-protocol/contracts/interfaces/ISemaphore.sol";
contract Feedback {
ISemaphore public semaphore;
uint256 public groupId;
constructor(address semaphoreAddress, uint256 _groupId) {
semaphore = ISemaphore(semaphoreAddress);
groupId = _groupId;
semaphore.createGroup(groupId, 20, address(this));
}
function joinGroup(uint256 identityCommitment) external {
semaphore.addMember(groupId, identityCommitment);
}
function sendFeedback(
uint256 feedback,
uint256 merkleTreeRoot,
uint256 nullifierHash,
uint256[8] calldata proof
) external {
semaphore.verifyProof(groupId, merkleTreeRoot, feedback, nullifierHash, groupId, proof);
}
}

View File

@@ -0,0 +1,87 @@
import "@nomicfoundation/hardhat-chai-matchers"
import "@nomiclabs/hardhat-ethers"
import "@nomiclabs/hardhat-etherscan"
import "@semaphore-protocol/hardhat"
import "@typechain/hardhat"
import { config as dotenvConfig } from "dotenv"
import "hardhat-gas-reporter"
import { HardhatUserConfig } from "hardhat/config"
import { NetworksUserConfig } from "hardhat/types"
import { resolve } from "path"
import "solidity-coverage"
import { config } from "./package.json"
import "./tasks/deploy"
dotenvConfig({ path: resolve(__dirname, "../../.env") })
function getNetworks(): NetworksUserConfig {
if (!process.env.INFURA_API_KEY || !process.env.ETHEREUM_PRIVATE_KEY) {
return {}
}
const accounts = [`0x${process.env.ETHEREUM_PRIVATE_KEY}`]
const infuraApiKey = process.env.INFURA_API_KEY
return {
goerli: {
url: `https://goerli.infura.io/v3/${infuraApiKey}`,
chainId: 5,
accounts
},
sepolia: {
url: `https://sepolia.infura.io/v3/${infuraApiKey}`,
chainId: 11155111,
accounts
},
mumbai: {
url: `https://polygon-mumbai.infura.io/v3/${infuraApiKey}`,
chainId: 80001,
accounts
},
"optimism-goerli": {
url: `https://optimism-goerli.infura.io/v3/${infuraApiKey}`,
chainId: 420,
accounts
},
"arbitrum-goerli": {
url: "https://goerli-rollup.arbitrum.io/rpc",
chainId: 421613,
accounts
},
arbitrum: {
url: "https://arb1.arbitrum.io/rpc",
chainId: 42161,
accounts
}
}
}
const hardhatConfig: HardhatUserConfig = {
solidity: config.solidity,
paths: {
sources: config.paths.contracts,
tests: config.paths.tests,
cache: config.paths.cache,
artifacts: config.paths.build.contracts
},
networks: {
hardhat: {
chainId: 1337
},
...getNetworks()
},
gasReporter: {
currency: "USD",
enabled: process.env.REPORT_GAS === "true",
coinmarketcap: process.env.COINMARKETCAP_API_KEY
},
typechain: {
outDir: config.paths.build.typechain,
target: "ethers-v5"
},
etherscan: {
apiKey: process.env.ETHERSCAN_API_KEY
}
}
export default hardhatConfig

View File

@@ -0,0 +1,60 @@
{
"name": "monorepo-ethers-contracts",
"version": "1.0.0",
"private": true,
"main": "index.js",
"scripts": {
"dev": "hardhat node & yarn compile && yarn deploy --network localhost",
"compile": "hardhat compile",
"download:snark-artifacts": "hardhat run scripts/download-snark-artifacts.ts",
"deploy": "yarn compile && hardhat deploy",
"test": "hardhat run scripts/download-snark-artifacts.ts && hardhat test",
"test:report-gas": "REPORT_GAS=true hardhat test",
"test:coverage": "hardhat coverage",
"typechain": "hardhat typechain",
"lint": "solhint 'contracts/**/*.sol'"
},
"devDependencies": {
"@nomicfoundation/hardhat-chai-matchers": "^1.0.5",
"@nomiclabs/hardhat-ethers": "^2.0.0",
"@nomiclabs/hardhat-etherscan": "^3.1.7",
"@semaphore-protocol/group": "3.10.0",
"@semaphore-protocol/hardhat": "3.10.0",
"@semaphore-protocol/identity": "3.10.0",
"@semaphore-protocol/proof": "3.10.0",
"@typechain/ethers-v5": "^10.0.0",
"@typechain/hardhat": "^6.0.0",
"@types/chai": "^4.3.1",
"@types/download": "^8.0.1",
"@types/mocha": "^9.1.1",
"chai": "^4.2.0",
"dotenv": "^14.3.2",
"download": "^8.0.0",
"ethers": "^5.0.0",
"hardhat": "^2.8.4",
"hardhat-gas-reporter": "^1.0.8",
"prettier-plugin-solidity": "^1.0.0-beta.19",
"solhint": "^3.3.6",
"solhint-plugin-prettier": "^0.0.5",
"solidity-coverage": "^0.7.21",
"typechain": "^8.0.0"
},
"dependencies": {
"@semaphore-protocol/contracts": "3.10.0"
},
"config": {
"solidity": {
"version": "0.8.4"
},
"paths": {
"contracts": "./contracts",
"tests": "./test",
"cache": "./cache",
"build": {
"snark-artifacts": "./build/snark-artifacts",
"contracts": "./build/contracts",
"typechain": "./build/typechain"
}
}
}
}

View File

@@ -0,0 +1,24 @@
import download from "download"
import fs from "fs"
import { config } from "../package.json"
async function main() {
const snarkArtifactsPath = config.paths.build["snark-artifacts"]
const url = `http://www.trusted-setup-pse.org/semaphore/${20}`
if (!fs.existsSync(snarkArtifactsPath)) {
fs.mkdirSync(snarkArtifactsPath, { recursive: true })
}
if (!fs.existsSync(`${snarkArtifactsPath}/semaphore.zkey`)) {
await download(`${url}/semaphore.wasm`, snarkArtifactsPath)
await download(`${url}/semaphore.zkey`, snarkArtifactsPath)
}
}
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error)
process.exit(1)
})

View File

@@ -0,0 +1,31 @@
import { task, types } from "hardhat/config"
task("deploy", "Deploy a Feedback contract")
.addOptionalParam("semaphore", "Semaphore contract address", undefined, types.string)
.addOptionalParam("group", "Group id", "42", types.string)
.addOptionalParam("logs", "Print the logs", true, types.boolean)
.setAction(async ({ logs, semaphore: semaphoreAddress, group: groupId }, { ethers, run }) => {
if (!semaphoreAddress) {
const { semaphore } = await run("deploy:semaphore", {
logs
})
semaphoreAddress = semaphore.address
}
if (!groupId) {
groupId = process.env.GROUP_ID
}
const FeedbackFactory = await ethers.getContractFactory("Feedback")
const feedbackContract = await FeedbackFactory.deploy(semaphoreAddress, groupId)
await feedbackContract.deployed()
if (logs) {
console.info(`Feedback contract has been deployed to: ${feedbackContract.address}`)
}
return feedbackContract
})

View File

@@ -0,0 +1,69 @@
import { Group } from "@semaphore-protocol/group"
import { Identity } from "@semaphore-protocol/identity"
import { generateProof } from "@semaphore-protocol/proof"
import { expect } from "chai"
import { formatBytes32String } from "ethers/lib/utils"
import { run } from "hardhat"
// @ts-ignore: typechain folder will be generated after contracts compilation
import { Feedback } from "../build/typechain"
import { config } from "../package.json"
describe("Feedback", () => {
let feedbackContract: Feedback
let semaphoreContract: string
const groupId = "42"
const group = new Group(groupId)
const users: Identity[] = []
before(async () => {
const { semaphore } = await run("deploy:semaphore", {
logs: false
})
feedbackContract = await run("deploy", { logs: false, group: groupId, semaphore: semaphore.address })
semaphoreContract = semaphore
users.push(new Identity())
users.push(new Identity())
})
describe("# joinGroup", () => {
it("Should allow users to join the group", async () => {
for await (const [i, user] of users.entries()) {
const transaction = feedbackContract.joinGroup(user.commitment)
group.addMember(user.commitment)
await expect(transaction)
.to.emit(semaphoreContract, "MemberAdded")
.withArgs(groupId, i, user.commitment, group.root)
}
})
})
describe("# sendFeedback", () => {
const wasmFilePath = `${config.paths.build["snark-artifacts"]}/semaphore.wasm`
const zkeyFilePath = `${config.paths.build["snark-artifacts"]}/semaphore.zkey`
it("Should allow users to send feedback anonymously", async () => {
const feedback = formatBytes32String("Hello World")
const fullProof = await generateProof(users[1], group, groupId, feedback, {
wasmFilePath,
zkeyFilePath
})
const transaction = feedbackContract.sendFeedback(
feedback,
fullProof.merkleTreeRoot,
fullProof.nullifierHash,
fullProof.proof
)
await expect(transaction)
.to.emit(semaphoreContract, "ProofVerified")
.withArgs(groupId, fullProof.merkleTreeRoot, fullProof.nullifierHash, groupId, fullProof.signal)
})
})
})

View File

@@ -0,0 +1,15 @@
{
"compilerOptions": {
"moduleResolution": "Node",
"noImplicitAny": true,
"resolveJsonModule": true,
"target": "ES2018",
"module": "CommonJS",
"strict": true,
"esModuleInterop": true,
"outDir": "dist",
"typeRoots": ["node_modules/@types", "types"]
},
"include": ["scripts/**/*", "tasks/**/*", "test/**/*", "build/typechain/**/*", "types/**/*"],
"files": ["./hardhat.config.ts"]
}

View File

@@ -0,0 +1,94 @@
{
"_format": "hh-sol-artifact-1",
"contractName": "Feedback",
"sourceName": "contracts/Feedback.sol",
"abi": [
{
"inputs": [
{
"internalType": "address",
"name": "semaphoreAddress",
"type": "address"
},
{
"internalType": "uint256",
"name": "_groupId",
"type": "uint256"
}
],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"inputs": [],
"name": "groupId",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "identityCommitment",
"type": "uint256"
}
],
"name": "joinGroup",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "semaphore",
"outputs": [
{
"internalType": "contract ISemaphore",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "feedback",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "merkleTreeRoot",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "nullifierHash",
"type": "uint256"
},
{
"internalType": "uint256[8]",
"name": "proof",
"type": "uint256[8]"
}
],
"name": "sendFeedback",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}
],
"bytecode": "0x608060405234801561001057600080fd5b506040516106e13803806106e18339818101604052810190610032919061013c565b816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508060018190555060008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16639c1121416001546014306040518463ffffffff1660e01b81526004016100d9939291906101a5565b600060405180830381600087803b1580156100f357600080fd5b505af1158015610107573d6000803e3d6000fd5b505050505050610258565b6000815190506101218161022a565b92915050565b60008151905061013681610241565b92915050565b6000806040838503121561014f57600080fd5b600061015d85828601610112565b925050602061016e85828601610127565b9150509250929050565b610181816101dc565b82525050565b61019081610218565b82525050565b61019f8161020e565b82525050565b60006060820190506101ba6000830186610196565b6101c76020830185610187565b6101d46040830184610178565b949350505050565b60006101e7826101ee565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b60006102238261020e565b9050919050565b610233816101dc565b811461023e57600080fd5b50565b61024a8161020e565b811461025557600080fd5b50565b61047a806102676000396000f3fe608060405234801561001057600080fd5b506004361061004c5760003560e01c80637b5d253414610051578063a0f44c921461006f578063d18ed1e91461008d578063eed02e4b146100a9575b600080fd5b6100596100c5565b604051610066919061030f565b60405180910390f35b6100776100e9565b604051610084919061032a565b60405180910390f35b6100a760048036038101906100a2919061027c565b6100ef565b005b6100c360048036038101906100be9190610253565b61018e565b005b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60015481565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16633bc778e3600154858786600154876040518763ffffffff1660e01b81526004016101569695949392919061036e565b600060405180830381600087803b15801561017057600080fd5b505af1158015610184573d6000803e3d6000fd5b5050505050505050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16631783efc3600154836040518363ffffffff1660e01b81526004016101eb929190610345565b600060405180830381600087803b15801561020557600080fd5b505af1158015610219573d6000803e3d6000fd5b5050505050565b60008190508260206008028201111561023857600080fd5b92915050565b60008135905061024d8161042d565b92915050565b60006020828403121561026557600080fd5b60006102738482850161023e565b91505092915050565b600080600080610160858703121561029357600080fd5b60006102a18782880161023e565b94505060206102b28782880161023e565b93505060406102c38782880161023e565b92505060606102d487828801610220565b91505092959194509250565b6102ed610100838361041e565b5050565b6102fa816103fa565b82525050565b610309816103f0565b82525050565b600060208201905061032460008301846102f1565b92915050565b600060208201905061033f6000830184610300565b92915050565b600060408201905061035a6000830185610300565b6103676020830184610300565b9392505050565b60006101a0820190506103846000830189610300565b6103916020830188610300565b61039e6040830187610300565b6103ab6060830186610300565b6103b86080830185610300565b6103c560a08301846102e0565b979650505050505050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b60006104058261040c565b9050919050565b6000610417826103d0565b9050919050565b82818337600083830152505050565b610436816103f0565b811461044157600080fd5b5056fea26469706673582212204d8dc3161abc759242364c3a754a86e5eb8653092bcdf1e20bd6fcd368e1997664736f6c63430008040033",
"deployedBytecode": "0x608060405234801561001057600080fd5b506004361061004c5760003560e01c80637b5d253414610051578063a0f44c921461006f578063d18ed1e91461008d578063eed02e4b146100a9575b600080fd5b6100596100c5565b604051610066919061030f565b60405180910390f35b6100776100e9565b604051610084919061032a565b60405180910390f35b6100a760048036038101906100a2919061027c565b6100ef565b005b6100c360048036038101906100be9190610253565b61018e565b005b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60015481565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16633bc778e3600154858786600154876040518763ffffffff1660e01b81526004016101569695949392919061036e565b600060405180830381600087803b15801561017057600080fd5b505af1158015610184573d6000803e3d6000fd5b5050505050505050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16631783efc3600154836040518363ffffffff1660e01b81526004016101eb929190610345565b600060405180830381600087803b15801561020557600080fd5b505af1158015610219573d6000803e3d6000fd5b5050505050565b60008190508260206008028201111561023857600080fd5b92915050565b60008135905061024d8161042d565b92915050565b60006020828403121561026557600080fd5b60006102738482850161023e565b91505092915050565b600080600080610160858703121561029357600080fd5b60006102a18782880161023e565b94505060206102b28782880161023e565b93505060406102c38782880161023e565b92505060606102d487828801610220565b91505092959194509250565b6102ed610100838361041e565b5050565b6102fa816103fa565b82525050565b610309816103f0565b82525050565b600060208201905061032460008301846102f1565b92915050565b600060208201905061033f6000830184610300565b92915050565b600060408201905061035a6000830185610300565b6103676020830184610300565b9392505050565b60006101a0820190506103846000830189610300565b6103916020830188610300565b61039e6040830187610300565b6103ab6060830186610300565b6103b86080830185610300565b6103c560a08301846102e0565b979650505050505050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b60006104058261040c565b9050919050565b6000610417826103d0565b9050919050565b82818337600083830152505050565b610436816103f0565b811461044157600080fd5b5056fea26469706673582212204d8dc3161abc759242364c3a754a86e5eb8653092bcdf1e20bd6fcd368e1997664736f6c63430008040033",
"linkReferences": {},
"deployedLinkReferences": {}
}

View File

@@ -0,0 +1,45 @@
/** @type {import('next').NextConfig} */
const fs = require("fs")
const withPWA = require("next-pwa")
if (!fs.existsSync("./.env")) {
// eslint-disable-next-line global-require
require("dotenv").config({ path: "../../.env" })
}
const nextConfig = withPWA({
dest: "public",
disable: process.env.NODE_ENV === "development"
})({
eslint: {
ignoreDuringBuilds: true
},
reactStrictMode: true,
swcMinify: true,
env: {
DEFAULT_NETWORK: process.env.DEFAULT_NETWORK,
INFURA_API_KEY: process.env.INFURA_API_KEY,
ETHEREUM_PRIVATE_KEY: process.env.ETHEREUM_PRIVATE_KEY,
FEEDBACK_CONTRACT_ADDRESS: process.env.FEEDBACK_CONTRACT_ADDRESS,
SEMAPHORE_CONTRACT_ADDRESS: process.env.SEMAPHORE_CONTRACT_ADDRESS
},
publicRuntimeConfig: {
DEFAULT_NETWORK: process.env.DEFAULT_NETWORK,
FEEDBACK_CONTRACT_ADDRESS: process.env.FEEDBACK_CONTRACT_ADDRESS,
SEMAPHORE_CONTRACT_ADDRESS: process.env.SEMAPHORE_CONTRACT_ADDRESS,
OPENZEPPELIN_AUTOTASK_WEBHOOK: process.env.OPENZEPPELIN_AUTOTASK_WEBHOOK,
GROUP_ID: process.env.GROUP_ID
},
webpack: (config, { isServer }) => {
if (!isServer) {
config.resolve.fallback = {
fs: false
}
}
return config
}
})
module.exports = nextConfig

View File

@@ -0,0 +1,27 @@
{
"name": "monorepo-ethers-web-app",
"version": "1.0.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"export": "next export",
"start": "next start"
},
"dependencies": {
"@next/font": "13.0.3",
"@semaphore-protocol/data": "3.10.0",
"@semaphore-protocol/group": "3.10.0",
"@semaphore-protocol/identity": "3.10.0",
"@semaphore-protocol/proof": "3.10.0",
"@types/react": "18.0.25",
"@types/react-dom": "18.0.8",
"dotenv": "^16.0.3",
"ethers": "^5.7.2",
"next": "13.0.3",
"next-pwa": "^5.6.0",
"react": "18.2.0",
"react-dom": "18.2.0",
"typescript": "^4.7.3"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 376 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 827 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View File

@@ -0,0 +1,31 @@
{
"theme_color": "#ebedff",
"background_color": "#ebedff",
"display": "standalone",
"scope": "/",
"start_url": "/",
"name": "Semaphore Boilerplate",
"short_name": "Semaphore",
"icons": [
{
"src": "/icon-192x192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "/icon-256x256.png",
"sizes": "256x256",
"type": "image/png"
},
{
"src": "/icon-384x384.png",
"sizes": "384x384",
"type": "image/png"
},
{
"src": "/icon-512x512.png",
"sizes": "512x512",
"type": "image/png"
}
]
}

View File

@@ -0,0 +1,29 @@
export type StepperProps = {
step: number
onPrevClick?: () => void
onNextClick?: () => void
}
export default function Stepper({ step, onPrevClick, onNextClick }: StepperProps) {
return (
<div className="stepper">
{onPrevClick !== undefined ? (
<button className="button-stepper" disabled={!onPrevClick} onClick={onPrevClick || undefined}>
Prev
</button>
) : (
<span></span>
)}
<p>{step.toString()}/3</p>
{onNextClick !== undefined ? (
<button className="button-stepper" disabled={!onNextClick} onClick={onNextClick || undefined}>
Next
</button>
) : (
<span></span>
)}
</div>
)
}

View File

@@ -0,0 +1,11 @@
import React from "react"
export type LogsContextType = {
_logs: string
setLogs: (logs: string) => void
}
export default React.createContext<LogsContextType>({
_logs: "",
setLogs: (logs: string) => logs
})

View File

@@ -0,0 +1,19 @@
import React from "react"
export type SemaphoreContextType = {
_users: string[]
_feedback: string[]
refreshUsers: () => Promise<void>
addUser: (user: string) => void
refreshFeedback: () => Promise<void>
addFeedback: (feedback: string) => void
}
export default React.createContext<SemaphoreContextType>({
_users: [],
_feedback: [],
refreshUsers: () => Promise.resolve(),
addUser: () => {},
refreshFeedback: () => Promise.resolve(),
addFeedback: () => {}
})

View File

@@ -0,0 +1,57 @@
import { SemaphoreEthers } from "@semaphore-protocol/data"
import { BigNumber, utils } from "ethers"
import getNextConfig from "next/config"
import { useCallback, useState } from "react"
import { SemaphoreContextType } from "../context/SemaphoreContext"
const { publicRuntimeConfig: env } = getNextConfig()
const ethereumNetwork = env.DEFAULT_NETWORK === "localhost" ? "http://localhost:8545" : env.DEFAULT_NETWORK
export default function useSemaphore(): SemaphoreContextType {
const [_users, setUsers] = useState<any[]>([])
const [_feedback, setFeedback] = useState<string[]>([])
const refreshUsers = useCallback(async (): Promise<void> => {
const semaphore = new SemaphoreEthers(ethereumNetwork, {
address: env.SEMAPHORE_CONTRACT_ADDRESS
})
const members = await semaphore.getGroupMembers(env.GROUP_ID)
setUsers(members)
}, [])
const addUser = useCallback(
(user: any) => {
setUsers([..._users, user])
},
[_users]
)
const refreshFeedback = useCallback(async (): Promise<void> => {
const semaphore = new SemaphoreEthers(ethereumNetwork, {
address: env.SEMAPHORE_CONTRACT_ADDRESS
})
const proofs = await semaphore.getGroupVerifiedProofs(env.GROUP_ID)
setFeedback(proofs.map(({ signal }: any) => utils.parseBytes32String(BigNumber.from(signal).toHexString())))
}, [])
const addFeedback = useCallback(
(feedback: string) => {
setFeedback([..._feedback, feedback])
},
[_feedback]
)
return {
_users,
_feedback,
refreshUsers,
addUser,
refreshFeedback,
addFeedback
}
}

View File

@@ -0,0 +1,58 @@
import "../styles/globals.css"
import type { AppProps } from "next/app"
import Head from "next/head"
import { useRouter } from "next/router"
import { useEffect, useState } from "react"
import LogsContext from "../context/LogsContext"
import SemaphoreContext from "../context/SemaphoreContext"
import useSemaphore from "../hooks/useSemaphore"
import { Inter } from "@next/font/google"
const inter = Inter({ subsets: ["latin"] })
export default function App({ Component, pageProps }: AppProps) {
const router = useRouter()
const semaphore = useSemaphore()
const [_logs, setLogs] = useState<string>("")
useEffect(() => {
semaphore.refreshUsers()
semaphore.refreshFeedback()
}, [])
return (
<div className={inter.className}>
<Head>
<title>Semaphore template</title>
<link rel="icon" href="/favicon.ico" />
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png" />
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png" />
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png" />
<link rel="manifest" href="/manifest.json" />
<meta name="theme-color" content="#ebedff" />
</Head>
<div>
<div className="container">
<div id="body">
<SemaphoreContext.Provider value={semaphore}>
<LogsContext.Provider
value={{
_logs,
setLogs
}}
>
<Component {...pageProps} />
</LogsContext.Provider>
</SemaphoreContext.Provider>
</div>
</div>
<div className="footer">
{_logs.endsWith("...")}
<p>{_logs || `Current step: ${router.route}`}</p>
</div>
</div>
</div>
)
}

View File

@@ -0,0 +1,48 @@
import { Contract, providers, Wallet } from "ethers"
import type { NextApiRequest, NextApiResponse } from "next"
import Feedback from "../../../contract-artifacts/Feedback.json"
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
if (typeof process.env.FEEDBACK_CONTRACT_ADDRESS !== "string") {
throw new Error("Please, define FEEDBACK_CONTRACT_ADDRESS in your .env file")
}
if (typeof process.env.DEFAULT_NETWORK !== "string") {
throw new Error("Please, define DEFAULT_NETWORK in your .env file")
}
if (typeof process.env.INFURA_API_KEY !== "string") {
throw new Error("Please, define INFURA_API_KEY in your .env file")
}
if (typeof process.env.ETHEREUM_PRIVATE_KEY !== "string") {
throw new Error("Please, define ETHEREUM_PRIVATE_KEY in your .env file")
}
const ethereumPrivateKey = process.env.ETHEREUM_PRIVATE_KEY
const ethereumNetwork = process.env.DEFAULT_NETWORK
const infuraApiKey = process.env.INFURA_API_KEY
const contractAddress = process.env.FEEDBACK_CONTRACT_ADDRESS
const provider =
ethereumNetwork === "localhost"
? new providers.JsonRpcProvider()
: new providers.InfuraProvider(ethereumNetwork, infuraApiKey)
const signer = new Wallet(ethereumPrivateKey, provider)
const contract = new Contract(contractAddress, Feedback.abi, signer)
const { feedback, merkleTreeRoot, nullifierHash, proof } = req.body
try {
const transaction = await contract.sendFeedback(feedback, merkleTreeRoot, nullifierHash, proof)
await transaction.wait()
res.status(200).end()
} catch (error: any) {
console.error(error)
res.status(500).end()
}
}

View File

@@ -0,0 +1,48 @@
import { Contract, providers, Wallet } from "ethers"
import type { NextApiRequest, NextApiResponse } from "next"
import Feedback from "../../../contract-artifacts/Feedback.json"
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
if (typeof process.env.FEEDBACK_CONTRACT_ADDRESS !== "string") {
throw new Error("Please, define FEEDBACK_CONTRACT_ADDRESS in your .env file")
}
if (typeof process.env.DEFAULT_NETWORK !== "string") {
throw new Error("Please, define DEFAULT_NETWORK in your .env file")
}
if (typeof process.env.INFURA_API_KEY !== "string") {
throw new Error("Please, define INFURA_API_KEY in your .env file")
}
if (typeof process.env.ETHEREUM_PRIVATE_KEY !== "string") {
throw new Error("Please, define ETHEREUM_PRIVATE_KEY in your .env file")
}
const ethereumPrivateKey = process.env.ETHEREUM_PRIVATE_KEY
const ethereumNetwork = process.env.DEFAULT_NETWORK
const infuraApiKey = process.env.INFURA_API_KEY
const contractAddress = process.env.FEEDBACK_CONTRACT_ADDRESS
const provider =
ethereumNetwork === "localhost"
? new providers.JsonRpcProvider()
: new providers.InfuraProvider(ethereumNetwork, infuraApiKey)
const signer = new Wallet(ethereumPrivateKey, provider)
const contract = new Contract(contractAddress, Feedback.abi, signer)
const { identityCommitment } = req.body
try {
const transaction = await contract.joinGroup(identityCommitment)
await transaction.wait()
res.status(200).end()
} catch (error: any) {
console.error(error)
res.status(500).end()
}
}

View File

@@ -0,0 +1,136 @@
import { Identity } from "@semaphore-protocol/identity"
import getNextConfig from "next/config"
import { useRouter } from "next/router"
import { useCallback, useContext, useEffect, useState } from "react"
import Feedback from "../../contract-artifacts/Feedback.json"
import Stepper from "../components/Stepper"
import LogsContext from "../context/LogsContext"
import SemaphoreContext from "../context/SemaphoreContext"
const { publicRuntimeConfig: env } = getNextConfig()
export default function GroupsPage() {
const router = useRouter()
const { setLogs } = useContext(LogsContext)
const { _users, refreshUsers, addUser } = useContext(SemaphoreContext)
const [_loading, setLoading] = useState(false)
const [_identity, setIdentity] = useState<Identity>()
useEffect(() => {
const identityString = localStorage.getItem("identity")
if (!identityString) {
router.push("/")
return
}
setIdentity(new Identity(identityString))
}, [])
useEffect(() => {
if (_users.length > 0) {
setLogs(`${_users.length} user${_users.length > 1 ? "s" : ""} retrieved from the group 🤙🏽`)
}
}, [_users])
const joinGroup = useCallback(async () => {
if (!_identity) {
return
}
setLoading(true)
setLogs(`Joining the Feedback group...`)
let response: any
if (env.OPENZEPPELIN_AUTOTASK_WEBHOOK) {
response = await fetch(env.OPENZEPPELIN_AUTOTASK_WEBHOOK, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
abi: Feedback.abi,
address: env.FEEDBACK_CONTRACT_ADDRESS,
functionName: "joinGroup",
functionParameters: [_identity.commitment.toString()]
})
})
} else {
response = await fetch("api/join", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
identityCommitment: _identity.commitment.toString()
})
})
}
if (response.status === 200) {
addUser(_identity.commitment.toString())
setLogs(`You joined the Feedback group event 🎉 Share your feedback anonymously!`)
} else {
setLogs("Some error occurred, please try again!")
}
setLoading(false)
}, [_identity])
const userHasJoined = useCallback((identity: Identity) => _users.includes(identity.commitment.toString()), [_users])
return (
<>
<h2>Groups</h2>
<p>
Semaphore{" "}
<a
href="https://semaphore.appliedzkp.org/docs/guides/groups"
target="_blank"
rel="noreferrer noopener nofollow"
>
groups
</a>{" "}
are binary incremental Merkle trees in which each leaf contains an identity commitment for a user.
Groups can be abstracted to represent events, polls, or organizations.
</p>
<div className="divider"></div>
<div className="text-top">
<h3>Feedback users ({_users.length})</h3>
<button className="button-link" onClick={refreshUsers}>
Refresh
</button>
</div>
<div>
<button
className="button"
onClick={joinGroup}
disabled={_loading || !_identity || userHasJoined(_identity)}
>
<span>Join group</span>
{_loading && <div className="loader"></div>}
</button>
</div>
{_users.length > 0 && (
<div>
{_users.map((user, i) => (
<div key={i}>
<p className="box box-text">{user}</p>
</div>
))}
</div>
)}
<div className="divider"></div>
<Stepper
step={2}
onPrevClick={() => router.push("/")}
onNextClick={_identity && userHasJoined(_identity) ? () => router.push("/proofs") : undefined}
/>
</>
)
}

View File

@@ -0,0 +1,89 @@
import { Identity } from "@semaphore-protocol/identity"
import { useRouter } from "next/router"
import { useCallback, useContext, useEffect, useState } from "react"
import Stepper from "../components/Stepper"
import LogsContext from "../context/LogsContext"
export default function IdentitiesPage() {
const router = useRouter()
const { setLogs } = useContext(LogsContext)
const [_identity, setIdentity] = useState<Identity>()
useEffect(() => {
const identityString = localStorage.getItem("identity")
if (identityString) {
const identity = new Identity(identityString)
setIdentity(identity)
setLogs("Your Semaphore identity was retrieved from the browser cache 👌🏽")
} else {
setLogs("Create your Semaphore identity 👆🏽")
}
}, [])
const createIdentity = useCallback(async () => {
const identity = new Identity()
setIdentity(identity)
localStorage.setItem("identity", identity.toString())
setLogs("Your new Semaphore identity was just created 🎉")
}, [])
return (
<>
<h2 className="font-size: 3rem;">Identities</h2>
<p>
Users interact with the protocol using a Semaphore{" "}
<a
href="https://semaphore.appliedzkp.org/docs/guides/identities"
target="_blank"
rel="noreferrer noopener nofollow"
>
identity
</a>{" "}
(similar to Ethereum accounts). It contains three values:
</p>
<ol>
<li>Trapdoor: private, known only by user</li>
<li>Nullifier: private, known only by user</li>
<li>Commitment: public</li>
</ol>
<div className="divider"></div>
<div className="text-top">
<h3>Identity</h3>
{_identity && (
<button className="button-link" onClick={createIdentity}>
New
</button>
)}
</div>
{_identity ? (
<div>
<div className="box">
<p className="box-text">Trapdoor: {_identity.trapdoor.toString()}</p>
<p className="box-text">Nullifier: {_identity.nullifier.toString()}</p>
<p className="box-text">Commitment: {_identity.commitment.toString()}</p>
</div>
</div>
) : (
<div>
<button className="button" onClick={createIdentity}>
Create identity
</button>
</div>
)}
<div className="divider"></div>
<Stepper step={1} onNextClick={_identity && (() => router.push("/groups"))} />
</>
)
}

View File

@@ -0,0 +1,156 @@
import { Group } from "@semaphore-protocol/group"
import { Identity } from "@semaphore-protocol/identity"
import { generateProof } from "@semaphore-protocol/proof"
import { BigNumber, utils } from "ethers"
import getNextConfig from "next/config"
import { useRouter } from "next/router"
import { useCallback, useContext, useEffect, useState } from "react"
import Feedback from "../../contract-artifacts/Feedback.json"
import Stepper from "../components/Stepper"
import LogsContext from "../context/LogsContext"
import SemaphoreContext from "../context/SemaphoreContext"
const { publicRuntimeConfig: env } = getNextConfig()
export default function ProofsPage() {
const router = useRouter()
const { setLogs } = useContext(LogsContext)
const { _users, _feedback, refreshFeedback, addFeedback } = useContext(SemaphoreContext)
const [_loading, setLoading] = useState(false)
const [_identity, setIdentity] = useState<Identity>()
useEffect(() => {
const identityString = localStorage.getItem("identity")
if (!identityString) {
router.push("/")
return
}
setIdentity(new Identity(identityString))
}, [])
useEffect(() => {
if (_feedback.length > 0) {
setLogs(`${_feedback.length} feedback retrieved from the group 🤙🏽`)
}
}, [_feedback])
const sendFeedback = useCallback(async () => {
if (!_identity) {
return
}
const feedback = prompt("Please enter your feedback:")
if (feedback && _users) {
setLoading(true)
setLogs(`Posting your anonymous feedback...`)
try {
const group = new Group(env.GROUP_ID)
const signal = BigNumber.from(utils.formatBytes32String(feedback)).toString()
group.addMembers(_users)
const { proof, merkleTreeRoot, nullifierHash } = await generateProof(
_identity,
group,
env.GROUP_ID,
signal
)
let response: any
if (env.OPENZEPPELIN_AUTOTASK_WEBHOOK) {
response = await fetch(env.OPENZEPPELIN_AUTOTASK_WEBHOOK, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
abi: Feedback.abi,
address: env.FEEDBACK_CONTRACT_ADDRESS,
functionName: "sendFeedback",
functionParameters: [signal, merkleTreeRoot, nullifierHash, proof]
})
})
} else {
response = await fetch("api/feedback", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
feedback: signal,
merkleTreeRoot,
nullifierHash,
proof
})
})
}
if (response.status === 200) {
addFeedback(feedback)
setLogs(`Your feedback was posted 🎉`)
} else {
setLogs("Some error occurred, please try again!")
}
} catch (error) {
console.error(error)
setLogs("Some error occurred, please try again!")
} finally {
setLoading(false)
}
}
}, [_identity])
return (
<>
<h2>Proofs</h2>
<p>
Semaphore members can anonymously{" "}
<a
href="https://semaphore.appliedzkp.org/docs/guides/proofs"
target="_blank"
rel="noreferrer noopener nofollow"
>
prove
</a>{" "}
that they are part of a group and that they are generating their own signals. Signals could be anonymous
votes, leaks, reviews, or feedback.
</p>
<div className="divider"></div>
<div className="text-top">
<h3>Feedback signals ({_feedback.length})</h3>
<button className="button-link" onClick={refreshFeedback}>
Refresh
</button>
</div>
<div>
<button className="button" onClick={sendFeedback} disabled={_loading}>
<span>Send Feedback</span>
{_loading && <div className="loader"></div>}
</button>
</div>
{_feedback.length > 0 && (
<div>
{_feedback.map((f, i) => (
<div key={i}>
<p className="box box-text">{f}</p>
</div>
))}
</div>
)}
<div className="divider"></div>
<Stepper step={3} onPrevClick={() => router.push("/groups")} />
</>
)
}

View File

@@ -0,0 +1,179 @@
:root {
--slate100: #f1f5f9;
--slate300: #cbd5e1;
--slate400: #94a3b8;
--slate700: #334155;
--blue200: #bfdbfe;
--blue600: #2563eb;
--blue800: #1e40af;
--blue900: #1e3a8a;
}
* {
box-sizing: border-box;
padding: 0;
margin: 0;
}
html,
body {
max-width: 100vw;
overflow-x: hidden;
}
body {
color: var(--slate700);
}
p {
line-height: 1.5rem;
}
.container {
display: flex;
flex-direction: column;
height: 100%;
max-width: 32rem;
margin: auto;
padding: 1rem;
min-height: calc(100vh - 3.5rem);
}
.container #body {
margin-top: 3rem;
}
.text-top {
display: flex;
justify-content: space-between;
margin-bottom: 1rem;
}
ol {
padding: 1rem;
}
li {
margin-top: 1rem;
}
h2 {
font-size: 2.25rem;
font-weight: 700;
margin-bottom: 1rem;
}
h3 {
font-size: 1.125rem;
font-weight: 700;
}
.divider {
height: 1px;
background: var(--slate400);
margin: 2rem 0;
}
.stepper {
display: flex;
justify-content: space-between;
margin-bottom: 1rem;
}
a {
color: var(--blue600);
}
.button {
background-color: var(--blue800);
width: 100%;
padding: 0.8rem 1rem;
border-radius: 4px;
cursor: pointer;
color: var(--slate100);
font-size: 1.125rem;
font-weight: 700;
transition: all 200ms linear;
margin-top: 1rem;
margin-bottom: 1.5rem;
opacity: 0.9;
display: flex;
justify-content: space-between;
height: 3.5rem;
align-items: center;
}
.button:hover {
background-color: var(--blue900);
}
.button:disabled {
cursor: not-allowed;
opacity: 0.5;
}
.button:disabled:hover {
background-color: var(--blue800);
}
.button-stepper {
cursor: pointer;
color: var(--blue900);
font-size: 1.1rem;
border: none;
background: none;
}
.button-link {
cursor: pointer;
color: var(--slate700);
font-size: 1.1rem;
border: none;
background: none;
}
.box {
padding: 0.8rem;
border-style: solid;
border-width: 1px;
border-color: var(--slate300);
border-radius: 4px;
}
.box-text {
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
margin: 0.5rem;
}
.footer {
background-color: var(--blue200);
padding: 1rem 0;
height: 3.5rem;
display: flex;
justify-content: center;
align-items: center;
font-weight: 700;
}
.loader {
width: 25px;
height: 25px;
border-radius: 50%;
border-top: 2px solid var(--slate100);
border-right: 2px solid transparent;
animation: spin 1s linear infinite;
z-index: 20;
}
@keyframes spin {
to {
transform: rotate(360deg);
}
}

View File

@@ -0,0 +1,20 @@
{
"compilerOptions": {
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"incremental": true
},
"include": ["next.config.js", "next-env.d.ts", "**/*.ts", "**/*.tsx"],
"exclude": ["node_modules"]
}

View File

@@ -0,0 +1,44 @@
{
"name": "@semaphore-protocol/cli-template-monorepo-ethers",
"version": "3.10.0",
"description": "Semaphore Hardhat + Next.js + SemaphoreEthers template.",
"license": "Unlicense",
"files": [
"files.tgz",
"scripts/",
".editorconfig",
".env.example",
".eslintignore",
".eslintrc.json",
".prettierignore",
".prettierrc.json",
"tsconfig.json",
"README.md"
],
"scripts": {
"dev": "yarn workspaces foreach -pi run dev",
"dev:web-app": "yarn workspace monorepo-ethers-web-app dev",
"dev:contracts": "yarn workspace monorepo-ethers-contracts dev",
"lint": "eslint . --ext .js,.ts",
"prettier": "prettier -c .",
"prettier:write": "prettier -w .",
"copy:contract-artifacts": "ts-node scripts/copy-contract-artifacts.ts",
"prepublish": "tar -czf files.tgz .gitignore .yarn .yarnrc.yml apps"
},
"workspaces": [
"apps/*"
],
"devDependencies": {
"@types/node": "^17.0.9",
"@typescript-eslint/eslint-plugin": "^5.9.1",
"@typescript-eslint/parser": "^5.9.1",
"eslint": "^8.2.0",
"eslint-config-airbnb-base": "15.0.0",
"eslint-config-airbnb-typescript": "^16.1.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-import": "^2.25.2",
"prettier": "^2.5.1",
"ts-node": "^10.8.1",
"typescript": "^4.7.3"
}
}

View File

@@ -0,0 +1,15 @@
import * as fs from "fs"
async function main() {
const contractArtifactsPath = "apps/contracts/build/contracts/contracts/Feedback.sol"
const webAppArtifactsPath = "apps/web-app/contract-artifacts"
await fs.promises.copyFile(`${contractArtifactsPath}/Feedback.json`, `${webAppArtifactsPath}/Feedback.json`)
}
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error)
process.exit(1)
})

View File

@@ -0,0 +1,3 @@
{
"include": ["scripts/**/*"]
}

View File

@@ -0,0 +1,13 @@
#root = true
[*]
indent_style = space
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
max_line_length = 120
indent_size = 4
[*.md]
trim_trailing_whitespace = false

View File

@@ -0,0 +1,10 @@
DEFAULT_NETWORK=localhost
INFURA_API_KEY=
ETHEREUM_PRIVATE_KEY=ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
FEEDBACK_CONTRACT_ADDRESS=0x5fc8d32690cc91d4c39d9d3abcbd16989f875707
SEMAPHORE_CONTRACT_ADDRESS=0xdc64a140aa3e981100a9beca4e685f962f0cf6c9
OPENZEPPELIN_AUTOTASK_WEBHOOK=
GROUP_ID=42
REPORT_GAS=false
COINMARKETCAP_API_KEY=
ETHERSCAN_API_KEY=

View File

@@ -0,0 +1,45 @@
# dependencies
node_modules
package-lock.json
yarn.lock
.yarn
# testing
coverage
coverage.json
# docs
docs
# types
types
# production
dist
build
cache
contract-artifacts
# misc
.DS_Store
*.pem
# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Next.js
.next/
out/
# The Graph
generated
# Auto Generated PWA files
**/public/sw.js
**/public/workbox-*.js
**/public/worker-*.js
**/public/sw.js.map
**/public/workbox-*.js.map
**/public/worker-*.js.map

View File

@@ -0,0 +1,36 @@
{
"root": true,
"env": {
"es6": true
},
"extends": ["airbnb-base", "airbnb-typescript/base", "prettier"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module",
"project": ["./**/tsconfig.json"]
},
"plugins": ["@typescript-eslint"],
"rules": {
"no-underscore-dangle": "off",
"no-alert": "off",
"no-nested-ternary": "off",
"import/no-extraneous-dependencies": "off",
"import/extensions": "off",
"import/no-relative-packages": "off",
"no-await-in-loop": "off",
"no-bitwise": "off",
"no-restricted-syntax": "off",
"no-console": ["warn", { "allow": ["info", "warn", "error"] }],
"@typescript-eslint/lines-between-class-members": "off",
"no-param-reassign": "off",
"@typescript-eslint/naming-convention": [
"error",
{
"selector": "variable",
"format": ["camelCase", "PascalCase", "UPPER_CASE", "snake_case"],
"leadingUnderscore": "allow"
}
]
}
}

View File

@@ -0,0 +1,122 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# IDE
.vscode
.idea
# Cargo
target
# Testing
coverage
coverage.json
*.lcov
# Dependency directories
node_modules/
# TypeScript cache
*.tsbuildinfo
# Output of 'npm pack'
*.tgz
# Optional eslint cache
.eslintcache
# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/
# Yarn Integrity file
.yarn-integrity
# Generate output
dist
build
cache
# Next.js
.next/
out/
# vercel
.vercel
# typescript
next-env.d.ts
# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local
# Optional npm cache directory
.npm
*.DS_Store
# yarn v3
.pnp.*
.pnp.js
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
# The Graph
generated
# Auto Generated PWA files
**/public/sw.js
**/public/workbox-*.js
**/public/worker-*.js
**/public/sw.js.map
**/public/workbox-*.js.map
**/public/worker-*.js.map
#amplify-do-not-edit-begin
amplify/\#current-cloud-backend
amplify/.config/local-*
amplify/logs
amplify/mock-data
amplify/mock-api-resources
amplify/backend/amplify-meta.json
amplify/backend/.temp
build/
dist/
node_modules/
aws-exports.js
awsconfiguration.json
amplifyconfiguration.json
amplifyconfiguration.dart
amplify-build-config.json
amplify-gradle-config.json
amplifytools.xcconfig
.secret-*
**.sample
#amplify-do-not-edit-end
# Others
files.tgz

View File

@@ -0,0 +1,45 @@
# dependencies
node_modules
package-lock.json
yarn.lock
.yarn
# testing
coverage
coverage.json
# docs
docs
# production
dist
build
cache
contract-artifacts
# github
.github/ISSUE_TEMPLATE
# misc
.DS_Store
*.pem
# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Next.js
.next/
out/
# The Graph
generated
# Auto Generated PWA files
**/public/sw.js
**/public/workbox-*.js
**/public/worker-*.js
**/public/sw.js.map
**/public/workbox-*.js.map
**/public/worker-*.js.map

View File

@@ -0,0 +1,5 @@
{
"semi": false,
"arrowParens": "always",
"trailingComma": "none"
}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
b3cadff6efb37a12712d12c2553ec703dbcaa4dd

View File

@@ -0,0 +1,9 @@
checksumBehavior: update
nodeLinker: node-modules
plugins:
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
spec: "@yarnpkg/plugin-workspace-tools"
yarnPath: .yarn/releases/yarn-3.2.1.cjs

View File

@@ -0,0 +1,59 @@
# Semaphore Hardhat + Next.js + SemaphoreEthers template
This project is a complete application that demonstrates a basic Semaphore use case. It comes with a sample contract, a test for that contract and a sample task that deploys that contract. It also contains a frontend to play around with the contract.
## 📜 Usage
Copy the `.env.example` file as `.env`:
```bash
cp .env.example .env
```
and add your environment variables or run the app in a local network.
### Local server
You can start your app locally with:
```bash
yarn dev
```
### Deploy the contract
1. Go to the `apps/contracts` directory and deploy your contract:
```bash
yarn deploy --semaphore <semaphore-address> --group <group-id> --network arbitrum-goerli
```
2. Update your `.env` file with your new contract address, the group id and the semaphore contract address.
3. Copy your contract artifacts from `apps/contracts/build/contracts/contracts` folder to `apps/web-app/contract-artifacts` folders manually. Or run `yarn copy:contract-artifacts` in the project root to do it automatically.
> **Note**
> Check the Semaphore contract addresses [here](https://semaphore.appliedzkp.org/docs/deployed-contracts).
> **Warning**
> The group id is a number!
### Code quality and formatting
Run [ESLint](https://eslint.org/) to analyze the code and catch bugs:
```bash
yarn lint
```
Run [Prettier](https://prettier.io/) to check formatting rules:
```bash
yarn prettier
```
or to automatically format the code:
```bash
yarn prettier:write
```

View File

@@ -0,0 +1,3 @@
{
"extends": "solhint:default"
}

View File

@@ -0,0 +1,30 @@
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "@semaphore-protocol/contracts/interfaces/ISemaphore.sol";
contract Feedback {
ISemaphore public semaphore;
uint256 public groupId;
constructor(address semaphoreAddress, uint256 _groupId) {
semaphore = ISemaphore(semaphoreAddress);
groupId = _groupId;
semaphore.createGroup(groupId, 20, address(this));
}
function joinGroup(uint256 identityCommitment) external {
semaphore.addMember(groupId, identityCommitment);
}
function sendFeedback(
uint256 feedback,
uint256 merkleTreeRoot,
uint256 nullifierHash,
uint256[8] calldata proof
) external {
semaphore.verifyProof(groupId, merkleTreeRoot, feedback, nullifierHash, groupId, proof);
}
}

View File

@@ -0,0 +1,87 @@
import "@nomicfoundation/hardhat-chai-matchers"
import "@nomiclabs/hardhat-ethers"
import "@nomiclabs/hardhat-etherscan"
import "@semaphore-protocol/hardhat"
import "@typechain/hardhat"
import { config as dotenvConfig } from "dotenv"
import "hardhat-gas-reporter"
import { HardhatUserConfig } from "hardhat/config"
import { NetworksUserConfig } from "hardhat/types"
import { resolve } from "path"
import "solidity-coverage"
import { config } from "./package.json"
import "./tasks/deploy"
dotenvConfig({ path: resolve(__dirname, "../../.env") })
function getNetworks(): NetworksUserConfig {
if (!process.env.INFURA_API_KEY || !process.env.ETHEREUM_PRIVATE_KEY) {
return {}
}
const accounts = [`0x${process.env.ETHEREUM_PRIVATE_KEY}`]
const infuraApiKey = process.env.INFURA_API_KEY
return {
goerli: {
url: `https://goerli.infura.io/v3/${infuraApiKey}`,
chainId: 5,
accounts
},
sepolia: {
url: `https://sepolia.infura.io/v3/${infuraApiKey}`,
chainId: 11155111,
accounts
},
mumbai: {
url: `https://polygon-mumbai.infura.io/v3/${infuraApiKey}`,
chainId: 80001,
accounts
},
"optimism-goerli": {
url: `https://optimism-goerli.infura.io/v3/${infuraApiKey}`,
chainId: 420,
accounts
},
"arbitrum-goerli": {
url: "https://goerli-rollup.arbitrum.io/rpc",
chainId: 421613,
accounts
},
arbitrum: {
url: "https://arb1.arbitrum.io/rpc",
chainId: 42161,
accounts
}
}
}
const hardhatConfig: HardhatUserConfig = {
solidity: config.solidity,
paths: {
sources: config.paths.contracts,
tests: config.paths.tests,
cache: config.paths.cache,
artifacts: config.paths.build.contracts
},
networks: {
hardhat: {
chainId: 1337
},
...getNetworks()
},
gasReporter: {
currency: "USD",
enabled: process.env.REPORT_GAS === "true",
coinmarketcap: process.env.COINMARKETCAP_API_KEY
},
typechain: {
outDir: config.paths.build.typechain,
target: "ethers-v5"
},
etherscan: {
apiKey: process.env.ETHERSCAN_API_KEY
}
}
export default hardhatConfig

View File

@@ -0,0 +1,60 @@
{
"name": "monorepo-subgraph-contracts",
"version": "1.0.0",
"private": true,
"main": "index.js",
"scripts": {
"dev": "hardhat node & yarn compile && yarn deploy --network localhost",
"compile": "hardhat compile",
"download:snark-artifacts": "hardhat run scripts/download-snark-artifacts.ts",
"deploy": "yarn compile && hardhat deploy",
"test": "hardhat run scripts/download-snark-artifacts.ts && hardhat test",
"test:report-gas": "REPORT_GAS=true hardhat test",
"test:coverage": "hardhat coverage",
"typechain": "hardhat typechain",
"lint": "solhint 'contracts/**/*.sol'"
},
"devDependencies": {
"@nomicfoundation/hardhat-chai-matchers": "^1.0.5",
"@nomiclabs/hardhat-ethers": "^2.0.0",
"@nomiclabs/hardhat-etherscan": "^3.1.7",
"@semaphore-protocol/group": "3.10.0",
"@semaphore-protocol/hardhat": "3.10.0",
"@semaphore-protocol/identity": "3.10.0",
"@semaphore-protocol/proof": "3.10.0",
"@typechain/ethers-v5": "^10.0.0",
"@typechain/hardhat": "^6.0.0",
"@types/chai": "^4.3.1",
"@types/download": "^8.0.1",
"@types/mocha": "^9.1.1",
"chai": "^4.2.0",
"dotenv": "^14.3.2",
"download": "^8.0.0",
"ethers": "^5.0.0",
"hardhat": "^2.8.4",
"hardhat-gas-reporter": "^1.0.8",
"prettier-plugin-solidity": "^1.0.0-beta.19",
"solhint": "^3.3.6",
"solhint-plugin-prettier": "^0.0.5",
"solidity-coverage": "^0.7.21",
"typechain": "^8.0.0"
},
"dependencies": {
"@semaphore-protocol/contracts": "3.10.0"
},
"config": {
"solidity": {
"version": "0.8.4"
},
"paths": {
"contracts": "./contracts",
"tests": "./test",
"cache": "./cache",
"build": {
"snark-artifacts": "./build/snark-artifacts",
"contracts": "./build/contracts",
"typechain": "./build/typechain"
}
}
}
}

View File

@@ -0,0 +1,24 @@
import download from "download"
import fs from "fs"
import { config } from "../package.json"
async function main() {
const snarkArtifactsPath = config.paths.build["snark-artifacts"]
const url = `http://www.trusted-setup-pse.org/semaphore/${20}`
if (!fs.existsSync(snarkArtifactsPath)) {
fs.mkdirSync(snarkArtifactsPath, { recursive: true })
}
if (!fs.existsSync(`${snarkArtifactsPath}/semaphore.zkey`)) {
await download(`${url}/semaphore.wasm`, snarkArtifactsPath)
await download(`${url}/semaphore.zkey`, snarkArtifactsPath)
}
}
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error)
process.exit(1)
})

View File

@@ -0,0 +1,31 @@
import { task, types } from "hardhat/config"
task("deploy", "Deploy a Feedback contract")
.addOptionalParam("semaphore", "Semaphore contract address", undefined, types.string)
.addOptionalParam("group", "Group id", "42", types.string)
.addOptionalParam("logs", "Print the logs", true, types.boolean)
.setAction(async ({ logs, semaphore: semaphoreAddress, group: groupId }, { ethers, run }) => {
if (!semaphoreAddress) {
const { semaphore } = await run("deploy:semaphore", {
logs
})
semaphoreAddress = semaphore.address
}
if (!groupId) {
groupId = process.env.GROUP_ID
}
const FeedbackFactory = await ethers.getContractFactory("Feedback")
const feedbackContract = await FeedbackFactory.deploy(semaphoreAddress, groupId)
await feedbackContract.deployed()
if (logs) {
console.info(`Feedback contract has been deployed to: ${feedbackContract.address}`)
}
return feedbackContract
})

View File

@@ -0,0 +1,73 @@
import { Group } from "@semaphore-protocol/group"
import { Identity } from "@semaphore-protocol/identity"
import { generateProof } from "@semaphore-protocol/proof"
import { expect } from "chai"
import { formatBytes32String } from "ethers/lib/utils"
import { run } from "hardhat"
// @ts-ignore: typechain folder will be generated after contracts compilation
import { Feedback } from "../build/typechain"
import { config } from "../package.json"
describe("Feedback", () => {
let feedbackContract: Feedback
let semaphoreContract: string
const groupId = "42"
const group = new Group(groupId)
const users: Identity[] = []
before(async () => {
const { semaphore } = await run("deploy:semaphore", {
logs: false
})
feedbackContract = await run("deploy", {
logs: false,
group: groupId,
semaphore: semaphore.address
})
semaphoreContract = semaphore
users.push(new Identity())
users.push(new Identity())
})
describe("# joinGroup", () => {
it("Should allow users to join the group", async () => {
for await (const [i, user] of users.entries()) {
const transaction = feedbackContract.joinGroup(user.commitment)
group.addMember(user.commitment)
await expect(transaction)
.to.emit(semaphoreContract, "MemberAdded")
.withArgs(groupId, i, user.commitment, group.root)
}
})
})
describe("# sendFeedback", () => {
const wasmFilePath = `${config.paths.build["snark-artifacts"]}/semaphore.wasm`
const zkeyFilePath = `${config.paths.build["snark-artifacts"]}/semaphore.zkey`
it("Should allow users to send feedback anonymously", async () => {
const feedback = formatBytes32String("Hello World")
const fullProof = await generateProof(users[1], group, groupId, feedback, {
wasmFilePath,
zkeyFilePath
})
const transaction = feedbackContract.sendFeedback(
feedback,
fullProof.merkleTreeRoot,
fullProof.nullifierHash,
fullProof.proof
)
await expect(transaction)
.to.emit(semaphoreContract, "ProofVerified")
.withArgs(groupId, fullProof.merkleTreeRoot, fullProof.nullifierHash, groupId, fullProof.signal)
})
})
})

View File

@@ -0,0 +1,15 @@
{
"compilerOptions": {
"moduleResolution": "Node",
"noImplicitAny": true,
"resolveJsonModule": true,
"target": "ES2018",
"module": "CommonJS",
"strict": true,
"esModuleInterop": true,
"outDir": "dist",
"typeRoots": ["node_modules/@types", "types"]
},
"include": ["scripts/**/*", "tasks/**/*", "test/**/*", "build/typechain/**/*", "types/**/*"],
"files": ["./hardhat.config.ts"]
}

View File

@@ -0,0 +1,94 @@
{
"_format": "hh-sol-artifact-1",
"contractName": "Feedback",
"sourceName": "contracts/Feedback.sol",
"abi": [
{
"inputs": [
{
"internalType": "address",
"name": "semaphoreAddress",
"type": "address"
},
{
"internalType": "uint256",
"name": "_groupId",
"type": "uint256"
}
],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"inputs": [],
"name": "groupId",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "identityCommitment",
"type": "uint256"
}
],
"name": "joinGroup",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "semaphore",
"outputs": [
{
"internalType": "contract ISemaphore",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "feedback",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "merkleTreeRoot",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "nullifierHash",
"type": "uint256"
},
{
"internalType": "uint256[8]",
"name": "proof",
"type": "uint256[8]"
}
],
"name": "sendFeedback",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}
],
"bytecode": "0x608060405234801561001057600080fd5b506040516106e13803806106e18339818101604052810190610032919061013c565b816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508060018190555060008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16639c1121416001546014306040518463ffffffff1660e01b81526004016100d9939291906101a5565b600060405180830381600087803b1580156100f357600080fd5b505af1158015610107573d6000803e3d6000fd5b505050505050610258565b6000815190506101218161022a565b92915050565b60008151905061013681610241565b92915050565b6000806040838503121561014f57600080fd5b600061015d85828601610112565b925050602061016e85828601610127565b9150509250929050565b610181816101dc565b82525050565b61019081610218565b82525050565b61019f8161020e565b82525050565b60006060820190506101ba6000830186610196565b6101c76020830185610187565b6101d46040830184610178565b949350505050565b60006101e7826101ee565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b60006102238261020e565b9050919050565b610233816101dc565b811461023e57600080fd5b50565b61024a8161020e565b811461025557600080fd5b50565b61047a806102676000396000f3fe608060405234801561001057600080fd5b506004361061004c5760003560e01c80637b5d253414610051578063a0f44c921461006f578063d18ed1e91461008d578063eed02e4b146100a9575b600080fd5b6100596100c5565b604051610066919061030f565b60405180910390f35b6100776100e9565b604051610084919061032a565b60405180910390f35b6100a760048036038101906100a2919061027c565b6100ef565b005b6100c360048036038101906100be9190610253565b61018e565b005b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60015481565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16633bc778e3600154858786600154876040518763ffffffff1660e01b81526004016101569695949392919061036e565b600060405180830381600087803b15801561017057600080fd5b505af1158015610184573d6000803e3d6000fd5b5050505050505050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16631783efc3600154836040518363ffffffff1660e01b81526004016101eb929190610345565b600060405180830381600087803b15801561020557600080fd5b505af1158015610219573d6000803e3d6000fd5b5050505050565b60008190508260206008028201111561023857600080fd5b92915050565b60008135905061024d8161042d565b92915050565b60006020828403121561026557600080fd5b60006102738482850161023e565b91505092915050565b600080600080610160858703121561029357600080fd5b60006102a18782880161023e565b94505060206102b28782880161023e565b93505060406102c38782880161023e565b92505060606102d487828801610220565b91505092959194509250565b6102ed610100838361041e565b5050565b6102fa816103fa565b82525050565b610309816103f0565b82525050565b600060208201905061032460008301846102f1565b92915050565b600060208201905061033f6000830184610300565b92915050565b600060408201905061035a6000830185610300565b6103676020830184610300565b9392505050565b60006101a0820190506103846000830189610300565b6103916020830188610300565b61039e6040830187610300565b6103ab6060830186610300565b6103b86080830185610300565b6103c560a08301846102e0565b979650505050505050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b60006104058261040c565b9050919050565b6000610417826103d0565b9050919050565b82818337600083830152505050565b610436816103f0565b811461044157600080fd5b5056fea26469706673582212204d8dc3161abc759242364c3a754a86e5eb8653092bcdf1e20bd6fcd368e1997664736f6c63430008040033",
"deployedBytecode": "0x608060405234801561001057600080fd5b506004361061004c5760003560e01c80637b5d253414610051578063a0f44c921461006f578063d18ed1e91461008d578063eed02e4b146100a9575b600080fd5b6100596100c5565b604051610066919061030f565b60405180910390f35b6100776100e9565b604051610084919061032a565b60405180910390f35b6100a760048036038101906100a2919061027c565b6100ef565b005b6100c360048036038101906100be9190610253565b61018e565b005b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60015481565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16633bc778e3600154858786600154876040518763ffffffff1660e01b81526004016101569695949392919061036e565b600060405180830381600087803b15801561017057600080fd5b505af1158015610184573d6000803e3d6000fd5b5050505050505050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16631783efc3600154836040518363ffffffff1660e01b81526004016101eb929190610345565b600060405180830381600087803b15801561020557600080fd5b505af1158015610219573d6000803e3d6000fd5b5050505050565b60008190508260206008028201111561023857600080fd5b92915050565b60008135905061024d8161042d565b92915050565b60006020828403121561026557600080fd5b60006102738482850161023e565b91505092915050565b600080600080610160858703121561029357600080fd5b60006102a18782880161023e565b94505060206102b28782880161023e565b93505060406102c38782880161023e565b92505060606102d487828801610220565b91505092959194509250565b6102ed610100838361041e565b5050565b6102fa816103fa565b82525050565b610309816103f0565b82525050565b600060208201905061032460008301846102f1565b92915050565b600060208201905061033f6000830184610300565b92915050565b600060408201905061035a6000830185610300565b6103676020830184610300565b9392505050565b60006101a0820190506103846000830189610300565b6103916020830188610300565b61039e6040830187610300565b6103ab6060830186610300565b6103b86080830185610300565b6103c560a08301846102e0565b979650505050505050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b60006104058261040c565b9050919050565b6000610417826103d0565b9050919050565b82818337600083830152505050565b610436816103f0565b811461044157600080fd5b5056fea26469706673582212204d8dc3161abc759242364c3a754a86e5eb8653092bcdf1e20bd6fcd368e1997664736f6c63430008040033",
"linkReferences": {},
"deployedLinkReferences": {}
}

View File

@@ -0,0 +1,45 @@
/** @type {import('next').NextConfig} */
const fs = require("fs")
const withPWA = require("next-pwa")
if (!fs.existsSync("./.env")) {
// eslint-disable-next-line global-require
require("dotenv").config({ path: "../../.env" })
}
const nextConfig = withPWA({
dest: "public",
disable: process.env.NODE_ENV === "development"
})({
eslint: {
ignoreDuringBuilds: true
},
reactStrictMode: true,
swcMinify: true,
env: {
DEFAULT_NETWORK: process.env.DEFAULT_NETWORK,
INFURA_API_KEY: process.env.INFURA_API_KEY,
ETHEREUM_PRIVATE_KEY: process.env.ETHEREUM_PRIVATE_KEY,
FEEDBACK_CONTRACT_ADDRESS: process.env.FEEDBACK_CONTRACT_ADDRESS,
SEMAPHORE_CONTRACT_ADDRESS: process.env.SEMAPHORE_CONTRACT_ADDRESS
},
publicRuntimeConfig: {
DEFAULT_NETWORK: process.env.DEFAULT_NETWORK,
FEEDBACK_CONTRACT_ADDRESS: process.env.FEEDBACK_CONTRACT_ADDRESS,
SEMAPHORE_CONTRACT_ADDRESS: process.env.SEMAPHORE_CONTRACT_ADDRESS,
OPENZEPPELIN_AUTOTASK_WEBHOOK: process.env.OPENZEPPELIN_AUTOTASK_WEBHOOK,
GROUP_ID: process.env.GROUP_ID
},
webpack: (config, { isServer }) => {
if (!isServer) {
config.resolve.fallback = {
fs: false
}
}
return config
}
})
module.exports = nextConfig

View File

@@ -0,0 +1,27 @@
{
"name": "monorepo-subgraph-web-app",
"version": "1.0.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"export": "next export",
"start": "next start"
},
"dependencies": {
"@next/font": "13.0.3",
"@semaphore-protocol/data": "3.10.0",
"@semaphore-protocol/group": "3.10.0",
"@semaphore-protocol/identity": "3.10.0",
"@semaphore-protocol/proof": "3.10.0",
"@types/react": "18.0.25",
"@types/react-dom": "18.0.8",
"dotenv": "^16.0.3",
"ethers": "^5.7.2",
"next": "13.0.3",
"next-pwa": "^5.6.0",
"react": "18.2.0",
"react-dom": "18.2.0",
"typescript": "^4.7.3"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 376 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 827 B

Some files were not shown because too many files have changed in this diff Show More