Compare commits

...

230 Commits

Author SHA1 Message Date
cedoor
a522fff448 chore: v4.0.0-beta.7 2024-03-28 19:06:18 +00:00
Cedoor
d9d97de09c Merge pull request #734 from semaphore-protocol/fix/convert-hex-pk
Convert hexadecimal private key before signing messages
2024-03-28 19:05:01 +00:00
Cedoor
88df87e339 Update packages/identity/tests/index.test.ts
Co-authored-by: Vivian Plasencia <v.pcalana@gmail.com>
2024-03-28 17:57:24 +00:00
cedoor
9c2968eecd fix(identity): convert hex private key before signing messages
The ZK-Kit EdDSA Poseidon package only supports the following private key types: text, buffer. The
Semaphore identity supports text and hexadecimal strings. If the identity private key is an
hexadicimal string it needs to be converted before being passed to any ZK-Kit function.

re #733
2024-03-28 15:52:08 +00:00
Cedoor
c795ddce35 Merge pull request #732 from semaphore-protocol/fix/group-checks
Add checks for removed members

Former-commit-id: 2faac4e30790a049a8377807ab507d980fa21b31
2024-03-28 14:43:37 +00:00
Cedoor
764ff52516 Merge pull request #731 from semaphore-protocol/refactor/bigint-type
Use native `bigint` type

Former-commit-id: 4adc328c9458e386ffc9f65e5ea06040911564cc
2024-03-28 14:43:19 +00:00
cedoor
2b7dbf3519 refactor(group): remove check on generateMerkleProof function
Contracts actually need devs to generate a Merkle proof of a removed member.

re #717


Former-commit-id: 0014365453
2024-03-28 13:04:58 +00:00
cedoor
ea2145471d fix(group): add checks for removed members
re #717


Former-commit-id: 1c42ab332a
2024-03-28 12:53:21 +00:00
cedoor
197a7ae204 test: fix types on tests
Former-commit-id: fa4d9860e4
2024-03-28 12:52:16 +00:00
cedoor
663bea73d0 docs: update group parameter types
Former-commit-id: 56c7fc8b23
2024-03-28 12:45:50 +00:00
cedoor
072d94fdee refactor(identity): keep index.ts file only as there's only 1 class
Former-commit-id: e25db2d89e
2024-03-28 12:09:09 +00:00
cedoor
a20d3db122 refactor: use native bigints
The core libraries can now use native bigints as the new ts target is es2020.


Former-commit-id: 238c6b3bbe
2024-03-28 12:06:18 +00:00
cedoor
d00c0a3309 style: format readme file with prettier
Former-commit-id: 7fd8d8245c
2024-03-28 10:34:56 +00:00
Cedoor
c071d5b6e5 docs: update README.md
Former-commit-id: 82d2cd04c4
2024-03-28 10:31:21 +00:00
Cedoor
c1ab686a6c Merge pull request #730 from semaphore-protocol/fix/docs-links
Fix docs links

Former-commit-id: afd0e07f12
2024-03-27 13:09:43 +00:00
cedoor
1942afe766 refactor(docs): use utils function to get explorer url
re #599


Former-commit-id: e05d89ce63
2024-03-27 12:38:09 +00:00
cedoor
f57f4979ce fix(docs): set correct anchor links
re #599


Former-commit-id: 38830641af
2024-03-27 12:37:34 +00:00
cedoor
65a6983c54 chore(docs): rename vercel conf file
Former-commit-id: 4ac10bab49
2024-03-27 11:17:50 +00:00
cedoor
30844cee5f chore(docs): add vercel conf file
Former-commit-id: 47524eec19
2024-03-27 11:10:59 +00:00
cedoor
5fecb53438 chore: v4.0.0-beta.6
Former-commit-id: 41494b62c8
2024-03-26 18:49:38 +00:00
cedoor
3f7eb28051 chore: deploy new semaphore subgraphs
Former-commit-id: 9a41d607e4
2024-03-26 18:49:02 +00:00
Vivian Plasencia
1fb6e99cd0 chore: v4.0.0-beta.5
Former-commit-id: 821735aae0
2024-03-26 18:39:03 +01:00
Cedoor
a3f86d9ad3 Merge pull request #728 from semaphore-protocol/chore/es2020-target
Update TypeScript target to `ES2020`

Former-commit-id: 02cd18f457
2024-03-26 17:26:11 +00:00
Cedoor
832b0d6887 Merge pull request #727 from semaphore-protocol/chore/update-template-contracts
Update CLI template contracts

Former-commit-id: 8da28a5a5d
2024-03-26 17:25:24 +00:00
cedoor
a159c23b91 chore: build libraries first
Former-commit-id: 6239919f9a
2024-03-26 17:03:33 +00:00
cedoor
825a52cc4d chore: build libraries before generating subgraph files
Former-commit-id: d55810d169
2024-03-25 19:11:12 +00:00
cedoor
e0057a56af chore: add pre-build script to subgraph
Former-commit-id: ce2ef1e87d
2024-03-25 19:06:15 +00:00
Cedoor
7afcd53649 Merge pull request #719 from semaphore-protocol/feat/deployed-contracts
Add deployed contracts to utils package

Former-commit-id: bc2bc37991
2024-03-25 18:55:09 +00:00
cedoor
f569b2fc70 chore: update ts target to es2020
Targeting ES2020 looks like it's generally fine today. It's widely supported across modern browsers
and environments and it would allow Semaphore bundles to use new ES features natively, like arrow
functions, promises, and classes, which can improve code readability and efficiency.

re #688


Former-commit-id: 9f49d91197
2024-03-25 13:04:21 +00:00
cedoor
aa0c9ceba2 chore(cli): update template contracts
re #722


Former-commit-id: 895f9e1e9e
2024-03-25 12:58:42 +00:00
Cedoor
4a68eb5e03 Merge pull request #721 from xiaoxianBoy/fix-typos
chore: fix typos
Former-commit-id: 87e94afeac
2024-03-25 11:50:35 +00:00
Cedoor
32944c412b Merge pull request #726 from semaphore-protocol/docs/add-social-media-card
Docs: Add social media card
Former-commit-id: f1441fd0c8
2024-03-25 11:47:47 +00:00
cedoor
8d8fb82407 refactor(utils): re-organize 'networks' module structure and add tests
re #715


Former-commit-id: ff3263d166
2024-03-25 11:43:17 +00:00
Cedoor
73a306241b Merge pull request #725 from patitonar/patch-1
chore(circuits): fix groth16 malleability broken link

Former-commit-id: 95cb7dd74d
2024-03-25 10:37:22 +00:00
Vivian Plasencia
9b023041e8 docs: update parameter order in generateProof function
Now the order of parameters in the generateProof function docs is correct.

re #686


Former-commit-id: 3e3c3f4f05
2024-03-23 12:07:50 +01:00
Vivian Plasencia
b6ffad5b8c chore(docs): add social media card to docs
Now when the documentation link is shared on social media, the Semaphore card for social media will
be displayed.

re #712


Former-commit-id: e981583172
2024-03-23 11:51:43 +01:00
cedoor
8abfb93b4c style(utils): format code with prettier
Former-commit-id: 7cfe752f4c
2024-03-22 18:17:38 +00:00
cedoor
138e5339bd chore: remove oz and add more networks
Former-commit-id: 92e189e17c
2024-03-22 18:08:27 +00:00
cedoor
784cddb483 chore: add pre-build script for building local packages
re #715


Former-commit-id: 042759b10e
2024-03-22 15:02:37 +00:00
cedoor
5898a175b0 chore(utils): move json of deployed contracts to utils pkg
re #715


Former-commit-id: 8caad14e3f
2024-03-22 14:53:20 +00:00
Gerardo Nardelli
6e8f84025f chore(circuits): fix groth16 malleability broken link
Former-commit-id: d5477644e0
2024-03-22 11:46:04 -03:00
cedoor
6b659a80d0 chore(utils): reduce number of supported networks
re #715


Former-commit-id: 095147afb3
2024-03-22 13:19:57 +00:00
cedoor
5caa3c7fd8 ci: build libraries first
re #715


Former-commit-id: 17d716f632
2024-03-22 11:18:22 +00:00
cedoor
619459e64b feat(utils): add deployed contracts to utils package
re #715


Former-commit-id: 1647ecaba5
2024-03-22 11:18:20 +00:00
Vivian Plasencia
11eff59b3b docs: fix whitepaper v1 link
re #723


Former-commit-id: ba3f7fb139
2024-03-22 12:17:12 +01:00
snoppy
0e2e6dfd0e chore: fix typos
Former-commit-id: ad43b8ab62
2024-03-22 18:43:24 +08:00
Cedoor
ecfcda70cc Merge pull request #718 from semaphore-protocol/feature/two-step-admin
Create a two-step mechanism to update group admins

Former-commit-id: 00f05510d6
2024-03-21 17:25:48 +00:00
cedoor
601a339d9b feat(contracts)!: create a two-step mechanism to update group admins
The best practice to update a group admin is through a two-step update. The existing admin assigns
the new potential admin, and the new admin accepts in a separate transaction. This prevents existing
admins from making mistakes and assigning wrong addresses.

re #690


Former-commit-id: 255bccf2eb
2024-03-21 15:54:46 +00:00
cedoor
6d0d7444b6 docs: fix variable name
Former-commit-id: d147958c67
2024-03-20 09:48:45 +00:00
cedoor
b441be91a4 revert(proof): remove resolutions and overrides fields
overrides only works with NPM and both overrides and resolutions works if they are in the project
root package.json. So they don't solve #713.

re #713


Former-commit-id: b77feebdea
2024-03-19 16:49:53 +00:00
cedoor
0d4d8508fc chore: v4.0.0-beta.4
Former-commit-id: 7102d0a084
2024-03-19 15:39:58 +00:00
cedoor
b215c6cbde chore(proof): add override version for web-worker
Former-commit-id: e2ad68d6da
2024-03-19 15:38:25 +00:00
cedoor
27956f1676 chore(cli): make contract packages in templates private
Former-commit-id: 63904fb678
2024-03-19 15:37:59 +00:00
cedoor
9c7afa888f chore: v4.0.0-beta.3
Former-commit-id: 9c6f9006e0
2024-03-19 15:16:21 +00:00
Cedoor
96cb583861 Merge pull request #716 from semaphore-protocol/fix/web-worker
Add temporary fixed resolution for `web-worker` dependency

Former-commit-id: 55eaa31dfb
2024-03-19 15:00:17 +00:00
cedoor
b603dbaf81 fix(proof): add temporary fixed resolution for web-worker dep
Adding the 'resolutions' field with the static version of web-worker solves the problem described in
issue #713. To be regarded as a temporary solution.

re #713


Former-commit-id: ca36ed5488
2024-03-19 12:54:43 +00:00
Cedoor
4fc4675678 Merge pull request #714 from semaphore-protocol/fix/deployed-contracts
Update link to fetch deployed contracts on docs

Former-commit-id: 65d3a41fa9
2024-03-18 20:08:37 +00:00
cedoor
6f0fdddae5 chore(contracts): update zk-kit imt.sol dependency
Former-commit-id: 4b074a443f
2024-03-18 20:04:10 +00:00
cedoor
31b05dba43 fix: update link to fetch deployed contracts on docs
Former-commit-id: a875e07ec2
2024-03-18 19:49:52 +00:00
Cedoor
94bdb44a45 Merge pull request #707 from semaphore-protocol/feat/create-group-contracts
Add a new `createGroup` function in the contracts

Former-commit-id: b55693948c
2024-03-18 10:30:49 +00:00
Cedoor
2bc10b0d5e Merge pull request #701 from semaphore-protocol/refactor/update-zk-kit
Update `utils` package and identity private key types.

Former-commit-id: 3b167fb46c
2024-03-15 23:13:54 +00:00
Cedoor
7ab9898beb Merge pull request #709 from semaphore-protocol/ref/remove-groupid-check
Remove existence check for `groupId `

Former-commit-id: d045bf9beb
2024-03-15 23:13:30 +00:00
cedoor
9e5f8351cc fix(utils): add missing exports to index.ts
re #642


Former-commit-id: 0987dee8db
2024-03-15 23:08:47 +00:00
cedoor
b6e6a8db03 fix(identity): update zk-kit packages with fixes
re #700


Former-commit-id: a2ec3013c8
2024-03-15 23:07:56 +00:00
cedoor
9eebaf4967 chore(identity): fix main path in package.json
re #700


Former-commit-id: e01ffb80b6
2024-03-15 23:07:52 +00:00
cedoor
9e5c464237 feat(utils): new semaphore utilities + zk-kit replacements
The utils package will no longer provide errors and types utilities as those functions have been
moved to zk-kit. The utils package now provides a list of supported networks and a function to
decode messages instead.

re #642, #641


Former-commit-id: d2ce1070f0
2024-03-15 23:07:44 +00:00
cedoor
2ea5d5c1cf refactor(identity)!: new private key types
The type of the identities' private key will always be a string type, either text or hexadecimal
strings. This will allow devs to store private keys more easily and avoid confusion with types.

re #700


Former-commit-id: eead04e45d
2024-03-15 23:02:51 +00:00
Cedoor
e9e24b04d1 Merge pull request #711 from semaphore-protocol/ref/add-tree-depth-constants
Add tree depth constants to JavaScript libraries and Solidity contracts

Former-commit-id: d256905c0c
2024-03-15 17:20:29 +00:00
Vivian Plasencia
2c5b0641c7 docs: update code comments related to supported tree depths
re #683


Former-commit-id: c3b9b98370
2024-03-15 17:39:42 +01:00
Vivian Plasencia
9e6d386748 refactor(contracts): add a constants sol file to store the constants
re #683


Former-commit-id: 969f1ed809
2024-03-15 17:27:37 +01:00
Vivian Plasencia
546d9f9dd6 refactor(contracts): add constants for the supported tree depths in contracts
the semaphore contract has new constants to save the min and max supported tree depth

re #683


Former-commit-id: 8793958d75
2024-03-15 13:44:38 +01:00
Vivian Plasencia
38b14a515c refactor(proof): add constants for supported tree depth
there is a new package in utils called constants which has the supported semaphore tree depths

re #683


Former-commit-id: 621003dd6c
2024-03-15 13:34:13 +01:00
Cedoor
193be0e1d5 Merge pull request #710 from semaphore-protocol/test/more-contracts-tests
Add more tests for the semaphore groups contract

Former-commit-id: 750c948157
2024-03-15 11:25:36 +00:00
Vivian Plasencia
dfb5473414 test(contracts): add more tests for the semaphore groups contract
re #484


Former-commit-id: e2c156d883
2024-03-15 11:00:00 +01:00
Vivian Plasencia
25847c4422 refactor(contracts): remove existence check for group id
since the group ids are created incrementally internally in the contracts, there's no need to check
whether the group id has already been taken.

re #708


Former-commit-id: e205bf6ad7
2024-03-14 23:40:41 +01:00
Vivian Plasencia
7b8a35470a feat(contracts): add a new create group function in the contracts
now there is a new function to create groups without passing any parameters

re #704


Former-commit-id: 67a0cecf3e
2024-03-14 23:19:55 +01:00
Cedoor
ee26734d94 Merge pull request #702 from zkfriendly/fix/accessControl
Fixes access control related issues

Former-commit-id: 0fe8d637f3
2024-03-14 20:38:21 +00:00
Cedoor
b50cddad2e Merge pull request #705 from semaphore-protocol/test/add-contracts-tests
Add contract tests

Former-commit-id: dcaba2583f
2024-03-14 20:37:46 +00:00
Cedoor
4578fc63de Merge pull request #703 from semaphore-protocol/fix/create-group
Use an incremental group id when creating a group in contracts

Former-commit-id: 87b48cac69
2024-03-14 20:37:31 +00:00
Vivian Plasencia
eb1f3ad5e2 test(contracts): add missing tests
re #484


Former-commit-id: e1481b8de8
2024-03-14 17:51:12 +01:00
Vivian Plasencia
6049a27308 chore: add hardhat artifacts to prettier ignore file
Former-commit-id: b12dd0fd98
2024-03-14 14:34:49 +01:00
Vivian Plasencia
7943fcd665 docs(contracts): update group counter code comment
Former-commit-id: 644f144e9c
2024-03-14 14:28:55 +01:00
Vivian Plasencia
66be942cb2 refactor(contracts): remove unnecessary initialization for group counter variable
Former-commit-id: f4ee63f909
2024-03-14 14:26:02 +01:00
Vivian Plasencia
b93ad8e14d chore(contracts): update prettier config
Former-commit-id: c670ed4b5d
2024-03-14 14:23:37 +01:00
Vivian Plasencia
7c69037745 style(contracts): add a line at the end of the prettierignore file
Former-commit-id: 2fc164b745
2024-03-14 10:52:42 +01:00
Vivian Plasencia
fcb3634e07 fix(contracts)!: use an incremental group id when creating a group
BREAKING CHANGE: the group id is no longer required when creating a group in contracts

re #682


Former-commit-id: 5f76dd5612
2024-03-14 10:34:42 +01:00
zkFriendly
b5825c52e5 style(contracts): format code with prettier
Former-commit-id: baa18c885e
2024-03-13 23:28:53 +01:00
zkFriendly
8795302788 perf(contracts): remove unnecessary onlyExistingGroup checks
Former-commit-id: 0b9d2a3d86
2024-03-13 23:28:16 +01:00
zkFriendly
3c2db6f724 test(contracts): assert only admin can add members
Former-commit-id: 4e4b4e629a
2024-03-13 23:19:51 +01:00
zkFriendly
fb79707e3e fix(contracts): add missing onlyGroupAdmin modifier to _addMembers
Former-commit-id: bfe050d16b
2024-03-13 23:19:31 +01:00
Cedoor
c5378b6914 Merge pull request #699 from semaphore-protocol/chore/automatic-releases
Update release workflow to auto-publish NPM packages

Former-commit-id: e75273ba27
2024-03-13 19:14:37 +00:00
Cedoor
8709b373e8 Merge pull request #695 from semaphore-protocol/chore/dev-deps
Update remaining dev dependencies

Former-commit-id: b22fa606dc
2024-03-13 19:13:58 +00:00
cedoor
3c993ab150 chore: update release workflow to auto-publish npm packages
re #698


Former-commit-id: 38d434083f
2024-03-13 16:42:11 +00:00
cedoor
541007d4a5 chore(contracts): update solhint-plugin-prettier dev dependency
re #662


Former-commit-id: fe30192879
2024-03-13 16:41:26 +00:00
cedoor
f3971efb55 chore: update dev dependencies + new cz adapter
re #662


Former-commit-id: 15d988efbb
2024-03-13 16:41:11 +00:00
cedoor
c8db909122 style: format code with prettier
re #662


Former-commit-id: 8a9d8a09b9
2024-03-13 16:40:56 +00:00
Cedoor
ab0366aa07 Merge pull request #697 from semaphore-protocol/ref/update-zk-kit-utils
Update `@zk-kit/utils` package

Former-commit-id: 84cf596e99
2024-03-13 16:02:56 +00:00
Vivian Plasencia
d4bda547ff refactor: update zk-kit utils package
Former-commit-id: 287f3a8796
2024-03-13 16:46:07 +01:00
Cedoor
d1f5fb331a Merge pull request #692 from zkfriendly/main
Gas optimization in getting new merkle tree roots after modifying group members

Former-commit-id: 81e8a6885a
2024-03-13 13:35:07 +00:00
Cedoor
14fe011ad7 Merge pull request #694 from semaphore-protocol/ref/proof-types
Replace `PackedPoints` with `PackedGroth16Proof`

Former-commit-id: c43a0a5ba2
2024-03-13 10:07:31 +00:00
Vivian Plasencia
2897754358 refactor(proof): update semaphore proof type
re #693


Former-commit-id: 09c842f9dc
2024-03-12 21:59:48 +01:00
zkFriendly
4a0ea1201c refactor(contracts): use returned new merkle tree root instead of calling getMerkleTreeRoot
Former-commit-id: f06ddd32e4
2024-03-12 16:41:15 +01:00
zkFriendly
634c2b11e6 refactor(contracts): return new merkle tree root after modifying group members
Former-commit-id: 7e2c208efd
2024-03-12 16:39:17 +01:00
cedoor
ac830458fa chore: v4.0.0-beta.2
Former-commit-id: 43f555e229
2024-03-04 15:46:23 +00:00
Cedoor
7b46be0725 Merge pull request #679 from semaphore-protocol/chore/stable-version-script
Add script to remove stableVersion field

Former-commit-id: 3dc31e55ae
2024-03-04 15:44:34 +00:00
Cedoor
f7fa9fe50d Merge pull request #677 from semaphore-protocol/docs/yarn-only
Remove pnpm and npm from supported package managers

Former-commit-id: 6ad2a79298
2024-03-04 13:32:00 +00:00
cedoor
ca944c6eed chore: add script to remove stableVersion field
re #305


Former-commit-id: fbe6b664f1
2024-03-04 13:31:08 +00:00
Cedoor
8bfebd3431 Merge pull request #678 from semaphore-protocol/chore/clean
Update folder name for generated artifacts

Former-commit-id: dfb972d2fa
2024-03-04 12:12:41 +00:00
cedoor
f7403cbdc7 chore: update folder name for generated artifacts
Former-commit-id: 17b072b778
2024-03-04 11:31:20 +00:00
cedoor
e81b4907da chore(docs): remove pnpm and npm from supported package managers
The Semaphore V4 CLI templates don't support npm and pnpm yet. The documentation should reflect this
aspect. It will be updated as soon as those templates support more package managers.

re #676


Former-commit-id: e6198cfdbf
2024-03-04 10:34:22 +00:00
Cedoor
0c540072c6 Merge pull request #674 from semaphore-protocol/ref/cli-templates
Cownload the correct CLI Template files

Former-commit-id: bdf36f9525
2024-03-01 12:30:46 +00:00
Vivian Plasencia
aaf2079274 refactor(cli-template-contracts-hardhat): remove unnecessary files from config
Former-commit-id: 42969e2f00
2024-03-01 13:29:44 +01:00
Vivian Plasencia
42991c5917 refactor(cli-template-monorepo-hardhat): remove unnecessary exclude tags
Former-commit-id: bee7433a52
2024-03-01 13:15:44 +01:00
Vivian Plasencia
4e84441770 fix: download the correct cli template files
Former-commit-id: e82b4638a9
2024-02-29 22:24:53 +01:00
cedoor
41f0b2909f test(circuits): add type assertion for secret value
Former-commit-id: c4dd1e4e10
2024-02-28 20:49:10 +00:00
cedoor
517fd44a23 chore: remove stableVersion field
Former-commit-id: 9c23fc70ef
2024-02-28 20:39:31 +00:00
cedoor
5d2a98d399 chore: v4.0.0-beta.1
Former-commit-id: 8eb19e83fd
2024-02-28 20:37:35 +00:00
cedoor
448f25841f chore: update zk-kit dependency versions
Former-commit-id: 1c72af21f1
2024-02-28 20:37:15 +00:00
cedoor
b81098d144 chore(docs): fix beta-v4 getting-started link
Former-commit-id: 41c01b5105
2024-02-28 19:54:30 +00:00
cedoor
6cfcb571ac chore: remove stableVersion field
Former-commit-id: 0c8e25dbf2
2024-02-28 19:49:04 +00:00
cedoor
ffd85050bd chore: v4.0.0-beta
Former-commit-id: d130f5f913
2024-02-28 19:49:04 +00:00
Cedoor
22d55d943c Merge pull request #670 from semaphore-protocol/docs/update-readme
Update readme file

Former-commit-id: 00a570d675
2024-02-28 19:42:25 +00:00
Vivian Plasencia
683a0bb982 Update README.md
Co-authored-by: Cedoor <me@cedoor.dev>
Former-commit-id: ced57c39cc
2024-02-28 20:41:00 +01:00
Cedoor
89fd8a7681 Merge pull request #672 from semaphore-protocol/docs/fix-broken-links
Fix broken links on V2 documentation

Former-commit-id: 17fe1f78fa
2024-02-28 19:37:40 +00:00
Cedoor
6e2cd546f5 Merge pull request #671 from semaphore-protocol/ci/docs
Build libraries before generating docs

Former-commit-id: 2d81f205a8
2024-02-28 19:36:24 +00:00
cedoor
09655719d5 docs(docs): fix broken links
Former-commit-id: 88c34622d0
2024-02-28 19:35:18 +00:00
Cedoor
fab5c3d6f4 Merge pull request #659 from semaphore-protocol/chore/v4-website
Update Semaphore code and links in the website

Former-commit-id: 8602771aa2
2024-02-28 19:26:30 +00:00
cedoor
dd57c27b63 ci: build libraries before generating docs
Former-commit-id: e8b58e03a5
2024-02-28 19:20:00 +00:00
Vivian Plasencia
b73c8aa7d0 docs: update readme
Former-commit-id: 49c873aff1
2024-02-28 20:18:16 +01:00
Vivian Plasencia
5eb3e168da docs: update readme file
Former-commit-id: c33eef6def
2024-02-28 20:13:06 +01:00
Cedoor
a4fba4ed85 Merge pull request #480 from semaphore-protocol/feat/semaphore-v4
Semaphore V4

Former-commit-id: 0d8c322dff
2024-02-28 19:07:48 +00:00
Cedoor
fa772876ed Merge pull request #668 from semaphore-protocol/chore/new-openzeppelin-version
New OpenZeppelin version

Former-commit-id: e0bda47229
2024-02-28 19:04:49 +00:00
Vivian Plasencia
c6f6b69cbb docs(contracts): remove code comment
Former-commit-id: 4905b81205
2024-02-28 19:58:21 +01:00
cedoor
da7accec9c chore(contracts): update openzeppelin dev dependency version
re #662


Former-commit-id: 05684921e8
2024-02-28 18:54:39 +00:00
Cedoor
fdfabbb3f2 Merge pull request #666 from semaphore-protocol/docs/fix-typedoc-links
Correct TypeDoc links

Former-commit-id: 7691d3724e
2024-02-28 18:51:47 +00:00
Cedoor
146bdacb2b Merge pull request #665 from semaphore-protocol/docs/group
More documentation on group lib code

Former-commit-id: 1a85ed1897
2024-02-28 18:50:58 +00:00
Cedoor
b038f925e5 Merge pull request #669 from semaphore-protocol/docs/contracts
Add code comments to contracts

Former-commit-id: fe1cb7e46a
2024-02-28 18:41:47 +00:00
Vivian Plasencia
b07aee03d4 fix(contracts): remove comment line that was causing an error when compiling contracts
Former-commit-id: 49cd4534b1
2024-02-28 19:30:34 +01:00
Vivian Plasencia
9cbb5a1c18 docs(contracts): update code comments
Former-commit-id: b0dd7e0d67
2024-02-28 19:25:57 +01:00
Vivian Plasencia
e028644973 style(contracts): style code with prettier
Former-commit-id: 3db7dc41f8
2024-02-28 19:18:00 +01:00
Vivian Plasencia
6703ff08c2 docs(contracts): add code comments to contracts
Former-commit-id: ecd046ce7f
2024-02-28 19:17:12 +01:00
Cedoor
7119ee4904 Merge pull request #667 from semaphore-protocol/chore/yarn-v4
Upgrade Yarn to v4

Former-commit-id: 524e3461fc
2024-02-28 16:22:32 +00:00
cedoor
4fabf7ce9c chore: upgrade yarn to v4
re #662


Former-commit-id: 74806d4426
2024-02-28 16:04:50 +00:00
cedoor
e2e4ee5254 style(data): format code with prettier
Former-commit-id: 09aa138fee
2024-02-28 15:37:07 +00:00
cedoor
b8e22aef4e docs: fix typedoc links
Former-commit-id: 794a8093a9
2024-02-28 15:29:21 +00:00
cedoor
75628f3958 docs(group): add more documentation to code
The commit adds more documentation to the group package functions and updates the TypeDoc link.

re #483


Former-commit-id: cf2355ff55
2024-02-28 15:12:42 +00:00
Cedoor
24157b7586 Merge pull request #664 from semaphore-protocol/docs/proof
More documentation on proof lib code

Former-commit-id: 2c144fc9e5
2024-02-28 14:39:38 +00:00
Cedoor
d9fdc4ee12 Merge pull request #661 from semaphore-protocol/docs/circuits
More documentation on Circom code

Former-commit-id: 308ffda7d3
2024-02-28 14:35:04 +00:00
cedoor
89882f3b8b docs(circuits): minor improvements on doc comments
re #483


Former-commit-id: c3389b6b99
2024-02-28 14:34:16 +00:00
Cedoor
30234960ca Update packages/circuits/semaphore.circom
Co-authored-by: Vivian Plasencia <v.pcalana@gmail.com>
Former-commit-id: bb293165d6
2024-02-28 13:29:46 +00:00
Cedoor
275dd501eb Update packages/proof/src/generate-proof.ts
Co-authored-by: Vivian Plasencia <v.pcalana@gmail.com>
Former-commit-id: 7a61311922
2024-02-28 13:26:45 +00:00
cedoor
f36bb460af docs(identity): fix jsdoc link syntax
Former-commit-id: 2e3b78a8fb
2024-02-28 13:22:21 +00:00
Cedoor
1bfa09926b Merge pull request #663 from semaphore-protocol/docs/identity
More documentation on Identity lib code

Former-commit-id: 143c628672
2024-02-28 12:54:31 +00:00
cedoor
c88c151e8d docs(circuits): revert order of hash pre-images on comments
re #483


Former-commit-id: b5acd41543
2024-02-28 12:53:24 +00:00
cedoor
ac71302781 docs(circuits): add link to identity package
re #483


Former-commit-id: cf65ec4aeb
2024-02-28 12:51:43 +00:00
cedoor
44afe68a37 chore: update lockfile
Former-commit-id: b2f6db95df
2024-02-28 12:48:56 +00:00
cedoor
51efe510a4 docs(identity): add links to zk-kit types
re #483


Former-commit-id: 0034f5f1a8
2024-02-28 12:45:10 +00:00
cedoor
165ee6f469 docs(circuits): add more documentation to secret signal
re #483


Former-commit-id: 23476c30dd
2024-02-28 12:36:36 +00:00
cedoor
d7d31423bb chore: update lockfile
Former-commit-id: 2f95c20d72
2024-02-28 12:24:08 +00:00
cedoor
a81edc09b0 docs(identity): add more documentation to code
The commit adds more documentation to the proof package functions and updates the TypeDoc link.

re #483


Former-commit-id: f3ee07c034
2024-02-28 12:22:32 +00:00
Cedoor
c98326e078 Merge pull request #652 from semaphore-protocol/ref/cli-template-monorepo-ethers
Update `cli-template-monorepo-ethers`

Former-commit-id: f50e78bd65
2024-02-28 11:47:52 +00:00
cedoor
8617657bff docs(identity): add more documentation to code
The commit adds more documentation to the Identity class and update the TypeDoc link. It also
removes the class method to verify signatures as the static method can be used instead.

re #483


Former-commit-id: b4c2887cf1
2024-02-28 11:16:49 +00:00
cedoor
57f135e305 chore: add npm script to test specific libs
Former-commit-id: b914dceb86
2024-02-28 11:14:28 +00:00
Cedoor
8d4b3a6c9e Merge pull request #653 from semaphore-protocol/ref/cli-template-monorepo-subgraph
Update `cli-template-monorepo-subgraph`

Former-commit-id: 3533876a1c
2024-02-28 10:54:31 +00:00
Vivian Plasencia
7616cd64e5 Merge branch 'feat/semaphore-v4' into ref/cli-template-monorepo-subgraph
Former-commit-id: 251bccab45
2024-02-28 11:35:24 +01:00
Vivian Plasencia
dbfc34df39 Merge branch 'feat/semaphore-v4' into ref/cli-template-monorepo-ethers
Former-commit-id: f61503205a
2024-02-28 11:32:15 +01:00
Vivian Plasencia
f348495d9c refactor(cli-template-contracts-hardhat): fix semaphore version in tests
Former-commit-id: 8437547f1a
2024-02-28 11:17:05 +01:00
Vivian Plasencia
27fc8e6b75 refactor(cli-template-monorepo-subgraph): update tsconfig contracts
Former-commit-id: 129d5059fa
2024-02-28 11:10:19 +01:00
Vivian Plasencia
b59ba20463 refactor(cli-template-contracts-hardhat): update tsconfig in contracts
Former-commit-id: e02a81ea11
2024-02-28 11:08:19 +01:00
Vivian Plasencia
bbc2b15058 refactor(cli-template-monorepo-ethers): fix semaphore version in tests
Former-commit-id: b3f20b6b7f
2024-02-28 11:01:21 +01:00
Vivian Plasencia
d45fd99cf2 refactor(cli-template-monorepo-subgraph): fix semaphore version
Former-commit-id: 446139215d
2024-02-28 10:59:50 +01:00
Vivian Plasencia
cf5937998f refactor(cli-template-monorepo-ethers): fix semaphore dependencies
Former-commit-id: 6640210700
2024-02-28 10:56:33 +01:00
Cedoor
e848bb6136 Merge pull request #651 from semaphore-protocol/ref/cli-template-contracts-hardhat
Update `cli-template-contracts-hardhat`

Former-commit-id: 0eb16c2aca
2024-02-28 09:47:24 +00:00
Vivian Plasencia
9282405a0b refactor(cli-template-contracts-hardhat): update tsconfig file
Former-commit-id: 5d47e99b73
2024-02-28 10:44:52 +01:00
Vivian Plasencia
067ddfd1be refactor: update yarn lock file
Former-commit-id: a8ffd7674b
2024-02-28 09:05:14 +01:00
Vivian Plasencia
444b4fa791 Merge branch 'ref/cli-template-contracts-hardhat' of https://github.com/semaphore-protocol/semaphore into ref/cli-template-contracts-hardhat
Former-commit-id: 76c80bef7d
2024-02-28 09:04:02 +01:00
vplasencia
a9b535f96e refactor(cli-template-contracts-hardhat): update configs
Former-commit-id: 46c2e52f22
2024-02-28 08:59:23 +01:00
vplasencia
f1a5262e34 style(cli-template-contracts-hardhat): add spaces to the end of files
Former-commit-id: 9b982f787f
2024-02-28 08:59:23 +01:00
vplasencia
1e6473bfc9 refactor(cli-template-contracts-hardhat): update cli contracts hardhat template
Former-commit-id: f6f8c9bc6e
2024-02-28 08:58:28 +01:00
vplasencia
4c9bf61170 refactor(cli-templates-monorepo-subgraph): update gitignore files
Former-commit-id: 29b2d762fc
2024-02-28 08:41:24 +01:00
vplasencia
245ede6a89 refactor(cli-template-monorepo-ethers): update gitignore files
Former-commit-id: f2653c9dbd
2024-02-28 08:38:48 +01:00
vplasencia
6315011a8e refactor(cli-template-monorepo-ethers): update eslintignore
Former-commit-id: d55f37f132
2024-02-27 23:27:19 +01:00
vplasencia
4ca4172a1f refactor(cli-template-monorepo-subgraph): update variable name
Former-commit-id: 8527317331
2024-02-27 23:23:06 +01:00
vplasencia
3a70a732c4 refactor(cli-template-monorepo-subgraph): remove unused env example file
Former-commit-id: 0bd8cf8e97
2024-02-27 23:20:12 +01:00
vplasencia
7a5afad2a5 refactor(cli-template-monorepo-subgraph): update configs
Former-commit-id: 4307411436
2024-02-27 23:16:33 +01:00
vplasencia
58affaadea refactor(cli-templates-monorepo-ethers): update configs
Former-commit-id: 70e465c7fe
2024-02-27 23:01:34 +01:00
vplasencia
64c5a35570 refactor(cli-template-contracts-hardhat): update configs
Former-commit-id: fe43cb4cd1
2024-02-27 22:20:26 +01:00
cedoor
491d949c52 docs(circuits): add documentation to circuits
This commit add more documentation to the Semaphore circuits, with the aim of providing an overview
of the code used and to refer to other resources for futher information.

re #483


Former-commit-id: de12d471c0
2024-02-27 20:01:54 +00:00
Cedoor
9af6153026 Merge pull request #655 from semaphore-protocol/docs/v4-beta
New V4-beta documentation

Former-commit-id: 90163748cf
2024-02-27 16:14:01 +00:00
Cedoor
0581607649 Merge pull request #660 from zkfriendly/feat/semaphore-v4
Adds `getGroupMembers` & `getGroupValidatedProofs` functions to `SemaphoreSubgraph`

Former-commit-id: 5aae5659f1
2024-02-27 16:13:03 +00:00
zkFriendly
1922f64f7c refactor(data): remove unnecessary ?? []
Former-commit-id: d84c9ceca6
2024-02-27 17:01:45 +01:00
cedoor
a00ea5434c chore(website): update identity description
re #658


Former-commit-id: f7d0bcf39e
2024-02-26 22:41:11 +00:00
Cedoor
6e66085293 Update apps/website/src/app/learn/page.tsx
Co-authored-by: Vivian Plasencia <v.pcalana@gmail.com>
Former-commit-id: 95a7a84f74
2024-02-26 22:26:43 +00:00
Cedoor
85fd006209 Update apps/website/src/app/learn/page.tsx
Co-authored-by: Vivian Plasencia <v.pcalana@gmail.com>
Former-commit-id: 861a64368e
2024-02-26 22:26:27 +00:00
zkFriendly
8f3d2e5455 feat(data): add getGroupValidatedProofs to SemaphoreSubgraph
Former-commit-id: 9f6c62f620
2024-02-26 17:40:29 +01:00
zkFriendly
5d4c592c3b feat(data): add getGroupMembers to SemaphoreSubgraph
Former-commit-id: 8f73965b95
2024-02-26 17:32:00 +01:00
cedoor
f2be01ecdd chore(website): update semaphore code and links
re #658


Former-commit-id: 2466e9b5c0
2024-02-26 12:29:34 +00:00
Cedoor
a0f6e0db13 Merge pull request #657 from semaphore-protocol/ref/pack-unpack-proof
Integrate `packGroth16Proof` and `unpackGroth16Proof` into Semaphore v4

Former-commit-id: 7af787a7de
2024-02-26 11:52:30 +00:00
vplasencia
95aad1a154 refactor(proof): integrate pack unpack groth16 proof
Former-commit-id: d28448624a
2024-02-26 12:38:01 +01:00
Cedoor
ff47c8ba0b Merge pull request #650 from semaphore-protocol/ref/cli
Update CLI code and dependencies

Former-commit-id: a2f3a6bbfe
2024-02-26 10:51:33 +00:00
cedoor
5390830e41 docs(docs): update boilerplate links
Former-commit-id: 38f4b91192
2024-02-26 10:30:21 +00:00
cedoor
f4bfe0ca2f chore(docs): set V4-beta as default version
Former-commit-id: b6d68817c2
2024-02-26 10:25:22 +00:00
cedoor
3c38e393f6 docs(docs): update V4-beta docs links
Former-commit-id: 324219f72e
2024-02-26 10:24:48 +00:00
cedoor
ba6df1d6fd docs(docs): update V3 github links
Former-commit-id: 79248dd06c
2024-02-26 10:24:24 +00:00
vplasencia
cb607be9b5 style(cli-template-monorepo-subgraph): add space to the end of files
Former-commit-id: a9994c24e3
2024-02-26 01:55:18 +01:00
vplasencia
2074dbf15f style(cli-template-monorepo-subgraph): format code with prettier
Former-commit-id: db438f947c
2024-02-26 01:49:44 +01:00
vplasencia
d4b41fcef6 refactor(cli-template-monorepo-subgraph): update the cli monorepo subgraph template
Former-commit-id: e39e57d33f
2024-02-26 01:48:37 +01:00
vplasencia
90447781b9 chore: update yarn lock file
Former-commit-id: 04fc12e10f
2024-02-26 00:49:51 +01:00
vplasencia
f292155979 style(cli-template-monorepo-ethers): add a space to the end of files
Former-commit-id: fa1ebffcb1
2024-02-26 00:44:44 +01:00
vplasencia
10f922cbf6 style(cli-template-monorepo-ethers): format code with prettier
Former-commit-id: 32acbeabb4
2024-02-26 00:35:28 +01:00
vplasencia
5450809424 refactor(cli-template-monorepo-ethers): update cli monorepo ethers template
Former-commit-id: f62b68285f
2024-02-26 00:33:52 +01:00
vplasencia
18bc5d9bb9 style(cli-template-contracts-hardhat): add spaces to the end of files
Former-commit-id: 7860fcfa50
2024-02-25 23:48:50 +01:00
vplasencia
0171f03008 refactor(cli-template-contracts-hardhat): update cli contracts hardhat template
Former-commit-id: 05c57f51b3
2024-02-25 23:36:58 +01:00
vplasencia
58cf5d117c refactor(cli): update cli code and dependencies
Former-commit-id: 19bb248857
2024-02-25 16:04:06 +01:00
cedoor
3e8e4a0b07 docs(docs): update v4 alpha docs to v4 beta
Former-commit-id: f31bfd9148
2024-02-23 13:18:10 +00:00
Cedoor
a3ac2f3382 Merge pull request #643 from semaphore-protocol/feat/utils-pkg
New `utils` package with functions two check types

Former-commit-id: 6f1b279e1e
2024-02-20 17:08:26 +00:00
cedoor
2592d477dc chore: update lockfile
Former-commit-id: 7bc25c2052
2024-02-19 16:40:27 +00:00
cedoor
f5faea9673 build(utils): set correct file extensions
Former-commit-id: 4e03ae7949
2024-02-19 16:38:48 +00:00
cedoor
778338b176 refactor(proof): add functions to check types
Former-commit-id: 3ef0553694
2024-02-19 13:13:01 +00:00
cedoor
1b9b45296c feat(utils): add functions to check bigint types
Former-commit-id: eb2fba2be0
2024-02-19 12:55:40 +00:00
cedoor
42acccce4f feat(utils): add functions to check object types
Former-commit-id: 85bed72535
2024-02-19 12:45:05 +00:00
cedoor
75530e6ee4 feat(utils): create new utils package
Former-commit-id: 785f955b2a
2024-02-19 12:38:08 +00:00
cedoor
9b4b278972 chore: remove stableVersion auto-generated field
Former-commit-id: 0dbf5f64da
2024-02-15 20:05:00 +00:00
Cedoor
4634be1ba5 Merge pull request #631 from semaphore-protocol/chore/docs-font
Set local "DM Sans" font

Former-commit-id: 2bab9acfd8
2024-02-15 10:06:15 +00:00
cedoor
3c1b83b82d style: format code with prettier
Former-commit-id: 1f5c078097
2024-02-14 18:30:28 +00:00
cedoor
6572e6c121 chore(docs): set local font
Former-commit-id: 8cc6597a06
2024-02-14 18:24:21 +00:00
Cedoor
9e39cc1013 chore: update pull_request_template.md
Former-commit-id: 6103f3ced2
2024-02-13 09:11:59 +00:00
Cedoor
9a098ddca7 Merge pull request #628 from semaphore-protocol/fix/docs-font
Set right `font-family` property

Former-commit-id: 48bdbd4850
2024-02-12 20:22:58 +00:00
cedoor
5df6476e4d fix(docs): set right font-family prop
Former-commit-id: 1483bef99f
2024-02-12 17:32:01 +00:00
Cedoor
6bd973fdea chore: update issue templates
Former-commit-id: f53aa88dd9
2024-02-12 16:54:13 +00:00
345 changed files with 36218 additions and 3058 deletions

21
.commitlintrc.js Normal file
View File

@@ -0,0 +1,21 @@
const fs = require("node:fs")
const path = require("node:path")
const packages = fs.readdirSync(path.resolve(__dirname, "packages"))
const apps = fs.readdirSync(path.resolve(__dirname, "apps"))
module.exports = {
extends: ["@commitlint/config-conventional"],
prompt: {
scopes: [...packages, ...apps],
markBreakingChangeMode: true,
allowCustomIssuePrefix: false,
allowEmptyIssuePrefix: false,
issuePrefixes: [
{
value: "re",
name: "re: ISSUES related"
}
]
}
}

View File

@@ -1,3 +0,0 @@
{
"extends": ["@commitlint/config-conventional"]
}

View File

@@ -2,9 +2,5 @@ DEFAULT_NETWORK=hardhat
TREE_DEPTH=10
REPORT_GAS=false
BACKEND_PRIVATE_KEY=
INFURA_API_KEY=
COINMARKETCAP_API_KEY=
ETHERSCAN_API_KEY=
DEFENDER_KEY=
DEFENDER_SECRET=
CREATE2_SALT=1234

View File

@@ -0,0 +1,17 @@
---
name: "♻️ Refactoring"
about: 'about: Suggest any improvements for this project'
title: ''
labels: 'refactoring :recycle:'
assignees: ''
---
**Describe the improvement you're thinking about**
A clear and concise description of what you think could improve the code.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions you've considered.
**Additional context**
Add any other context or screenshots about the improvement request here.

View File

@@ -34,6 +34,7 @@
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [ ] I have run `yarn prettier` and `yarn lint` without getting any errors
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged and published in downstream modules

View File

@@ -21,6 +21,9 @@ jobs:
- name: Install dependencies
run: yarn
- name: Build libraries
run: yarn build:libraries
- name: Generate doc website
run: yarn docs

View File

@@ -24,12 +24,12 @@ jobs:
- name: Install dependencies
run: yarn
- name: Compile contracts
run: yarn compile:contracts
- name: Build libraries
run: yarn build:libraries
- name: Compile contracts
run: yarn compile:contracts
- name: Build subgraph
run: yarn build:subgraph
@@ -54,6 +54,9 @@ jobs:
- name: Install dependencies
run: yarn
- name: Build libraries
run: yarn build:libraries
- name: Build subgraph
run: yarn build:subgraph

View File

@@ -22,12 +22,12 @@ jobs:
- name: Install dependencies
run: yarn
- name: Compile contracts
run: yarn compile:contracts
- name: Build libraries
run: yarn build:libraries
- name: Compile contracts
run: yarn compile:contracts
- name: Build subgraph
run: yarn build:subgraph

View File

@@ -22,10 +22,22 @@ jobs:
with:
node-version: 20
cache: yarn
registry-url: "https://registry.npmjs.org"
- name: Authentication
run: |
echo npmAuthToken: "$NODE_AUTH_TOKEN" >> ./.yarnrc.yml
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Install dependencies
run: yarn
- name: Publish packages
run: yarn version:publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- run: yarn version:release
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

View File

@@ -0,0 +1,6 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
if [ "$NO_HOOK" != "1" ]; then
exec < /dev/tty && yarn cz --hook || true
fi

View File

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

File diff suppressed because one or more lines are too long

View File

@@ -1 +0,0 @@
b3cadff6efb37a12712d12c2553ec703dbcaa4dd

893
.yarn/releases/yarn-4.1.0.cjs vendored Executable file

File diff suppressed because one or more lines are too long

View File

@@ -1,11 +1,9 @@
checksumBehavior: update
compressionLevel: mixed
enableGlobalCache: false
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
yarnPath: .yarn/releases/yarn-4.1.0.cjs

View File

@@ -46,7 +46,7 @@ We always use ESLint and Prettier. To check that your code follows the rules, si
For commits it is recommended to use [Conventional Commits](https://www.conventionalcommits.org).
Don't worry if it looks complicated, in our repositories, after `git add`, you can usually run the npm script `yarn commit` to make many of these steps interactive.
Don't worry if it looks complicated, in our repositories, `git commit` opens an interactive app to create your conventional commit.
Each commit message consists of a **header**, a **body** and a **footer**. The **header** has a special format that includes a **type**, a **scope** and a **subject**:

View File

@@ -34,7 +34,9 @@
<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>
<a href="http://commitizen.github.io/cz-cli/">
<img alt="Commitizen friendly" src="https://img.shields.io/badge/commitizen-friendly-586D76?style=flat-square">
</a>
</p>
<div align="center">
@@ -57,10 +59,10 @@
</h4>
</div>
| 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. |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Semaphore is a generic privacy layer. Leveraging zero-knowledge technology, users can prove their membership in groups and send messages (extending from votes to endorsements) off-chain or across EVM-compatible blockchains, all without revealing their personal identity. |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
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.pse.dev](https://semaphore.pse.dev).
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/offchain verification easier. To learn more about Semaphore visit [semaphore.pse.dev](https://semaphore.pse.dev).
## 📦 Packages
@@ -233,6 +235,28 @@ The core of the Semaphore protocol is in the [circuit logic](/packages/circuits/
</a>
</td>
</tr>
<tr>
<td>
<a href="/packages/utils">
@semaphore-protocol/utils
</a>
<a href="https://js.semaphore.pse.dev/modules/_semaphore_protocol_utils">
(docs)
</a>
</td>
<td>
<!-- NPM version -->
<a href="https://npmjs.org/package/@semaphore-protocol/utils">
<img src="https://img.shields.io/npm/v/@semaphore-protocol/utils.svg?style=flat-square" alt="NPM version" />
</a>
</td>
<td>
<!-- Downloads -->
<a href="https://npmjs.org/package/@semaphore-protocol/utils">
<img src="https://img.shields.io/npm/dm/@semaphore-protocol/utils.svg?style=flat-square" alt="Downloads" />
</a>
</td>
</tr>
<tr>
<td>
<a href="/packages/heyauthn">
@@ -312,14 +336,6 @@ yarn commit
It will also automatically check that the modified files comply with ESLint and Prettier rules.
### Snark artifacts
Download the Semaphore snark artifacts needed to generate and verify proofs:
```bash
yarn download:snark-artifacts
```
### Testing
Run [Jest](https://jestjs.io/) to test the JS libraries:
@@ -342,10 +358,10 @@ yarn test
### Build libraries & compile contracts
Run [Rollup](https://www.rollupjs.org) to build all the packages:
Run [Rollup](https://www.rollupjs.org) and [TheGraph](https://www.npmjs.com/package/@graphprotocol/graph-cli) to build all the packages and the subgraph:
```bash
yarn build:libraries
yarn build
```
Compile the smart contracts with [Hardhat](https://hardhat.org/):
@@ -363,3 +379,15 @@ yarn docs
```
The output will be placed on the `docs` folder.
### Releases
Bump a new version with:
```bash
yarn version:bump <version>
# e.g. yarn version:bump 2.0.0
```
It will create a commit and a git tag that will need to pushed on the main branch. A workflow will be triggered and will
publish the Semaphore packages on [npm](https://www.npmjs.com/) and release a new version on Github with its changelogs automatically.

View File

@@ -43,7 +43,8 @@ const config: Config = {
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.async=true; g.src='//cdn.matomo.cloud/psedev.matomo.cloud/matomo.js'; s.parentNode.insertBefore(g,s);
})();
`
`,
attributes: {}
}
],
presets: [
@@ -54,8 +55,7 @@ const config: Config = {
routeBasePath: "/",
sidebarPath: require.resolve("./sidebars.js"),
editUrl: "https://github.com/semaphore-protocol/semaphore/edit/main/apps/docs",
includeCurrentVersion: false,
lastVersion: "V3"
includeCurrentVersion: false
},
theme: {
customCss: [require.resolve("./src/css/custom.scss")]
@@ -65,12 +65,14 @@ const config: Config = {
],
themeConfig: {
announcementBar: {
id: "semaphore-v4-alpha",
id: "semaphore-v4-beta",
content:
'<b>Semaphore V4-alpha is out 🎉 <a href="/V4-alpha/getting-started">Try it out</a> and let us know for any feedback on <a href="https://semaphore.pse.dev/discord" target="_blank">Discord</a> or <a href="https://github.com/orgs/semaphore-protocol/discussions" target="_blank">Github</a>!</b>',
'<b>Semaphore V4-beta is out 🎉 <a href="/getting-started">Try it out</a> and let us know for any feedback on <a href="https://semaphore.pse.dev/discord" target="_blank">Discord</a> or <a href="https://github.com/orgs/semaphore-protocol/discussions" target="_blank">Github</a>!</b>',
backgroundColor: "#dde6fc",
textColor: "#000000"
},
// Social media card
image: "img/social-media.png",
navbar: {
logo: {
alt: "Semaphore Logo",
@@ -84,7 +86,7 @@ const config: Config = {
},
{
label: "Whitepaper",
to: "https://docs.semaphore.pse.dev/whitepaper-v1.pdf",
to: "https://semaphore.pse.dev/whitepaper-v1.pdf",
position: "left",
className: "whitepaper-v1"
},

View File

@@ -40,7 +40,7 @@ For more information, see [Merkle tree in Wikipedia](https://en.wikipedia.org/wi
A value used to prevent double entry or double signalling.
See [Circuit nullifier hash](/technical-reference/circuits/#hash-anulador-nullifier-hash).
See [Circuit nullifier hash](/V2/technical-reference/circuits/#nullifier-hash).
## Relay
@@ -48,7 +48,7 @@ A third-party who receives a fee for including relayed transactions in the block
To preserve the anonymity of the user broadcasting a signal with Semaphore, an application may use a relayer to post the signal transaction to Ethereum on behalf of the user.
Applications may provide rewards for relayers and implement front-running prevention mechanisms, such as requiring the signals to include the relayers address, binding the
signal to that specific address (https://docs.semaphore.pse.dev/whitepaper-v1.pdf, p.6).
signal to that specific address (https://semaphore.pse.dev/whitepaper-v1.pdf, p.6).
## Trusted setup files

View File

@@ -20,14 +20,14 @@ title: Groups
Use Semaphore in your application or smart contract to create off-chain and on-chain groups.
A [Semaphore group](/glossary/#grupo-semaphore) contains [identity commitments](/glossary/#compromiso-de-identidad-identity-commitment) of group members.
A [Semaphore group](/V2/glossary/#semaphore-group) contains [identity commitments](/V2/glossary/#identity-commitment) of group members.
Example uses of groups include the following:
- Poll question that attendees join to rate an event.
- Ballot that members join to vote on a proposal.
- Whistleblowers who are verified employees of an organization.
A Semaphore group is an [incremental Merkle tree](/glossary/#árbol-de-merkle-merkle-tree), and group members (i.e., identity commitments) are tree leaves.
A Semaphore group is an [incremental Merkle tree](/V2/glossary/#merkle-tree), and group members (i.e., identity commitments) are tree leaves.
Semaphore groups set the following two parameters:
- **Tree depth**: the maximum number of members a group can contain (`max size = 2 ^ tree depth`).

View File

@@ -5,7 +5,7 @@ title: Identities
# Semaphore identities
In order to join a [Semaphore group](/glossary#semaphore-group), a user must first create a [Semaphore identity](/glossary#semaphore-identity).
In order to join a [Semaphore group](/V2/glossary#semaphore-group), a user must first create a [Semaphore identity](/V2/glossary#semaphore-identity).
A Semaphore identity contains two values generated with the identity:
- Identity trapdoor

View File

@@ -7,7 +7,7 @@ title: Proofs
Learn how to use Semaphore to generate and verify zero-knowledge proofs.
Once a user joins their [Semaphore identity](/glossary#semaphore-identity) to a [Semaphore group](/glossary#semaphore-group), the user can signal anonymously with a zero-knowledge proof that proves the following:
Once a user joins their [Semaphore identity](/V2/glossary#semaphore-identity) to a [Semaphore group](/V2/glossary#semaphore-group), the user can signal anonymously with a zero-knowledge proof that proves the following:
- The user is a member of the group.
- The same user created the signal and the proof.
@@ -27,11 +27,11 @@ To generate a proof, pass the following properties to the `generateProof` functi
- `group`: The group to which the user belongs.
- `externalNullifier`: The value that prevents double-signaling.
- `signal`: The signal the user wants to send anonymously.
- `snarkArtifacts`: The `zkey` and `wasm` [trusted setup files](/glossary/#trusted-setup-files).
- `snarkArtifacts`: The `zkey` and `wasm` [trusted setup files](/V2/glossary/#trusted-setup-files).
In the voting system use case, once all the voters have joined their [identities](/guides/identities#create-an-identity) to the ballot [group](/guides/groups),
In the voting system use case, once all the voters have joined their [identities](/V2/guides/identities#create-identities) to the ballot [group](/V2/guides/groups),
a voter can generate a proof to vote for a proposal.
In the call to `generateProof`, the voting system passes the unique ballot ID (the [Merkle tree](/glossary/#merkle-tree/) root of the group) as the
In the call to `generateProof`, the voting system passes the unique ballot ID (the [Merkle tree](/V2/glossary#merkle-tree) root of the group) as the
`externalNullifier` to prevent the voter signaling more than once for the ballot.
The following code sample shows how to use `generateProof` to generate the voting proof:
@@ -53,7 +53,7 @@ Use the [`@semaphore-protocol/proof`](https://github.com/semaphore-protocol/sema
To verify a proof, pass the following to the `verifyProof` function:
- _`proof`_: the Semaphore proof.
- _`verificationKey`_: the JavaScript object in the `semaphore.json` [trusted setup file](/glossary/#trusted-setup-files).
- _`verificationKey`_: the JavaScript object in the `semaphore.json` [trusted setup file](/V2/glossary/#trusted-setup-files).
The following code sample shows how to parse the verification key object from `semaphore.json`
and verify the previously generated proof:

View File

@@ -213,7 +213,7 @@ and [Chai assertions](https://www.chaijs.com/).
wget http://www.trusted-setup-pse.org/semaphore/20/semaphore.wasm
```
Learn more about [trusted setup files](/glossary/#trusted-setup-files).
Learn more about [trusted setup files](/V2/glossary/#trusted-setup-files).
3. Rename the `Lock.js` test file to `Greeter.js` and replace the content with the following:

View File

@@ -6,9 +6,9 @@ sidebar_position: 2
The [Semaphore circuit](https://github.com/semaphore-protocol/semaphore/tree/v2.6.1/packages/circuits) is the heart of the protocol and consists of three parts:
- [**Proof of membership**](/technical-reference/circuits#proof-of-membership)
- [**Nullifier hash**](/technical-reference/circuits#nullifier-hash)
- [**Signal**](/technical-reference/circuits#signal)
- [**Proof of membership**](/V2/technical-reference/circuits#proof-of-membership)
- [**Nullifier hash**](/V2/technical-reference/circuits#nullifier-hash)
- [**Signal**](/V2/technical-reference/circuits#signal)
![Semaphore circuit](https://github.com/semaphore-protocol/semaphore/raw/v2.6.1/packages/circuits/scheme.png)

View File

@@ -6,9 +6,9 @@ sidebar_position: 3
Semaphore includes three types of contracts:
- [**Base contracts**](/technical-reference/contracts#base-contracts)
- [**Extension contracts**](/technical-reference/contracts#extension-contracts)
- [**Verifiers**](/technical-reference/contracts#verifiers)
- [**Base contracts**](/V2/technical-reference/contracts#base-contracts)
- [**Extension contracts**](/V2/technical-reference/contracts#extension-contracts)
- [**Verifiers**](/V2/technical-reference/contracts#verifiers)
:::info
To use Semaphore contracts and interfaces in your project,
@@ -24,7 +24,7 @@ Semaphore provides the following base contracts:
These contracts are closely related to the protocol.
You can inherit them in your contract or you can use [`Semaphore.sol`](https://github.com/semaphore-protocol/semaphore/tree/v2.6.1/packages/contracts/Semaphore.sol), which inherits them for you.
See our [deployed contracts](/deployed-contracts#semaphore) to find the addresses for your network.
See our [deployed contracts](/V2/deployed-contracts#semaphore) to find the addresses for your network.
:::info
While some dApps may use on-chain groups, others may prefer to use off-chain groups, saving only their tree roots in the contract.
@@ -41,7 +41,7 @@ More extensions will be added in the future.
## Verifiers
To verify Semaphore proofs, the [`SemaphoreCore.sol`](https://github.com/semaphore-protocol/semaphore/tree/v2.6.1/packages/contracts/base/SemaphoreCore.sol) contract requires the address of a deployed verifier contract.
You can choose to manually deploy the [verifier](https://github.com/semaphore-protocol/semaphore/tree/v2.6.1/packages/contracts/verifiers) you prefer or you can use one of our [deployed verifiers](/deployed-contracts#verifiers).
You can choose to manually deploy the [verifier](https://github.com/semaphore-protocol/semaphore/tree/v2.6.1/packages/contracts/verifiers) you prefer or you can use one of our [deployed verifiers](/V2/deployed-contracts#verifiers).
Each verifier name indicates the tree depth that it can verify.
For example, given a Semaphore proof generated with a tree depth `20`:

View File

@@ -36,7 +36,7 @@ Community members connect their wallets to the dApp to take the following action
### Relay
To preserve anonymity and avoid disclosing the member's wallet address, the dApp may use a [relay](/glossary/#relay) to broadcast the vote.
To preserve anonymity and avoid disclosing the member's wallet address, the dApp may use a [relay](/V2/glossary/#relay) to broadcast the vote.
The relay calls the **contract** function that then posts the member's vote transaction to Ethereum.
## Private voting
@@ -52,7 +52,7 @@ The voting scenario has the following steps:
### Create a poll
A community coordinator or dApp administrator uses the deployed smart contract to create an on-chain (Ethereum) poll, a [Semaphore group](/guides/groups/) that members can join and cast votes to.
A community coordinator or dApp administrator uses the deployed smart contract to create an on-chain (Ethereum) poll, a [Semaphore group](/V2/guides/groups/) that members can join and cast votes to.
In the following sample code, the voting contract declares a `createPoll` function that uses the Semaphore base `_createGroup` function:
@@ -78,11 +78,11 @@ function createPoll(
}
```
A poll is a Semaphore [group](/guides/groups/) that stores the following:
A poll is a Semaphore [group](/V2/guides/groups/) that stores the following:
- A topic to vote on.
- The public ID of the poll creator.
- [Semaphore IDs](/guides/identities/) of members who joined the poll.
- [Semaphore IDs](/V2/guides/identities/) of members who joined the poll.
To create the poll, the administrator calls the smart contract function--for example:
@@ -128,10 +128,10 @@ With a member registered for a poll, learn how the dApp [records votes](#record-
Once members have joined a poll, the coordinator starts the poll to allow voting.
When a member votes (for example, by selecting a radio button), then the dApp takes the following actions:
1. Uses the `@semaphore-protocol/proof` library to create a proof of the vote, the poll identifier, the Semaphore ID, and a [nullifier](/glossary/#nullifier) that prevents double-voting.
1. Uses the `@semaphore-protocol/proof` library to create a proof of the vote, the poll identifier, the Semaphore ID, and a [nullifier](/V2/glossary/#nullifier) that prevents double-voting.
2. Sends the vote proof to the [relay](#relay).
### Related
- To get started developing with Semaphore, see the [Quick setup](/quick-setup/) guide.
- To get started developing with Semaphore, see the [Quick setup](/V2/quick-setup/) guide.
- For an example app that you can use to start your own project, see [Semaphore boilerplate](https://github.com/semaphore-protocol/boilerplate).

View File

@@ -15,9 +15,9 @@ Use cases include private voting, whistleblowing, anonymous DAOs and mixers.
With Semaphore, you can allow your users to do the following:
1. [Create a Semaphore identity](/guides/identities/).
2. [Add their Semaphore identity to a group (i.e. _Merkle tree_)](/guides/groups/).
3. [Send a verifiable, anonymous signal (e.g a vote or endorsement)](/guides/proofs/).
1. [Create a Semaphore identity](/V2/guides/identities/).
2. [Add their Semaphore identity to a group (i.e. _Merkle tree_)](/V2/guides/groups/).
3. [Send a verifiable, anonymous signal (e.g a vote or endorsement)](/V2/guides/proofs/).
When a user broadcasts a signal (for example: a vote), Semaphore zero-knowledge
proofs can ensure that the user has joined the group and hasn't already cast a signal with their nullifier.

View File

@@ -9,18 +9,18 @@ sidebar_position: 7
La identidad de un usuario en el protocolo Semaphore.
Una identidad contiene los tres valores que se mencionan a continuación:
- [Compromiso de identidad](#identity-commitment) (identity commitment): el valor público.
- [Compromiso de identidad](#compromiso-de-identidad-identity-commitment) (identity commitment): el valor público.
- Identidad trampilla (identity trapdoor) y anulador de identidad (identity nullifier): valores secretos que únicamente son del conocimiento del usuario.
## Compromiso de identidad (Identity commitment)
El valor público de la [identidad Semaphore](#semaphore-identity) utilizado en los [grupos Semaphore](#semaphore-group).
El valor público de la [identidad Semaphore](#identidad-semaphore) utilizado en los [grupos Semaphore](#grupo-semaphore).
Semaphore utiliza la función hash [Poseidon](https://www.poseidon-hash.info/) para crear un compromiso de identidad a partir de los valores secretos de la identidad Semaphore.
## Grupo Semaphore
Un grupo es un [árbol de Merkle](#merkle-tree) binario e incremental en el que cada hoja contiene un [compromiso de identidad](#identity-commitment) para un usuario.
Un grupo es un [árbol de Merkle](#árbol-de-merkle-merkle-tree) binario e incremental en el que cada hoja contiene un [compromiso de identidad](#compromiso-de-identidad-identity-commitment) para un usuario.
El compromiso de identidad comprueba que un usuario es un miembro del grupo sin revelar la identidad Semaphore del usuario.
Semaphore utiliza la función hash **Poseidon** para crear árboles de Merkle.
@@ -39,14 +39,14 @@ Para más información, vea [árbol de Merkle en Wikipedia](https://es.wikipedia
Un valor utilizado para prevenir registros dobles o dos señales emitidas por el mismo usuario.
Ver [hash de circuito nullifier](/technical-reference/circuits/#nullifier-hash).
Ver [hash de circuito nullifier](/V3/technical-reference/circuits#hash-anulador-nullifier-hash).
## Retransmisor (Relayer)
Un tercero que recibe una comisión por incluir transacciones retransmitidas en la blockchain (McMenamin, Daza, and Fitz. https://eprint.iacr.org/2022/155.pdf, p.3).
Para preservar la anonimidad del usuario emitiendo una señal con Semaphore, una aplicación puede utilizar un retransmisor para publicar la transacción de la señal en Ethereum en nombre del usuario.
Las aplicaciones pueden ofrecer recompensas a los retransmisores e implementar mecanismos para prevenir ventajas maliciosas, como requerir que las señales incluyan la dirección del retransmisor, vinculando así la señal a esa dirección en específico (https://docs.semaphore.pse.dev/whitepaper-v1.pdf, p.6).
Las aplicaciones pueden ofrecer recompensas a los retransmisores e implementar mecanismos para prevenir ventajas maliciosas, como requerir que las señales incluyan la dirección del retransmisor, vinculando así la señal a esa dirección en específico (https://semaphore.pse.dev/whitepaper-v1.pdf, p.6).
## Archivos confiables de configuración (Trusted setup files)

View File

@@ -8,14 +8,14 @@ import TabItem from "@theme/TabItem"
# Gupos Semaphore
Un [grupo Semaphore](/glossary/#semaphore-group) contiene los [identity commitments](/glossary/#identity-commitment) (compromisos de identidad) de miembros del grupo.
Un [grupo Semaphore](/V3/glossary/#grupo-semaphore) contiene los [identity commitments](/V3/glossary/#compromiso-de-identidad-identity-commitment) (compromisos de identidad) de miembros del grupo.
Estos son algunos ejemplos de uso de los grupos:
- Encuesta con preguntas a la que se unen las personas que acudieron a un evento para calificarlo,
- votación a la que se unen los miembros para votar por una propuesta,
- Denunciantes que están verificados como empleados de una organización.
Un grupo Semaphore es un [árbol de Merkle incremental](/glossary/#incremental-merkle-tree), y los miembros del grupo (por ejemplo, [identity commitments](/glossary/#identity-commitments)) son las hojas del árbol.
Un grupo Semaphore es un [árbol de Merkle incremental](/V3/glossary/#árbol-de-merkle-merkle-tree), y los miembros del grupo (por ejemplo, [identity commitments](/V3/glossary/#compromiso-de-identidad-identity-commitment)) son las hojas del árbol.
Los grupos Semaphore determinan los siguientes tres parámetro:
- **Group id**: un identificador único para el grupo;
@@ -24,14 +24,14 @@ Los grupos Semaphore determinan los siguientes tres parámetro:
Aprenda cómo trabajar con grupos.
- [**Grupos off-chain**](#off-chain-groups)
- [**Grupos on-chain**](#on-chain-groups)
- [**Grupos off-chain**](#grupos-off-chain-externos-a-la-cadena)
- [**Grupos on-chain**](#grupos-on-chain)
## Grupos off-chain (externos a la cadena)
- [Crear un grupo](#create-a-group)
- [Añadir miembros](#add-members)
- [Remover o actualizar miembros](#remove-or-update-members)
- [Crear un grupo](#crear-un-grupo)
- [Añadir miembros](#añadir-miembros)
- [Remover o actualizar miembros](#remover-o-actualizar-miembros)
### Crear un grupo

View File

@@ -8,7 +8,7 @@ import TabItem from "@theme/TabItem"
# Identidades Semaphore
Para unirse a un [grupo Semaphore](/glossary#semaphore-group), un usuario primero deberá crear una [identidad Semaphore](/glossary#semaphore-identity).
Para unirse a un [grupo Semaphore](/V3/glossary#grupo-semaphore), un usuario primero deberá crear una [identidad Semaphore](/V3/glossary#identidad-semaphore).
Una identidad Semaphore contiene dos valores generados junto con la identidad:
- Identity trapdoor (Identidad trampilla)
@@ -21,8 +21,8 @@ Para prevenir fraudes, la persona dueña debe conservar de forma secreta ambos v
En su código, utilice la librería [`@semaphore-protocol/identity`](https://github.com/semaphore-protocol/semaphore/tree/main/packages/identity) para crear una identidad Semaphore _de forma determinística_ (del hash de un mensaje) o _de forma aleatoria_.
- [**Crear identidades aleatorias**](#create-random-identities)
- [**Crear identidades determinísticas**](#create-deterministic-identities)
- [**Crear identidades aleatorias**](#crear-identidades-aleatorias)
- [**Crear identidades determinísticas**](#crear-identidades-determinísticas)
### Instalar librería:

View File

@@ -8,16 +8,16 @@ import TabItem from "@theme/TabItem"
# Pruebas Semaphore
Una vez que un usuario liga su [identidad Semaphore](/glossary#semaphore-identity) a un [grupo Semaphore](/glossary#semaphore-group), el usuario puede emitir una señal anónima con una prueba de conocimiento cero (ZKP) que demuestre lo siguiente:
Una vez que un usuario liga su [identidad Semaphore](/V3/glossary#identidad-semaphore) a un [grupo Semaphore](/V3/glossary#grupo-semaphore), el usuario puede emitir una señal anónima con una prueba de conocimiento cero (ZKP) que demuestre lo siguiente:
- el usuario es un miembro del grupo,
- el mismo usuario creo tanto la señal como la prueba.
Las y los desarrolladores pueden utilizar Semaphore para realizar las siguientes acciones:
- [**Generar una prueba externa a la cadena (off-chain)**](#generate-a-proof-off-chain)
- [**Verificar una prueba externa a la cadena (off-chain)**](#verify-a-proof-off-chain)
- [**Verificar una prueba interna a la cadena (on-chain)**](#verify-a-proof-on-chain)
- [**Generar una prueba externa a la cadena (off-chain)**](#generar-una-prueba-off-chain)
- [**Verificar una prueba externa a la cadena (off-chain)**](#verificar-una-prueba-off-chain)
- [**Verificar una prueba interna a la cadena (on-chain)**](#verificar-una-prueba-on-chain)
## Generar una prueba off-chain
@@ -28,7 +28,7 @@ Para generar una prueba, transforme los siguientes parámetros con la función `
- `group`: el grupo al cual pertenece el usuario;
- `externalNullifier`: el valor que impide la emisión de dos señales por el mismo usuario;
- `signal`: la señal que el usuario quiere enviar de forma anónima;
- `snarkArtifacts`: la `zkey` y `wasm` de los [archivos confiables de configuración](/glossary/#trusted-setup-files).
- `snarkArtifacts`: la `zkey` y `wasm` de los [archivos confiables de configuración](/V3/glossary/#archivos-confiables-de-configuración-trusted-setup-files).
#### Instalar librería:
@@ -62,9 +62,9 @@ pnpm add @semaphore-protocol/proof@^3
</TabItem>
</Tabs>
En el caso de uso de un sistema de votación, una vez que todos los votantes hayan ligado sus [identidades](/guides/identities#create-an-identity) al [grupo](/guides/groups) de la votación,
En el caso de uso de un sistema de votación, una vez que todos los votantes hayan ligado sus [identidades](/V3/guides/identities#crear-identidades) al [grupo](/V3/guides/groups) de la votación,
un votante puede generar una prueba para votar por una propuesta.
En el llamado para `generateProof`(generar la prueba), el sistema de votación envía el ID único de la votación (la raíz del [árbol de Merkle](/glossary/#merkle-tree/) del grupo) como el
En el llamado para `generateProof`(generar la prueba), el sistema de votación envía el ID único de la votación (la raíz del [árbol de Merkle](/V3/glossary/#árbol-de-merkle-merkle-tree) del grupo) como el
`externalNullifier` para impedir que el votante emita más de una señal para esta votación.
La siguiente muestra de código demuestra cómo utilizar `generateProof` para generar una prueba de votación:
@@ -108,10 +108,10 @@ await verifyProof(fullProof, 20) // verdadero o falso.
## Verificar una prueba on-chain
Utilice el contrato [`Semaphore.sol`](/technical-reference/contracts#semaphoresol) para verificar pruebas on-chain.
Utilice el contrato [`Semaphore.sol`](/V3/technical-reference/contracts#semaphoresol) para verificar pruebas on-chain.
:::info
Vea nuestros [contratos desplegados](/deployed-contracts) para encontrar las direcciones adecuadas para su red.
Vea nuestros [contratos desplegados](/V3/deployed-contracts) para encontrar las direcciones adecuadas para su red.
::::
Para verificar las pruebas Semaphore en su contrato, importe `ISemaphore.sol`, transfórmelo a la dirección `Semaphore.sol` y llame el método `verifyProof` con los siguientes parámetros:
@@ -119,9 +119,9 @@ Para verificar las pruebas Semaphore en su contrato, importe `ISemaphore.sol`, t
- `groupId`: el identificador del grupo;
- `merkleTreeRoot`: la raíz del árbol de Merkle;
- `signal`: la señal que el usuario quiere enviar de forma anónima ;
- `nullifierHash`: un [nullifier hash](#retrieve-a-nullifier-hash) (hash anulador);
- `nullifierHash`: un nullifier hash (hash anulador);
- `externalNullifier`: el valor que impide la emisión de dos señales por el mismo usuario;
- `proof`: una [prueba Semaphore que es compatible con Solidity](#generate-a-solidity-compatible-proof).
- `proof`: una prueba Semaphore que es compatible con Solidity.
:::info
Puede importar `ISemaphore.sol` y otros contratos Semaphore del módulo NPM [`@semaphore-protocol/contracts`](https://github.com/semaphore-protocol/semaphore/tree/main/packages/contracts).

View File

@@ -293,7 +293,7 @@ En la carpeta raíz del proyecto:
</Tabs>
:::note
Revise las direcciones de los contratos de Semaphore [aquí](/deployed-contracts).
Revise las direcciones de los contratos de Semaphore [aquí](/V3/deployed-contracts).
:::
:::caution

View File

@@ -6,7 +6,7 @@ sidebar_position: 9
## Artículos
[Propuesta de la comunidad: Semaphore: Señalización de conocimiento cero (ZK) en Ethereum (v1 Whitepaper)](https://docs.semaphore.pse.dev/whitepaper-v1.pdf) - Kobi Gurkan, Koh Wei Jie y Barry WhiteHat
[Propuesta de la comunidad: Semaphore: Señalización de conocimiento cero (ZK) en Ethereum (v1 Whitepaper)](https://semaphore.pse.dev/whitepaper-v1.pdf) - Kobi Gurkan, Koh Wei Jie y Barry WhiteHat
[Para Mezcladores y más allá: presentando Semaphore, una herramienta de privacidad construida en Ethereum](https://medium.com/coinmonks/to-mixers-and-beyond-presenting-semaphore-a-privacy-gadget-built-on-ethereum-4c8b00857c9b) - Koh Wei Jie

View File

@@ -6,9 +6,9 @@ sidebar_position: 2
El [circuito Semaphore](https://github.com/semaphore-protocol/semaphore/tree/main/packages/circuits) es el corazón del protocolo y está compuesto por tres partes:
- [**Prueba de membresía**](/technical-reference/circuits#proof-of-membership)
- [**Nullifier hash**](/technical-reference/circuits#nullifier-hash) (hash anulador)
- [**Señal**](/technical-reference/circuits#signal)
- [**Prueba de membresía**](#prueba-de-membresía)
- [**Nullifier hash**](#hash-anulador-nullifier-hash) (hash anulador)
- [**Señal**](#señal)
![Semaphore circuit](https://github.com/semaphore-protocol/semaphore/raw/main/packages/circuits/scheme.png)

View File

@@ -6,10 +6,10 @@ sidebar_position: 3
Semaphore incluye dos tipos de contratos:
- [**Contratos base**](/technical-reference/contracts#base-contracts)
- [**Contratos para la extensión**](/technical-reference/contracts#extension-contracts)
- [**Contratos base**](#contratos-base)
- [**Contratos para la extensión**](#contratos-para-la-extensión)
así como [**Semaphore.sol**](/technical-reference/contracts#semaphoresol), el principal contrato desplegado en las redes soportadas por Semaphore.
así como [**Semaphore.sol**](#semaphoresol), el principal contrato desplegado en las redes soportadas por Semaphore.
:::info
Para utilizar los contratos e interfaces Semaphore en su proyecto, instale el paquete NPM [`@semaphore-protocol/contracts`](https://github.com/semaphore-protocol/semaphore/tree/main/packages/contracts).
@@ -23,7 +23,7 @@ Semaphore ofrece los siguientes contratos base:
- [`SemaphoreGroups.sol`](https://github.com/semaphore-protocol/semaphore/blob/main/packages/contracts/base/SemaphoreGroups.sol): contiene las funciones para crear grupos y añadir/remover/actualizar miembros.
Los contratos base están relacionados de forma muy cercana al protocolo.
Puede utilizarlos en su contrato o puede utilizar [**Semaphore.sol**](/technical-reference/contracts#semaphoresol) que ya los tiene integrados.
Puede utilizarlos en su contrato o puede utilizar [**Semaphore.sol**](/V3/technical-reference/contracts#semaphoresol) que ya los tiene integrados.
:::info
Si bien algunas dApps pueden utilizar grupos internos a la cadena, otros puede que prefieran utilizar grupos externos a la cadena, por lo que únicamente guardarán las raíces de sus árboles en el contrato.
@@ -42,9 +42,9 @@ En un futuro se incluirán más extensiones.
[`Semaphore.sol`](https://github.com/semaphore-protocol/semaphore/blob/main/packages/contracts/contracts/Semaphore.sol) utiliza los contratos base como punto de partida, los integra y de forma adicional brinda:
- un sistema que solamente permite que administradores (ej. cuentas de Ethereum o contratos inteligentes) controlen grupos;
- un mecanismo que guarda los [hashes anuladores](/technical-reference/circuits#nullifier-hash) (nullifier hashes) de cada grupo y evita que el mismo miembro emita dos señales;
- un mecanismo que guarda los [hashes anuladores](/V3/technical-reference/circuits#hash-anulador-nullifier-hash) (nullifier hashes) de cada grupo y evita que el mismo miembro emita dos señales;
- un mecanismo que permite que pruebas Semaphore generadas con raíces de Merkle antiguas sean verificadas por un periodo de tiempo determinado por el administrador del grupo.
:::info
Visitando [contratos desplegados](/deployed-contracts) puede encontrar las direcciones correspondientes a su red.
Visitando [contratos desplegados](/V3/deployed-contracts) puede encontrar las direcciones correspondientes a su red.
::::

View File

@@ -15,9 +15,9 @@ Algunos de los potenciales casos de uso son: votaciones, denuncias, DAOs anónim
Con Semaphore puede permitir que sus usuarios realicen las siguientes acciones:
1. [Crear una identidad Semaphore](/guides/identities/).
2. [Agregar su identidad Semaphore a un grupo (es decir: _Árbol de Merkle_)](/guides/groups/).
3. [Enviar una señal anónima, verificable (ej. un voto o una aprobación)](/guides/proofs/).
1. [Crear una identidad Semaphore](/V3/guides/identities/).
2. [Agregar su identidad Semaphore a un grupo (es decir: _Árbol de Merkle_)](/V3/guides/groups/).
3. [Enviar una señal anónima, verificable (ej. un voto o una aprobación)](/V3/guides/proofs/).
Cuando un usuario emite una señal (por ejemplo: un voto), las pruebas de conocimiento cero (ZKP) pueden asegurar que el usuario se ha incorporado al grupo y aún no ha emitido una señal con su nullifier (anulador).
@@ -39,7 +39,7 @@ y [librerías en JavaScript](https://github.com/semaphore-protocol/semaphore#-pa
### Ceremonia de configuración de confianza (Trusted Setup Ceremony)
Los [parámetros seguros](/glossary#trusted-setup-files) para generar pruebas válidas con los circuitos Semaphore fueron generados en una [ceremonia de configuración de confianza](https://storage.googleapis.com/trustedsetup-a86f4.appspot.com/semaphore/semaphore_top_index.html) que se completó con más de 300 participantes el [29 de Marzo de 2022](https://etherscan.io/tx/0xec6dbe68883c7593c2bea82f55af18b3aeb5cc146e026d0083a9b3faa9aa0b65#eventlog).
Los [parámetros seguros](/V3/glossary#archivos-confiables-de-configuración-trusted-setup-files) para generar pruebas válidas con los circuitos Semaphore fueron generados en una [ceremonia de configuración de confianza](https://storage.googleapis.com/trustedsetup-a86f4.appspot.com/semaphore/semaphore_top_index.html) que se completó con más de 300 participantes el [29 de Marzo de 2022](https://etherscan.io/tx/0xec6dbe68883c7593c2bea82f55af18b3aeb5cc146e026d0083a9b3faa9aa0b65#eventlog).
### Auditorías

View File

@@ -4,7 +4,8 @@
"scripts": {
"start": "docusaurus start",
"start:es": "docusaurus start --locale es",
"build": "docusaurus build",
"pre-build": "yarn workspace @semaphore-protocol/utils build",
"build": "yarn pre-build && docusaurus build",
"swizzle": "docusaurus swizzle",
"deploy": "docusaurus deploy",
"clear": "docusaurus clear",
@@ -16,6 +17,7 @@
"@docusaurus/core": "3.1.1",
"@docusaurus/preset-classic": "3.1.1",
"@mdx-js/react": "^3.0.0",
"@semaphore-protocol/utils": "4.0.0-beta.7",
"@svgr/webpack": "^5.5.0",
"clsx": "^1.2.1",
"docusaurus-plugin-sass": "^0.2.5",

View File

@@ -1,39 +1,11 @@
import { deployedContracts, supportedNetworks } from "@semaphore-protocol/utils"
import Heading from "@theme/Heading"
import { useEffect, useState } from "react"
function capitalizeFirstLetter(s: string): string {
return s.charAt(0).toUpperCase() + s.slice(1)
}
function getEtherscanLink(network: string): string {
switch (network) {
case "sepolia":
return "https://sepolia.etherscan.io/address/"
case "mumbai":
return "https://mumbai.polygonscan.com/address/"
case "arbitrum":
return "https://arbiscan.io/address/"
case "arbitrum-sepolia":
return "https://sepolia.arbiscan.io/address/"
case "optimism-sepolia":
return "https://sepolia-optimism.etherscan.io/address/"
default:
return ""
}
}
export default function DeployedContracts() {
const [deployedContracts, setDeployedContracts] = useState<any[]>([])
useEffect(() => {
fetch(
"https://raw.githubusercontent.com/semaphore-protocol/semaphore/feat/semaphore-v4/packages/contracts/deployed-contracts.json"
)
.then((response) => response.json())
.catch(() => [])
.then(setDeployedContracts)
}, [])
return (
<div>
{deployedContracts.map(({ network, contracts }) => (
@@ -43,7 +15,11 @@ export default function DeployedContracts() {
{contracts.map(({ name, address }) => (
<li key={address}>
{name}:{" "}
<a href={getEtherscanLink(network) + address} target="_blank" rel="noreferrer">
<a
href={`${supportedNetworks[network].explorer}/address/${address}`}
target="_blank"
rel="noreferrer"
>
{address}
</a>
</li>

View File

@@ -6,8 +6,12 @@
/* You can override the default Infima variables here. */
@import url("https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600&display=swap");
@import url("https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600&display=swap");
@font-face {
font-family: "DM Sans";
src: url("/static/fonts/DMSans.ttf") format("truetype");
font-weight: 400;
font-style: normal;
}
:root {
--ifm-color-primary: "linear(to-r, #4771ea, #2735a6)";
@@ -73,13 +77,17 @@ html[data-theme="light"] {
}
html {
font-family: "DMSans", sans-serif;
font-family: "DM Sans", sans-serif;
font-size: 18px;
font-variant: none;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
font-feature-settings: "ss01" on, "ss02" on, "cv01" on, "cv03" on;
font-feature-settings:
"ss01" on,
"ss02" on,
"cv01" on,
"cv03" on;
font-weight: 400;
}
@@ -93,7 +101,7 @@ svg.custom-icon circle {
}
p {
font-family: "DMSans", sans-serif;
font-family: "DM Sans", sans-serif;
line-height: 32px;
font-weight: 400;
}
@@ -109,7 +117,6 @@ h2,
h3,
h4,
h5 {
font-family: "Outfit", sans-serif;
font-weight: 500;
}
@@ -267,18 +274,6 @@ html.docs-version-V1 {
box-shadow: none !important;
}
.navbar__title {
font-family: "Outfit", sans-serif;
color: var(--ifm-color-primary);
font-weight: 500;
}
.navbar__link {
font-family: "Outfit", sans-serif;
color: var(--ifm-color-primary);
font-weight: 400;
}
.menu__link {
font-size: 18px;
font-weight: 400;

BIN
apps/docs/static/fonts/DMSans.ttf vendored Normal file

Binary file not shown.

BIN
apps/docs/static/img/social-media.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 190 KiB

3
apps/docs/vercel.json Normal file
View File

@@ -0,0 +1,3 @@
{
"cleanUrls": true
}

View File

@@ -95,7 +95,7 @@ to any question. The user, however, can only vote once per question.
## About the code
This repository contains the code for Semaphore's contracts written in
Soliidty, and zk-SNARK circuits written in
Solidity, and zk-SNARK circuits written in
[circom](https://github.com/iden3/circom). It also contains Typescript code to
execute tests.

View File

@@ -40,7 +40,7 @@ For more information, see [Merkle tree in Wikipedia](https://en.wikipedia.org/wi
A value used to prevent double entry or double signalling.
See [Circuit nullifier hash](/technical-reference/circuits/#nullifier-hash).
See [Circuit nullifier hash](/V2/technical-reference/circuits/#nullifier-hash).
## Relay
@@ -48,7 +48,7 @@ A third-party who receives a fee for including relayed transactions in the block
To preserve the anonymity of the user broadcasting a signal with Semaphore, an application may use a relayer to post the signal transaction to Ethereum on behalf of the user.
Applications may provide rewards for relayers and implement front-running prevention mechanisms, such as requiring the signals to include the relayers address, binding the
signal to that specific address (https://docs.semaphore.pse.dev/whitepaper-v1.pdf, p.6).
signal to that specific address (https://semaphore.pse.dev/whitepaper-v1.pdf, p.6).
## Trusted setup files

View File

@@ -20,14 +20,14 @@ title: Groups
Use Semaphore in your application or smart contract to create off-chain and on-chain groups.
A [Semaphore group](/glossary/#semaphore-group) contains [identity commitments](/glossary/#identity-commitment) of group members.
A [Semaphore group](/V2/glossary/#semaphore-group) contains [identity commitments](/V2/glossary/#identity-commitment) of group members.
Example uses of groups include the following:
- Poll question that attendees join to rate an event.
- Ballot that members join to vote on a proposal.
- Whistleblowers who are verified employees of an organization.
A Semaphore group is an [incremental Merkle tree](/glossary/#incremental-merkle-tree), and group members (i.e., [identity commitments](/glossary/#identity-commitments)) are tree leaves.
A Semaphore group is an [incremental Merkle tree](/V2/glossary/#merkle-tree), and group members (i.e., [identity commitments](/V2/glossary/#identity-commitment)) are tree leaves.
Semaphore groups set the following two parameters:
- **Tree depth**: the maximum number of members a group can contain (`max size = 2 ^ tree depth`).

View File

@@ -5,7 +5,7 @@ title: Identities
# Semaphore identities
In order to join a [Semaphore group](/glossary#semaphore-group), a user must first create a [Semaphore identity](/glossary#semaphore-identity).
In order to join a [Semaphore group](/V2/glossary#semaphore-group), a user must first create a [Semaphore identity](/V2/glossary#semaphore-identity).
A Semaphore identity contains two values generated with the identity:
- Identity trapdoor

View File

@@ -7,7 +7,7 @@ title: Proofs
Learn how to use Semaphore to generate and verify zero-knowledge proofs.
Once a user joins their [Semaphore identity](/glossary#semaphore-identity) to a [Semaphore group](/glossary#semaphore-group), the user can signal anonymously with a zero-knowledge proof that proves the following:
Once a user joins their [Semaphore identity](/V2/glossary#semaphore-identity) to a [Semaphore group](/V2/glossary#semaphore-group), the user can signal anonymously with a zero-knowledge proof that proves the following:
- The user is a member of the group.
- The same user created the signal and the proof.
@@ -27,11 +27,11 @@ To generate a proof, pass the following properties to the `generateProof` functi
- `group`: The group to which the user belongs.
- `externalNullifier`: The value that prevents double-signaling.
- `signal`: The signal the user wants to send anonymously.
- `snarkArtifacts`: The `zkey` and `wasm` [trusted setup files](/glossary/#trusted-setup-files).
- `snarkArtifacts`: The `zkey` and `wasm` [trusted setup files](/V2/glossary/#trusted-setup-files).
In the voting system use case, once all the voters have joined their [identities](/guides/identities#create-an-identity) to the ballot [group](/guides/groups),
In the voting system use case, once all the voters have joined their [identities](/guides/identities#create-identities) to the ballot [group](/guides/groups),
a voter can generate a proof to vote for a proposal.
In the call to `generateProof`, the voting system passes the unique ballot ID (the [Merkle tree](/glossary/#merkle-tree/) root of the group) as the
In the call to `generateProof`, the voting system passes the unique ballot ID (the [Merkle tree](/V2/glossary/#merkle-tree) root of the group) as the
`externalNullifier` to prevent the voter signaling more than once for the ballot.
The following code sample shows how to use `generateProof` to generate the voting proof:
@@ -53,7 +53,7 @@ Use the [`@semaphore-protocol/proof`](https://github.com/semaphore-protocol/sema
To verify a proof, pass the following to the `verifyProof` function:
- _`proof`_: the Semaphore proof.
- _`verificationKey`_: the JavaScript object in the `semaphore.json` [trusted setup file](/glossary/#trusted-setup-files).
- _`verificationKey`_: the JavaScript object in the `semaphore.json` [trusted setup file](/V2/glossary/#trusted-setup-files).
The following code sample shows how to parse the verification key object from `semaphore.json`
and verify the previously generated proof:

View File

@@ -213,7 +213,7 @@ and [Chai assertions](https://www.chaijs.com/).
wget http://www.trusted-setup-pse.org/semaphore/20/semaphore.wasm
```
Learn more about [trusted setup files](/glossary/#trusted-setup-files).
Learn more about [trusted setup files](/V2/glossary/#trusted-setup-files).
3. Rename the `Lock.js` test file to `Greeter.js` and replace the content with the following:

View File

@@ -6,9 +6,9 @@ sidebar_position: 2
The [Semaphore circuit](https://github.com/semaphore-protocol/semaphore/tree/v2.6.1/packages/circuits) is the heart of the protocol and consists of three parts:
- [**Proof of membership**](/technical-reference/circuits#proof-of-membership)
- [**Nullifier hash**](/technical-reference/circuits#nullifier-hash)
- [**Signal**](/technical-reference/circuits#signal)
- [**Proof of membership**](/V2/technical-reference/circuits#proof-of-membership)
- [**Nullifier hash**](/V2/technical-reference/circuits#nullifier-hash)
- [**Signal**](/V2/technical-reference/circuits#signal)
![Semaphore circuit](https://github.com/semaphore-protocol/semaphore/raw/v2.6.1/packages/circuits/scheme.png)

View File

@@ -6,9 +6,9 @@ sidebar_position: 3
Semaphore includes three types of contracts:
- [**Base contracts**](/technical-reference/contracts#base-contracts)
- [**Extension contracts**](/technical-reference/contracts#extension-contracts)
- [**Verifiers**](/technical-reference/contracts#verifiers)
- [**Base contracts**](/V2/technical-reference/contracts#base-contracts)
- [**Extension contracts**](/V2/technical-reference/contracts#extension-contracts)
- [**Verifiers**](/V2/technical-reference/contracts#verifiers)
:::info
To use Semaphore contracts and interfaces in your project,
@@ -24,7 +24,7 @@ Semaphore provides the following base contracts:
These contracts are closely related to the protocol.
You can inherit them in your contract or you can use [`Semaphore.sol`](https://github.com/semaphore-protocol/semaphore/tree/v2.6.1/packages/contracts/contracts/Semaphore.sol), which inherits them for you.
See our [deployed contracts](/deployed-contracts#semaphore) to find the addresses for your network.
See our [deployed contracts](/V2/deployed-contracts#semaphore) to find the addresses for your network.
:::info
While some dApps may use on-chain groups, others may prefer to use off-chain groups, saving only their tree roots in the contract.
@@ -41,10 +41,10 @@ More extensions will be added in the future.
## Verifiers
To verify Semaphore proofs, the [`SemaphoreCore.sol`](https://github.com/semaphore-protocol/semaphore/tree/v2.6.1/packages/contracts/contracts/base/SemaphoreCore.sol) contract requires the address of a deployed verifier contract.
You can choose to manually deploy the [verifier](https://github.com/semaphore-protocol/semaphore/tree/v2.6.1/packages/contracts/contracts/verifiers) you prefer or you can use one of our [deployed verifiers](/deployed-contracts#verifiers).
You can choose to manually deploy the [verifier](https://github.com/semaphore-protocol/semaphore/tree/v2.6.1/packages/contracts/contracts/verifiers) you prefer or you can use one of our [deployed verifiers](/V2/deployed-contracts#verifiers).
Each verifier name indicates the tree depth that it can verify.
For example, given a Semaphore proof generated with a tree depth `20`:
- The `Verifier20.sol` contract can verify the proof.
- The [group](/guides/groups) used for the proof can have a maximum `2^20=1048576` members.
- The [group](/V2/guides/groups) used for the proof can have a maximum `2^20=1048576` members.

View File

@@ -36,7 +36,7 @@ Community members connect their wallets to the dApp to take the following action
### Relay
To preserve anonymity and avoid disclosing the member's wallet address, the dApp may use a [relay](/glossary/#relay) to broadcast the vote.
To preserve anonymity and avoid disclosing the member's wallet address, the dApp may use a [relay](/V2/glossary/#relay) to broadcast the vote.
The relay calls the **contract** function that then posts the member's vote transaction to Ethereum.
## Private voting
@@ -52,7 +52,7 @@ The voting scenario has the following steps:
### Create a poll
A community coordinator or dApp administrator uses the deployed smart contract to create an on-chain (Ethereum) poll, a [Semaphore group](/guides/groups/) that members can join and cast votes to.
A community coordinator or dApp administrator uses the deployed smart contract to create an on-chain (Ethereum) poll, a [Semaphore group](/V2/guides/groups/) that members can join and cast votes to.
In the following sample code, the voting contract declares a `createPoll` function that uses the Semaphore base `_createGroup` function:
@@ -77,11 +77,11 @@ function createPoll(
}
```
A poll is a Semaphore [group](/guides/groups/) that stores the following:
A poll is a Semaphore [group](/V2/guides/groups/) that stores the following:
- A topic to vote on.
- The public ID of the poll creator.
- [Semaphore IDs](/guides/identities/) of members who joined the poll.
- [Semaphore IDs](/V2/guides/identities/) of members who joined the poll.
To create the poll, the administrator calls the smart contract function--for example:
@@ -127,10 +127,10 @@ With a member registered for a poll, learn how the dApp [records votes](#record-
Once members have joined a poll, the coordinator starts the poll to allow voting.
When a member votes (for example, by selecting a radio button), then the dApp takes the following actions:
1. Uses the `@semaphore-protocol/proof` library to create a proof of the vote, the poll identifier, the Semaphore ID, and a [nullifier](/glossary/#nullifier) that prevents double-voting.
1. Uses the `@semaphore-protocol/proof` library to create a proof of the vote, the poll identifier, the Semaphore ID, and a [nullifier](/V2/glossary/#nullifier) that prevents double-voting.
2. Sends the vote proof to the [relay](#relay).
### Related
- To get started developing with Semaphore, see the [Quick setup](/quick-setup/) guide.
- To get started developing with Semaphore, see the [Quick setup](/V2/quick-setup/) guide.
- For an example app that you can use to start your own project, see [Semaphore boilerplate](https://github.com/semaphore-protocol/boilerplate).

View File

@@ -15,9 +15,9 @@ Use cases include private voting, whistleblowing, anonymous DAOs and mixers.
With Semaphore, you can allow your users to do the following:
1. [Create a Semaphore identity](/guides/identities/).
2. [Add their Semaphore identity to a group (i.e. _Merkle tree_)](/guides/groups/).
3. [Send a verifiable, anonymous signal (e.g a vote or endorsement)](/guides/proofs/).
1. [Create a Semaphore identity](/V2/guides/identities/).
2. [Add their Semaphore identity to a group (i.e. _Merkle tree_)](/V2/guides/groups/).
3. [Send a verifiable, anonymous signal (e.g a vote or endorsement)](/V2/guides/proofs/).
When a user broadcasts a signal (for example: a vote), Semaphore zero-knowledge
proofs can ensure that the user has joined the group and hasn't already cast a signal with their nullifier.

View File

@@ -30,7 +30,7 @@ Finally, the nullifier hash is just the hash of the identity nullifier and the e
In the case of a voting application, if you have a group and you want all members of this group to vote only once, you can use the id of the group as an external nullifier. When a user votes the first time, you can save the hash of their identity nullifier and the group id (i.e. the nullifier hash) and prevent double-voting by checking if that hash already exists.
See the [Semaphore circuits](https://docs.semaphore.pse.dev/technical-reference/circuits) for more technical information, or the [Semaphore boilerplate](https://github.com/semaphore-protocol/boilerplate) for a real use-case.
See the [Semaphore circuits](https://docs.semaphore.pse.dev/technical-reference/circuits) for more technical information, or the [Semaphore boilerplate](https://github.com/semaphore-protocol/boilerplate/tree/version/3) for a real use-case.
## Why should I prevent proofs from being verified twice?
@@ -44,11 +44,11 @@ You can find some applications that are using Semaphore in [this blog post](http
## How can I start a project using Semaphore?
There are three ways you can start using Semaphore in your project: using the [Semaphore CLI](https://github.com/semaphore-protocol/semaphore/tree/main/packages/cli), using the [Semaphore boilerplate](https://github.com/semaphore-protocol/boilerplate) as a template or forking it, or installing the Semaphore packages manually.
There are three ways you can start using Semaphore in your project: using the [Semaphore CLI](https://github.com/semaphore-protocol/semaphore/tree/v3.15.2/packages/cli), using the [Semaphore boilerplate](https://github.com/semaphore-protocol/boilerplate/tree/version/3) as a template or forking it, or installing the Semaphore packages manually.
### Semaphore CLI
To create a new project you could use `npx` or install the [Semaphore CLI](https://github.com/semaphore-protocol/semaphore/tree/main/packages/cli) globally using `npm` and then create the new project using the `semaphore create` command. See the [Quick Setup](https://docs.semaphore.pse.dev/quick-setup) for more information.
To create a new project you could use `npx` or install the [Semaphore CLI](https://github.com/semaphore-protocol/semaphore/tree/v3.15.2/packages/cli) globally using `npm` and then create the new project using the `semaphore create` command. See the [Quick Setup](https://docs.semaphore.pse.dev/quick-setup) for more information.
There are three supported templates right now: `contracts-hardhat`, `monorepo-ethers` and `monorepo-subgraph`.
@@ -65,7 +65,7 @@ The Semaphore CLI can also be used to get group data from a supported network. T
### Semaphore boilerplate
To create a project, you could also use the [Semaphore boilerplate](https://github.com/semaphore-protocol/boilerplate). You could fork it or use it as a template.
To create a project, you could also use the [Semaphore boilerplate](https://github.com/semaphore-protocol/boilerplate/tree/version/3). You could fork it or use it as a template.
The Semaphore CLI templates and the Semaphore boilerplate contain the same code, which is a feedback application where you can create an identity, join a group, and send your feedback anonymously. They are almost the same, the only difference is that the templates use plain CSS so you can decide the CSS framework or library you want to use and the boilerplate uses [ChakraUI](https://chakra-ui.com/) by default.

View File

@@ -39,7 +39,7 @@ For more information, see [Merkle tree in Wikipedia](https://en.wikipedia.org/wi
A value used to prevent double entry or double signalling.
See [Circuit nullifier hash](/technical-reference/circuits/#nullifier-hash).
See [Circuit nullifier hash](/V3/technical-reference/circuits/#nullifier-hash).
## Relay
@@ -47,7 +47,7 @@ A third-party who receives a fee for including relayed transactions in the block
To preserve the anonymity of the user broadcasting a signal with Semaphore, an application may use a relayer to post the signal transaction to Ethereum on behalf of the user.
Applications may provide rewards for relayers and implement front-running prevention mechanisms, such as requiring the signals to include the relayers address, binding the
signal to that specific address (https://docs.semaphore.pse.dev/whitepaper-v1.pdf, p.6).
signal to that specific address (https://semaphore.pse.dev/whitepaper-v1.pdf, p.6).
## Trusted setup files

View File

@@ -8,9 +8,9 @@ import TabItem from "@theme/TabItem"
# Semaphore data
To fetch on-chain data from the [Semaphore.sol](https://github.com/semaphore-protocol/semaphore/blob/main/packages/contracts/contracts/Semaphore.sol) contract, you can use the [@semaphore-protocol/data](https://github.com/semaphore-protocol/semaphore/tree/main/packages/data) library.
To fetch on-chain data from the [Semaphore.sol](https://github.com/semaphore-protocol/semaphore/blob/v3.15.2/packages/contracts/contracts/Semaphore.sol) contract, you can use the [@semaphore-protocol/data](https://github.com/semaphore-protocol/semaphore/tree/v3.15.2/packages/data) library.
There are two ways to do this, using [`SemaphoreSubgraph`](https://github.com/semaphore-protocol/semaphore/blob/main/packages/data/src/subgraph.ts) or [`SemaphoreEthers`](https://github.com/semaphore-protocol/semaphore/blob/main/packages/data/src/ethers.ts). The `SemaphoreSubgraph` class uses the [Semaphore subgraph](https://github.com/semaphore-protocol/subgraph), which uses [The Graph Protocol](https://thegraph.com/) under the hood, and the `SemaphoreEthers` class uses [Ethers](https://github.com/ethers-io/ethers.js/).
There are two ways to do this, using [`SemaphoreSubgraph`](https://github.com/semaphore-protocol/semaphore/blob/v3.15.2/packages/data/src/subgraph.ts) or [`SemaphoreEthers`](https://github.com/semaphore-protocol/semaphore/blob/v3.15.2/packages/data/src/ethers.ts). The `SemaphoreSubgraph` class uses the [Semaphore subgraph](https://github.com/semaphore-protocol/subgraph), which uses [The Graph Protocol](https://thegraph.com/) under the hood, and the `SemaphoreEthers` class uses [Ethers](https://github.com/ethers-io/ethers.js/).
- [**Fetch data using SemaphoreSubgraph**](#fetch-data-using-semaphoresubgraph)
- [**Fetch data using SemaphoreEthers**](#fetch-data-using-semaphoreethers)
@@ -50,7 +50,7 @@ pnpm add @semaphore-protocol/data@^3
## Fetch data using SemaphoreSubgraph
To fetch data using the Semaphore subgraph you can use the [`SemaphoreSubgraph`](https://github.com/semaphore-protocol/semaphore/blob/main/packages/data/src/subgraph.ts) class from the [@semaphore-protocol/data](https://github.com/semaphore-protocol/semaphore/tree/main/packages/data) package.
To fetch data using the Semaphore subgraph you can use the [`SemaphoreSubgraph`](https://github.com/semaphore-protocol/semaphore/blob/v3.15.2/packages/data/src/subgraph.ts) class from the [@semaphore-protocol/data](https://github.com/semaphore-protocol/semaphore/tree/v3.15.2/packages/data) package.
```typescript
import { SemaphoreSubgraph } from "@semaphore-protocol/data"
@@ -117,7 +117,7 @@ const group = new Group(groupId, 20, members)
## Fetch data using SemaphoreEthers
To fetch data using Ethers you can use the [`SemaphoreEthers`](https://github.com/semaphore-protocol/semaphore/blob/main/packages/data/src/ethers.ts) class from the [@semaphore-protocol/data](https://github.com/semaphore-protocol/semaphore/tree/main/packages/data) package.
To fetch data using Ethers you can use the [`SemaphoreEthers`](https://github.com/semaphore-protocol/semaphore/blob/v3.15.2/packages/data/src/ethers.ts) class from the [@semaphore-protocol/data](https://github.com/semaphore-protocol/semaphore/tree/v3.15.2/packages/data) package.
```typescript
import { SemaphoreEthers } from "@semaphore-protocol/data"

View File

@@ -8,14 +8,14 @@ import TabItem from "@theme/TabItem"
# Semaphore groups
A [Semaphore group](/glossary/#semaphore-group) contains [identity commitments](/glossary/#identity-commitment) of group members.
A [Semaphore group](/V3/glossary/#semaphore-group) contains [identity commitments](/V3/glossary/#identity-commitment) of group members.
Example uses of groups include the following:
- poll question that attendees join to rate an event,
- ballot that members join to vote on a proposal,
- whistleblowers who are verified employees of an organization.
A Semaphore group is an [incremental Merkle tree](/glossary/#incremental-merkle-tree), and group members (i.e., [identity commitments](/glossary/#identity-commitments)) are tree leaves.
A Semaphore group is an [incremental Merkle tree](/V3/glossary/#merkle-tree), and group members (i.e., [identity commitments](/V3/glossary/#identity-commitment)) are tree leaves.
Semaphore groups set the following three parameters:
- **Group id**: a unique identifier for the group;
@@ -35,7 +35,7 @@ Learn how to work with groups.
### Create a group
Use the [`@semaphore-protocol/group`](https://github.com/semaphore-protocol/semaphore/blob/main/packages/group) library `Group` class to create an off-chain group with the following parameters:
Use the [`@semaphore-protocol/group`](https://github.com/semaphore-protocol/semaphore/blob/v3.15.2/packages/group) library `Group` class to create an off-chain group with the following parameters:
- `Group id`: a unique identifier for the group;
- `Tree depth`: (_default `20`_) the maximum number of members a group can contain (`max size = 2 ^ tree depth`).
@@ -142,13 +142,13 @@ Given that the node isn't removed, and the length of the `group.members` array d
## On-chain groups
The [`SemaphoreGroups`](https://github.com/semaphore-protocol/semaphore/blob/main/packages/contracts/contracts/base/SemaphoreGroups.sol) contract uses the [`IncrementalBinaryTree`](https://github.com/privacy-scaling-explorations/zk-kit/blob/main/packages/incremental-merkle-tree.sol/contracts/IncrementalBinaryTree.sol) library and provides methods to create and manage groups.
The [`SemaphoreGroups`](https://github.com/semaphore-protocol/semaphore/blob/v3.15.2/packages/contracts/contracts/base/SemaphoreGroups.sol) contract uses the [`IncrementalBinaryTree`](https://github.com/privacy-scaling-explorations/zk-kit/blob/main/packages/incremental-merkle-tree.sol/contracts/IncrementalBinaryTree.sol) library and provides methods to create and manage groups.
:::info
You can import `SemaphoreGroups.sol` and other Semaphore contracts from the [`@semaphore-protocol/contracts`](https://github.com/semaphore-protocol/semaphore/tree/main/packages/contracts) NPM module.
You can import `SemaphoreGroups.sol` and other Semaphore contracts from the [`@semaphore-protocol/contracts`](https://github.com/semaphore-protocol/semaphore/tree/v3.15.2/packages/contracts) NPM module.
:::
Alternatively, you can use an already deployed [`Semaphore.sol`](https://github.com/semaphore-protocol/semaphore/blob/main/packages/contracts/contracts/Semaphore.sol) contract and use its group external functions.
Alternatively, you can use an already deployed [`Semaphore.sol`](https://github.com/semaphore-protocol/semaphore/blob/v3.15.2/packages/contracts/contracts/Semaphore.sol) contract and use its group external functions.
:::caution
`Semaphore.sol` does not check if a member with a specific identity commitment already exists in a group. This check must be done off-chain.

View File

@@ -8,7 +8,7 @@ import TabItem from "@theme/TabItem"
# Semaphore identities
In order to join a [Semaphore group](/glossary#semaphore-group), a user must first create a [Semaphore identity](/glossary#semaphore-identity).
In order to join a [Semaphore group](/V3/glossary#semaphore-group), a user must first create a [Semaphore identity](/V3/glossary#semaphore-identity).
A Semaphore identity contains two values generated with the identity:
- Identity trapdoor
@@ -19,7 +19,7 @@ To prevent fraud, the owner should keep both values secret.
## Create identities
In your code, use the [`@semaphore-protocol/identity`](https://github.com/semaphore-protocol/semaphore/tree/main/packages/identity) library to create a Semaphore identity _deterministically_ (from the hash of a message) or _randomly_.
In your code, use the [`@semaphore-protocol/identity`](https://github.com/semaphore-protocol/semaphore/tree/v3.15.2/packages/identity) library to create a Semaphore identity _deterministically_ (from the hash of a message) or _randomly_.
- [**Create random identities**](#create-random-identities)
- [**Create deterministic identities**](#create-deterministic-identities)

View File

@@ -8,7 +8,7 @@ import TabItem from "@theme/TabItem"
# Semaphore proofs
Once a user joins their [Semaphore identity](/glossary#semaphore-identity) to a [Semaphore group](/glossary#semaphore-group), the user can signal anonymously with a zero-knowledge proof that proves the following:
Once a user joins their [Semaphore identity](/V3/glossary#semaphore-identity) to a [Semaphore group](/V3/glossary#semaphore-group), the user can signal anonymously with a zero-knowledge proof that proves the following:
- the user is a member of the group,
- the same user created the signal and the proof.
@@ -21,14 +21,14 @@ Developers can use Semaphore for the following:
## Generate a proof off-chain
Use the [`@semaphore-protocol/proof`](https://github.com/semaphore-protocol/semaphore/tree/main/packages/proof) library to generate an off-chain proof.
Use the [`@semaphore-protocol/proof`](https://github.com/semaphore-protocol/semaphore/tree/v3.15.2/packages/proof) library to generate an off-chain proof.
To generate a proof, pass the following parameters to the `generateProof` function:
- `identity`: the Semaphore identity of the user broadcasting the signal and generating the proof;
- `group`: the group to which the user belongs;
- `externalNullifier`: the value that prevents double-signaling;
- `signal`: the signal the user wants to send anonymously;
- `snarkArtifacts`: the `zkey` and `wasm` [trusted setup files](/glossary/#trusted-setup-files).
- `snarkArtifacts`: the `zkey` and `wasm` [trusted setup files](/V3/glossary/#trusted-setup-files).
#### Install library:
@@ -63,9 +63,9 @@ pnpm add @semaphore-protocol/proof@^3
</TabItem>
</Tabs>
In the voting system use case, once all the voters have joined their [identities](/guides/identities#create-an-identity) to the ballot [group](/guides/groups),
In the voting system use case, once all the voters have joined their [identities](/V3/guides/identities#create-identities) to the ballot [group](/V3/guides/groups),
a voter can generate a proof to vote for a proposal.
In the call to `generateProof`, the voting system passes the unique ballot ID (the [Merkle tree](/glossary/#merkle-tree/) root of the group) as the
In the call to `generateProof`, the voting system passes the unique ballot ID (the [Merkle tree](/V3/glossary#merkle-tree) root of the group) as the
`externalNullifier` to prevent the voter signaling more than once for the ballot.
The following code sample shows how to use `generateProof` to generate the voting proof:
@@ -91,7 +91,7 @@ const fullProof = await generateProof(identity, group, externalNullifier, signal
## Verify a proof off-chain
Use the [`@semaphore-protocol/proof`](https://github.com/semaphore-protocol/semaphore/tree/main/packages/proof) library to verify a Semaphore proof off-chain.
Use the [`@semaphore-protocol/proof`](https://github.com/semaphore-protocol/semaphore/tree/v3.15.2/packages/proof) library to verify a Semaphore proof off-chain.
To verify a proof, pass the following to the `verifyProof` function:
- `fullProof`: the Semaphore proof;
@@ -109,10 +109,10 @@ await verifyProof(fullProof, 20) // true or false.
## Verify a proof on-chain
Use the [`Semaphore.sol`](/technical-reference/contracts#semaphoresol) contract to verify proofs on-chain.
Use the [`Semaphore.sol`](/V3/technical-reference/contracts#semaphoresol) contract to verify proofs on-chain.
:::info
See our [deployed contracts](/deployed-contracts) to find the addresses for your network.
See our [deployed contracts](/V3/deployed-contracts) to find the addresses for your network.
::::
To verify Semaphore proofs in your contract, import `ISemaphore.sol`, pass it the `Semaphore.sol` address and call the `verifyProof` method with following parameters:
@@ -120,10 +120,10 @@ To verify Semaphore proofs in your contract, import `ISemaphore.sol`, pass it th
- `groupId`: the identifier of the group;
- `merkleTreeRoot`: the root of the Merkle tree;
- `signal`: the signal the user wants to send anonymously;
- `nullifierHash`: a [nullifier hash](#retrieve-a-nullifier-hash);
- `nullifierHash`: a nullifier hash;
- `externalNullifier`: the value that prevents double-signaling;
- `proof`: a [Solidity-compatible Semaphore proof](#generate-a-solidity-compatible-proof).
- `proof`: a Solidity-compatible Semaphore proof.
:::info
You can import `ISemaphore.sol` and other Semaphore contracts from the [`@semaphore-protocol/contracts`](https://github.com/semaphore-protocol/semaphore/tree/main/packages/contracts) NPM module.
You can import `ISemaphore.sol` and other Semaphore contracts from the [`@semaphore-protocol/contracts`](https://github.com/semaphore-protocol/semaphore/tree/v3.15.2/packages/contracts) NPM module.
:::

View File

@@ -21,11 +21,11 @@ semaphore create my-app --template monorepo-ethers
```
:::info
The supported templates are: [`contracts-hardhat`](https://github.com/semaphore-protocol/semaphore/tree/main/packages/cli-template-contracts-hardhat), [`monorepo-ethers`](https://github.com/semaphore-protocol/semaphore/tree/main/packages/cli-template-monorepo-ethers), [`monorepo-subgraph`](https://github.com/semaphore-protocol/semaphore/tree/main/packages/cli-template-monorepo-subgraph).
The supported templates are: [`contracts-hardhat`](https://github.com/semaphore-protocol/semaphore/tree/v3.15.2/packages/cli-template-contracts-hardhat), [`monorepo-ethers`](https://github.com/semaphore-protocol/semaphore/tree/v3.15.2/packages/cli-template-monorepo-ethers), [`monorepo-subgraph`](https://github.com/semaphore-protocol/semaphore/tree/v3.15.2/packages/cli-template-monorepo-subgraph).
:::
:::info
The [`semaphore CLI`](https://github.com/semaphore-protocol/semaphore/tree/main/packages/cli) can also be used to get group data from a supported network (e.g `semaphore get-groups --network arbitrum-goerli`).
The [`semaphore CLI`](https://github.com/semaphore-protocol/semaphore/tree/v3.15.2/packages/cli) can also be used to get group data from a supported network (e.g `semaphore get-groups --network arbitrum-goerli`).
:::
To start working on your project, install the dependencies:
@@ -293,7 +293,7 @@ In the project root folder:
</Tabs>
:::note
Check the Semaphore contract addresses [here](/deployed-contracts).
Check the Semaphore contract addresses [here](/V3/deployed-contracts).
:::
:::caution

View File

@@ -6,7 +6,7 @@ sidebar_position: 9
## Articles
[Community Proposal: Semaphore: Zero-Knowledge Signaling on Ethereum (Whitepaper v1)](https://docs.semaphore.pse.dev/whitepaper-v1.pdf) - Kobi Gurkan, Koh Wei Jie and Barry WhiteHat
[Community Proposal: Semaphore: Zero-Knowledge Signaling on Ethereum (Whitepaper v1)](https://semaphore.pse.dev/whitepaper-v1.pdf) - Kobi Gurkan, Koh Wei Jie and Barry WhiteHat
[To Mixers and Beyond: presenting Semaphore, a privacy gadget built on Ethereum](https://medium.com/coinmonks/to-mixers-and-beyond-presenting-semaphore-a-privacy-gadget-built-on-ethereum-4c8b00857c9b) - Koh Wei Jie

View File

@@ -6,7 +6,7 @@ sidebar_position: 6
[The Graph](https://thegraph.com/) is a protocol for indexing networks like Ethereum and IPFS.
Site owners publish _subgraphs_ that expose site data for anyone to query.
Semaphore's subgraph allows you to retrieve data from the [`Semaphore.sol`](https://github.com/semaphore-protocol/semaphore/blob/main/packages/contracts/Semaphore.sol) smart contract.
Semaphore's subgraph allows you to retrieve data from the [`Semaphore.sol`](https://github.com/semaphore-protocol/semaphore/blob/v3.15.2/packages/contracts/Semaphore.sol) smart contract.
:::tip
The Graph protocol uses the [GraphQL](https://graphql.org/) query language. For examples, see the [GraphQL API documentation](https://thegraph.com/docs/developer/graphql-api). Visit the [subgraph repository](https://github.com/semaphore-protocol/subgraph) to see the list of Semaphore subgraphs.

View File

@@ -4,13 +4,13 @@ sidebar_position: 2
# Circuits
The [Semaphore circuit](https://github.com/semaphore-protocol/semaphore/tree/main/packages/circuits) is the heart of the protocol and consists of three parts:
The [Semaphore circuit](https://github.com/semaphore-protocol/semaphore/tree/v3.15.2/packages/circuits) is the heart of the protocol and consists of three parts:
- [**Proof of membership**](/technical-reference/circuits#proof-of-membership)
- [**Nullifier hash**](/technical-reference/circuits#nullifier-hash)
- [**Signal**](/technical-reference/circuits#signal)
- [**Proof of membership**](/V3/technical-reference/circuits#proof-of-membership)
- [**Nullifier hash**](/V3/technical-reference/circuits#nullifier-hash)
- [**Signal**](/V3/technical-reference/circuits#signal)
![Semaphore circuit](https://github.com/semaphore-protocol/semaphore/raw/main/packages/circuits/scheme.png)
![Semaphore circuit](https://github.com/semaphore-protocol/semaphore/raw/v3.15.2/packages/circuits/scheme.png)
The diagram above shows how the input signals are used in the Semaphore circuit and how the outputs are calculated.

View File

@@ -6,25 +6,25 @@ sidebar_position: 3
Semaphore includes two types of contracts:
- [**Base contracts**](/technical-reference/contracts#base-contracts)
- [**Extension contracts**](/technical-reference/contracts#extension-contracts)
- [**Base contracts**](/V3/technical-reference/contracts#base-contracts)
- [**Extension contracts**](/V3/technical-reference/contracts#extension-contracts)
And [**Semaphore.sol**](/technical-reference/contracts#semaphoresol), the main contract deployed on the networks supported by Semaphore.
And [**Semaphore.sol**](/V3/technical-reference/contracts#semaphoresol), the main contract deployed on the networks supported by Semaphore.
:::info
To use Semaphore contracts and interfaces in your project,
install the [`@semaphore-protocol/contracts`](https://github.com/semaphore-protocol/semaphore/tree/main/packages/contracts) NPM package.
install the [`@semaphore-protocol/contracts`](https://github.com/semaphore-protocol/semaphore/tree/v3.15.2/packages/contracts) NPM package.
:::
## Base contracts
Semaphore provides the following base contracts:
- [`SemaphoreVerifier.sol`](https://github.com/semaphore-protocol/semaphore/blob/main/packages/contracts/contracts/base/SemaphoreVerifier.sol): contains a function to verify Semaphore proofs;
- [`SemaphoreGroups.sol`](https://github.com/semaphore-protocol/semaphore/blob/main/packages/contracts/contracts/base/SemaphoreGroups.sol): contains the functions to create groups and add/remove/update members.
- [`SemaphoreVerifier.sol`](https://github.com/semaphore-protocol/semaphore/blob/v3.15.2/packages/contracts/contracts/base/SemaphoreVerifier.sol): contains a function to verify Semaphore proofs;
- [`SemaphoreGroups.sol`](https://github.com/semaphore-protocol/semaphore/blob/v3.15.2/packages/contracts/contracts/base/SemaphoreGroups.sol): contains the functions to create groups and add/remove/update members.
These contracts are closely related to the protocol.
You can use them in your contract or you can use [**Semaphore.sol**](/technical-reference/contracts#semaphoresol), which integrates them for you.
You can use them in your contract or you can use [**Semaphore.sol**](/V3/technical-reference/contracts#semaphoresol), which integrates them for you.
:::info
While some DApps may use on-chain groups, others may prefer to use off-chain groups, saving only their tree roots in the contract.
@@ -32,20 +32,20 @@ While some DApps may use on-chain groups, others may prefer to use off-chain gro
## Extension contracts
- [`SemaphoreVoting.sol`](https://github.com/semaphore-protocol/semaphore/blob/main/packages/contracts/contracts/extensions/SemaphoreVoting.sol): voting contract that contains the essential functions to create polls, add voters, and anonymously cast votes;
- [`SemaphoreWhistleblowing.sol`](https://github.com/semaphore-protocol/semaphore/blob/main/packages/contracts/contracts/extensions/SemaphoreWhistleblowing.sol): whistleblowing contract that contains the essential functions to create entities (for example: non-profit organizations), add whistleblowers, and anonymously publish leaks.
- [`SemaphoreVoting.sol`](https://github.com/semaphore-protocol/semaphore/blob/v3.15.2/packages/contracts/contracts/extensions/SemaphoreVoting.sol): voting contract that contains the essential functions to create polls, add voters, and anonymously cast votes;
- [`SemaphoreWhistleblowing.sol`](https://github.com/semaphore-protocol/semaphore/blob/v3.15.2/packages/contracts/contracts/extensions/SemaphoreWhistleblowing.sol): whistleblowing contract that contains the essential functions to create entities (for example: non-profit organizations), add whistleblowers, and anonymously publish leaks.
These contracts extend the protocol to provide application logic for specific use-cases.
More extensions will be added in the future.
## Semaphore.sol
[`Semaphore.sol`](https://github.com/semaphore-protocol/semaphore/blob/main/packages/contracts/contracts/Semaphore.sol) is based on the base contracts. It integrates them and additionally provides:
[`Semaphore.sol`](https://github.com/semaphore-protocol/semaphore/blob/v3.15.2/packages/contracts/contracts/Semaphore.sol) is based on the base contracts. It integrates them and additionally provides:
- a system to allow only admins (i.e. Ethereum accounts or smart contracts) to manage groups;
- a mechanism to save the [nullifier hashes](/technical-reference/circuits#nullifier-hash) of each group and prevent double-signaling;
- a mechanism to save the [nullifier hashes](/V3/technical-reference/circuits#nullifier-hash) of each group and prevent double-signaling;
- a mechanism to allow Semaphore proofs generated with old Merkle roots to be verified for a certain period of time defined by the group admin.
:::info
See our [deployed contracts](/deployed-contracts) to find the addresses for your network.
See our [deployed contracts](/V3/deployed-contracts) to find the addresses for your network.
::::

View File

@@ -11,7 +11,7 @@ If these suggestions do not work, feel free to ask in the [Semaphore Discussions
## Using Semaphore in the frontend
Semaphore works with any JavaScript frontend framework, but the [`@semaphore-protocol/proof`](https://github.com/semaphore-protocol/semaphore/tree/main/packages/proof) package is using [snarkjs](https://github.com/iden3/snarkjs), which uses Node.js modules which are not compatible with frontend frameworks and there are some changes that we need to do to make it work on the client side.
Semaphore works with any JavaScript frontend framework, but the [`@semaphore-protocol/proof`](https://github.com/semaphore-protocol/semaphore/tree/v3.15.2/packages/proof) package is using [snarkjs](https://github.com/iden3/snarkjs), which uses Node.js modules which are not compatible with frontend frameworks and there are some changes that we need to do to make it work on the client side.
### Semaphore with Nextjs
@@ -229,10 +229,10 @@ Your `tsconfig.json` file would be something like this:
When you create a group and the transaction is reverted, make sure that the group id you are using does not exist on the network you are using.
To check that, you can use the [Semaphore CLI](https://github.com/semaphore-protocol/semaphore/tree/main/packages/cli) with the command `get-groups` and the network you are using and then, make sure that your group id is not part of that list. You can also use the [Semaphore explorer](https://explorer.semaphore.pse.dev/).
To check that, you can use the [Semaphore CLI](https://github.com/semaphore-protocol/semaphore/tree/v3.15.2/packages/cli) with the command `get-groups` and the network you are using and then, make sure that your group id is not part of that list. You can also use the [Semaphore explorer](https://explorer.semaphore.pse.dev/).
## Semaphore Proofs
### Transaction reverted when using the same external nullifier
When you generate a proof using the same external nullifier you used to verify a proof before, the transaction will be reverted because that external nullifier was already used. If you want to send and verify several proofs from the same identity, you should use a different external nullifier each time you generate a proof.
When you generate a proof using the same external nullifier you used to verify a proof before, the transaction will be reverted because that external nullifier was already used. If you want to send and verify several proofs from the same identity, you should use a different external nullifier each time you generate a proof.

View File

@@ -7,7 +7,7 @@ slug: /
## Overview
[Semaphore](https://github.com/semaphore-protocol/semaphore) is a [zero-knowledge](https://z.cash/technology/zksnarks) protocol that allows you to cast a signal (for example, a vote or endorsement) as a provable group member without revealing your identity.
[Semaphore](https://github.com/semaphore-protocol/semaphore/tree/v3.15.2) is a [zero-knowledge](https://z.cash/technology/zksnarks) protocol that allows you to cast a signal (for example, a vote or endorsement) as a provable group member without revealing your identity.
Additionally, it provides a simple mechanism to prevent double-signaling.
Use cases include private voting, whistleblowing, anonymous DAOs and mixers.
@@ -15,9 +15,9 @@ Use cases include private voting, whistleblowing, anonymous DAOs and mixers.
With Semaphore, you can allow your users to do the following:
1. [Create a Semaphore identity](/guides/identities/).
2. [Add their Semaphore identity to a group (i.e. _Merkle tree_)](/guides/groups/).
3. [Send a verifiable, anonymous signal (e.g a vote or endorsement)](/guides/proofs/).
1. [Create a Semaphore identity](/V3/guides/identities/).
2. [Add their Semaphore identity to a group (i.e. _Merkle tree_)](/V3/guides/groups/).
3. [Send a verifiable, anonymous signal (e.g a vote or endorsement)](/V3/guides/proofs/).
When a user broadcasts a signal (for example: a vote), Semaphore zero-knowledge
proofs can ensure that the user has joined the group and hasn't already cast a signal with their nullifier.
@@ -33,14 +33,14 @@ Semaphore is designed to be a simple and generic _privacy layer_ for decentraliz
## About the code
The core of the protocol is the [circuit logic](https://github.com/semaphore-protocol/semaphore/tree/main/packages/circuits/scheme.png).
The core of the protocol is the [circuit logic](https://github.com/semaphore-protocol/semaphore/tree/v3.15.2/packages/circuits/scheme.png).
In addition to circuits,
Semaphore provides [Solidity contracts](https://github.com/semaphore-protocol/semaphore/tree/main/packages/contracts)
and [JavaScript libraries](https://github.com/semaphore-protocol/semaphore#-packages) that allow developers to generate zero-knowledge proofs and verify them with minimal effort.
Semaphore provides [Solidity contracts](https://github.com/semaphore-protocol/semaphore/tree/v3.15.2/packages/contracts)
and [JavaScript libraries](https://github.com/semaphore-protocol/semaphore/tree/v3.15.2#-packages) that allow developers to generate zero-knowledge proofs and verify them with minimal effort.
### Trusted Setup Ceremony
The [secure parameters](/glossary#trusted-setup-files) for generating valid proofs with Semaphore circuits were generated in a [Trusted Setup Ceremony](https://storage.googleapis.com/trustedsetup-a86f4.appspot.com/semaphore/semaphore_top_index.html) that was completed with over 300 participants on [29 March 2022](https://etherscan.io/tx/0xec6dbe68883c7593c2bea82f55af18b3aeb5cc146e026d0083a9b3faa9aa0b65#eventlog).
The [secure parameters](/V3/glossary#trusted-setup-files) for generating valid proofs with Semaphore circuits were generated in a [Trusted Setup Ceremony](https://storage.googleapis.com/trustedsetup-a86f4.appspot.com/semaphore/semaphore_top_index.html) that was completed with over 300 participants on [29 March 2022](https://etherscan.io/tx/0xec6dbe68883c7593c2bea82f55af18b3aeb5cc146e026d0083a9b3faa9aa0b65#eventlog).
### Audits

View File

@@ -1,336 +0,0 @@
---
sidebar_position: 2
---
import Tabs from "@theme/Tabs"
import TabItem from "@theme/TabItem"
# Getting started
Semaphore provides an official CLI to set up your project with Hardhat. If your NPM version is 5.2 or higher you can use NPX:
```bash
npx @semaphore-protocol/cli create my-app --template monorepo-ethers
```
Otherwise, install `@semaphore-protocol/cli` globally and run the `create` command:
```bash
npm i -g @semaphore-protocol/cli
semaphore create my-app --template monorepo-ethers
```
:::info
The supported templates are: [`contracts-hardhat`](https://github.com/semaphore-protocol/semaphore/tree/feat/semaphore-v4/packages/cli-template-contracts-hardhat), [`monorepo-ethers`](https://github.com/semaphore-protocol/semaphore/tree/feat/semaphore-v4/packages/cli-template-monorepo-ethers), [`monorepo-subgraph`](https://github.com/semaphore-protocol/semaphore/tree/feat/semaphore-v4/packages/cli-template-monorepo-subgraph).
:::
:::info
The [`semaphore CLI`](https://github.com/semaphore-protocol/semaphore/tree/feat/semaphore-v4/packages/cli) can also be used to get group data from a supported network (e.g. `semaphore get-groups --network sepolia`).
:::
To start working on your project, install the dependencies:
<Tabs
defaultValue="npm"
groupId="package-managers"
values={[
{label: 'npm', value: 'npm'},
{label: 'Yarn', value: 'yarn'},
{label: 'pnpm', value: 'pnpm'}
]}>
<TabItem value="npm">
```bash
cd my-app
npm i
```
</TabItem>
<TabItem value="yarn">
```bash
cd my-app
yarn
```
</TabItem>
<TabItem value="pnpm">
```bash
cd my-app
pnpm install
```
</TabItem>
</Tabs>
## Output
The `create` command will create a directory called my-app (or whatever name you choose) inside the current folder. That directory will contain the initial project structure, which includes a simple contract, a task to deploy it, some tests and a Next.js application (the web-app folder) to interact with that contract.
```
my-app
├── .yarn
├── apps
│ └── contracts
│ │ └── contracts
| │ │ └── Feedback.sol
│ │ └── tasks
| │ │ └── deploy.ts
│ │ └── test
| │ │ └── Feedback.ts
│ │ └── hardhat.config.ts
│ │ └── package.json
│ │ └── tsconfig.json
│ └── web-app
├── .editorconfig
├── .env
├── .env.example
├── .eslintignore
├── .eslintrc.json
├── .gitignore
├── .prettierignore
├── .prettierrc.json
├── .yarnrc.yml
├── package.json
├── README.md
└── tsconfig.json
```
The `Feedback.sol` contract creates a Semaphore group, allows users to join that group with their Semaphore identity, and finally allows group members to send an anonymous feedback.
## Usage
### Compile contracts
Go to the `contracts` folder:
```bash
cd apps/contracts
```
And compile your contracts:
<Tabs
defaultValue="npm"
groupId="package-managers"
values={[
{label: 'npm', value: 'npm'},
{label: 'Yarn', value: 'yarn'},
{label: 'pnpm', value: 'pnpm'}
]}>
<TabItem value="npm">
```bash
npm run compile
```
</TabItem>
<TabItem value="yarn">
```bash
yarn compile
```
</TabItem>
<TabItem value="pnpm">
```bash
pnpm compile
```
</TabItem>
</Tabs>
### Test contracts
Test your contracts:
<Tabs
defaultValue="npm"
groupId="package-managers"
values={[
{label: 'npm', value: 'npm'},
{label: 'Yarn', value: 'yarn'},
{label: 'pnpm', value: 'pnpm'}
]}>
<TabItem value="npm">
```bash
npm test
```
</TabItem>
<TabItem value="yarn">
```bash
yarn test
```
</TabItem>
<TabItem value="pnpm">
```bash
pnpm test
```
</TabItem>
</Tabs>
Generate a test coverage report:
<Tabs
defaultValue="npm"
groupId="package-managers"
values={[
{label: 'npm', value: 'npm'},
{label: 'Yarn', value: 'yarn'},
{label: 'pnpm', value: 'pnpm'}
]}>
<TabItem value="npm">
```bash
npm run test:coverage
```
</TabItem>
<TabItem value="yarn">
```bash
yarn test:coverage
```
</TabItem>
<TabItem value="pnpm">
```bash
pnpm test:coverage
```
</TabItem>
</Tabs>
Or a test gas report:
<Tabs
defaultValue="npm"
groupId="package-managers"
values={[
{label: 'npm', value: 'npm'},
{label: 'Yarn', value: 'yarn'},
{label: 'pnpm', value: 'pnpm'}
]}>
<TabItem value="npm">
```bash
npm run test:report-gas
```
</TabItem>
<TabItem value="yarn">
```bash
yarn test:report-gas
```
</TabItem>
<TabItem value="pnpm">
```bash
pnpm test:report-gas
```
</TabItem>
</Tabs>
### Deploy contracts
Follow the instructions below to deploy your contracts:
In the project root folder:
1. Add your environment variables in the `.env` file.
:::note
You should at least set a valid Infura API Key (you could use Alchemy as well) and a private key with some ethers.
:::
2. Go to the `apps/contracts` folder and deploy your contract.
<Tabs
defaultValue="npm"
groupId="package-managers"
values={[
{label: 'npm', value: 'npm'},
{label: 'Yarn', value: 'yarn'},
{label: 'pnpm', value: 'pnpm'}
]}>
<TabItem value="npm">
```bash
npm run deploy -- --semaphore <semaphore-address> --group <group-id> --network sepolia
```
</TabItem>
<TabItem value="yarn">
```bash
yarn deploy --semaphore <semaphore-address> --group <group-id> --network sepolia
```
</TabItem>
<TabItem value="pnpm">
```bash
pnpm deploy --semaphore <semaphore-address> --group <group-id> --network sepolia
```
</TabItem>
</Tabs>
:::note
Check the Semaphore contract addresses [here](/V4-alpha/deployed-contracts).
:::
:::caution
The group id is a number.
:::
### Start app
Start the application:
<Tabs
defaultValue="npm"
groupId="package-managers"
values={[
{label: 'npm', value: 'npm'},
{label: 'Yarn', value: 'yarn'},
{label: 'pnpm', value: 'pnpm'}
]}>
<TabItem value="npm">
```bash
npm run dev
```
</TabItem>
<TabItem value="yarn">
```bash
yarn dev
```
</TabItem>
<TabItem value="pnpm">
```bash
pnpm dev
```
</TabItem>
</Tabs>
:::info
If you want to see the code of a comprehensive application built on top of Semaphore see the [boilerplate](https://github.com/semaphore-protocol/boilerplate/tree/version/4). For more info about the core libraries, keep reading the next guides.
:::

View File

@@ -1,20 +0,0 @@
---
sidebar_position: 9
---
import Tabs from "@theme/Tabs"
import TabItem from "@theme/TabItem"
# Troubleshooting
If these suggestions do not work, feel free to ask for more help and support on [Github Discussions](https://github.com/semaphore-protocol/semaphore/discussions) or [Discord](https://semaphore.pse.dev/discord) ("dev-chat" channel).
## Creating a Group
When you create a group and the transaction is reverted, make sure that the group id you are using does not exist on the network you are using.
To check that, you can use the [Semaphore CLI](https://github.com/semaphore-protocol/semaphore/tree/feat/semaphore-v4/packages/cli) with the command `get-groups` and the network you are using and then, make sure that your group id is not part of that list. You can also use the [Semaphore explorer](https://explorer.semaphore.pse.dev/).
## Transaction reverted when using the same nullifier
When you generate a proof using the same [scope](/V4-alpha/glossary#scope) you used to validate a proof before, the transaction will be reverted because that scope (and thus the [nullifier](/V4-alpha/glossary#nullifier)) has already been used. If you want to send and validate several proofs from the same identity, you need to use a different scope for each time you generate a proof.

View File

@@ -16,13 +16,13 @@ For example, in an anonymous voting application a valid proof could be reused to
## What is the difference between the "nullifier" and "scope"?
The [scope](/V4-alpha/glossary#scope) is used like a topic on which users can generate a valid proof only once. The scope is a public value and every one can see what the scope of a proof is.
The [scope](/glossary#scope) is used like a topic on which users can generate a valid proof only once. The scope is a public value and every one can see what the scope of a proof is.
The [nullifier](/V4-alpha/glossary#nullifier) is the hash of the private key of the identity and the scope, and it is used to check if the same proof with that specific scope has already been generated by the same user. The nullifier is also a public value and it is what is actually stored to prevent, for example, double-voting.
The [nullifier](/glossary#nullifier) is the hash of the private key of the identity and the scope, and it is used to check if the same proof with that specific scope has already been generated by the same user. The nullifier is also a public value and it is what is actually stored to prevent, for example, double-voting.
In the case of a voting application, if you have a group and you want all members of this group to vote only once, you can use the id of the group as the scope. When a user votes the first time, you can store the hash of voter's private key and the group id (i.e., the nullifier) and prevent double-voting by checking if that hash already exists.
See the [Semaphore circuits](/V4-alpha/technical-reference/circuits) for more technical information, or the [Semaphore boilerplate](https://github.com/semaphore-protocol/boilerplate/tree/version/4) for a real use-case.
See the [Semaphore circuits](/technical-reference/circuits) for more technical information, or the [Semaphore boilerplate](https://github.com/semaphore-protocol/boilerplate/tree/main) for a real use-case.
## Where can I find examples of applications using Semaphore?
@@ -30,7 +30,7 @@ You can find a complete list of applications that are using Semaphore on the [Se
## How can I start a project using Semaphore?
There are three ways you can start using Semaphore in your project: using the [CLI](https://github.com/semaphore-protocol/semaphore/tree/feat/semaphore-v4/packages/cli), using the [boilerplate](https://github.com/semaphore-protocol/boilerplate/tree/version/4) as a template or forking it, or installing the Semaphore [packages](/V4-alpha/guides/identities) manually.
There are three ways you can start using Semaphore in your project: using the [CLI](https://github.com/semaphore-protocol/semaphore/tree/main/packages/cli), using the [boilerplate](https://github.com/semaphore-protocol/boilerplate/tree/main) as a template or forking it, or installing the Semaphore [packages](/guides/identities) manually.
## How can I contribute to the protocol?

View File

@@ -0,0 +1,142 @@
---
sidebar_position: 2
---
# Getting started
Semaphore provides an official CLI to set up your project with Hardhat. If your NPM version is 5.2 or higher you can use NPX:
```bash
npx @semaphore-protocol/cli create my-app --template monorepo-ethers
```
Otherwise, install `@semaphore-protocol/cli` globally and run the `create` command:
```bash
npm i -g @semaphore-protocol/cli
semaphore create my-app --template monorepo-ethers
```
:::info
The supported templates are: [`contracts-hardhat`](https://github.com/semaphore-protocol/semaphore/tree/main/packages/cli-template-contracts-hardhat), [`monorepo-ethers`](https://github.com/semaphore-protocol/semaphore/tree/main/packages/cli-template-monorepo-ethers), [`monorepo-subgraph`](https://github.com/semaphore-protocol/semaphore/tree/main/packages/cli-template-monorepo-subgraph).
:::
:::info
The [`semaphore CLI`](https://github.com/semaphore-protocol/semaphore/tree/main/packages/cli) can also be used to get group data from a supported network (e.g. `semaphore get-groups --network sepolia`).
:::
To start working on your project, install the dependencies:
```bash
cd my-app
yarn
```
## Output
The `create` command will create a directory called my-app (or whatever name you choose) inside the current folder. That directory will contain the initial project structure, which includes a simple contract, a task to deploy it, some tests and a Next.js application (the web-app folder) to interact with that contract.
```
my-app
├── .yarn
├── apps
│ └── contracts
│ │ └── contracts
| │ │ └── Feedback.sol
│ │ └── tasks
| │ │ └── deploy.ts
│ │ └── test
| │ │ └── Feedback.ts
│ │ └── hardhat.config.ts
│ │ └── package.json
│ │ └── tsconfig.json
│ └── web-app
├── .editorconfig
├── .env
├── .env.example
├── .eslintignore
├── .eslintrc.json
├── .gitignore
├── .prettierignore
├── .prettierrc.json
├── .yarnrc.yml
├── package.json
├── README.md
└── tsconfig.json
```
The `Feedback.sol` contract creates a Semaphore group, allows users to join that group with their Semaphore identity, and finally allows group members to send an anonymous feedback.
## Usage
### Compile contracts
Go to the `contracts` folder:
```bash
cd apps/contracts
```
And compile your contracts:
```bash
yarn compile
```
### Test contracts
Test your contracts:
```bash
yarn test
```
Generate a test coverage report:
```bash
yarn test:coverage
```
Or a test gas report:
```bash
yarn test:report-gas
```
### Deploy contracts
Follow the instructions below to deploy your contracts:
In the project root folder:
1. Add your environment variables in the `.env` file.
:::note
You should at least set a valid Infura API Key (you could use Alchemy as well) and a private key with some ethers.
:::
2. Go to the `apps/contracts` folder and deploy your contract.
```bash
yarn deploy --semaphore <semaphore-address> --group <group-id> --network sepolia
```
:::note
Check the Semaphore contract addresses [here](/deployed-contracts).
:::
:::caution
The group id is a number.
:::
### Start app
Start the application:
```bash
yarn dev
```
:::info
If you want to see the code of a comprehensive application built on top of Semaphore see the [boilerplate](https://github.com/semaphore-protocol/boilerplate/tree/main). For more info about the core libraries, keep reading the next guides.
:::

View File

@@ -46,4 +46,4 @@ A trusted setup in the context of zero-knowledge proofs, particularly zk-SNARKs,
## Trusted setup files
The secure, verifiable parameters generated by Semaphore's trusted setup ceremony. Semaphore uses the trusted setup files to generate and verify valid zero-knowledge proofs. The [Semaphore circuit](/V4-alpha/technical-reference/circuits) includes a parameter to set the tree's maximum depth (MAX_DEPTH). During the trusted setup, parameters are specifically generated for each circuit instance, aligning with their designated MAX_DEPTH (from 1 to 32).
The secure, verifiable parameters generated by Semaphore's trusted setup ceremony. Semaphore uses the trusted setup files to generate and verify valid zero-knowledge proofs. The [Semaphore circuit](/technical-reference/circuits) includes a parameter to set the tree's maximum depth (MAX_DEPTH). During the trusted setup, parameters are specifically generated for each circuit instance, aligning with their designated MAX_DEPTH (from 1 to 32).

View File

@@ -8,7 +8,7 @@ import TabItem from "@theme/TabItem"
# Semaphore groups
A [Semaphore group](/V4-alpha/glossary/#group) contains [identity commitments](/V4-alpha/glossary/#commitment) of group members.
A [Semaphore group](/glossary/#group) contains [identity commitments](/glossary/#identity-commitment) of group members.
Example uses of groups include the following:
- poll question that attendees join to rate an event,
@@ -23,7 +23,7 @@ Merkle Tree) [Solidity](https://github.com/privacy-scaling-explorations/zk-kit/t
## Off-chain groups
Use the [`@semaphore-protocol/group`](https://github.com/semaphore-protocol/semaphore/blob/feat/semaphore-v4/packages/group) package to manage off-chain groups.
Use the [`@semaphore-protocol/group`](https://github.com/semaphore-protocol/semaphore/blob/main/packages/group) package to manage off-chain groups.
### Install package
@@ -58,6 +58,10 @@ pnpm add @semaphore-protocol/group
</TabItem>
</Tabs>
:::info
Semaphore also provides `@semaphore-protocol/core`, which includes the functions of the following core packages: `@semaphore-protocol/identity`, `@semaphore-protocol/group`, `@semaphore-protocol/proof`.
:::
### Create a group
To create a group instantiate `Group` without any parameters. For example:
@@ -72,9 +76,9 @@ You can also initialize a group with multiple members by passing the list of ide
```ts
const members = [
"11237622825477336339577122413451117718539783476837539122310492284566644730311",
"9332663527862709610616009715800254142772436825222910251631161087138559093425",
"13255821893820536903335282929376140649646180444238593676033702344407594536519"
11237622825477336339577122413451117718539783476837539122310492284566644730311n,
9332663527862709610616009715800254142772436825222910251631161087138559093425n,
13255821893820536903335282929376140649646180444238593676033702344407594536519n
]
const group2 = new Group(members)
@@ -113,7 +117,7 @@ group.removeMember(0)
To update members in a group, pass the member index and the new value to the `updateMember` method. For example:
```ts
group.updateMember(0, 2)
group.updateMember(0, 2n)
```
:::caution
@@ -123,7 +127,7 @@ Given that the member isn't removed, the number of members (i.e., `group.size` o
### Generate a Merkle proof
Semaphore groups are [Merkle trees](/V4-alpha/glossary#merkle-tree), and it is therefore possible to calculate the Merkle proof of a group member (i.e., tree leaf) by passing the index of the member to the `generateMerkleProof`. For example:
Semaphore groups are [Merkle trees](/glossary#merkle-tree), and it is therefore possible to calculate the Merkle proof of a group member (i.e., tree leaf) by passing the index of the member to the `generateMerkleProof`. For example:
```ts
group.generateMerkleProof(0)
@@ -131,9 +135,9 @@ group.generateMerkleProof(0)
## On-chain groups
Semaphore provides [`Semaphore.sol`](https://github.com/semaphore-protocol/semaphore/blob/feat/semaphore-v4/packages/contracts/contracts/Semaphore.sol), a contract designed for managing on-chain groups ([deployed](/V4-alpha/deployed-contracts) on major testnets).
Semaphore provides [`Semaphore.sol`](https://github.com/semaphore-protocol/semaphore/blob/main/packages/contracts/contracts/Semaphore.sol), a contract designed for managing on-chain groups ([deployed](/deployed-contracts) on major testnets).
Use the [`@semaphore-protocol/contracts`](https://github.com/semaphore-protocol/semaphore/blob/feat/semaphore-v4/packages/contracts) package to import the `ISemaphore.sol` interface in your contract and start using its functions.
Use the [`@semaphore-protocol/contracts`](https://github.com/semaphore-protocol/semaphore/blob/main/packages/contracts) package to import the `ISemaphore.sol` interface in your contract and start using its functions.
### Install package
@@ -235,6 +239,6 @@ function removeMember(uint256 identityCommitment, uint256[] calldata merkleProof
```
:::info
If you want to see an example of a working contract, have a look at the [`contracts-hardhat`](https://github.com/semaphore-protocol/semaphore/tree/feat/semaphore-v4/packages/cli-template-contracts-hardhat) CLI template. You can also create a project with that template by running `semaphore create my-app --template contracts-hardhat`.
If you want to see an example of a working contract, have a look at the [`contracts-hardhat`](https://github.com/semaphore-protocol/semaphore/tree/main/packages/cli-template-contracts-hardhat) CLI template. You can also create a project with that template by running `semaphore create my-app --template contracts-hardhat`.
:::

View File

@@ -8,7 +8,7 @@ import TabItem from "@theme/TabItem"
# Semaphore identities
In order to join a [Semaphore group](/V4-alpha/glossary#group), a user must first create a [Semaphore identity](/V4-alpha/glossary#identity).
In order to join a [Semaphore group](/glossary#group), a user must first create a [Semaphore identity](/glossary#identity).
A Semaphore identity contains three values generated with the identity:
- Private key
@@ -20,7 +20,7 @@ To prevent fraud, the owner should keep their private key secret.
## Install package
In your code, use the [`@semaphore-protocol/identity`](https://github.com/semaphore-protocol/semaphore/tree/feat/semaphore-v4/packages/identity) package to manage Semaphore identites.
In your code, use the [`@semaphore-protocol/identity`](https://github.com/semaphore-protocol/semaphore/tree/main/packages/identity) package to manage Semaphore identites.
<Tabs
defaultValue="npm"
@@ -53,6 +53,10 @@ pnpm add @semaphore-protocol/identity
</TabItem>
</Tabs>
:::info
Semaphore also provides `@semaphore-protocol/core`, which includes the functions of the following core packages: `@semaphore-protocol/identity`, `@semaphore-protocol/group`, `@semaphore-protocol/proof`.
:::
## Create identities
### Create random identities

View File

@@ -8,16 +8,16 @@ import TabItem from "@theme/TabItem"
# Semaphore proofs
Once a user joins a [Semaphore group](/V4-alpha/glossary#group) with their [Semaphore identity](/V4-alpha/glossary#identity), the user can send their anonymous [message](/V4-alpha/glossary#message) with a zero-knowledge proof that proves the following:
Once a user joins a [Semaphore group](/glossary#group) with their [Semaphore identity](/glossary#identity), the user can send their anonymous [message](/glossary#message) with a zero-knowledge proof that proves the following:
- the user is a member of the group,
- the same user created the message and the proof.
A unique [nullifier](/V4-alpha/glossary#nullifier) is also generated for each proof that can be used to check whether that proof has already been validated.
A unique [nullifier](/glossary#nullifier) is also generated for each proof that can be used to check whether that proof has already been validated.
## Install package
In your code, use the [`@semaphore-protocol/proof`](https://github.com/semaphore-protocol/semaphore/tree/feat/semaphore-v4/packages/proof) package to generate and verify a proof.
In your code, use the [`@semaphore-protocol/proof`](https://github.com/semaphore-protocol/semaphore/tree/main/packages/proof) package to generate and verify a proof.
<Tabs
defaultValue="npm"
@@ -50,18 +50,22 @@ pnpm add @semaphore-protocol/proof
</TabItem>
</Tabs>
:::info
Semaphore also provides `@semaphore-protocol/core`, which includes the functions of the following core packages: `@semaphore-protocol/identity`, `@semaphore-protocol/group`, `@semaphore-protocol/proof`.
:::
## Generate a proof
### 1. Create the identity
In order for a user to generate a proof, it is necessary to create a Semaphore identity. If you do not know how to
create an identity, see the previous [guide](/V4-alpha/guides/identities) on identities.
create an identity, see the previous [guide](/guides/identities) on identities.
### 2. Create the group
Before generating a proof you also need to create a Semaphore group containing the commitment of the Semaphore identity of the user who will generate the proof. If you do not know how to create a group, see the previous [guide](/V4-alpha/guides/groups) on groups.
Before generating a proof you also need to create a Semaphore group containing the commitment of the Semaphore identity of the user who will generate the proof. If you do not know how to create a group, see the previous [guide](/guides/groups) on groups.
If your group is on-chain, you can use the [`@semaphore-protocol/data`](https://github.com/semaphore-protocol/semaphore/tree/feat/semaphore-v4/packages/data) library to fetch the group members and re-create the off-chain group. For example:
If your group is on-chain, you can use the [`@semaphore-protocol/data`](https://github.com/semaphore-protocol/semaphore/tree/main/packages/data) library to fetch the group members and re-create the off-chain group. For example:
```ts
import { SemaphoreSubgraph } from "@semaphore-protocol/data"
@@ -76,7 +80,7 @@ const group = new Group(members)
### 3. Choose the scope
Each proof requires a [scope](/V4-alpha/glossary#scope), on which each user may only generate one valid proof. The scope, together with the user's private key, is used to generate the nullifier, which is the value you can actually use to check whether a proof with that scope has already been generated by that user. In a voting application where double-voting must be prevented, the scope could be the ballot id, or the Merkle root of the group.
Each proof requires a [scope](/glossary#scope), on which each user may only generate one valid proof. The scope, together with the user's private key, is used to generate the nullifier, which is the value you can actually use to check whether a proof with that scope has already been generated by that user. In a voting application where double-voting must be prevented, the scope could be the ballot id, or the Merkle root of the group.
### 4. Generate the anomymous message
@@ -88,7 +92,7 @@ import { generateProof } from "@semaphore-protocol/proof"
const scope = group.root
const message = 1
const proof = await generateProof(identity, group, externalNullifier, message)
const proof = await generateProof(identity, group, message, scope)
```
## Verify a proof
@@ -101,7 +105,7 @@ import { verifyProof } from "@semaphore-protocol/proof"
await verifyProof(proof) // true or false.
```
If you want to validate a proof on-chain, you can use [`@semaphore-protocol/contracts`](https://github.com/semaphore-protocol/semaphore/blob/feat/semaphore-v4/packages/contracts) and the [`Semaphore.sol`](https://github.com/semaphore-protocol/semaphore/blob/feat/semaphore-v4/packages/contracts/contracts/Semaphore.sol) contract, as explained in the previous [guide](/V4-alpha/guides/groups#install-package-1), and use the `validateProof` function. For example:
If you want to validate a proof on-chain, you can use [`@semaphore-protocol/contracts`](https://github.com/semaphore-protocol/semaphore/blob/main/packages/contracts) and the [`Semaphore.sol`](https://github.com/semaphore-protocol/semaphore/blob/main/packages/contracts/contracts/Semaphore.sol) contract, as explained in the previous [guide](/guides/groups#install-package-1), and use the `validateProof` function. For example:
```solidity
function validateProof(ISemaphore.SemaphoreProof calldata proof) external {

View File

@@ -8,13 +8,13 @@ import RemoteCode from '@site/src/components/RemoteCode';
[The Graph](https://thegraph.com/) is a protocol for indexing networks like Ethereum and IPFS.
Site owners publish _subgraphs_ that expose site data for anyone to query.
Semaphore's subgraph allows you to retrieve data from the [`Semaphore.sol`](https://github.com/semaphore-protocol/semaphore/blob/feat/semaphore-v4/packages/contracts/contracts/Semaphore.sol) smart contract.
Semaphore's subgraph allows you to retrieve data from the [`Semaphore.sol`](https://github.com/semaphore-protocol/semaphore/blob/main/packages/contracts/contracts/Semaphore.sol) smart contract.
:::tip
The Graph protocol uses the [GraphQL](https://graphql.org/) query language. For examples, see the [GraphQL API documentation](https://thegraph.com/docs/developer/graphql-api). Visit the [Semaphore subgraph](https://github.com/semaphore-protocol/semaphore/tree/feat/semaphore-v4/apps/subgraph) to see the list of networks supported by Semaphore and its URLs.
The Graph protocol uses the [GraphQL](https://graphql.org/) query language. For examples, see the [GraphQL API documentation](https://thegraph.com/docs/developer/graphql-api). Visit the [Semaphore subgraph](https://github.com/semaphore-protocol/semaphore/tree/main/apps/subgraph) to see the list of networks supported by Semaphore and its URLs.
:::
## Schema
<RemoteCode url="https://raw.githubusercontent.com/semaphore-protocol/semaphore/feat/semaphore-v4/apps/subgraph/schema.graphql"
<RemoteCode url="https://raw.githubusercontent.com/semaphore-protocol/semaphore/main/apps/subgraph/schema.graphql"
title="apps/subgraph/schema.graphql" language="graphql" />

View File

@@ -4,13 +4,13 @@ sidebar_position: 2
# Circuits
The [Semaphore circuit](https://github.com/semaphore-protocol/semaphore/tree/feat/semaphore-v4/packages/circuits/semaphore.circom) is the heart of the protocol and consists of three parts:
The [Semaphore circuit](https://github.com/semaphore-protocol/semaphore/tree/main/packages/circuits/semaphore.circom) is the heart of the protocol and consists of three parts:
- [Proof of membership](#proof-of-membership)
- [Nullifier](#nullifier)
- [Message](#message)
![Semaphore circuit](https://github.com/semaphore-protocol/semaphore/raw/feat/semaphore-v4/packages/circuits/scheme.png)
![Semaphore circuit](https://github.com/semaphore-protocol/semaphore/raw/main/packages/circuits/scheme.png)
The diagram above shows how the input signals are used in the Semaphore circuit and how the outputs are calculated.

View File

@@ -7,20 +7,20 @@ sidebar_position: 3
Semaphore contracts are designed with minimal yet essential code, enabling developers to efficiently manage on-chain groups and verify or validate zero-knowledge proofs.
There are three contracts:
- [`SemaphoreVerifier.sol`](https://github.com/semaphore-protocol/semaphore/blob/feat/semaphore-v4/packages/contracts/contracts/base/SemaphoreVerifier.sol)
- [`SemaphoreGroups.sol`](https://github.com/semaphore-protocol/semaphore/blob/feat/semaphore-v4/packages/contracts/contracts/base/SemaphoreGroups.sol)
- [`Semaphore.sol`](https://github.com/semaphore-protocol/semaphore/blob/feat/semaphore-v4/packages/contracts/contracts/Semaphore.sol)
- [`SemaphoreVerifier.sol`](https://github.com/semaphore-protocol/semaphore/blob/main/packages/contracts/contracts/base/SemaphoreVerifier.sol)
- [`SemaphoreGroups.sol`](https://github.com/semaphore-protocol/semaphore/blob/main/packages/contracts/contracts/base/SemaphoreGroups.sol)
- [`Semaphore.sol`](https://github.com/semaphore-protocol/semaphore/blob/main/packages/contracts/contracts/Semaphore.sol)
:::info
To use Semaphore contracts and interfaces in your project,
install the [`@semaphore-protocol/contracts`](https://github.com/semaphore-protocol/semaphore/tree/feat/semaphore-v4/packages/contracts) NPM package.
install the [`@semaphore-protocol/contracts`](https://github.com/semaphore-protocol/semaphore/tree/main/packages/contracts) NPM package.
:::
## SemaphoreVerifier.sol
`SemaphoreVerifier.sol` is an extended version of the Groth16 verifier generated by default with [SnarkJS](https://github.com/iden3/snarkjs). It contains a function for verifying proofs and a list of verification keys parameters.
Since the Semaphore circuit is compiled with a `MAX_DEPTH` range from 1 to 32 during the [trusted setup](/V4-alpha/glossary#trusted-setup), the verifier must contain the parameters of the verification keys of each instance.
Since the Semaphore circuit is compiled with a `MAX_DEPTH` range from 1 to 32 during the [trusted setup](/glossary#trusted-setup), the verifier must contain the parameters of the verification keys of each instance.
## SemaphoreGroups.sol
@@ -37,5 +37,5 @@ The `verifyProof` function contains code for checking whether a Semaphore proof
The `validateProof` function first checks whether a proof with the same nullifier has already been validated, and then verifies the proof with the `verifyProof` function and saves the nullifier. This function also creates a log with the group id and the proof, which can then additionally be verified off-chain.
:::info
Semaphore contracts are deployed on the main testnets and Arbitrum One. See the [deployed contracts](/V4-alpha/deployed-contracts) to check the addresses.
Semaphore contracts are deployed on the main testnets and Arbitrum One. See the [deployed contracts](/deployed-contracts) to check the addresses.
::::

View File

@@ -0,0 +1,20 @@
---
sidebar_position: 9
---
import Tabs from "@theme/Tabs"
import TabItem from "@theme/TabItem"
# Troubleshooting
If these suggestions do not work, feel free to ask for more help and support on [Github Discussions](https://github.com/semaphore-protocol/semaphore/discussions) or [Discord](https://semaphore.pse.dev/discord) ("dev-chat" channel).
## Creating a Group
When you create a group and the transaction is reverted, make sure that the group id you are using does not exist on the network you are using.
To check that, you can use the [Semaphore CLI](https://github.com/semaphore-protocol/semaphore/tree/main/packages/cli) with the command `get-groups` and the network you are using and then, make sure that your group id is not part of that list. You can also use the [Semaphore explorer](https://explorer.semaphore.pse.dev/).
## Transaction reverted when using the same nullifier
When you generate a proof using the same [scope](/glossary#scope) you used to validate a proof before, the transaction will be reverted because that scope (and thus the [nullifier](/glossary#nullifier)) has already been used. If you want to send and validate several proofs from the same identity, you need to use a different scope for each time you generate a proof.

View File

@@ -7,7 +7,7 @@ slug: /
## Overview
[Semaphore](https://github.com/semaphore-protocol/semaphore/tree/feat/semaphore-v4) is a [zero-knowledge](https://z.cash/technology/zksnarks) protocol that allows you to cast a message (for example, a vote or endorsement) as a provable group member without revealing your identity.
[Semaphore](https://github.com/semaphore-protocol/semaphore/tree/main) is a [zero-knowledge](https://z.cash/technology/zksnarks) protocol that allows you to cast a message (for example, a vote or endorsement) as a provable group member without revealing your identity.
Additionally, it provides a simple mechanism to prevent double-signaling.
Use cases include private voting, whistleblowing, anonymous DAOs and mixers.
@@ -15,9 +15,9 @@ Use cases include private voting, whistleblowing, anonymous DAOs and mixers.
With Semaphore, you can allow your users to do the following:
1. [Create a Semaphore identity](/V4-alpha/guides/identities/).
2. [Add their Semaphore identity to a group (i.e. _Merkle tree_)](/V4-alpha/guides/groups/).
3. [Send a verifiable, anonymous message (e.g a vote or endorsement)](/V4-alpha/guides/proofs/).
1. [Create a Semaphore identity](/guides/identities/).
2. [Add their Semaphore identity to a group (i.e. _Merkle tree_)](/guides/groups/).
3. [Send a verifiable, anonymous message (e.g a vote or endorsement)](/guides/proofs/).
When a user broadcasts a message, Semaphore zero-knowledge
proofs can ensure that the user has joined the group and hasn't already cast a message with their nullifier.
@@ -33,10 +33,10 @@ Semaphore is designed to be a simple and generic _privacy layer_ for decentraliz
## About the code
The core of the protocol is the [circuit logic](https://github.com/semaphore-protocol/semaphore/tree/feat/semaphore-v4/packages/circuits/semaphore.circom).
The core of the protocol is the [circuit logic](https://github.com/semaphore-protocol/semaphore/tree/main/packages/circuits/semaphore.circom).
In addition to circuits,
Semaphore provides [Solidity contracts](https://github.com/semaphore-protocol/semaphore/tree/feat/semaphore-v4/packages/contracts)
and [JavaScript libraries](https://github.com/semaphore-protocol/semaphore/tree/feat/semaphore-v4#-packages) that allow developers to generate zero-knowledge proofs and verify them with minimal effort.
Semaphore provides [Solidity contracts](https://github.com/semaphore-protocol/semaphore/tree/main/packages/contracts)
and [JavaScript libraries](https://github.com/semaphore-protocol/semaphore/tree/main#-packages) that allow developers to generate zero-knowledge proofs and verify them with minimal effort.
### Audits

View File

@@ -1 +1 @@
["V4-alpha", "V3", "V2", "V1"]
["V4-beta", "V3", "V2", "V1"]

View File

@@ -42,13 +42,14 @@
## Networks
| Semaphore version | Sepolia | Mumbai | Optimism Sepolia | Arbitrum Sepolia | Arbitrum One |
| ----------------- | ----------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- | ---------------- | ---------------- | --------------------------------------------------------------------------------------------------------------------- |
| v2.0 | N/A | N/A | N/A | N/A | [semaphore-protocol/arbitrum](https://thegraph.com/hosted-service/subgraph/semaphore-protocol/arbitrum) |
| v2.5 | N/A | N/A | N/A | N/A | N/A |
| v2.6 | N/A | N/A | N/A | N/A | [semaphore-protocol/arbitrum-86337c](https://thegraph.com/hosted-service/subgraph/semaphore-protocol/arbitrum-86337c) |
| v3.0 - v3.1 | N/A | N/A | N/A | N/A | [semaphore-protocol/arbitrum-72dca3](https://thegraph.com/hosted-service/subgraph/semaphore-protocol/arbitrum-72dca3) |
| >= v3.2 | [semaphore-sepolia](https://api.studio.thegraph.com/query/14377/semaphore-sepolia/v3.6.1) | [semaphore-mumbai](https://api.studio.thegraph.com/query/14377/semaphore-mumbai/v3.6.1) | N/A | N/A | [semaphore-arbitrum](https://api.studio.thegraph.com/query/14377/semaphore-arbitrum/v3.6.1) |
| Semaphore version | Sepolia | Mumbai | Optimism Sepolia | Arbitrum Sepolia | Arbitrum One |
| ----------------- | ---------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------- |
| v2.0 | N/A | N/A | N/A | N/A | [semaphore-protocol/arbitrum](https://thegraph.com/hosted-service/subgraph/semaphore-protocol/arbitrum) |
| v2.5 | N/A | N/A | N/A | N/A | N/A |
| v2.6 | N/A | N/A | N/A | N/A | [semaphore-protocol/arbitrum-86337c](https://thegraph.com/hosted-service/subgraph/semaphore-protocol/arbitrum-86337c) |
| v3.0 - v3.1 | N/A | N/A | N/A | N/A | [semaphore-protocol/arbitrum-72dca3](https://thegraph.com/hosted-service/subgraph/semaphore-protocol/arbitrum-72dca3) |
| >= v3.2 | [semaphore-sepolia](https://api.studio.thegraph.com/query/14377/semaphore-sepolia/v3.6.1) | [semaphore-mumbai](https://api.studio.thegraph.com/query/14377/semaphore-mumbai/v3.6.1) | N/A | N/A | [semaphore-arbitrum](https://api.studio.thegraph.com/query/14377/semaphore-arbitrum/v3.6.1) |
| >= v4.0.0-beta | [semaphore-sepolia](https://api.studio.thegraph.com/query/14377/semaphore-sepolia/v4.0.0-beta) | [semaphore-matic-mumbai](https://api.studio.thegraph.com/query/14377/semaphore-matic-mumbai/v4.0.0-beta) | [semaphore-optimism-sepolia](https://api.studio.thegraph.com/query/14377/semaphore-optimism-sepolia/v4.0.0-beta) | [semaphore-arbitrum-sepolia](https://api.studio.thegraph.com/query/14377/semaphore-arbitrum-sepolia/v4.0.0-beta) | N/A |
## 🛠 Install

File diff suppressed because one or more lines are too long

View File

@@ -1,38 +0,0 @@
{
"sepolia": {
"Semaphore": {
"address": "0x5B8e7cC7bAC61A4b952d472b67056B2f260ba6dc",
"startBlock": 5150903
}
},
"mumbai": {
"Semaphore": {
"address": "",
"startBlock": 0
}
},
"optimism-sepolia": {
"Semaphore": {
"address": "",
"startBlock": 0
}
},
"arbitrum-sepolia": {
"Semaphore": {
"address": "",
"startBlock": 0
}
},
"arbitrum-one": {
"Semaphore": {
"address": "",
"startBlock": 0
}
},
"localhost": {
"Semaphore": {
"address": "0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0",
"startBlock": 0
}
}
}

View File

@@ -17,7 +17,8 @@
},
"dependencies": {
"@graphprotocol/graph-cli": "0.67.0",
"@graphprotocol/graph-ts": "0.32.0"
"@graphprotocol/graph-ts": "0.32.0",
"@semaphore-protocol/utils": "workspace:packages/utils"
},
"devDependencies": {
"@types/mustache": "^4.2.2",

View File

@@ -1,10 +1,11 @@
import Mustache from "mustache"
import { getDeployedContract } from "@semaphore-protocol/utils"
import { readFileSync, writeFileSync } from "fs"
import Mustache from "mustache"
const network = process.argv.at(2)
const template = readFileSync("./subgraph.template.yaml", "utf-8")
const networks = JSON.parse(readFileSync("./networks.json", "utf-8"))
const subgraph = Mustache.render(template, { network, ...networks[network].Semaphore })
const subgraph = Mustache.render(template, { network, ...getDeployedContract(network) })
writeFileSync("./subgraph.yaml", subgraph)

View File

@@ -95,27 +95,32 @@ export default function Learn() {
{
title: "Semaphore identities",
description:
"Given to all Semaphore group members, it is comprised of three parts - identity commitment, trapdoor, and nullifier.",
"A Semaphore identity is an EdDSA key-pair plus the commitment (i.e. the hash of the public key), which is used as the public value of the Semaphore group members.",
linkText: "Create Semaphore identities",
linkUrl: "https://docs.semaphore.pse.dev/guides/identities",
codeText: `import { Identity } from "@semaphore-protocol/identity"
const { trapdoor, nullifier, commitment } = new Identity()`,
// Random identity.
const identity1 = new Identity()
// Passing a secret.
const identity2 = new Identity("secret")
`,
itemList: [
{
icon: <IconEyelash w="24px" h="24px" color="primary.600" />,
heading: "Private values",
body: "Trapdoor and nullifier values are the private values of the Semaphore identity. To avoid fraud, the owner must keep both values secret."
heading: "Private value",
body: "The private key is a secret that identity owners must keep private. It can either be generated randomly or passed as a parameter."
},
{
icon: <IconEye w="24px" h="24px" color="primary.600" />,
heading: "Public values",
body: "Semaphore uses the Poseidon hash function to create the identity commitment from the identity private values. Identity commitments can be made public, similarly to Ethereum addresses."
body: "Semaphore uses the Poseidon hash function to derive the identity commitment from the identity public key. Identity commitments can be made public, similarly to Ethereum addresses."
},
{
icon: <IconUser w="24px" h="24px" color="primary.600" />,
heading: "Generate identities",
body: "Semaphore identities can be generated deterministically or randomly. Deterministic identities can be generated from the hash of a secret message."
heading: "Storing identities",
body: "Building a system to save or recover secret values of Semaphore identities is nontrivial. You may choose to delegate such functionality, for example by using a signature as a secret."
}
]
},
@@ -127,45 +132,41 @@ const { trapdoor, nullifier, commitment } = new Identity()`,
linkUrl: "https://docs.semaphore.pse.dev/guides/groups",
codeText: `import { Group } from "@semaphore-protocol/group"
const group = new Group(1)
const members = [identity1.commitment, identity2.commitment]
group.addMember(commitment)`,
const group = new Group(members)
`,
itemList: [
{
icon: <IconTree w="24px" h="24px" color="primary.600" />,
heading: "Merkle trees",
body: "Each leaf contains an identity commitment for a user. The identity commitment proves that the user is a group member without revealing the private identity of the user."
body: "Each leaf contains an identity commitment for a user. The structure of Merkle trees ensures that it can be efficiently proved that an identity commitment is a member of the group."
},
{
icon: <IconGroup w="24px" h="24px" color="primary.600" />,
heading: "Types of groups",
body: "Groups can be created and managed in a decentralized fashion with Semaphore contracts or off-chain with our JavaScript libraries."
body: "Groups can be created and managed in a decentralized fashion with Semaphore contracts or off-chain with the JavaScript libraries."
},
{
icon: <IconManageUsers w="24px" h="24px" color="primary.600" />,
heading: "Group management",
body: "Users can join and leave groups by themselves, or an admin can add and remove them. Admins can be centralized authorities, Ethereum accounts, multi-sig wallets or smart contracts."
body: "Users could join and leave groups by themselves, or an admin could add and remove them. Admins can be centralized authorities, Ethereum accounts, multi-sig wallets or smart contracts."
}
]
},
{
title: "Semaphore proofs",
description:
"Semaphore group members can anonymously prove that they are part of a group and that they are generating their own proofs and signals.",
description: "Semaphore group members can prove that they are part of a group and send anonymous messages.",
linkText: "Generate Semaphore proofs",
linkUrl: "https://docs.semaphore.pse.dev/guides/proofs",
codeText: `import { generateProof, verifyProof } from "@semaphore-protocol/proof"
import { utils } from "ethers"
const externalNullifier = utils.formatBytes32String("Topic")
const signal = utils.formatBytes32String("Hello world")
const scope = "Semaphore"
const message = "Hello world"
const fullProof = await generateProof(identity, group, externalNullifier, signal, {
zkeyFilePath: "./semaphore.zkey",
wasmFilePath: "./semaphore.wasm"
})
const proof = await generateProof(identity1, group, scope, message)
await verifyProof(fullProof, group.depth)`,
await verifyProof(proof)`,
itemList: [
{
icon: <IconBadge w="24px" h="24px" color="primary.600" />,
@@ -174,13 +175,13 @@ await verifyProof(fullProof, group.depth)`,
},
{
icon: <IconFlag w="24px" h="24px" color="primary.600" />,
heading: "Signals",
body: "Group users can anonymously broadcast signals such as votes or endorsements without revealing their original identity."
heading: "Messages",
body: "Group users can anonymously share messages such as votes or endorsements without revealing their original identity."
},
{
icon: <IconCheck w="24px" h="24px" color="primary.600" />,
heading: "Verifiers",
body: "Semaphore proofs can be verified with our contracts or off-chain with our JavaScript libraries."
heading: "Proof verification",
body: "Semaphore proofs can be verified both on-chain with the Semaphore contracts, or off-chain with the JavaScript libraries."
}
]
}

View File

@@ -45,7 +45,7 @@ export default function Home() {
</VStack>
<Stack direction={{ base: "column", sm: "row" }} spacing="6" align="center">
<Link href="https://docs.semaphore.pse.dev/quick-setup" isExternal>
<Link href="https://docs.semaphore.pse.dev/getting-started" isExternal>
<Button size={{ base: "md", md: "lg" }}>Get Started</Button>
</Link>
<Link href="https://demo.semaphore.pse.dev" isExternal>

View File

@@ -13,7 +13,8 @@ const projects: any = fs
displayName: name,
setupFiles: ["dotenv/config"],
moduleNameMapper: {
"@semaphore-protocol/(.*)": "<rootDir>/../$1/src/index.ts" // Interdependency packages.
"@semaphore-protocol/(.*)/(.*)": "<rootDir>/../$1/src/$2",
"@semaphore-protocol/(.*)": "<rootDir>/../$1/src"
}
}))

View File

@@ -7,11 +7,13 @@
"bugs": "https://github.com/semaphore-protocol/semaphore/issues",
"private": true,
"scripts": {
"build:libraries": "yarn workspaces foreach -t --no-private run build",
"build": "yarn build:libraries && yarn build:subgraph",
"build:libraries": "yarn workspaces foreach -A -t --no-private run build",
"build:subgraph": "yarn workspace semaphore-subgraph codegen sepolia && yarn workspace semaphore-subgraph build",
"compile:contracts": "yarn workspace semaphore-contracts compile",
"test": "yarn test:libraries && yarn test:contracts && yarn test:circuits && yarn test:subgraph",
"test:libraries": "jest --coverage",
"test:library": "jest packages/${0}",
"test:subgraph": "yarn workspace semaphore-subgraph test",
"test:contracts": "yarn workspace semaphore-contracts test:coverage",
"test:circuits": "yarn workspace @semaphore-protocol/circuits test",
@@ -19,12 +21,12 @@
"prettier": "prettier -c .",
"prettier:write": "prettier -w .",
"docs": "typedoc --cname js.semaphore.pse.dev --githubPages true",
"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 clean:cli-templates && yarn workspaces foreach --no-private npm publish --tolerate-republish --access public",
"version:bump": "yarn workspaces foreach -A --no-private version -d ${0} && yarn version apply --all && yarn remove:stable-version-field && NO_HOOK=1 git commit -am \"chore: v${0}\" && git tag v${0}",
"version:publish": "yarn build:libraries && yarn clean:cli-templates && yarn workspaces foreach -A --no-private npm publish --tolerate-republish --access public",
"version:release": "changelogithub",
"clean": "ts-node scripts/clean-apps.ts && ts-node scripts/clean-packages.ts && yarn clean:cli-templates && rimraf node_modules",
"clean:cli-templates": "ts-node scripts/clean-cli-templates.ts",
"commit": "cz",
"remove:stable-version-field": "ts-node scripts/remove-stable-version-field.ts && yarn prettier:write",
"precommit": "lint-staged",
"postinstall": "husky install"
},
@@ -46,49 +48,44 @@
"packages/*",
"packages/contracts/contracts"
],
"packageManager": "yarn@3.2.1",
"packageManager": "yarn@4.1.0",
"devDependencies": {
"@commitlint/cli": "^16.0.2",
"@commitlint/config-conventional": "^16.0.0",
"@rollup/plugin-typescript": "^11.1.6",
"@types/circomlibjs": "^0.1.4",
"@types/download": "^8.0.1",
"@commitlint/cli": "^18.6.1",
"@commitlint/config-conventional": "^18.6.2",
"@types/glob": "^7.2.0",
"@types/jest": "^29.5.12",
"@types/node": "^20",
"@types/rimraf": "^3.0.2",
"@typescript-eslint/eslint-plugin": "^5.9.1",
"@typescript-eslint/parser": "^5.9.1",
"@typescript-eslint/eslint-plugin": "^7.0.2",
"@typescript-eslint/parser": "^7.0.2",
"changelogithub": "0.12.7",
"commitizen": "^4.2.4",
"cz-conventional-changelog": "^3.3.0",
"commitizen": "^4.3.0",
"cz-git": "^1.9.0",
"dotenv": "^16.0.2",
"eslint": "^8.2.0",
"eslint": "^8.56.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-config-airbnb-typescript": "^16.1.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-import": "^2.25.2",
"eslint-plugin-jest": "^27.8.0",
"eslint-config-airbnb-typescript": "^17.1.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jest": "^27.9.0",
"eslint-plugin-jsx-a11y": "^6.8.0",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react": "^7.34.0",
"eslint-plugin-react-hooks": "^4.6.0",
"husky": "^8.0.3",
"husky": "^9.0.11",
"jest": "^29.7.0",
"jest-config": "^29.7.0",
"lint-staged": "^12.1.7",
"prettier": "^2.5.1",
"rimraf": "^3.0.2",
"rollup": "^4.9.6",
"lint-staged": "^15.2.2",
"prettier": "^3.2.5",
"rimraf": "^5.0.5",
"snarkjs": "^0.7.2",
"ts-jest": "^29.1.2",
"ts-node": "^10.9.2",
"tslib": "^2.6.2",
"typedoc": "^0.25.7",
"typedoc": "^0.25.8",
"typescript": "^5.3.3"
},
"config": {
"commitizen": {
"path": "./node_modules/cz-conventional-changelog"
"path": "./node_modules/cz-git"
}
},
"resolutions": {

View File

@@ -2,7 +2,7 @@
<h1 align="center">
Semaphore circuits
</h1>
<p align="center">Semaphore circuits to create and verify zero-knowledge proofs.</p>
<p align="center">Semaphore circuits to generate and verify zero-knowledge proofs.</p>
</p>
<p align="center">

View File

@@ -1,6 +1,6 @@
{
"name": "@semaphore-protocol/circuits",
"version": "4.0.0-alpha.8",
"version": "4.0.0-beta.7",
"description": "Semaphore Circom circuits to generate zero-knowledge proofs.",
"license": "MIT",
"files": [
@@ -29,11 +29,10 @@
},
"devDependencies": {
"@types/mocha": "^10.0.6",
"@zk-kit/eddsa-poseidon": "0.3.1",
"@zk-kit/imt": "^2.0.0-beta.1",
"@zk-kit/eddsa-poseidon": "0.6.0",
"@zk-kit/imt": "^2.0.0-beta.2",
"circomkit": "^0.0.19",
"mocha": "^10.2.0",
"poseidon-lite": "^0.2.0"
},
"stableVersion": "4.0.0-alpha.7"
}
}

View File

@@ -4,22 +4,64 @@ include "babyjub.circom";
include "poseidon.circom";
include "binary-merkle-root.circom";
// The Semaphore circuit can be divided into 3 main parts.
// The first part involves the generation of the Semaphore identity,
// i.e. the public key and its hash, which is called the commitment
// and is used as a public value.
// In the second part, it is verified whether or not the identity commitment is part
// of the Merkle tree, i.e. the Semaphore group. That is, a proof of membership is verified.
// The third part covers the generation of a nullifier, i.e. the hash of the scope of the proof
// and the secret used to derive the public key (secret scalar). The nullifier is used to prevent the same
// proof from being verified twice.
// The circuit lastly includes the message, which is an arbitrary anonymous value defined by
// the user, or the hash of that value.
template Semaphore(MAX_DEPTH) {
// Input signals.
// The input signals are all private except 'message' and 'scope'.
// The secret is the scalar generated from the EdDSA private key.
// Using the secret scalar instead of the private key allows this circuit
// to skip steps 1, 2, 3 in the generation of the public key defined here:
// https://www.rfc-editor.org/rfc/rfc8032#section-5.1.5, making the circuit
// more efficient and simple.
// See the Semaphore identity package to know more about how the identity is generated:
// https://github.com/semaphore-protocol/semaphore/tree/main/packages/identity.
signal input secret;
signal input merkleProofLength, merkleProofIndices[MAX_DEPTH], merkleProofSiblings[MAX_DEPTH];
signal input message;
signal input scope;
// Output signals.
// The output signals are all public.
signal output merkleRoot, nullifier;
// Identity generation.
// The circuit derives the EdDSA public key from a secret using
// Baby Jubjub (https://eips.ethereum.org/EIPS/eip-2494),
// which is basically nothing more than a point with two coordinates.
// It then calculates the hash of the public key, which is used
// as the commitment, i.e. the public value of the Semaphore identity.
var Ax, Ay;
(Ax, Ay) = BabyPbk()(secret);
var identityCommitment = Poseidon(2)([Ax, Ay]);
// Proof of membership verification.
// The Merkle root passed as output must be equal to that calculated within
// the circuit through the inputs of the Merkle proof.
// See https://github.com/privacy-scaling-explorations/zk-kit/blob/main/packages/circuits/circom/binary-merkle-root.circom
// to know more about how the 'BinaryMerkleRoot' template works.
merkleRoot <== BinaryMerkleRoot(MAX_DEPTH)(identityCommitment, merkleProofLength, merkleProofIndices, merkleProofSiblings);
// Nullifier generation.
// The nullifier is a value that essentially identifies the proof generated in a specific scope
// and by a specific identity, so that externally anyone can check if another proof with the same
// nullifier has already been generated. This mechanism can be particularly useful in cases
// where one wants to prevent double-spending or double-voting, for example.
nullifier <== Poseidon(2)([scope, secret]);
// Dummy constraint to prevent compiler from optimizing it.
// The message is not really used within the circuit.
// The square applied to it is a way to force Circom's compiler to add a constraint and
// prevent its value from being changed by an attacker.
// More information here: https://geometry.xyz/notebook/groth16-malleability.
signal dummySquare <== message * message;
}

View File

@@ -45,7 +45,7 @@ describe("semaphore", () => {
}
const INPUT = {
secret: deriveSecretScalar(secret),
secret: deriveSecretScalar(secret) as `${number}`,
merkleProofLength: tree.depth,
merkleProofIndices,
merkleProofSiblings,

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

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