Compare commits

..

116 Commits

Author SHA1 Message Date
cedoor
05b9386ec3 chore: v4.0.0-alpha.2
Former-commit-id: d6769c70fc
2024-01-26 17:29:17 +00:00
Cedoor
1555b3e5a5 Merge pull request #598 from semaphore-protocol/docs/license-labels
New Shields license links

Former-commit-id: 1ca66f0420
2024-01-26 17:23:53 +00:00
Cedoor
fc78a69312 Merge pull request #597 from semaphore-protocol/build/rollup-bundles
Rollup config to handle browser bundle

Former-commit-id: 8e66879c23
2024-01-26 17:23:21 +00:00
Cedoor
fad565c00a Merge pull request #596 from semaphore-protocol/feat/get-admin
New contract function to get group admin

Former-commit-id: 6e511c458c
2024-01-26 17:21:09 +00:00
Cedoor
dcb217c085 Merge pull request #595 from semaphore-protocol/fix/cli-monorepo-apps
Check for groups with 1 member

Former-commit-id: fa7033cf03
2024-01-26 17:19:40 +00:00
cedoor
afc13b7e93 docs: update shields license labels
re #466


Former-commit-id: 9afc1c31c0
2024-01-25 17:07:53 +00:00
cedoor
8b5f95499c build: fix bundle paths
Former-commit-id: 2475f1f5ee
2024-01-25 17:07:31 +00:00
cedoor
bca72c6f80 chore: update lock file
Former-commit-id: ee4cb5747f
2024-01-25 16:22:52 +00:00
cedoor
269a1b4fc0 build(identity): config rollup to handle browser bundle
re #481


Former-commit-id: f3557d7c34
2024-01-25 16:18:21 +00:00
cedoor
b1c18bb1f8 feat(contracts): add function to get group admin
re #574


Former-commit-id: 340524e592
2024-01-25 12:37:19 +00:00
cedoor
8e604514c8 fix(cli): add check for groups with 1 member
Former-commit-id: 5844e9c1f6
2024-01-25 10:26:56 +00:00
Cedoor
9712d21956 Merge pull request #594 from swellander/chore/change-cli-create-message
Chore/change cli create message

Former-commit-id: e873fca202
2024-01-25 09:59:24 +00:00
cedoor
5438031470 chore: remove stableVersion auto-generated field
Former-commit-id: 72cf9f10d2
2024-01-25 09:45:52 +00:00
cedoor
13f1dc5e31 chore: v4.0.0-alpha.1
Former-commit-id: 1fc8c207f4
2024-01-25 09:42:30 +00:00
Sam Wellander
2e0a671621 chore(cli): change create command message
converts all `npm` commands to `yarn` commands

re #592


Former-commit-id: 1fe2757bf1
2024-01-24 15:18:39 -08:00
Cedoor
7b137d296b Merge pull request #588 from semaphore-protocol/refactor/merkle-proof
Support `MerkleProof` parameter in the `generateProof` function

Former-commit-id: 2b52ea34f6
2024-01-24 22:09:54 +00:00
Cedoor
253344f71d Merge pull request #593 from semaphore-protocol/chore/snarkjs
Replace `@zk-kit/groth16` with new `snarkjs` package

Former-commit-id: 33a7dd7243
2024-01-24 22:09:14 +00:00
cedoor
5b9065b227 chore(proof): replace zk-kit groth16 with snarkjs
Former-commit-id: 915325917b
2024-01-24 18:30:23 +00:00
cedoor
34f40d4002 refactor(proof): add merkle proof parameter
Former-commit-id: 20a0c87381
2024-01-24 17:01:50 +00:00
Cedoor
3079d0ad28 Merge pull request #583 from semaphore-protocol/refactor/artifacts-download
Remove code to create temporary folder for artifacts

Former-commit-id: c00b007504
2024-01-24 15:32:28 +00:00
cedoor
1a6e26b468 refactor(proof): remove folder creation before downloading artifacts
re #582


Former-commit-id: b08485db44
2024-01-24 15:32:05 +00:00
Cedoor
097e8b1e34 Merge pull request #580 from semaphore-protocol/refactor/semaphore-proof-struct
New `SemaphoreProof` struct

Former-commit-id: 3393930721
2024-01-24 15:30:47 +00:00
cedoor
0bbb1ae015 chore(contracts): create script to add mock data on testnets
Former-commit-id: 76aba71eba
2024-01-24 15:10:13 +00:00
cedoor
554eeca801 style: format code with prettier
Former-commit-id: a976fc2a02
2024-01-24 12:58:18 +00:00
cedoor
17db7ca32b refactor: rename proof with points
Former-commit-id: fbc8efd93e
2024-01-24 12:54:26 +00:00
cedoor
522fd030dc refactor(contracts): create SemaphoreProof struct
Former-commit-id: 8845d89375
2024-01-23 18:34:56 +00:00
cedoor
56d3a2d605 chore: remove stableVersion auto-generated field
Former-commit-id: 3f286fefc9
2024-01-23 17:27:08 +00:00
cedoor
8be5eab7af chore: remove stableVersion auto-generated field
Former-commit-id: 9eccded857
2024-01-23 17:23:01 +00:00
cedoor
35e994d8ab chore: v4.0.0-alpha
Former-commit-id: dfc0629b04
2024-01-23 17:02:21 +00:00
Cedoor
09f4671112 Merge pull request #571 from semaphore-protocol/chore/update-rem-pkgs
Update subgraph and data/CLI libraries with new contracts

Former-commit-id: d0e8bb1dd4
2024-01-23 16:54:03 +00:00
Cedoor
9fec3138f7 Merge pull request #578 from semaphore-protocol/chore/oz-deployer
OpenZeppelin Defender deployer

Former-commit-id: c8f6d3ad46
2024-01-23 16:51:11 +00:00
Cedoor
d83e06e833 Merge pull request #569 from semaphore-protocol/chore/new-testnets
Remove Goerli from supported networks

Former-commit-id: 4e33b01d1f
2024-01-23 16:22:09 +00:00
cedoor
0529774445 test(data): update ethers tests
Former-commit-id: a637d6c705
2024-01-23 15:46:19 +00:00
cedoor
aa9329007c style(cli): update cli templates' contract artifacts
Former-commit-id: 983472570d
2024-01-23 15:29:53 +00:00
cedoor
aacff93bd8 chore(cli): update cli monorepo templates
Former-commit-id: 23151872a5
2024-01-23 15:28:16 +00:00
cedoor
58aac07f7a refactor(identity): convert priv key buffer to bigint
Former-commit-id: 27df0d55c1
2024-01-23 15:28:16 +00:00
cedoor
ac51bba9ea chore(contracts): update proof pkg var names
Former-commit-id: 364977da0d
2024-01-23 15:28:16 +00:00
cedoor
0acf57b9b1 refactor(proof): include merkle depth in the proof
Former-commit-id: 4221412367
2024-01-23 15:28:16 +00:00
cedoor
c91b09d7c5 chore(hardhat): update hardhat package dependencies
Former-commit-id: 2cd7484c62
2024-01-23 15:28:16 +00:00
cedoor
66b6ddd165 chore(cli): update contracts-hardhat template
Former-commit-id: 7441b930e8
2024-01-23 15:28:16 +00:00
cedoor
eecef0e77a fix: adjust cli and data packages
Former-commit-id: 7b447f9f63
2024-01-23 15:28:16 +00:00
cedoor
b3101f0a0a refactor(subgraph): update merkle tree var name
Former-commit-id: f50892525b
2024-01-23 15:28:16 +00:00
cedoor
4c365862ae chore: update cli and data packages
Former-commit-id: 0c0b5b0984
2024-01-23 15:28:16 +00:00
cedoor
be46c9c05d refactor(subgraph): set correct type for tree depth
Former-commit-id: ee8db0edcf
2024-01-23 15:28:16 +00:00
cedoor
a290ecbfdc revert(contracts): re-add script to verify contracts
Former-commit-id: 968fb10e1c
2024-01-23 15:28:16 +00:00
cedoor
d5e8c94af9 chore(subgraph): update docker compose file
Former-commit-id: 0080f3163f
2024-01-23 15:28:16 +00:00
cedoor
f3806dd7cb refactor(contracts): improve task to deploy
Former-commit-id: d593f484dd
2024-01-23 15:28:16 +00:00
cedoor
22ad55e1eb style(subgraph): format code with prettier
Former-commit-id: 7a1ba9ef4a
2024-01-23 15:28:16 +00:00
cedoor
667f890a93 chore(subgraph): update subgraph with new contract events
re #543


Former-commit-id: e231afb30f
2024-01-23 15:28:16 +00:00
cedoor
546ddba38e style(contracts): format code with prettier
Former-commit-id: 2ea27978a4
2024-01-23 14:37:56 +00:00
cedoor
b714501de0 chore(contracts): deploy contracts on sepolia
Former-commit-id: ceb7f902cd
2024-01-23 14:37:56 +00:00
cedoor
22b54a9e80 perf(contracts): merge verifiers
Former-commit-id: 0ec9abb962
2024-01-23 14:37:56 +00:00
cedoor
4e9c930c27 chore: update env file
Former-commit-id: 0964eda363
2024-01-23 14:37:56 +00:00
cedoor
93d8aadf2f chore(contracts): add open-zeppelin deployer
Former-commit-id: f8753f42fb
2024-01-23 14:37:56 +00:00
cedoor
25d3bee901 style: format code with prettier
Former-commit-id: 741fe54083
2024-01-23 14:36:51 +00:00
cedoor
b817f7e186 test(data): temporary comment tests for sepolia testnets
Former-commit-id: ac92b477c0
2024-01-23 14:32:41 +00:00
cedoor
fd4d51ca40 chore: improve scripts to clean repo
Former-commit-id: a24e5b1a8e
2024-01-17 13:53:15 +00:00
cedoor
94566774f9 style(subgraph): format code with prettier
Former-commit-id: 0640e06242
2024-01-17 13:15:29 +00:00
cedoor
52f139d2f4 chore: remove goerli from supported networks
re #352


Former-commit-id: 15ffd2695b
2024-01-17 13:07:05 +00:00
Cedoor
5d532c1bff Merge pull request #566 from semaphore-protocol/feat/add-many-contracts-new-event
Add batch insertion in contracts

Former-commit-id: 6f8cecbcd7
2024-01-17 11:50:13 +00:00
vplasencia
62cb8d02f6 Merge branch 'feat/semaphore-v4' into feat/add-many-contracts-new-event
Former-commit-id: 7f13bb18e5
2024-01-17 10:13:41 +01:00
Vivian Plasencia
acda38f666 Merge pull request #568 from semaphore-protocol/chore/zk-artifacts
New ZK artifacts & verifiers to support tree depths 1-12

Former-commit-id: 70a85e9e6b
2024-01-17 10:08:37 +01:00
cedoor
f31d95e834 style(contracts): format code with prettier
Former-commit-id: 8175e0d99f
2024-01-16 19:04:02 +00:00
cedoor
95b38ba7dd refactor(proof): support multi tree depths (1-12)
Former-commit-id: a60f1f21d0
2024-01-16 18:47:31 +00:00
cedoor
ba898915d7 chore(contracts): remove base contracts
Former-commit-id: 921f699c8e
2024-01-16 18:46:34 +00:00
cedoor
6d1af90fab refactor(contracts): update tests, tasks and scripts
Former-commit-id: 8a8c21c2f1
2024-01-16 18:46:17 +00:00
cedoor
d42e5c875e refactor(contracts): add 1 verifier for each tree depth
Former-commit-id: 937f2ee930
2024-01-16 18:45:33 +00:00
vplasencia
24828b41a4 docs(contracts): add code docs for the members added event
Former-commit-id: 8d1270e80b
2024-01-16 18:27:16 +01:00
vplasencia
7033b00c2b test(contracts): remove skip tests
Former-commit-id: 65a219373a
2024-01-16 18:02:01 +01:00
vplasencia
5dfd8c1cba refactor(contracts): optimize gas
Former-commit-id: b0f40ef5c9
2024-01-16 17:54:37 +01:00
cedoor
2b5ec257cf refactor(circuits): rename privateKey with secret
Former-commit-id: 076e5de03c
2024-01-16 16:06:12 +00:00
vplasencia
409cc624fa test(contracts): update add members test
Former-commit-id: dd1e3a1249
2024-01-16 10:29:35 +01:00
vplasencia
0ff15f5c92 chore(contracts): update imt version
Former-commit-id: 415fe35031
2024-01-16 09:56:03 +01:00
vplasencia
6ec5eb8319 chore(contracts): update zk-kit imt version
Former-commit-id: e6eceafb0d
2024-01-15 18:26:42 +01:00
vplasencia
8cafe09de6 feat(contracts): add many members using new event
Former-commit-id: d27da573ae
2024-01-15 09:57:15 +01:00
cedoor
bd4d30fd19 ci: remove unnecessary cache actions from workflows
Former-commit-id: 3c7ce0e47c
2024-01-12 10:54:42 +00:00
cedoor
cf66732974 feat(contracts): add new function to verify proofs without nullifiers
Former-commit-id: 0367d238df
2024-01-12 10:54:42 +00:00
cedoor
1c300672d0 chore(circuits): udpate zk-kit dependency
Former-commit-id: dea0d4c016
2024-01-12 10:54:42 +00:00
cedoor
19a6768a1d chore(contracts): update solidity version
Former-commit-id: c95cc8beaf
2024-01-12 10:54:42 +00:00
cedoor
175b5485dc test(proof): add longer timeout for generiting proofs
Former-commit-id: d3d82c0c55
2024-01-12 10:54:42 +00:00
cedoor
2666c69728 chore(contracts): downgrade prettier & solhint packages
Former-commit-id: 004803916c
2024-01-12 10:54:42 +00:00
cedoor
b9b12184b5 refactor(contracts): update script to verify contracts
Former-commit-id: c9c99c7855
2024-01-12 10:54:42 +00:00
cedoor
38bd1747a0 chore(contracts): removed unused snarkjs templates
Former-commit-id: 85acdb7801
2024-01-12 10:54:42 +00:00
cedoor
59b8fd30b6 chore(contracts): update solidity and hardhat versions
Former-commit-id: 94453ad50e
2024-01-12 10:54:42 +00:00
Jeeiii
5151249a10 docs: add missing external references for EdDSA and Poseidon
Former-commit-id: 617d0c6dd1
2024-01-12 10:54:42 +00:00
Jeeiii
e30dcca7d6 fix: typo for ISemaphore contract interface custom error
Former-commit-id: aa29a2fdee
2024-01-12 10:54:42 +00:00
Jeeiii
ba99809deb chore: update copyright year
Former-commit-id: 1847f0bc40
2024-01-12 10:54:42 +00:00
Jeeiii
3fb4b5effc refactor: update npm types for node up to latest NodeJS LTS version (20)
Former-commit-id: 81cc94840b
2024-01-12 10:54:42 +00:00
Jeeiii
d8f9078471 build: move github actions to V4 along with new NodeJS LTS version (20)
Former-commit-id: 6ee2499571
2024-01-12 10:54:42 +00:00
Jeeiii
14227d2088 fix: use merkleTreeSize instead of merkleTreeDepth to support groups with one member
Former-commit-id: 5e7cd2693c
2024-01-12 10:54:42 +00:00
Cedoor
af7187a687 Update packages/proof/README.md
Co-authored-by: Giacomo <giacomo.corrias7@gmail.com>
Former-commit-id: ac26789818
2024-01-12 10:54:42 +00:00
cedoor
7572e921a4 refactor(circuits): update merkle proof variable names
Former-commit-id: 5cf4226272
2024-01-12 10:54:42 +00:00
cedoor
908b541fab fix(proof): set correct var name
Former-commit-id: 1c591e1213
2024-01-12 10:54:42 +00:00
cedoor
4c513c26f5 refactor(circuits): update variable name
Former-commit-id: 89c9b6d063
2024-01-12 10:54:42 +00:00
cedoor
fcecad1146 chore(proof): create env bundles
Former-commit-id: 195c87dc2e
2024-01-12 10:54:42 +00:00
cedoor
ee819255d6 docs: update readme files
Former-commit-id: 5f3b266c18
2024-01-12 10:54:42 +00:00
cedoor
d1e9cdcb16 refactor(contracts): fix eslint warnings
Former-commit-id: bd025350c6
2024-01-12 10:54:42 +00:00
cedoor
c45137e373 chore: move test files outside src
Former-commit-id: 7e69ffd743
2024-01-12 10:54:42 +00:00
cedoor
7c61118a40 refactor(hardhat): update hardhat pkg tasks
Former-commit-id: b162ae60e4
2024-01-12 10:54:42 +00:00
cedoor
17cad2b93c refactor(heyauthn): update tests and doc
Former-commit-id: c8da0dc575
2024-01-12 10:54:42 +00:00
cedoor
7a10acb153 refactor(contracts): move access logic to group contract
Former-commit-id: 2b05a94e15
2024-01-12 10:54:42 +00:00
cedoor
ef1f22a043 refactor: hash message and scope
Former-commit-id: b7d58bdac8
2024-01-12 10:54:42 +00:00
cedoor
37d081e1d0 fix(contracts): reverse proof b points
Former-commit-id: 4d4a31cb28
2024-01-12 10:54:42 +00:00
cedoor
6a427480cd chore(proof): update zk-kit groth16 pkg version
Former-commit-id: 7708477001
2024-01-12 10:54:42 +00:00
cedoor
7d781dc09b refactor: update verifiers
Former-commit-id: 26195e3944
2024-01-12 10:54:42 +00:00
cedoor
a93b590d42 feat(contracts): update contracts with new imt
Former-commit-id: cc32feeb27
2024-01-12 10:54:42 +00:00
cedoor
32fd451eb9 refactor(contracts): remove extension contracts
Former-commit-id: 6b347ff5fb
2024-01-12 10:54:42 +00:00
cedoor
a5bb7a6c73 chore: update env variables
Former-commit-id: 5983ed6e08
2024-01-12 10:54:42 +00:00
cedoor
ddf0045699 feat(proof): update proof package with new circuit
Former-commit-id: bc5b294323
2024-01-12 10:54:42 +00:00
cedoor
c0cb8fb0a7 refactor(identity): update commitment variable name
Former-commit-id: f80bb04d19
2024-01-12 10:54:42 +00:00
cedoor
f3e896eaaf feat(group): update group with lean-imt
Former-commit-id: 1c8e2185b9
2024-01-12 10:54:42 +00:00
cedoor
361510d206 refactor(identity): add identity commitment attribute
Former-commit-id: 202e4bead4
2024-01-12 10:54:42 +00:00
cedoor
00953a9233 feat(identity): update identity with eddsa
Former-commit-id: fee7f10a3d
2024-01-12 10:54:42 +00:00
cedoor
ae7be9a47a chore(circuits): update circom configuration
re #357


Former-commit-id: 267a250c43
2024-01-12 10:54:42 +00:00
cedoor
b3a0e5ac8d ci: add circuit tests to workflows
re #357


Former-commit-id: 5c8881cc86
2024-01-12 10:54:42 +00:00
cedoor
3aa5241334 feat(circuits): update semaphore circuits
re #357


Former-commit-id: 4a01dfb179
2024-01-12 10:54:42 +00:00
334 changed files with 2435 additions and 5311 deletions

View File

@@ -1,17 +0,0 @@
---
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

@@ -1,40 +1,24 @@
<!-- Please refer to our CONTRIBUTING documentation for any questions on submitting a pull request. -->
<!-- Provide a general summary of your changes in the Title above. -->
<!-- Please refer to our contributing documentation for any questions on submitting a pull request -->
<!--- Provide a general summary of your changes in the Title above -->
## Description
<!-- Describe your changes in detail. -->
<!-- You may want to answer some of the following questions: -->
<!-- What kind of change does this PR introduce?** (Bug fix, feature, docs update, ...) -->
<!-- What is the current behavior?** (You can also link to an open issue here) -->
<!-- What is the new behavior (if this is a feature change)? -->
<!-- Does this PR introduce a breaking change?** (What changes might users need to make in their application due to this PR?) -->
<!--- Describe your changes in detail -->
## Related Issue(s)
## Related Issue
<!-- This project accepts pull requests related to open issues. -->
<!-- If suggesting a new feature or change, please discuss it in an issue first. -->
<!-- If fixing a bug, there should be an issue describing it with steps to reproduce. -->
<!-- Please link to the issue(s) here -->
<!--- This project accepts pull requests related to open issues -->
<!--- If suggesting a new feature or change, please discuss it in an issue first -->
<!--- If fixing a bug, there should be an issue describing it with steps to reproduce -->
<!--- Please link to the issue here: -->
<!-- Closes # -->
<!-- Fixes # -->
## Does this introduce a breaking change?
- [ ] Yes
- [ ] No
<!-- If this introduces a breaking change, please describe the impact and migration path for existing applications below. -->
## Other information
<!-- Any other information that is important to this PR such as screenshots of how the component looks before and after the change. -->
<!-- Feel free to remove this section if you will not use it. -->
## Checklist
<!-- Please check if the PR fulfills these requirements. -->
- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my code
- [ ] 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,9 +21,6 @@ jobs:
- name: Install dependencies
run: yarn
- name: Build libraries
run: yarn build:libraries
- name: Generate doc website
run: yarn docs

3
.gitignore vendored
View File

@@ -73,6 +73,9 @@ dist
artifacts
cache
typechain-types
packages/contracts/deployed-contracts/undefined.json
packages/contracts/deployed-contracts/hardhat.json
packages/contracts/deployed-contracts/localhost.json
# Stores VSCode versions used for testing VSCode extensions
.vscode-test

View File

@@ -12,6 +12,9 @@ coverage.json
artifacts
cache
typechain-types
packages/contracts/deployed-contracts/undefined.json
packages/contracts/deployed-contracts/hardhat.json
packages/contracts/deployed-contracts/localhost.json
# production
dist

View File

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

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
b3cadff6efb37a12712d12c2553ec703dbcaa4dd

View File

@@ -1 +0,0 @@
738adce5914a0e193f2e1255e4dcf7042256a1c1

View File

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

View File

@@ -28,7 +28,7 @@ Pull requests are great if you want to add a feature or fix a bug. Here's a quic
6. Commit your changes.
7. Push to your fork and submit a pull request on our `main` branch. Please provide us with some explanation of why you made the changes you made. For new features make sure to explain a standard use case to us.
7. Push to your fork and submit a pull request on our `dev` branch. Please provide us with some explanation of why you made the changes you made. For new features make sure to explain a standard use case to us.
## CI (Github Actions) Tests
@@ -93,6 +93,7 @@ Just as in the subject, use the imperative, present tense: "change" not "changed
### Branch rules
- There must be a `main` branch, used only for the releases.
- There must be a `dev` branch, used to merge all the branches under it.
- Avoid long descriptive names for long-lived branches.
- Use kebab-case (no CamelCase).
- Use grouping tokens (words) at the beginning of your branch names (in a similar way to the `type` of commit).

View File

@@ -69,25 +69,6 @@ The core of the Semaphore protocol is in the [circuit logic](/packages/circuits/
<th>Version</th>
<th>Downloads</th>
<tbody>
<tr>
<td>
<a href="/packages/core">
@semaphore-protocol/core
</a>
</td>
<td>
<!-- NPM version -->
<a href="https://npmjs.org/package/@semaphore-protocol/core">
<img src="https://img.shields.io/npm/v/@semaphore-protocol/core.svg?style=flat-square" alt="NPM version" />
</a>
</td>
<td>
<!-- Downloads -->
<a href="https://npmjs.org/package/@semaphore-protocol/core">
<img src="https://img.shields.io/npm/dm/@semaphore-protocol/core.svg?style=flat-square" alt="Downloads" />
</a>
</td>
</tr>
<tr>
<td>
<a href="/packages/contracts">
@@ -233,28 +214,6 @@ 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">
@@ -334,6 +293,14 @@ 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:
@@ -356,10 +323,10 @@ yarn test
### Build libraries & compile contracts
Run [Rollup](https://www.rollupjs.org) and [TheGraph](https://www.npmjs.com/package/@graphprotocol/graph-cli) to build all the packages and the subgraph:
Run [Rollup](https://www.rollupjs.org) to build all the packages:
```bash
yarn build
yarn build:libraries
```
Compile the smart contracts with [Hardhat](https://hardhat.org/):

View File

@@ -0,0 +1,96 @@
// @ts-check
// Note: type annotations allow type checking and IDEs autocompletion
const lightCodeTheme = require("prism-react-renderer/themes/github")
const darkCodeTheme = require("prism-react-renderer/themes/dracula")
/** @type {import('@docusaurus/types').Config} */
module.exports = {
title: "Semaphore",
tagline: "Documentation and Guides",
url: "https://docs.semaphore.pse.dev/",
baseUrl: "/",
favicon: "/img/favicon.ico",
onBrokenLinks: "throw",
onBrokenMarkdownLinks: "warn",
organizationName: "semaphore-protocol",
projectName: "semaphore",
trailingSlash: false,
plugins: ["docusaurus-plugin-sass"],
i18n: {
defaultLocale: "en",
locales: ["en", "es"]
},
presets: [
[
"classic",
/** @type {import('@docusaurus/preset-classic').Options} */
({
docs: {
routeBasePath: "/",
sidebarPath: require.resolve("./sidebars.js"),
editUrl: "https://github.com/semaphore-protocol/website/edit/main/",
includeCurrentVersion: false
},
theme: {
customCss: [require.resolve("./src/css/custom.scss")]
}
})
]
],
themeConfig:
/** @type {import('@docusaurus/preset-classic').ThemeConfig} */
({
// announcementBar: {
// id: "semaphore-v3",
// content:
// '<b>We are pleased to announce the release of <a target="_blank" rel="noopener noreferrer" href="https://github.com/semaphore-protocol/semaphore/releases/tag/v3.0.0">Semaphore V3</a> 🎉</b>',
// backgroundColor: "#DAE0FF",
// textColor: "#000000"
// },
navbar: {
logo: {
alt: "Semaphore Logo",
src: "img/semaphore-logo.svg"
},
items: [
{
label: "Whitepaper",
to: "https://docs.semaphore.pse.dev/whitepaper-v1.pdf",
position: "right",
className: "V1"
},
{
label: "Github",
href: "https://github.com/semaphore-protocol",
position: "right"
},
{
type: "localeDropdown",
position: "right"
}
]
},
colorMode: {
defaultMode: "dark",
// Should we use the prefers-color-scheme media-query,
// using user system preferences, instead of the hardcoded defaultMode
respectPrefersColorScheme: true
},
prism: {
theme: lightCodeTheme,
darkTheme: darkCodeTheme,
additionalLanguages: ["solidity"]
},
algolia: {
appId: "6P229KVKCB",
apiKey: "879bb5b002b6370f181f0f79f5c2afe2",
indexName: "semaphoreliedzkp",
contextualSearch: true
}
})
}

View File

@@ -1,127 +0,0 @@
import type * as Preset from "@docusaurus/preset-classic"
import type { Config } from "@docusaurus/types"
import { themes } from "prism-react-renderer"
const lightCodeTheme = themes.oneLight
const darkCodeTheme = themes.oneDark
const config: Config = {
title: "Semaphore",
tagline: "Semaphore documentation and guides.",
url: "https://docs.semaphore.pse.dev/",
baseUrl: "/",
favicon: "/img/favicon.ico",
onBrokenLinks: "throw",
onBrokenMarkdownLinks: "warn",
organizationName: "semaphore-protocol",
projectName: "semaphore",
trailingSlash: false,
plugins: ["docusaurus-plugin-sass"],
i18n: {
defaultLocale: "en",
locales: ["en", "es"]
},
headTags: [
{
tagName: "link",
attributes: {
rel: "preconnect",
href: "https://psedev.matomo.cloud"
}
},
{
tagName: "script",
innerHTML: `
var _paq = window._paq = window._paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="https://psedev.matomo.cloud/";
_paq.push(['setTrackerUrl', u+'matomo.php']);
_paq.push(['setSiteId', '10']);
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: [
[
"classic",
{
docs: {
routeBasePath: "/",
sidebarPath: require.resolve("./sidebars.js"),
editUrl: "https://github.com/semaphore-protocol/semaphore/edit/main/apps/docs",
includeCurrentVersion: false
},
theme: {
customCss: [require.resolve("./src/css/custom.scss")]
}
} satisfies Preset.Options
]
],
themeConfig: {
announcementBar: {
id: "semaphore-v4-beta",
content:
'<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"
},
navbar: {
logo: {
alt: "Semaphore Logo",
src: "img/semaphore-logo.svg"
},
items: [
{
type: "docsVersionDropdown",
position: "left",
dropdownActiveClassDisabled: true
},
{
label: "Whitepaper",
to: "https://docs.semaphore.pse.dev/whitepaper-v1.pdf",
position: "left",
className: "whitepaper-v1"
},
{
label: "Github",
href: "https://github.com/semaphore-protocol",
position: "right"
},
{
label: "Website",
href: "https://semaphore.pse.dev",
position: "right"
},
{
type: "localeDropdown",
position: "right"
}
]
},
colorMode: {
defaultMode: "light",
// Should we use the prefers-color-scheme media-query,
// using user system preferences, instead of the hardcoded defaultMode
respectPrefersColorScheme: true
},
prism: {
theme: lightCodeTheme,
darkTheme: darkCodeTheme,
additionalLanguages: ["solidity", "bash", "typescript"]
},
algolia: {
appId: "6P229KVKCB",
apiKey: "879bb5b002b6370f181f0f79f5c2afe2",
indexName: "semaphoreliedzkp",
contextualSearch: true
}
} satisfies Preset.ThemeConfig
}
export default config

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](/technical-reference/circuits/#nullifier-hash).
## Relay
@@ -60,5 +60,5 @@ To generate or verify valid zero-knowledge proofs with Semaphore, applications m
- semaphore.wasm
- semaphore.json
For a complete list of ready-to-use files, see [trusted-setup-pse.org](https://www.trusted-setup-pse.org).
For a complete list of ready-to-use files, see <http://www.trusted-setup-pse.org>.
To learn more, see the [trusted setup ceremony](https://storage.googleapis.com/trustedsetup-a86f4.appspot.com/semaphore/semaphore_top_index.html).

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](/glossary/#semaphore-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.
- 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](/glossary/#incremental-merkle-tree), and group members (i.e., [identity commitments](/glossary/#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

@@ -133,5 +133,5 @@ When a member votes (for example, by selecting a radio button), then the dApp ta
### Related
- To get started developing with Semaphore, see the [Quick setup](/V2/quick-setup/) guide.
- To get started developing with Semaphore, see the [Quick setup](/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

@@ -58,7 +58,7 @@ Para generar o verificar pruebas válidas de conocimiento cero con Semaphore, la
- semaphore.wasm
- semaphore.json
Para ver una lista completa de archivos listos para utilizarse, vea [trusted-setup-pse.org](https://www.trusted-setup-pse.org).
Para ver una lista completa de archivos listos para utilizarse, vea <http://www.trusted-setup-pse.org>.
Para aprender más, vea la [ceremonia de configuración de confianza](https://storage.googleapis.com/trustedsetup-a86f4.appspot.com/semaphore/semaphore_top_index.html) (trusted setup ceremony).
## Señales (Signals)

View File

@@ -28,21 +28,21 @@ values={[
<TabItem value="npm">
```bash
npm install @semaphore-protocol/data@^3
npm install @semaphore-protocol/data
```
</TabItem>
<TabItem value="yarn">
```bash
yarn add @semaphore-protocol/data@^3
yarn add @semaphore-protocol/data
```
</TabItem>
<TabItem value="pnpm">
```bash
pnpm add @semaphore-protocol/data@^3
pnpm add @semaphore-protocol/data
```
</TabItem>
@@ -178,4 +178,4 @@ const semaphoreEthers = new SemaphoreEthers("sepolia")
const members = await semaphoreEthers.getGroupMembers(groupId)
const group = new Group(groupId, 20, members)
```
:::
:::

View File

@@ -54,21 +54,21 @@ values={[
<TabItem value="npm">
```bash
npm install @semaphore-protocol/group@^3
npm install @semaphore-protocol/group
```
</TabItem>
<TabItem value="yarn">
```bash
yarn add @semaphore-protocol/group@^3
yarn add @semaphore-protocol/group
```
</TabItem>
<TabItem value="pnpm">
```bash
pnpm add @semaphore-protocol/group@^3
pnpm add @semaphore-protocol/group
```
</TabItem>
@@ -156,4 +156,4 @@ Alternativamente, puede utilizar un contrato [`Semaphore.sol`](https://github.co
:::caution
`Semaphore.sol` incluye un mecanismo para verificar pruebas Semaphore creadas con raíces de árboles de Merkle antiguas. La duración de este mecanismo puede ser definido por el admin en la función `createGroup`. Por lo tanto, los miembros de un grupo pueden continuar generando pruebas válidas incluso después de ser removidos. Para más información ver el issue [#98](https://github.com/semaphore-protocol/semaphore/issues/98).
:::
:::

View File

@@ -37,19 +37,19 @@ values={[
<TabItem value="npm">
```bash
npm install @semaphore-protocol/identity@^3
npm install @semaphore-protocol/identity
```
</TabItem>
<TabItem value="yarn">
```bash
yarn add @semaphore-protocol/identity@^3
yarn add @semaphore-protocol/identity
```
</TabItem>
<TabItem value="pnpm">
```bash
pnpm add @semaphore-protocol/identity@^3
pnpm add @semaphore-protocol/identity
```
</TabItem>

View File

@@ -43,20 +43,20 @@ values={[
<TabItem value="npm">
```bash
npm install @semaphore-protocol/proof@^3
npm install @semaphore-protocol/proof
```
</TabItem>
<TabItem value="yarn">
```bash
yarn add @semaphore-protocol/proof@^3
yarn add @semaphore-protocol/proof
```
</TabItem>
<TabItem value="pnpm">
```bash
pnpm add @semaphore-protocol/proof@^3
pnpm add @semaphore-protocol/proof
```
</TabItem>

View File

@@ -10,13 +10,13 @@ import TabItem from "@theme/TabItem"
Semaphore ofrece un CLI oficial para configurar su proyecto con Hardhat. Si su NPM es versión 5.2 or más reciente puede utilizar NPX:
```bash
npx @semaphore-protocol/cli@^3 create my-app --template monorepo-ethers
npx @semaphore-protocol/cli@latest create my-app --template monorepo-ethers
```
De lo contrario, instale `@semaphore-protocol/cli@^3` de forma global y corra el comando `init`:
De lo contrario, instale `@semaphore-protocol/cli` de forma global y corra el comando `init`:
```bash
npm i -g @semaphore-protocol/cli@^3
npm i -g @semaphore-protocol/cli@latest
semaphore create my-app --template monorepo-ethers
```
@@ -333,4 +333,4 @@ pnpm dev
```
</TabItem>
</Tabs>
</Tabs>

View File

@@ -1,5 +1,6 @@
{
"name": "semaphore-docs",
"version": "2.0.0",
"private": true,
"scripts": {
"start": "docusaurus start",
@@ -13,24 +14,26 @@
"write-heading-ids": "docusaurus write-heading-ids"
},
"dependencies": {
"@docusaurus/core": "3.1.1",
"@docusaurus/preset-classic": "3.1.1",
"@mdx-js/react": "^3.0.0",
"@docusaurus/core": "2.2.0",
"@docusaurus/preset-classic": "2.2.0",
"@mdx-js/react": "^1.6.22",
"@svgr/webpack": "^5.5.0",
"clsx": "^1.2.1",
"docusaurus-plugin-sass": "^0.2.5",
"docusaurus-plugin-sass": "^0.2.2",
"file-loader": "^6.2.0",
"prism-react-renderer": "^2.1.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"prism-react-renderer": "^1.3.5",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"sass": "^1.52.3",
"url-loader": "^4.1.1"
},
"devDependencies": {
"@docusaurus/module-type-aliases": "3.1.1",
"@docusaurus/tsconfig": "3.1.1",
"@types/react": "^18.2.29",
"typescript": "~5.2.2"
"@docusaurus/module-type-aliases": "2.2.0",
"@tsconfig/docusaurus": "^1.0.6",
"@types/react": "^17.0.14",
"@types/react-helmet": "^6.1.2",
"@types/react-router-dom": "^5.1.8",
"typescript": "^4.3.5"
},
"browserslist": {
"production": [
@@ -43,8 +46,5 @@
"last 1 firefox version",
"last 1 safari version"
]
},
"engines": {
"node": ">=18.0"
}
}

View File

@@ -1,25 +0,0 @@
import React, { useEffect, useState } from "react"
export default function Articles() {
const [articles, setArticles] = useState<any[]>([])
useEffect(() => {
fetch("https://raw.githubusercontent.com/semaphore-protocol/semaphore/main/apps/website/src/data/articles.json")
.then((response) => response.json())
.catch(() => [])
.then(setArticles)
}, [])
return (
<ul>
{articles.map((article) => (
<li key={article.url + article.title}>
<a href={article.url} target="_blank" rel="noreferrer">
{article.title}
</a>{" "}
- {article.authors.join(", ")} (<i>{article.date}</i>)
</li>
))}
</ul>
)
}

View File

@@ -1,56 +0,0 @@
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 }) => (
<div key={network}>
<Heading as="h2">{capitalizeFirstLetter(network)}</Heading>
<ul>
{contracts.map(({ name, address }) => (
<li key={address}>
{name}:{" "}
<a href={getEtherscanLink(network) + address} target="_blank" rel="noreferrer">
{address}
</a>
</li>
))}
</ul>
</div>
))}
</div>
)
}

View File

@@ -1,21 +0,0 @@
import React, { useEffect, useState } from "react"
import CodeBlock from "@theme/CodeBlock"
export default function RemoteCode({ url, language, title }: { url: string; language: string; title: string }) {
const [code, setCode] = useState<string>("")
useEffect(() => {
fetch(url)
.then((response) => response.text())
.catch(() => "")
.then((text) => setCode(text))
}, [url])
return (
<div>
<CodeBlock language={language} title={title} showLineNumbers>
{code}
</CodeBlock>
</div>
)
}

View File

@@ -1,25 +0,0 @@
import React, { useEffect, useState } from "react"
export default function Videos() {
const [videos, setVideos] = useState<any[]>([])
useEffect(() => {
fetch("https://raw.githubusercontent.com/semaphore-protocol/semaphore/main/apps/website/src/data/videos.json")
.then((response) => response.json())
.catch(() => [])
.then(setVideos)
}, [])
return (
<ul>
{videos.map((video) => (
<li key={video.url + video.title}>
<a href={video.url} target="_blank" rel="noreferrer">
{video.title}
</a>{" "}
- {video.speakers.join(", ")} at <u>{video.eventName}</u> (<i>{video.date}</i>)
</li>
))}
</ul>
)
}

View File

@@ -6,12 +6,8 @@
/* You can override the default Infima variables here. */
@font-face {
font-family: "DM Sans";
src: url("/static/fonts/DMSans.ttf") format("truetype");
font-weight: 400;
font-style: normal;
}
@import url("https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600&display=swap");
@import url("https://fonts.googleapis.com/css2?family=DMSans:wght@400;500;600&display=swap");
:root {
--ifm-color-primary: "linear(to-r, #4771ea, #2735a6)";
@@ -77,7 +73,7 @@ html[data-theme="light"] {
}
html {
font-family: "DM Sans", sans-serif;
font-family: "DMSans", sans-serif;
font-size: 18px;
font-variant: none;
-webkit-font-smoothing: antialiased;
@@ -97,7 +93,7 @@ svg.custom-icon circle {
}
p {
font-family: "DM Sans", sans-serif;
font-family: "DMSans", sans-serif;
line-height: 32px;
font-weight: 400;
}
@@ -113,6 +109,7 @@ h2,
h3,
h4,
h5 {
font-family: "Outfit", sans-serif;
font-weight: 500;
}
@@ -150,6 +147,7 @@ h5 {
}
.navbar {
height: 95px;
align-items: center;
box-shadow: none;
font-size: 18px;
@@ -236,18 +234,6 @@ html[data-theme="light"] {
}
}
/* Navbar items visibility */
a.whitepaper-v1 {
display: none;
}
html.docs-version-V1 {
a.whitepaper-v1 {
display: inline-block;
}
}
.container {
padding: 0px;
/* margin: 4rem auto 0px; */
@@ -270,6 +256,18 @@ 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;

View File

@@ -0,0 +1,30 @@
import { useLocation } from "@docusaurus/router"
import useDocusaurusContext from "@docusaurus/useDocusaurusContext"
import OriginalNavBarItem from "@theme-original/NavbarItem"
import React from "react"
export default function NavbarItem(props: any) {
const { pathname } = useLocation()
const { i18n } = useDocusaurusContext()
const pathSegments = pathname.split("/")
let version: string
if (i18n.locales.includes(pathSegments[1])) {
;[, , version] = pathSegments
} else {
;[, version] = pathSegments
}
const { className = "" } = props
return (
(!className ||
!(
(className.includes("V1") && version !== "V1") ||
(className.includes("V2") && version !== "V2") ||
(className.includes("V3") && version !== "V3")
)) && <OriginalNavBarItem {...props} />
)
}

Binary file not shown.

View File

@@ -1,6 +1,6 @@
{
// This file is not used in compilation. It is here just for a nice editor experience.
"extends": "@docusaurus/tsconfig",
"extends": "@tsconfig/docusaurus/tsconfig.json",
"compilerOptions": {
"baseUrl": "."
}

View File

@@ -60,5 +60,5 @@ To generate or verify valid zero-knowledge proofs with Semaphore, applications m
- semaphore.wasm
- semaphore.json
For a complete list of ready-to-use files, see [trusted-setup-pse.org](https://www.trusted-setup-pse.org).
For a complete list of ready-to-use files, see <http://www.trusted-setup-pse.org>.
To learn more, see the [trusted setup ceremony](https://storage.googleapis.com/trustedsetup-a86f4.appspot.com/semaphore/semaphore_top_index.html).

View File

@@ -132,5 +132,5 @@ When a member votes (for example, by selecting a radio button), then the dApp ta
### Related
- To get started developing with Semaphore, see the [Quick setup](/V2/quick-setup/) guide.
- To get started developing with Semaphore, see the [Quick setup](/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

@@ -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/tree/version/3) 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) 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/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.
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.
### Semaphore CLI
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.
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.
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/tree/version/3). 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). 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](/V3/technical-reference/circuits/#nullifier-hash).
See [Circuit nullifier hash](/technical-reference/circuits/#nullifier-hash).
## Relay
@@ -59,7 +59,7 @@ To generate or verify valid zero-knowledge proofs with Semaphore, applications m
- semaphore.wasm
- semaphore.json
For a complete list of ready-to-use files, see [trusted-setup-pse.org](https://www.trusted-setup-pse.org).
For a complete list of ready-to-use files, see <http://www.trusted-setup-pse.org>.
To learn more, see the [trusted setup ceremony](https://storage.googleapis.com/trustedsetup-a86f4.appspot.com/semaphore/semaphore_top_index.html).
## Signals

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/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.
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.
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/).
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/).
- [**Fetch data using SemaphoreSubgraph**](#fetch-data-using-semaphoresubgraph)
- [**Fetch data using SemaphoreEthers**](#fetch-data-using-semaphoreethers)
@@ -28,21 +28,21 @@ values={[
<TabItem value="npm">
```bash
npm install @semaphore-protocol/data@^3
npm install @semaphore-protocol/data
```
</TabItem>
<TabItem value="yarn">
```bash
yarn add @semaphore-protocol/data@^3
yarn add @semaphore-protocol/data
```
</TabItem>
<TabItem value="pnpm">
```bash
pnpm add @semaphore-protocol/data@^3
pnpm add @semaphore-protocol/data
```
</TabItem>
@@ -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/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.
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.
```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/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.
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.
```typescript
import { SemaphoreEthers } from "@semaphore-protocol/data"
@@ -178,4 +178,4 @@ const semaphoreEthers = new SemaphoreEthers("sepolia")
const members = await semaphoreEthers.getGroupMembers(groupId)
const group = new Group(groupId, 20, members)
```
:::
:::

View File

@@ -8,14 +8,14 @@ import TabItem from "@theme/TabItem"
# Semaphore groups
A [Semaphore group](/V3/glossary/#semaphore-group) contains [identity commitments](/V3/glossary/#identity-commitment) of group members.
A [Semaphore group](/glossary/#semaphore-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,
- 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](/V3/glossary/#incremental-merkle-tree), and group members (i.e., [identity commitments](/V3/glossary/#identity-commitments)) are tree leaves.
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.
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/v3.15.2/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/main/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`).
@@ -54,21 +54,21 @@ values={[
<TabItem value="npm">
```bash
npm install @semaphore-protocol/group@^3
npm install @semaphore-protocol/group
```
</TabItem>
<TabItem value="yarn">
```bash
yarn add @semaphore-protocol/group@^3
yarn add @semaphore-protocol/group
```
</TabItem>
<TabItem value="pnpm">
```bash
pnpm add @semaphore-protocol/group@^3
pnpm add @semaphore-protocol/group
```
</TabItem>
@@ -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/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.
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.
:::info
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.
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.
:::
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.
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.
:::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.
@@ -156,4 +156,4 @@ Alternatively, you can use an already deployed [`Semaphore.sol`](https://github.
:::caution
`Semaphore.sol` includes a mechanism to verify Semaphore proofs created with old Merkle tree roots, the duration of which can be defined by the admin in the `createGroup` function. Members of a group could then continue to generate valid proofs even after being removed. For more info see the issue [#98](https://github.com/semaphore-protocol/semaphore/issues/98).
:::
:::

View File

@@ -8,7 +8,7 @@ import TabItem from "@theme/TabItem"
# Semaphore identities
In order to join a [Semaphore group](/V3/glossary#semaphore-group), a user must first create a [Semaphore identity](/V3/glossary#semaphore-identity).
In order to join a [Semaphore group](/glossary#semaphore-group), a user must first create a [Semaphore identity](/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/v3.15.2/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/main/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)
@@ -37,21 +37,21 @@ values={[
<TabItem value="npm">
```bash
npm install @semaphore-protocol/identity@^3
npm install @semaphore-protocol/identity
```
</TabItem>
<TabItem value="yarn">
```bash
yarn add @semaphore-protocol/identity@^3
yarn add @semaphore-protocol/identity
```
</TabItem>
<TabItem value="pnpm">
```bash
pnpm add @semaphore-protocol/identity@^3
pnpm add @semaphore-protocol/identity
```
</TabItem>
@@ -116,4 +116,4 @@ To reuse the saved identity, pass the JSON to the `Identity()` constructor.
```ts
const identity2 = new Identity(identity.toString())
```
```

View File

@@ -8,7 +8,7 @@ import TabItem from "@theme/TabItem"
# Semaphore proofs
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:
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:
- 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/v3.15.2/packages/proof) library to generate an off-chain proof.
Use the [`@semaphore-protocol/proof`](https://github.com/semaphore-protocol/semaphore/tree/main/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](/V3/glossary/#trusted-setup-files).
- `snarkArtifacts`: the `zkey` and `wasm` [trusted setup files](/glossary/#trusted-setup-files).
#### Install library:
@@ -43,29 +43,29 @@ values={[
<TabItem value="npm">
```bash
npm install @semaphore-protocol/proof@^3
npm install @semaphore-protocol/proof
```
</TabItem>
<TabItem value="yarn">
```bash
yarn add @semaphore-protocol/proof@^3
yarn add @semaphore-protocol/proof
```
</TabItem>
<TabItem value="pnpm">
```bash
pnpm add @semaphore-protocol/proof@^3
pnpm add @semaphore-protocol/proof
```
</TabItem>
</Tabs>
In the voting system use case, once all the voters have joined their [identities](/V3/guides/identities#create-an-identity) to the ballot [group](/V3/guides/groups),
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),
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](/V3/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](/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/v3.15.2/packages/proof) library to verify a Semaphore 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.
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`](/V3/technical-reference/contracts#semaphoresol) contract to verify proofs on-chain.
Use the [`Semaphore.sol`](/technical-reference/contracts#semaphoresol) contract to verify proofs on-chain.
:::info
See our [deployed contracts](/V3/deployed-contracts) to find the addresses for your network.
See our [deployed contracts](/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:
@@ -125,5 +125,5 @@ To verify Semaphore proofs in your contract, import `ISemaphore.sol`, pass it th
- `proof`: a [Solidity-compatible Semaphore proof](#generate-a-solidity-compatible-proof).
:::info
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.
:::
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.
:::

View File

@@ -10,22 +10,22 @@ import TabItem from "@theme/TabItem"
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@^3 create my-app --template monorepo-ethers
npx @semaphore-protocol/cli@latest create my-app --template monorepo-ethers
```
Otherwise, install `@semaphore-protocol/cli@^3` globally and run the `create` command:
Otherwise, install `@semaphore-protocol/cli` globally and run the `create` command:
```bash
npm i -g @semaphore-protocol/cli@^3
npm i -g @semaphore-protocol/cli@latest
semaphore create my-app --template monorepo-ethers
```
:::info
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).
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/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`).
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`).
:::
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](/V3/deployed-contracts).
Check the Semaphore contract addresses [here](/deployed-contracts).
:::
:::caution
@@ -333,4 +333,4 @@ pnpm dev
```
</TabItem>
</Tabs>
</Tabs>

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/v3.15.2/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/main/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/v3.15.2/packages/circuits) is the heart of the protocol and consists of three parts:
The [Semaphore circuit](https://github.com/semaphore-protocol/semaphore/tree/main/packages/circuits) is the heart of the protocol and consists of three parts:
- [**Proof of membership**](/V3/technical-reference/circuits#proof-of-membership)
- [**Nullifier hash**](/V3/technical-reference/circuits#nullifier-hash)
- [**Signal**](/V3/technical-reference/circuits#signal)
- [**Proof of membership**](/technical-reference/circuits#proof-of-membership)
- [**Nullifier hash**](/technical-reference/circuits#nullifier-hash)
- [**Signal**](/technical-reference/circuits#signal)
![Semaphore circuit](https://github.com/semaphore-protocol/semaphore/raw/v3.15.2/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

@@ -6,25 +6,25 @@ sidebar_position: 3
Semaphore includes two types of contracts:
- [**Base contracts**](/V3/technical-reference/contracts#base-contracts)
- [**Extension contracts**](/V3/technical-reference/contracts#extension-contracts)
- [**Base contracts**](/technical-reference/contracts#base-contracts)
- [**Extension contracts**](/technical-reference/contracts#extension-contracts)
And [**Semaphore.sol**](/V3/technical-reference/contracts#semaphoresol), the main contract deployed on the networks supported by Semaphore.
And [**Semaphore.sol**](/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/v3.15.2/packages/contracts) NPM package.
install the [`@semaphore-protocol/contracts`](https://github.com/semaphore-protocol/semaphore/tree/main/packages/contracts) NPM package.
:::
## Base contracts
Semaphore provides the following base contracts:
- [`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.
- [`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.
These contracts are closely related to the protocol.
You can use them in your contract or you can use [**Semaphore.sol**](/V3/technical-reference/contracts#semaphoresol), which integrates them for you.
You can use them in your contract or you can use [**Semaphore.sol**](/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/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.
- [`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.
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/v3.15.2/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/main/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](/V3/technical-reference/circuits#nullifier-hash) of each group and prevent double-signaling;
- a mechanism to save the [nullifier hashes](/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](/V3/deployed-contracts) to find the addresses for your network.
See our [deployed contracts](/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/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 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 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/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/).
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/).
## 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/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.
[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.
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](/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/).
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/).
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/v3.15.2/packages/circuits/scheme.png).
The core of the protocol is the [circuit logic](https://github.com/semaphore-protocol/semaphore/tree/main/packages/circuits/scheme.png).
In addition to circuits,
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.
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.
### Trusted Setup Ceremony
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).
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).
### Audits

View File

@@ -1,19 +0,0 @@
---
sidebar_position: 11
---
# Credits
Semaphore is the work of several people, for a complete list of contributors you can visit the Semaphore [Github insights](https://github.com/semaphore-protocol/semaphore/graphs/contributors).
- [Barry WhiteHat](https://github.com/barryWhiteHat)
- [Kobi Gurkan](https://github.com/kobigurk)
- [Koh Wei Jie](https://github.com/weijiekoh)
- [Andrija Novakovic](https://github.com/akinovak)
- [Cedoor](https://github.com/cedoor)
- [Rachel Aux](https://github.com/rachelaux)
- [Andy Guzman](https://github.com/aguzmant103)
- [Vivian Plasencia](https://github.com/vplasencia)
- [LauNaMu](https://github.com/0xyNaMu)
- [0xjei](https://github.com/0xjei)
- [Mari Poveda](https://github.com/maripoveda)

View File

@@ -1,9 +0,0 @@
---
sidebar_position: 5
---
import DeployedContracts from '@site/src/components/DeployedContracts';
# Deployed contracts
<DeployedContracts />

View File

@@ -1,37 +0,0 @@
---
sidebar_position: 10
---
# FAQ
## Where can I ask questions about Semaphore?
You can ask questions about Semaphore on [Discord](https://semaphore.pse.dev/discord) or by opening a [Semaphore Discussion](https://github.com/semaphore-protocol/semaphore/discussions). The most frequent questions will be listed below.
## Why should I prevent proofs from being verified twice?
Since zero-knowledge proofs are completely anonymous, it is important to prevent those generated by eligible identities from being reused by a malicious party.
For example, in an anonymous voting application a valid proof could be reused to vote again.
## What is the difference between the "nullifier" and "scope"?
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](/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](/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?
You can find a complete list of applications that are using Semaphore on the [Semaphore website](https://semaphore.pse.dev/projects).
## 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/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?
There are several ways you could contribute to the protocol, you can find more information about on [Github](https://github.com/semaphore-protocol#ways-to-contribute).

View File

@@ -1,142 +0,0 @@
---
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

@@ -1,49 +0,0 @@
---
sidebar_position: 7
---
# Glossary
## Identity
The identity of a user in the Semaphore protocol. A Semaphore identity consists of an [EdDSA](https://en.wikipedia.org/wiki/EdDSA) public/private key pair and a [commitment](#identity-commitment). Semaphore uses an [EdDSA](https://github.com/privacy-scaling-explorations/zk-kit/tree/main/packages/eddsa-poseidon) implementation based on [Baby Jubjub](https://eips.ethereum.org/EIPS/eip-2494) and [Poseidon](https://www.poseidon-hash.info).
## Identity commitment
The public [Semaphore identity](#identity) value used in [Semaphore groups](#group). Semaphore uses the [Poseidon](https://www.poseidon-hash.info) hash function to create the identity commitment from the Semaphore identity public key.
## Group
A group is a [Merkle tree](#merkle-tree) in which each leaf is an [identity commitment](#identity-commitment) for a user. Semaphore uses the [LeanIMT](https://zkkit.pse.dev/classes/_zk_kit_imt.LeanIMT.html) implementation, which is an optimized binary incremental Merkle tree. The tree nodes are calculated using [Poseidon](https://www.poseidon-hash.info).
## Merkle tree
A [tree](https://en.wikipedia.org/wiki/Merkle_tree) in which every leaf (i.e., a node that doesn't have children) is labelled with the cryptographic hash of a data block,
and every node that isn't a leaf is labelled with the cryptographic hash of its child node labels.
In zero-knowledge protocols, Merkle trees can be used to efficiently summarize and validate large data sets.
To validate that a tree contains a specific leaf, a verifier only needs a portion of the complete data structure.
## Scope
A value used like a topic on which users can generate a valid proof only once. The scope is supposed to be used to generate the [nullifier](#nullifier).
## Nullifier
A value designed to be a unique identifier and used to prevent the same zero-knowledge proof from being used twice. In Semaphore, the nullifier is the hash of the scope and private key of the user's Semaphore identity.
## Message
The term "message" in Semaphore refers to the value the user broadcasts when voting, confirming, sending a text message and so on.
## Relay
A third-party who could receive a fee for including relayed transactions in the blockchain (McMenamin, Daza, and Fitz. https://eprint.iacr.org/2022/155.pdf, p.3).
To preserve the anonymity of the user broadcasting a message with Semaphore, an application may use a relayer to send the transaction to Ethereum on behalf of the user.
## Trusted setup
A trusted setup in the context of zero-knowledge proofs, particularly zk-SNARKs, is a preparatory phase where [certain parameters](#trusted-setup-files) are generated for later use in creating and verifying proofs. This process must be conducted by trusted parties, as any retained secret information (toxic waste) could compromise the system's integrity by enabling the creation of false proofs.
## 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](/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

@@ -1,4 +0,0 @@
{
"label": "Guides",
"position": 3
}

View File

@@ -1,244 +0,0 @@
---
sidebar_position: 2
title: Groups
---
import Tabs from "@theme/Tabs"
import TabItem from "@theme/TabItem"
# Semaphore groups
A [Semaphore group](/glossary/#group) contains [identity commitments](/glossary/#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.
:::info
Semaphore V4 uses the [ZK-Kit](https://github.com/privacy-scaling-explorations/zk-kit) LeanIMT (i.e., Lean Incremental
Merkle Tree) [Solidity](https://github.com/privacy-scaling-explorations/zk-kit/tree/main/packages/imt.sol/contracts) and
[JavaScript](https://github.com/privacy-scaling-explorations/zk-kit/tree/main/packages/imt) implementations for managing groups. Groups are Merkle trees, and the group members (i.e., identity commitments) are their leaves.
:::
## 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
<Tabs
defaultValue="npm"
groupId="package-managers"
values={[
{label: 'npm', value: 'npm'},
{label: 'Yarn', value: 'yarn'},
{label: 'pnpm', value: 'pnpm'}
]}>
<TabItem value="npm">
```bash
npm install @semaphore-protocol/group
```
</TabItem>
<TabItem value="yarn">
```bash
yarn add @semaphore-protocol/group
```
</TabItem>
<TabItem value="pnpm">
```bash
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:
```ts
import { Group } from "@semaphore-protocol/group"
const group1 = new Group()
```
You can also initialize a group with multiple members by passing the list of identity commitments as the first parameter when creating the group:
```ts
const members = [
"11237622825477336339577122413451117718539783476837539122310492284566644730311",
"9332663527862709610616009715800254142772436825222910251631161087138559093425",
"13255821893820536903335282929376140649646180444238593676033702344407594536519"
]
const group2 = new Group(members)
```
### Add members
Use the `addMember` method to add a member to a group. For example:
```ts
import { Identity } from "@semaphore-protocol/identity"
const { commitment } = new Identity()
group1.addMember(commitment)
```
To add a batch of members to a group, pass an array to the `addMembers` method. For example:
```ts
group1.addMembers(members)
```
:::caution
When you use the same Semaphore identity across multiple groups, if an attacker takes control of that identity all the groups it is part of will be compromised. Consider using different identities for each group.
:::
### Remove or update members
To remove members from a group, pass the member index to the `removeMember` method. For example:
```ts
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)
```
:::caution
Removing a member from a group sets its value to 0.
Given that the member isn't removed, the number of members (i.e., `group.size` on `group.members.length`) doesn't change.
:::
### Generate a Merkle proof
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)
```
## On-chain groups
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/main/packages/contracts) package to import the `ISemaphore.sol` interface in your contract and start using its functions.
### Install package
<Tabs
defaultValue="npm"
groupId="package-managers"
values={[
{label: 'npm', value: 'npm'},
{label: 'Yarn', value: 'yarn'},
{label: 'pnpm', value: 'pnpm'}
]}>
<TabItem value="npm">
```bash
npm install @semaphore-protocol/contracts
```
</TabItem>
<TabItem value="yarn">
```bash
yarn add @semaphore-protocol/contracts
```
</TabItem>
<TabItem value="pnpm">
```bash
pnpm add @semaphore-protocol/contracts
```
</TabItem>
</Tabs>
### Create a group
To create a group initialize your contract with the `Semaphore.sol` address and a group ID.
The `createGroup` function can be used to create a Semaphore group. For example:
```solidity
pragma solidity ^0.8.23;
import "@semaphore-protocol/contracts/interfaces/ISemaphore.sol";
contract YourContract {
ISemaphore public semaphore;
uint256 public groupId;
constructor(ISemaphore _semaphore, uint256 _groupId) {
semaphore = _semaphore;
groupId = _groupId;
semaphore.createGroup(groupId, address(this));
}
}
```
`Semaphore.sol` also includes a mechanism to verify Semaphore proofs created with old Merkle tree roots, the duration of which can optionally be defined by the admin in the `createGroup` function as the third parameter. The default value duration is 1 hour and it should be fine for most use-cases. For more context see the issue [#98](https://github.com/semaphore-protocol/semaphore/issues/98).
### Add members
Use the `addMember` function to add a member to a group. For example:
```solidity
function addMember(uint256 identityCommitment) external {
semaphore.addMember(groupId, identityCommitment);
}
```
To add a batch of members to a group, pass an array to the `addMembers` function. For example:
```solidity
function addMembers(uint256[] calldata identityCommitments) external {
semaphore.addMembers(groupId, identityCommitments);
}
```
### Remove or update members
To update members in a group, pass the identity commitment of the member you want to update, its new identity commitment and the siblings of the Merkle proof for that member. For example:
```solidity
function updateMember(uint256 identityCommitment, uint256 newIdentityCommitment, uint256[] calldata merkleProofSiblings) external {
semaphore.updateMember(groupId, identityCommitment, newIdentityCommitment, merkleProofSiblings);
}
```
:::info
To calculate the Merkle proof of a group member you can use the `generateMerkleProof` method of the JavaScript `Group` class described above.
:::
To remove members from a group, pass the identity commitment of the member you want to remove and the siblings of the Merkle proof for that member. For example:
```solidity
function removeMember(uint256 identityCommitment, uint256[] calldata merkleProofSiblings) external {
semaphore.removeMember(groupId, identityCommitment, merkleProofSiblings);
}
```
:::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/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

@@ -1,114 +0,0 @@
---
sidebar_position: 1
title: Identities
---
import Tabs from "@theme/Tabs"
import TabItem from "@theme/TabItem"
# Semaphore identities
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
- Public key
- Commitment
To use and verify the identity, the identity owner (user) must know its private key.
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/main/packages/identity) package to manage Semaphore identites.
<Tabs
defaultValue="npm"
groupId="package-managers"
values={[
{label: 'npm', value: 'npm'},
{label: 'Yarn', value: 'yarn'},
{label: 'pnpm', value: 'pnpm'}
]}>
<TabItem value="npm">
```bash
npm install @semaphore-protocol/identity
```
</TabItem>
<TabItem value="yarn">
```bash
yarn add @semaphore-protocol/identity
```
</TabItem>
<TabItem value="pnpm">
```bash
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
To create a random identity, instantiate `Identity` without any parameters. For example:
```ts
import { Identity } from "@semaphore-protocol/identity"
const { privateKey, publicKey, commitment } = new Identity()
```
The new identity contains your private key, your public key, and its associated commitment, which serves as a public representation of the identity (similar to an Ethereum address).
### Create deterministic identities
If you pass a previously used private key or any secret value that acts as your private key as parameter, you can deterministically generate a Semaphore identity.
```ts
const identity1 = new Identity(privateKey)
// or
const identity2 = new Identity("secret-value")
```
:::tip
Building a system to save or recover secret values of Semaphore identities is nontrivial.
You may choose to delegate such functionality to existing wallets such as Metamask. For example:
1. In Metamask, a user signs a message with the private key of their Ethereum account.
2. In your application, the user creates a deterministic identity with the signed message that acts as your Semaphore private key.
3. The user can now recreate their Semaphore identity whenever they want by signing the same message with their Ethereum account in Metamask.
:::
## Sign and verify messages
Semaphore V4 uses asymmetric cryptography and in particular EdDSA to generate the identity keys. It is therefore also possible to sign messages and verify their signatures.
### Sign a message
Any Semaphore identity can sign a message by simply passing a string, number or buffer.
```ts
const message = "Hello World"
const signature = identity1.signMessage(message)
```
### Verify a signature
After a message is signed, anyone can verify the signature using the message itself, the signature, and the signer's public key.
```ts
// Static method.
Identity.verifySignature(message, signature, identity1.publicKey)
```

View File

@@ -1,114 +0,0 @@
---
sidebar_position: 3
title: Proofs
---
import Tabs from "@theme/Tabs"
import TabItem from "@theme/TabItem"
# Semaphore proofs
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](/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/main/packages/proof) package to generate and verify a proof.
<Tabs
defaultValue="npm"
groupId="package-managers"
values={[
{label: 'npm', value: 'npm'},
{label: 'Yarn', value: 'yarn'},
{label: 'pnpm', value: 'pnpm'}
]}>
<TabItem value="npm">
```bash
npm install @semaphore-protocol/proof
```
</TabItem>
<TabItem value="yarn">
```bash
yarn add @semaphore-protocol/proof
```
</TabItem>
<TabItem value="pnpm">
```bash
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](/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](/guides/groups) on groups.
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"
import { Group } from "@semaphore-protocol/group"
const semaphoreSubgraph = new SemaphoreSubgraph("sepolia")
const { members } = semaphoreSubgraph.getGroup("42", { members: true })
const group = new Group(members)
```
### 3. Choose the scope
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
Finally, you can generate the proof with the anonymous message using the `generateProof` function. For example:
```ts
import { generateProof } from "@semaphore-protocol/proof"
const scope = group.root
const message = 1
const proof = await generateProof(identity, group, externalNullifier, message)
```
## Verify a proof
To verify a proof, pass the proof you generated to the `verifyProof` function. For example:
```ts
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/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 {
semaphore.validateProof(groupId, proof);
}
```

View File

@@ -1,16 +0,0 @@
---
sidebar_position: 8
---
import Articles from '@site/src/components/Articles';
import Videos from '@site/src/components/Videos';
# Resources
## Articles
<Articles />
## Videos
<Videos />

View File

@@ -1,20 +0,0 @@
---
sidebar_position: 6
---
import RemoteCode from '@site/src/components/RemoteCode';
# Subgraph
[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/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/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/main/apps/subgraph/schema.graphql"
title="apps/subgraph/schema.graphql" language="graphql" />

View File

@@ -1,4 +0,0 @@
{
"label": "Technical reference",
"position": 4
}

View File

@@ -1,54 +0,0 @@
---
sidebar_position: 2
---
# Circuits
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/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.
## Proof of membership
The circuit derive the public key from the secret and hashes the public key to generate an identity commitment. Then, it verifies the proof of membership against the Merkle root and the identity commitment.
**Private inputs:**
- `merkleProofLength`: the actual number of nodes in the Merkle proof path,
- `merkleProofIndices[MAX_DEPTH]`: the list of 0s and 1s to calculate the hashes of the nodes at the correct position,
- `merkleProofSiblings[MAX_DEPTH]`: the list of siblings nodes to be used to calculate the hashes of the nodes up to the root,
- `secret`: the EdDSA [secret scalar](https://www.rfc-editor.org/rfc/rfc8032#section-5.1.5) derived from the private key.
**Public outputs:**
- `merkleRoot`: The Merkle root of the tree.
## Nullifier
The circuit hashes the secret with the scope and then checks that the result matches the provided nullifier.
**Private inputs:**
- `secret`: the EdDSA [secret scalar](https://www.rfc-editor.org/rfc/rfc8032#section-5.1.5) derived from the private key.
**Public inputs:**
- `scope`: the value used like a topic on which users can generate a valid proof only once.
**Public outputs:**
- `nullifier`: the value designed to be a unique identifier and used to prevent the same proof from being used twice.
## Message
The circuit calculates a dummy square of the message to prevent any tampering with the proof.
**Public inputs:**
- `message`: the anonymous value the user broadcasts.

View File

@@ -1,41 +0,0 @@
---
sidebar_position: 3
---
# Contracts
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/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/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](/glossary#trusted-setup), the verifier must contain the parameters of the verification keys of each instance.
## SemaphoreGroups.sol
`SemaphoreGroups.sol` is an abstract contract which contains the functions required to create on-chain groups, and add/remove/update members. Each group is assigned an admin, which can be an Ethereum account or another contract.
This contract uses the [`LeanIMT.sol`](https://github.com/privacy-scaling-explorations/zk-kit/blob/main/packages/imt.sol/contracts/internal/InternalLeanIMT.sol) ZK-Kit library, an optimized binary incremental Merkle tree with [Poseidon](https://www.poseidon-hash.info).
## Semaphore.sol
`Semaphore.sol` inherits `SemaphoreGroups.sol` and adds functions to verify (`verifyProof`) or validate (`validateProof`) a Semaphore proof. The only constructor parameter is the `SemaphoreVerifier.sol` address, which must be deployed separately.
The `verifyProof` function contains code for checking whether a Semaphore proof is true or false. It is a read-only view function that in addition to verifying the proof also includes a mechanism for keeping track of proofs generated with old Merkle roots, i.e. group instances that contained fewer or different members.
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](/deployed-contracts) to check the addresses.
::::

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/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

@@ -1,51 +0,0 @@
---
id: introduction
title: What Is Semaphore?
sidebar_position: 1
slug: /
---
## Overview
[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.
## Features
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 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.
Semaphore uses on-chain Solidity contracts and off-chain JavaScript libraries that work in tandem.
- Off chain, JavaScript libraries can be used to create identities, manage groups and generate proofs.
- On chain, Solidity contracts can be used to manage groups and verify proofs.
## Developer benefits
Semaphore is designed to be a simple and generic _privacy layer_ for decentralized applications (dApps) on Ethereum. It encourages modular application design, allowing dApp developers to choose and customize the on-chain and off-chain components they need.
## About the code
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/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
| Version | Auditors | Report | Scope |
| ------- | --------------------------------- | --------------------------------------------------------------------------------------------------------------------- | ------------------------ |
| v2.0.0 | [PSE](https://pse.dev/) | [Semaphore_2.0.0_Audit.pdf](https://github.com/semaphore-protocol/semaphore/files/9850441/Semaphore_2.0.0_Audit.pdf) | `circuits`, `contracts` |
| v2.5.0 | [PSE](https://pse.dev/) | [Semaphore_2.5.0_Audit.pdf](https://github.com/semaphore-protocol/semaphore/files/9845008/Semaphore_2.5.0_Audit.pdf) | `contracts`, `libraries` |
| v3.0.0 | [Veridise](https://veridise.com/) | [Semaphore_3.0.0_Audit.pdf](https://github.com/semaphore-protocol/semaphore/files/10513776/Semaphore_3.0.0_Audit.pdf) | `circuits`, `contracts` |
:::caution
Semaphore V4 is in early testing and might have bugs. Please, don't use it in production.
:::

View File

@@ -1,5 +1,5 @@
{
"mySidebar": [
"version-V1/mySidebar": [
{
"type": "autogenerated",
"dirName": "."

View File

@@ -1,5 +1,5 @@
{
"mySidebar": [
"version-V2/mySidebar": [
{
"type": "autogenerated",
"dirName": "."

View File

@@ -1,5 +1,5 @@
{
"mySidebar": [
"version-V3/mySidebar": [
{
"type": "autogenerated",
"dirName": "."

View File

@@ -1,8 +0,0 @@
{
"mySidebar": [
{
"type": "autogenerated",
"dirName": "."
}
]
}

View File

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

View File

@@ -1,5 +1,6 @@
{
"name": "semaphore-website",
"version": "2.0.0",
"private": true,
"scripts": {
"dev": "next dev",

View File

@@ -59,7 +59,7 @@ export default function Build() {
]
return (
<VStack justify="center">
<VStack pt="170px" pb="128px">
<VStack mt="90px">
<Heading fontSize={{ base: "40px", sm: "46px", md: "72px" }} textAlign="center">
Lets build something new
</Heading>
@@ -81,9 +81,9 @@ export default function Build() {
</Flex>
</VStack>
</VStack>
<Flex
justifyContent="space-between"
mt="128px"
direction="row"
backgroundColor="darkBlue"
p="0"
@@ -121,9 +121,9 @@ export default function Build() {
key={linkInfo.title}
>
<Text
borderBottomWidth="2px"
borderBottomWidth="1px"
borderBottomColor="white"
_hover={{ borderBottomColor: "primary.600" }}
_hover={{ borderBottomColor: "transparent" }}
fontSize="18px"
fontWeight="normal"
>
@@ -139,7 +139,7 @@ export default function Build() {
<Box position="relative" w={{ base: "full", xl: "727px" }} h="630" overflow="hidden">
<Image
src="https://semaphore.cedoor.dev/flower-shadow.jpg"
alt=""
alt="Flower Shadow"
objectFit="cover"
w="full"
h="full"

View File

@@ -1,6 +1,5 @@
import { Box, Container } from "@chakra-ui/react"
import type { Metadata } from "next"
import Script from "next/script"
import Footer from "../components/Footer"
import Navbar from "../components/Navbar"
import Providers from "./providers"
@@ -38,22 +37,6 @@ export default function RootLayout({ children }: { children: React.ReactNode })
</Container>
</Providers>
</body>
<Script id="matomo-tracking" strategy="afterInteractive">
{`
var _paq = window._paq = window._paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="https://psedev.matomo.cloud/";
_paq.push(['setTrackerUrl', u+'matomo.php']);
_paq.push(['setSiteId', '10']);
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);
})();
`}
</Script>
</html>
)
}

View File

@@ -74,20 +74,6 @@ export default function Learn() {
title: "Zero-knowledge",
body: "If the statement is true, no verifier learns anything other than the fact that the statement is true."
}
],
[
{
title: "Privacy",
body: "Zero-knowledge property enables hiding any personal information while still enabling to building convincing proofs."
},
{
title: "Scalability",
body: "Multiple proofs can be aggregated into a single one, enabling smaller machines to verify 100s of transactions or claims in one go."
},
{
title: "Interoperability",
body: "ZKPs enable porting trust from one “realm” to another, for example between web2<>web3 worlds."
}
]
]
@@ -95,32 +81,31 @@ export default function Learn() {
{
title: "Semaphore identities",
description:
"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.",
"Given to all Semaphore group members, it is comprised of three parts - identity commitment, trapdoor, and nullifier.",
linkText: "Create Semaphore identities",
linkUrl: "https://docs.semaphore.pse.dev/guides/identities",
linkUrl: "https://semaphore.pse.dev/docs/guides/identities",
codeText: `import { Identity } from "@semaphore-protocol/identity"
// Random identity.
const identity1 = new Identity()
const identity = new Identity()
// Passing a secret.
const identity2 = new Identity("secret")
`,
const trapdoor = identity.getTrapdoor()
const nullifier = identity.getNullifier()
const commitment = identity.generateCommitment()`,
itemList: [
{
icon: <IconEyelash w="24px" h="24px" color="primary.600" />,
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."
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."
},
{
icon: <IconEye w="24px" h="24px" color="primary.600" />,
heading: "Public values",
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."
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."
},
{
icon: <IconUser w="24px" h="24px" color="primary.600" />,
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."
heading: "Generate identities",
body: "Semaphore identities can be generated deterministically or randomly. Deterministic identities can be generated from the hash of a secret message."
}
]
},
@@ -129,44 +114,49 @@ const identity2 = new Identity("secret")
description:
"Semaphore groups are binary incremental Merkle trees that store the public identity commitment of each member.",
linkText: "Create Semaphore groups",
linkUrl: "https://docs.semaphore.pse.dev/guides/groups",
linkUrl: "https://semaphore.pse.dev/docs/guides/groups",
codeText: `import { Group } from "@semaphore-protocol/group"
const members = [identity1.commitment, identity2.commitment]
const group = new Group(1)
const group = new Group(members)
`,
group.addMember(commitment)`,
itemList: [
{
icon: <IconTree w="24px" h="24px" color="primary.600" />,
heading: "Merkle trees",
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."
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."
},
{
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 the JavaScript libraries."
body: "Groups can be created and managed in a decentralized fashion with Semaphore contracts or off-chain with our JavaScript libraries."
},
{
icon: <IconManageUsers w="24px" h="24px" color="primary.600" />,
heading: "Group management",
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."
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."
}
]
},
{
title: "Semaphore proofs",
description: "Semaphore group members can prove that they are part of a group and send anonymous messages.",
description:
"Semaphore group members can anonymously prove that they are part of a group and that they are generating their own proofs and signals.",
linkText: "Generate Semaphore proofs",
linkUrl: "https://docs.semaphore.pse.dev/guides/proofs",
linkUrl: "https://semaphore.pse.dev/docs/guides/proofs",
codeText: `import { generateProof, verifyProof } from "@semaphore-protocol/proof"
const scope = "Semaphore"
const message = "Hello world"
const externalNullifier = BigInt(1)
const signal = "Hello world"
const proof = await generateProof(identity1, group, scope, message)
const fullProof = await generateProof(identity, group, externalNullifier, signal, {
zkeyFilePath: "./semaphore.zkey",
wasmFilePath: "./semaphore.wasm"
})
await verifyProof(proof)`,
const verificationKey = JSON.parse(fs.readFileSync("./semaphore.json", "utf-8"))
await verifyProof(verificationKey, fullProof)`,
itemList: [
{
icon: <IconBadge w="24px" h="24px" color="primary.600" />,
@@ -175,13 +165,13 @@ await verifyProof(proof)`,
},
{
icon: <IconFlag w="24px" h="24px" color="primary.600" />,
heading: "Messages",
body: "Group users can anonymously share messages such as votes or endorsements without revealing their original identity."
heading: "Signals",
body: "Group users can anonymously broadcast signals such as votes or endorsements without revealing their original identity."
},
{
icon: <IconCheck w="24px" h="24px" color="primary.600" />,
heading: "Proof verification",
body: "Semaphore proofs can be verified both on-chain with the Semaphore contracts, or off-chain with the JavaScript libraries."
heading: "Verifiers",
body: "Semaphore proofs can be verified with our contracts or off-chain with our JavaScript libraries."
}
]
}
@@ -231,9 +221,9 @@ await verifyProof(proof)`,
</Text>
<Link href="https://pse.dev/resources" isExternal>
<Text
borderBottomWidth="2px"
borderBottomWidth="1px"
borderBottomColor="white"
_hover={{ borderBottomColor: "primary.600" }}
_hover={{ borderBottomColor: "transparent" }}
fontSize={{ base: "16px", md: "20px" }}
fontWeight="normal"
>
@@ -242,31 +232,22 @@ await verifyProof(proof)`,
</Link>
</VStack>
<VStack mt="40px">
<Flex wrap={{ base: "wrap", lg: "nowrap" }} justify="center" alignItems="center" gap="32px">
<VStack>
<Text fontSize={{ base: "24px", md: "30px" }} fontWeight={{ base: "400", md: "500" }}>
Characteristics
</Text>
<InfoCard texts={infoCardTexts[2]} />
</VStack>
<VStack>
<Text fontSize={{ base: "24px", md: "30px" }} fontWeight={{ base: "400", md: "500" }}>
Main use cases
</Text>
<InfoCard texts={infoCardTexts[3]} />
</VStack>
</Flex>
<VStack>
<Text fontSize={{ base: "24px", md: "30px" }} fontWeight={{ base: "400", md: "500" }}>
Characteristics
</Text>
<InfoCard texts={infoCardTexts[0]} />
</VStack>
</VStack>
</VStack>
)
return (
<VStack w="full">
<VStack pt="170px" pb="112px" position="relative">
<VStack position="relative">
<Box
display={{ base: "none", md: "block" }}
zIndex="-1"
top="0"
left="50%"
transform="translateX(-50%)"
w="100vw"
@@ -275,7 +256,7 @@ await verifyProof(proof)`,
overflow="hidden"
>
<Image
alt=""
alt="Guy shadow image"
src="https://semaphore.cedoor.dev/guy-shadow-horizontal.jpg"
objectFit="cover"
w="full"
@@ -286,7 +267,6 @@ await verifyProof(proof)`,
<Box
display={{ base: "block", lg: "none" }}
zIndex="-1"
top="0"
left="50%"
transform="translateX(-50%)"
w="100vw"
@@ -295,7 +275,7 @@ await verifyProof(proof)`,
overflow="hidden"
>
<Image
alt=""
alt="Guy shadow image"
src="https://semaphore.cedoor.dev/guy-shadow.jpg"
objectFit="cover"
w="full"
@@ -303,7 +283,13 @@ await verifyProof(proof)`,
/>
</Box>
<Tabs maxWidth="100vw" variant="unstyled" align="center">
<Tabs
maxWidth="100vw"
variant="unstyled"
align="center"
mt={{ base: "100px", md: "170px" }}
mb={{ base: "50px", md: "112px" }}
>
<Box overflow="auto" mx="3">
<TabList gap="40px" w="max-content" whiteSpace="nowrap">
<Tab px={0} fontSize="24px" _selected={{ borderBottom: "2px solid white" }}>

View File

@@ -1,5 +1,4 @@
import { Box, Button, Card, CardBody, HStack, Heading, Image, Link, Stack, Text, VStack } from "@chakra-ui/react"
import NextLink from "next/link"
import { Sora } from "next/font/google"
import Carousel from "../components/Carousel"
import ProjectCard from "../components/ProjectCard"
@@ -13,11 +12,10 @@ const sora = Sora({
export default function Home() {
return (
<>
<VStack pt="170px" pb={{ base: "128px", md: "170px" }} justify="center" spacing="20" position="relative">
<VStack>
<VStack h={{ base: "718", sm: "734", md: "724" }} justify="center" spacing="20" position="relative">
<Box
zIndex="-1"
top="0"
left="50%"
transform="translateX(-50%)"
w="100vw"
@@ -26,7 +24,7 @@ export default function Home() {
overflow="hidden"
>
<Image
alt=""
alt="Midnight whispers image"
src="https://semaphore.cedoor.dev/midnight-whispers.jpg"
objectFit="cover"
w="full"
@@ -45,7 +43,7 @@ export default function Home() {
</VStack>
<Stack direction={{ base: "column", sm: "row" }} spacing="6" align="center">
<Link href="https://docs.semaphore.pse.dev/getting-started" isExternal>
<Link href="https://semaphore.pse.dev/docs/quick-setup" isExternal>
<Button size={{ base: "md", md: "lg" }}>Get Started</Button>
</Link>
<Link href="https://demo.semaphore.pse.dev" isExternal>
@@ -82,143 +80,115 @@ export default function Home() {
/>
))}
</VStack>
<HStack justify="center" fontSize="12px">
<Link
as={NextLink}
href="/projects"
textTransform="uppercase"
textDecoration="underline"
_hover={{
textDecoration: "underline"
}}
>
View more
</Link>
</HStack>
</VStack>
</VStack>
<HStack justify="center">
<Card
bg="darkBlue"
color="white"
borderRadius="18px"
padding="80px 60px 80px 60px"
maxW="1110px"
mt="20"
mb="28"
>
<CardBody padding="0">
<Heading fontSize={{ base: "30px", md: "44px" }} textAlign="center" pb="90px">
Semaphore Features
</Heading>
<Card
bg="darkBlue"
color="white"
borderRadius="18px"
padding="80px 60px 80px 60px"
maxW="1110px"
mt="20"
mb="28"
>
<CardBody padding="0">
<Heading fontSize={{ base: "30px", md: "44px" }} textAlign="center" pb="90px">
Semaphore Features
</Heading>
<VStack spacing="16">
<Stack
direction={{ base: "column", md: "row" }}
align="top"
justify="space-between"
spacing="16"
>
<HStack flex="1" align="top" spacing="6">
<Heading
fontSize={{ base: "30px", md: "38px" }}
color="#1E46F2"
fontFamily={sora.style.fontFamily}
>
1
</Heading>
<VStack align="left">
<Text
fontSize={{ base: "18px", md: "20px" }}
fontFamily={sora.style.fontFamily}
>
Simplified privacy
</Text>
<Text color="text.400" fontSize="14px">
Semaphore streamlines privacy-centric app development. It empowers
developers to effortlessly incorporate robust privacy features.
</Text>
</VStack>
</HStack>
<HStack flex="1" align="top" spacing="6">
<Heading
fontSize={{ base: "30px", md: "38px" }}
color="#1E46F2"
fontFamily={sora.style.fontFamily}
>
3
</Heading>
<VStack align="left">
<Text
fontSize={{ base: "18px", md: "20px" }}
fontFamily={sora.style.fontFamily}
>
Universal integrations
</Text>
<Text color="text.400" fontSize="14px">
Semaphore is a protocol for Web2 and Web3. It integrates into any front-end
framework or pure HTML/CSS/JS. It is cross-chain compatible with EVM, L2s,
and alt-blockchains.
</Text>
</VStack>
</HStack>
</Stack>
<Stack
direction={{ base: "column", md: "row" }}
align="top"
justify="space-between"
spacing="16"
>
<HStack flex="1" align="top" spacing="6">
<Heading
fontSize={{ base: "30px", md: "38px" }}
color="#1E46F2"
fontFamily={sora.style.fontFamily}
>
2
</Heading>
<VStack align="left">
<Text
fontSize={{ base: "18px", md: "20px" }}
fontFamily={sora.style.fontFamily}
>
Leverage Zero Knowledge
</Text>
<Text color="text.400" fontSize="14px">
Semaphore leverages Zero Knowledge, allowing us to verify information
without revealing any underlying data. This powerful primitive allows one to
prove membership and signal anonymously.
</Text>
</VStack>
</HStack>
<HStack flex="1" align="top" spacing="6">
<Heading
fontSize={{ base: "30px", md: "38px" }}
color="#1E46F2"
fontFamily={sora.style.fontFamily}
>
4
</Heading>
<VStack align="left">
<Text
fontSize={{ base: "18px", md: "20px" }}
fontFamily={sora.style.fontFamily}
>
Free open source software
</Text>
<Text color="text.400" fontSize="14px">
Semaphore is a Public Good. This means it will never seek to profit, it is
owned by the community and will always remain open source.
</Text>
</VStack>
</HStack>
</Stack>
</VStack>
</CardBody>
</Card>
</HStack>
<VStack spacing="16">
<Stack
direction={{ base: "column", md: "row" }}
align="top"
justify="space-between"
spacing="16"
>
<HStack flex="1" align="top" spacing="6">
<Heading
fontSize={{ base: "30px", md: "38px" }}
color="#1E46F2"
fontFamily={sora.style.fontFamily}
>
1
</Heading>
<VStack align="left">
<Text fontSize={{ base: "18px", md: "20px" }} fontFamily={sora.style.fontFamily}>
Simplified privacy
</Text>
<Text color="text.400" fontSize="14px">
Semaphore streamlines privacy-centric app development. It empowers developers to
effortlessly incorporate robust privacy features.
</Text>
</VStack>
</HStack>
<HStack flex="1" align="top" spacing="6">
<Heading
fontSize={{ base: "30px", md: "38px" }}
color="#1E46F2"
fontFamily={sora.style.fontFamily}
>
3
</Heading>
<VStack align="left">
<Text fontSize={{ base: "18px", md: "20px" }} fontFamily={sora.style.fontFamily}>
Universal integrations
</Text>
<Text color="text.400" fontSize="14px">
Semaphore is a protocol for Web2 and Web3. It integrates into any front-end
framework or pure HTML/CSS/JS. It is cross-chain compatible with EVM, L2s, and
alt-blockchains.
</Text>
</VStack>
</HStack>
</Stack>
<Stack
direction={{ base: "column", md: "row" }}
align="top"
justify="space-between"
spacing="16"
>
<HStack flex="1" align="top" spacing="6">
<Heading
fontSize={{ base: "30px", md: "38px" }}
color="#1E46F2"
fontFamily={sora.style.fontFamily}
>
2
</Heading>
<VStack align="left">
<Text fontSize={{ base: "18px", md: "20px" }} fontFamily={sora.style.fontFamily}>
Leverage Zero Knowledge
</Text>
<Text color="text.400" fontSize="14px">
Semaphore leverages Zero Knowledge, allowing us to verify information without
revealing any underlying data. This powerful primitive allows one to prove
membership and signal anonymously.
</Text>
</VStack>
</HStack>
<HStack flex="1" align="top" spacing="6">
<Heading
fontSize={{ base: "30px", md: "38px" }}
color="#1E46F2"
fontFamily={sora.style.fontFamily}
>
4
</Heading>
<VStack align="left">
<Text fontSize={{ base: "18px", md: "20px" }} fontFamily={sora.style.fontFamily}>
Free open source software
</Text>
<Text color="text.400" fontSize="14px">
Semaphore is a Public Good. This means it will never seek to profit, it is owned
by the community and will always remain open source.
</Text>
</VStack>
</HStack>
</Stack>
</VStack>
</CardBody>
</Card>
<VStack justify="center" spacing="40" py="32" position="relative">
<Box
@@ -231,7 +201,7 @@ export default function Home() {
overflow="hidden"
>
<Image
alt=""
alt="Fluttering shadow image"
src="https://semaphore.cedoor.dev/shadow-flutter.jpg"
objectFit="cover"
w="full"
@@ -283,6 +253,6 @@ export default function Home() {
</Card>
</Stack>
</VStack>
</>
</VStack>
)
}

View File

@@ -4,11 +4,17 @@ import ProjectsList from "../../components/ProjectsList"
export default function Projects() {
return (
<>
<VStack pt="170px" pb="56px" w="100%" justify="end" align="left" spacing="40" position="relative">
<VStack>
<VStack
h={{ base: "442", sm: "420", md: "393" }}
w="100%"
justify="end"
align="left"
spacing="40"
position="relative"
>
<Box
zIndex="-1"
top="0"
left="50%"
transform="translateX(-50%)"
w="100vw"
@@ -17,7 +23,7 @@ export default function Projects() {
overflow="hidden"
>
<Image
alt=""
alt="Blue texture image"
src="https://semaphore.cedoor.dev/blue-texture.jpg"
objectFit="cover"
w="full"
@@ -45,6 +51,6 @@ export default function Projects() {
buttonUrl="https://github.com/semaphore-protocol/semaphore/issues/new?assignees=&labels=documentation++%F0%9F%93%96&projects=&template=----project.md&title="
/>
</VStack>
</>
</VStack>
)
}

View File

@@ -15,11 +15,9 @@ export default function ArticleCard({ title, minRead, url }: ArticleCardProps) {
color="white"
padding="24px 20px"
width={{ base: "full", sm: "297.5px" }}
_hover={{ bgColor: "darkBlueBg" }}
h="full"
variant="unstyled"
borderWidth="1px"
borderColor="text.900"
_hover={{ bgColor: "darkBlueBg", borderColor: "transparent" }}
>
<CardBody padding="0">
<Heading fontSize="20px" lineHeight="28px">

View File

@@ -47,8 +47,10 @@ export default function Carousel({ title, sizes, type, ...props }: CarouselProps
return (
<VStack align="left" w="full" spacing="16" {...props}>
<HStack justify={type === "projects" ? "center" : "space-between"}>
<Heading fontSize={{ base: "30px", md: "44px" }}>{title}</Heading>
<HStack justify="space-between">
<Heading fontSize={{ base: "30px", md: "44px" }} textAlign={type === "projects" ? "center" : "left"}>
{title}
</Heading>
{type !== "projects" && (
<HStack visibility={!size ? "hidden" : "visible"}>
@@ -126,7 +128,7 @@ export default function Carousel({ title, sizes, type, ...props }: CarouselProps
<HStack w="100%">
<Box flex="1" />
<HStack flex="1" justify="center">
<HStack flex="1" justify="center" visibility={!size ? "hidden" : "visible"}>
<IconButton
onClick={previousProject}
variant="link"

View File

@@ -1,6 +1,6 @@
"use client"
import { Grid, GridItem, HStack, IconButton, Tag, TagLabel, TagLeftIcon, Text, VStack } from "@chakra-ui/react"
import { Button, Grid, GridItem, HStack, IconButton, Text, VStack } from "@chakra-ui/react"
import { useCallback, useEffect, useRef, useState } from "react"
import ProjectCard from "../components/ProjectCard"
import allProjects from "../data/projects.json"
@@ -56,30 +56,22 @@ export default function ProjectsList(props: any) {
<Text fontSize="20">Projects created by</Text>
<HStack spacing="4" flexWrap="wrap">
<Tag
<Button
size="lg"
leftIcon={<IconPSE />}
variant={onlyPSE === true ? "solid" : "outline"}
colorScheme={onlyPSE === true ? "primary" : "white"}
onClick={() => setOnlyPSE(onlyPSE === true ? null : true)}
cursor="pointer"
px="18px"
py="13px"
>
<TagLeftIcon boxSize="18px" as={IconPSE} />
<TagLabel>PSE</TagLabel>
</Tag>
<Tag
PSE
</Button>
<Button
size="lg"
leftIcon={<IconCommunity />}
variant={onlyPSE === false ? "solid" : "outline"}
colorScheme={onlyPSE === false ? "primary" : "white"}
onClick={() => setOnlyPSE(onlyPSE === false ? null : false)}
cursor="pointer"
px="18px"
py="13px"
>
<TagLeftIcon boxSize="18px" as={IconCommunity} />
<TagLabel>Community</TagLabel>
</Tag>
Community
</Button>
</HStack>
</VStack>
@@ -87,11 +79,10 @@ export default function ProjectsList(props: any) {
<Text fontSize="20">Category</Text>
<HStack spacing="3" flexWrap="wrap">
{getProjectCategories(sortedProjects).map((category) => (
<Tag
<Button
key={category}
size="md"
size="sm"
variant={selectedCategories.includes(category) ? "solid" : "outline"}
colorScheme={selectedCategories.includes(category) ? "primary" : "white"}
onClick={() => {
const newCategories = selectedCategories.includes(category)
? selectedCategories.filter((c) => c !== category)
@@ -99,10 +90,9 @@ export default function ProjectsList(props: any) {
setSelectedCategories(newCategories)
}}
cursor="pointer"
>
{category}
</Tag>
</Button>
))}
</HStack>
</VStack>

View File

@@ -32,9 +32,9 @@ export default function SectionBlock({ title, description, linkText, linkUrl, co
</Text>
<Link display="flex" alignItems="center" gap="10px" justifyItems="center" href={linkUrl} isExternal>
<Text
borderBottomWidth="2px"
borderBottomWidth="1px"
borderBottomColor="white"
_hover={{ borderBottomColor: "primary.600" }}
_hover={{ borderBottomColor: "transparent" }}
fontSize="18px"
fontWeight="400"
>

View File

@@ -14,10 +14,8 @@ export default function VideoCard({ thumbnail, url, title }: VideoCardProps) {
borderRadius="10px"
color="white"
h="full"
_hover={{ bgColor: "darkBlueBg" }}
variant="unstyled"
borderWidth="1px"
borderColor="text.900"
_hover={{ bgColor: "darkBlueBg", borderColor: "transparent" }}
>
<HStack>
<AspectRatio borderRadius="10px 10px 0px 0px" width="297px" height="215px" overflow="hidden">

View File

@@ -1,14 +1,14 @@
[
{
"name": "ETHGlobal - Circuit Breaker",
"date": "Feb 2-21, 2024",
"description": "Semaphore team will deliver the online workshop \"Semaphore: The power of anonymity\" about building ZK applications. It will also mention improvements on Semaphore v4 and ZK-KIT.",
"link": "https://ethglobal.com/events/circuitbreaker"
"name": "Devconnect - ProgCrypto",
"date": "Nov 16-17, 2023",
"description": "Semaphore team will deliver a workshop on how to build applications with Semaphore.",
"link": "https://progcrypto.org"
},
{
"name": "ETHDam",
"date": "Apr 12-14, 2024",
"description": "Semaphore team will deliver an in-person talk and sponsor prizes for the hackathon.",
"link": "https://www.ethdam.com/"
"name": "Devconnect - Zero Knowledge Unleashed",
"date": "Nov 14, 2023",
"description": "Semaphore team will deliver a workshop on how to build zero-knowledge applications.",
"link": "https://lu.ma/tpgzkday_devconnect"
}
]

View File

@@ -124,12 +124,11 @@
},
{
"name": "Plurality",
"tagline": "Plurality boosts web3 retention by simplifying onboarding and personalizing web3 accounts using data from user's social profiles whilst ensuring privacy.",
"tagline": "An Identity Lego for DApps to verify users independently, preserving privacy without third-party KYC.",
"categories": ["Identity", "Trust"],
"pse": false,
"icon": "",
"links": {
"website": "https://plurality.network",
"github": "https://github.com/Web3-Plurality"
}
},
@@ -516,15 +515,5 @@
"links": {
"website": "https://zkvote.vercel.app"
}
},
{
"name": "Remix",
"tagline": "Circom Plugin and ZKP Circom Semaphore Template.",
"categories": ["Development", "Infra"],
"pse": false,
"icon": "",
"links": {
"website": "https://medium.com/remix-ide/remix-release-v0-37-0-dbc750f7ab15"
}
}
]

View File

@@ -102,21 +102,5 @@
"speakers": ["Vivian Plasencia"],
"url": "https://youtu.be/4e4EAdu0WVg",
"thumbnail": "https://img.youtube.com/vi/4e4EAdu0WVg/0.jpg"
},
{
"title": "Semaphore in a Nutshell",
"eventName": "PROGCRYPTO - Devconnect 2023",
"date": "2023-11-16",
"speakers": ["Cedoor"],
"url": "https://youtu.be/WEKqycIMmLY",
"thumbnail": "https://img.youtube.com/vi/WEKqycIMmLY/0.jpg"
},
{
"title": "Semaphore: The power of anonymity",
"eventName": "ETHGlobal Circuit Breaker",
"date": "2024-02-02",
"speakers": ["Vivian Plasencia"],
"url": "https://youtu.be/tx1Xglf07yE",
"thumbnail": "https://img.youtube.com/vi/tx1Xglf07yE/0.jpg"
}
]

View File

@@ -4,8 +4,7 @@ const Tag = {
baseStyle: {
container: {
borderRadius: "100px",
padding: "5px 16px 5px 16px",
borderWidth: "1px"
padding: "5px 16px 5px 16px"
}
},
defaultProps: {
@@ -23,8 +22,7 @@ const Tag = {
return {
container: {
bg,
color,
borderColor: bg
color
}
}
}
@@ -34,8 +32,7 @@ const Tag = {
return {
container: {
bg,
color: `darkBlue`,
borderColor: bg
color: `darkBlue`
}
}
},
@@ -45,7 +42,7 @@ const Tag = {
return {
container: {
color: c,
borderColor: c
shadow: `inset 0 0 0px 1px ${c}`
}
}
}

3
babel.config.json Normal file
View File

@@ -0,0 +1,3 @@
{
"presets": [["@babel/preset-env", { "targets": { "node": "current" } }], "@babel/preset-typescript"]
}

View File

@@ -1,5 +1,5 @@
import fs from "fs"
import type { Config } from "jest"
import type { Config } from "@jest/types"
const exclude = ["circuits", "contracts"]
@@ -8,20 +8,19 @@ const projects: any = fs
.filter((directory) => directory.isDirectory())
.filter((directory) => !exclude.includes(directory.name))
.map(({ name }) => ({
preset: "ts-jest",
rootDir: `packages/${name}`,
displayName: name,
setupFiles: ["dotenv/config"],
moduleNameMapper: {
"@semaphore-protocol/(.*)/(.*)": "<rootDir>/../$1/src/$2.ts",
"@semaphore-protocol/(.*)": "<rootDir>/../$1/src/index.ts"
"@semaphore-protocol/(.*)": "<rootDir>/../$1/src/index.ts" // Interdependency packages.
}
}))
const config: Config = {
export default async (): Promise<Config.InitialOptions> => ({
projects,
verbose: true,
coverageDirectory: "./coverage/libraries",
collectCoverageFrom: ["<rootDir>/src/**/*.ts", "!<rootDir>/src/**/index.ts", "!<rootDir>/src/**/*.d.ts"],
coverageThreshold: {
global: {
branches: 90,
@@ -30,6 +29,4 @@ const config: Config = {
statements: 95
}
}
}
export default config
})

View File

@@ -7,13 +7,11 @@
"bugs": "https://github.com/semaphore-protocol/semaphore/issues",
"private": true,
"scripts": {
"build": "yarn build:subgraph && yarn build:libraries",
"build:libraries": "yarn workspaces foreach -A -t --no-private run build",
"build:libraries": "yarn workspaces foreach -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",
@@ -21,12 +19,11 @@
"prettier": "prettier -c .",
"prettier:write": "prettier -w .",
"docs": "typedoc --cname js.semaphore.pse.dev --githubPages true",
"version:bump": "yarn workspaces foreach -A --no-private version -d ${0} && yarn version apply --all && yarn remove:stable-version-field && 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: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: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",
"remove:stable-version-field": "ts-node scripts/remove-stable-version-field.ts && yarn prettier:write",
"commit": "cz",
"precommit": "lint-staged",
"postinstall": "husky install"
@@ -49,19 +46,23 @@
"packages/*",
"packages/contracts/contracts"
],
"packageManager": "yarn@4.1.0",
"packageManager": "yarn@3.2.1",
"devDependencies": {
"@babel/core": "^7.16.7",
"@babel/preset-env": "^7.16.8",
"@babel/preset-typescript": "^7.17.12",
"@commitlint/cli": "^16.0.2",
"@commitlint/config-conventional": "^16.0.0",
"@rollup/plugin-typescript": "^11.1.6",
"@rollup/plugin-typescript": "^8.3.0",
"@types/circomlibjs": "^0.1.4",
"@types/download": "^8.0.1",
"@types/glob": "^7.2.0",
"@types/jest": "^29.5.12",
"@types/jest": "^27.4.0",
"@types/node": "^20",
"@types/rimraf": "^3.0.2",
"@typescript-eslint/eslint-plugin": "^5.9.1",
"@typescript-eslint/parser": "^5.9.1",
"babel-jest": "^27.4.6",
"changelogithub": "0.12.7",
"commitizen": "^4.2.4",
"cz-conventional-changelog": "^3.3.0",
@@ -71,23 +72,22 @@
"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-plugin-jest": "^25.7.0",
"eslint-plugin-jsx-a11y": "^6.8.0",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.6.0",
"husky": "^8.0.3",
"jest": "^29.7.0",
"jest-config": "^29.7.0",
"jest": "^27.4.1",
"jest-config": "^27.4.7",
"lint-staged": "^12.1.7",
"prettier": "^2.5.1",
"rimraf": "^5.0.5",
"rollup": "^4.9.6",
"rimraf": "^3.0.2",
"rollup": "^2.64.0",
"snarkjs": "^0.7.2",
"ts-jest": "^29.1.2",
"ts-node": "^10.9.2",
"tslib": "^2.6.2",
"typedoc": "^0.25.7",
"typescript": "^5.3.3"
"ts-node": "^10.4.0",
"tslib": "^2.3.1",
"typedoc": "^0.25.1",
"typescript": "^4.7.0"
},
"config": {
"commitizen": {

View File

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

View File

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

View File

@@ -4,64 +4,22 @@ 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]);
// 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://geometryresearch.xyz/notebook/groth16-malleability.
// Dummy constraint to prevent compiler from optimizing it.
signal dummySquare <== message * message;
}

View File

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

View File

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

View File

@@ -1,23 +0,0 @@
# dependencies
node_modules
package-lock.json
yarn.lock
.yarn
# testing
coverage
coverage.json
# hardhat
artifacts
cache
typechain-types
# misc
.DS_Store
*.pem
# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

View File

@@ -1,71 +1,10 @@
node_modules
.env
coverage
coverage.json
typechain
typechain-types
# Hardhat files
/cache
/artifacts
# TypeChain files
/typechain
/typechain-types
# solidity-coverage files
/coverage
/coverage.json
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# IDE
.vscode
.idea
# Dependency directories
node_modules/
# Output of 'npm pack'
*.tgz
# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/
# Yarn Integrity file
.yarn-integrity
# vercel
.vercel
# dotenv environment variable files
.env
# Optional npm cache directory
.npm
.DS_Store
# yarn v3
.pnp.*
.pnp.js
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
cache
artifacts

View File

@@ -1,29 +0,0 @@
# dependencies
node_modules
package-lock.json
yarn.lock
.yarn
# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# testing
coverage
coverage.json
# hardhat
artifacts
cache
typechain-types
# misc
.DS_Store
*.pem
# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

View File

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

View File

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

View File

@@ -1 +0,0 @@
738adce5914a0e193f2e1255e4dcf7042256a1c1

View File

@@ -1,7 +0,0 @@
compressionLevel: mixed
enableGlobalCache: false
nodeLinker: node-modules
yarnPath: .yarn/releases/yarn-4.1.0.cjs

View File

@@ -2,23 +2,15 @@
This project demonstrates a basic Semaphore use case. It comes with a sample contract, a test for that contract and a sample task that deploys that contract.
## Install
### Install dependencies
```bash
yarn
```
## Usage
### Compile contracts
### Compile
```bash
yarn compile
```
### Test contracts
### Testing
```bash
yarn test
@@ -36,7 +28,7 @@ Or a test gas report:
yarn test:report-gas
```
### Deploy contracts
### Deploy
1. Copy the `.env.example` file as `.env`.
@@ -60,23 +52,3 @@ yarn deploy --semaphore <semaphore-address> --group <group-id> --network sepolia
> **Warning**
> The group id is a number!
### Code quality and formatting
Run [ESLint](https://eslint.org/) and [solhint](https://github.com/protofire/solhint) to analyze the code and catch bugs:
```bash
yarn lint
```
Run [Prettier](https://prettier.io/) to check formatting rules:
```bash
yarn prettier
```
Or to automatically format the code:
```bash
yarn prettier:write
```

View File

@@ -8,8 +8,8 @@ contract Feedback {
uint256 public groupId;
constructor(address semaphoreAddress, uint256 _groupId) {
semaphore = ISemaphore(semaphoreAddress);
constructor(ISemaphore _semaphore, uint256 _groupId) {
semaphore = _semaphore;
groupId = _groupId;
semaphore.createGroup(groupId, address(this));

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