mirror of
https://github.com/semaphore-protocol/semaphore.git
synced 2026-01-15 01:28:02 -05:00
Compare commits
230 Commits
v4.0.0-alp
...
v4.0.0-bet
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a522fff448 | ||
|
|
d9d97de09c | ||
|
|
88df87e339 | ||
|
|
9c2968eecd | ||
|
|
c795ddce35 | ||
|
|
764ff52516 | ||
|
|
2b7dbf3519 | ||
|
|
ea2145471d | ||
|
|
197a7ae204 | ||
|
|
663bea73d0 | ||
|
|
072d94fdee | ||
|
|
a20d3db122 | ||
|
|
d00c0a3309 | ||
|
|
c071d5b6e5 | ||
|
|
c1ab686a6c | ||
|
|
1942afe766 | ||
|
|
f57f4979ce | ||
|
|
65a6983c54 | ||
|
|
30844cee5f | ||
|
|
5fecb53438 | ||
|
|
3f7eb28051 | ||
|
|
1fb6e99cd0 | ||
|
|
a3f86d9ad3 | ||
|
|
832b0d6887 | ||
|
|
a159c23b91 | ||
|
|
825a52cc4d | ||
|
|
e0057a56af | ||
|
|
7afcd53649 | ||
|
|
f569b2fc70 | ||
|
|
aa0c9ceba2 | ||
|
|
4a68eb5e03 | ||
|
|
32944c412b | ||
|
|
8d8fb82407 | ||
|
|
73a306241b | ||
|
|
9b023041e8 | ||
|
|
b6ffad5b8c | ||
|
|
8abfb93b4c | ||
|
|
138e5339bd | ||
|
|
784cddb483 | ||
|
|
5898a175b0 | ||
|
|
6e8f84025f | ||
|
|
6b659a80d0 | ||
|
|
5caa3c7fd8 | ||
|
|
619459e64b | ||
|
|
11eff59b3b | ||
|
|
0e2e6dfd0e | ||
|
|
ecfcda70cc | ||
|
|
601a339d9b | ||
|
|
6d0d7444b6 | ||
|
|
b441be91a4 | ||
|
|
0d4d8508fc | ||
|
|
b215c6cbde | ||
|
|
27956f1676 | ||
|
|
9c7afa888f | ||
|
|
96cb583861 | ||
|
|
b603dbaf81 | ||
|
|
4fc4675678 | ||
|
|
6f0fdddae5 | ||
|
|
31b05dba43 | ||
|
|
94bdb44a45 | ||
|
|
2bc10b0d5e | ||
|
|
7ab9898beb | ||
|
|
9e5f8351cc | ||
|
|
b6e6a8db03 | ||
|
|
9eebaf4967 | ||
|
|
9e5c464237 | ||
|
|
2ea5d5c1cf | ||
|
|
e9e24b04d1 | ||
|
|
2c5b0641c7 | ||
|
|
9e6d386748 | ||
|
|
546d9f9dd6 | ||
|
|
38b14a515c | ||
|
|
193be0e1d5 | ||
|
|
dfb5473414 | ||
|
|
25847c4422 | ||
|
|
7b8a35470a | ||
|
|
ee26734d94 | ||
|
|
b50cddad2e | ||
|
|
4578fc63de | ||
|
|
eb1f3ad5e2 | ||
|
|
6049a27308 | ||
|
|
7943fcd665 | ||
|
|
66be942cb2 | ||
|
|
b93ad8e14d | ||
|
|
7c69037745 | ||
|
|
fcb3634e07 | ||
|
|
b5825c52e5 | ||
|
|
8795302788 | ||
|
|
3c2db6f724 | ||
|
|
fb79707e3e | ||
|
|
c5378b6914 | ||
|
|
8709b373e8 | ||
|
|
3c993ab150 | ||
|
|
541007d4a5 | ||
|
|
f3971efb55 | ||
|
|
c8db909122 | ||
|
|
ab0366aa07 | ||
|
|
d4bda547ff | ||
|
|
d1f5fb331a | ||
|
|
14fe011ad7 | ||
|
|
2897754358 | ||
|
|
4a0ea1201c | ||
|
|
634c2b11e6 | ||
|
|
ac830458fa | ||
|
|
7b46be0725 | ||
|
|
f7fa9fe50d | ||
|
|
ca944c6eed | ||
|
|
8bfebd3431 | ||
|
|
f7403cbdc7 | ||
|
|
e81b4907da | ||
|
|
0c540072c6 | ||
|
|
aaf2079274 | ||
|
|
42991c5917 | ||
|
|
4e84441770 | ||
|
|
41f0b2909f | ||
|
|
517fd44a23 | ||
|
|
5d2a98d399 | ||
|
|
448f25841f | ||
|
|
b81098d144 | ||
|
|
6cfcb571ac | ||
|
|
ffd85050bd | ||
|
|
22d55d943c | ||
|
|
683a0bb982 | ||
|
|
89fd8a7681 | ||
|
|
6e2cd546f5 | ||
|
|
09655719d5 | ||
|
|
fab5c3d6f4 | ||
|
|
dd57c27b63 | ||
|
|
b73c8aa7d0 | ||
|
|
5eb3e168da | ||
|
|
a4fba4ed85 | ||
|
|
fa772876ed | ||
|
|
c6f6b69cbb | ||
|
|
da7accec9c | ||
|
|
fdfabbb3f2 | ||
|
|
146bdacb2b | ||
|
|
b038f925e5 | ||
|
|
b07aee03d4 | ||
|
|
9cbb5a1c18 | ||
|
|
e028644973 | ||
|
|
6703ff08c2 | ||
|
|
7119ee4904 | ||
|
|
4fabf7ce9c | ||
|
|
e2e4ee5254 | ||
|
|
b8e22aef4e | ||
|
|
75628f3958 | ||
|
|
24157b7586 | ||
|
|
d9fdc4ee12 | ||
|
|
89882f3b8b | ||
|
|
30234960ca | ||
|
|
275dd501eb | ||
|
|
f36bb460af | ||
|
|
1bfa09926b | ||
|
|
c88c151e8d | ||
|
|
ac71302781 | ||
|
|
44afe68a37 | ||
|
|
51efe510a4 | ||
|
|
165ee6f469 | ||
|
|
d7d31423bb | ||
|
|
a81edc09b0 | ||
|
|
c98326e078 | ||
|
|
8617657bff | ||
|
|
57f135e305 | ||
|
|
8d4b3a6c9e | ||
|
|
7616cd64e5 | ||
|
|
dbfc34df39 | ||
|
|
f348495d9c | ||
|
|
27fc8e6b75 | ||
|
|
b59ba20463 | ||
|
|
bbc2b15058 | ||
|
|
d45fd99cf2 | ||
|
|
cf5937998f | ||
|
|
e848bb6136 | ||
|
|
9282405a0b | ||
|
|
067ddfd1be | ||
|
|
444b4fa791 | ||
|
|
a9b535f96e | ||
|
|
f1a5262e34 | ||
|
|
1e6473bfc9 | ||
|
|
4c9bf61170 | ||
|
|
245ede6a89 | ||
|
|
6315011a8e | ||
|
|
4ca4172a1f | ||
|
|
3a70a732c4 | ||
|
|
7a5afad2a5 | ||
|
|
58affaadea | ||
|
|
64c5a35570 | ||
|
|
491d949c52 | ||
|
|
9af6153026 | ||
|
|
0581607649 | ||
|
|
1922f64f7c | ||
|
|
a00ea5434c | ||
|
|
6e66085293 | ||
|
|
85fd006209 | ||
|
|
8f3d2e5455 | ||
|
|
5d4c592c3b | ||
|
|
f2be01ecdd | ||
|
|
a0f6e0db13 | ||
|
|
95aad1a154 | ||
|
|
ff47c8ba0b | ||
|
|
5390830e41 | ||
|
|
f4bfe0ca2f | ||
|
|
3c38e393f6 | ||
|
|
ba6df1d6fd | ||
|
|
cb607be9b5 | ||
|
|
2074dbf15f | ||
|
|
d4b41fcef6 | ||
|
|
90447781b9 | ||
|
|
f292155979 | ||
|
|
10f922cbf6 | ||
|
|
5450809424 | ||
|
|
18bc5d9bb9 | ||
|
|
0171f03008 | ||
|
|
58cf5d117c | ||
|
|
3e8e4a0b07 | ||
|
|
a3ac2f3382 | ||
|
|
2592d477dc | ||
|
|
f5faea9673 | ||
|
|
778338b176 | ||
|
|
1b9b45296c | ||
|
|
42acccce4f | ||
|
|
75530e6ee4 | ||
|
|
9b4b278972 | ||
|
|
4634be1ba5 | ||
|
|
3c1b83b82d | ||
|
|
6572e6c121 | ||
|
|
9e39cc1013 | ||
|
|
9a098ddca7 | ||
|
|
5df6476e4d | ||
|
|
6bd973fdea |
21
.commitlintrc.js
Normal file
21
.commitlintrc.js
Normal file
@@ -0,0 +1,21 @@
|
||||
const fs = require("node:fs")
|
||||
const path = require("node:path")
|
||||
|
||||
const packages = fs.readdirSync(path.resolve(__dirname, "packages"))
|
||||
const apps = fs.readdirSync(path.resolve(__dirname, "apps"))
|
||||
|
||||
module.exports = {
|
||||
extends: ["@commitlint/config-conventional"],
|
||||
prompt: {
|
||||
scopes: [...packages, ...apps],
|
||||
markBreakingChangeMode: true,
|
||||
allowCustomIssuePrefix: false,
|
||||
allowEmptyIssuePrefix: false,
|
||||
issuePrefixes: [
|
||||
{
|
||||
value: "re",
|
||||
name: "re: ISSUES related"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
{
|
||||
"extends": ["@commitlint/config-conventional"]
|
||||
}
|
||||
@@ -2,9 +2,5 @@ DEFAULT_NETWORK=hardhat
|
||||
TREE_DEPTH=10
|
||||
REPORT_GAS=false
|
||||
BACKEND_PRIVATE_KEY=
|
||||
INFURA_API_KEY=
|
||||
COINMARKETCAP_API_KEY=
|
||||
ETHERSCAN_API_KEY=
|
||||
DEFENDER_KEY=
|
||||
DEFENDER_SECRET=
|
||||
CREATE2_SALT=1234
|
||||
|
||||
17
.github/ISSUE_TEMPLATE/♻️-refactoring.md
vendored
Normal file
17
.github/ISSUE_TEMPLATE/♻️-refactoring.md
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
---
|
||||
name: "♻️ Refactoring"
|
||||
about: 'about: Suggest any improvements for this project'
|
||||
title: ''
|
||||
labels: 'refactoring :recycle:'
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Describe the improvement you're thinking about**
|
||||
A clear and concise description of what you think could improve the code.
|
||||
|
||||
**Describe alternatives you've considered**
|
||||
A clear and concise description of any alternative solutions you've considered.
|
||||
|
||||
**Additional context**
|
||||
Add any other context or screenshots about the improvement request here.
|
||||
1
.github/pull_request_template.md
vendored
1
.github/pull_request_template.md
vendored
@@ -34,6 +34,7 @@
|
||||
- [ ] I have commented my code, particularly in hard-to-understand areas
|
||||
- [ ] I have made corresponding changes to the documentation
|
||||
- [ ] My changes generate no new warnings
|
||||
- [ ] I have run `yarn prettier` and `yarn lint` without getting any errors
|
||||
- [ ] I have added tests that prove my fix is effective or that my feature works
|
||||
- [ ] New and existing unit tests pass locally with my changes
|
||||
- [ ] Any dependent changes have been merged and published in downstream modules
|
||||
|
||||
3
.github/workflows/docs.yml
vendored
3
.github/workflows/docs.yml
vendored
@@ -21,6 +21,9 @@ jobs:
|
||||
- name: Install dependencies
|
||||
run: yarn
|
||||
|
||||
- name: Build libraries
|
||||
run: yarn build:libraries
|
||||
|
||||
- name: Generate doc website
|
||||
run: yarn docs
|
||||
|
||||
|
||||
9
.github/workflows/production.yml
vendored
9
.github/workflows/production.yml
vendored
@@ -24,12 +24,12 @@ jobs:
|
||||
- name: Install dependencies
|
||||
run: yarn
|
||||
|
||||
- name: Compile contracts
|
||||
run: yarn compile:contracts
|
||||
|
||||
- name: Build libraries
|
||||
run: yarn build:libraries
|
||||
|
||||
- name: Compile contracts
|
||||
run: yarn compile:contracts
|
||||
|
||||
- name: Build subgraph
|
||||
run: yarn build:subgraph
|
||||
|
||||
@@ -54,6 +54,9 @@ jobs:
|
||||
- name: Install dependencies
|
||||
run: yarn
|
||||
|
||||
- name: Build libraries
|
||||
run: yarn build:libraries
|
||||
|
||||
- name: Build subgraph
|
||||
run: yarn build:subgraph
|
||||
|
||||
|
||||
6
.github/workflows/pull-requests.yml
vendored
6
.github/workflows/pull-requests.yml
vendored
@@ -22,12 +22,12 @@ jobs:
|
||||
- name: Install dependencies
|
||||
run: yarn
|
||||
|
||||
- name: Compile contracts
|
||||
run: yarn compile:contracts
|
||||
|
||||
- name: Build libraries
|
||||
run: yarn build:libraries
|
||||
|
||||
- name: Compile contracts
|
||||
run: yarn compile:contracts
|
||||
|
||||
- name: Build subgraph
|
||||
run: yarn build:subgraph
|
||||
|
||||
|
||||
12
.github/workflows/release.yml
vendored
12
.github/workflows/release.yml
vendored
@@ -22,10 +22,22 @@ jobs:
|
||||
with:
|
||||
node-version: 20
|
||||
cache: yarn
|
||||
registry-url: "https://registry.npmjs.org"
|
||||
|
||||
- name: Authentication
|
||||
run: |
|
||||
echo npmAuthToken: "$NODE_AUTH_TOKEN" >> ./.yarnrc.yml
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
|
||||
- name: Install dependencies
|
||||
run: yarn
|
||||
|
||||
- name: Publish packages
|
||||
run: yarn version:publish
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
|
||||
- run: yarn version:release
|
||||
env:
|
||||
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
||||
|
||||
6
.husky/prepare-commit-msg
Normal file
6
.husky/prepare-commit-msg
Normal file
@@ -0,0 +1,6 @@
|
||||
#!/usr/bin/env sh
|
||||
. "$(dirname -- "$0")/_/husky.sh"
|
||||
|
||||
if [ "$NO_HOOK" != "1" ]; then
|
||||
exec < /dev/tty && yarn cz --hook || true
|
||||
fi
|
||||
@@ -1 +0,0 @@
|
||||
87de4f440a77841135f97a187e09140c6d4e6ae2
|
||||
File diff suppressed because one or more lines are too long
1
.yarn/releases/yarn-3.2.1.cjs.REMOVED.git-id
vendored
1
.yarn/releases/yarn-3.2.1.cjs.REMOVED.git-id
vendored
@@ -1 +0,0 @@
|
||||
b3cadff6efb37a12712d12c2553ec703dbcaa4dd
|
||||
893
.yarn/releases/yarn-4.1.0.cjs
vendored
Executable file
893
.yarn/releases/yarn-4.1.0.cjs
vendored
Executable file
File diff suppressed because one or more lines are too long
12
.yarnrc.yml
12
.yarnrc.yml
@@ -1,11 +1,9 @@
|
||||
checksumBehavior: update
|
||||
|
||||
compressionLevel: mixed
|
||||
|
||||
enableGlobalCache: false
|
||||
|
||||
nodeLinker: node-modules
|
||||
|
||||
plugins:
|
||||
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
|
||||
spec: "@yarnpkg/plugin-workspace-tools"
|
||||
- path: .yarn/plugins/@yarnpkg/plugin-version.cjs
|
||||
spec: "@yarnpkg/plugin-version"
|
||||
|
||||
yarnPath: .yarn/releases/yarn-3.2.1.cjs
|
||||
yarnPath: .yarn/releases/yarn-4.1.0.cjs
|
||||
|
||||
@@ -46,7 +46,7 @@ We always use ESLint and Prettier. To check that your code follows the rules, si
|
||||
|
||||
For commits it is recommended to use [Conventional Commits](https://www.conventionalcommits.org).
|
||||
|
||||
Don't worry if it looks complicated, in our repositories, after `git add`, you can usually run the npm script `yarn commit` to make many of these steps interactive.
|
||||
Don't worry if it looks complicated, in our repositories, `git commit` opens an interactive app to create your conventional commit.
|
||||
|
||||
Each commit message consists of a **header**, a **body** and a **footer**. The **header** has a special format that includes a **type**, a **scope** and a **subject**:
|
||||
|
||||
|
||||
56
README.md
56
README.md
@@ -34,7 +34,9 @@
|
||||
<a href="https://www.gitpoap.io/gh/semaphore-protocol/semaphore" target="_blank">
|
||||
<img src="https://public-api.gitpoap.io/v1/repo/semaphore-protocol/semaphore/badge">
|
||||
</a>
|
||||
|
||||
<a href="http://commitizen.github.io/cz-cli/">
|
||||
<img alt="Commitizen friendly" src="https://img.shields.io/badge/commitizen-friendly-586D76?style=flat-square">
|
||||
</a>
|
||||
</p>
|
||||
|
||||
<div align="center">
|
||||
@@ -57,10 +59,10 @@
|
||||
</h4>
|
||||
</div>
|
||||
|
||||
| Semaphore is a protocol, designed to be a simple and generic privacy layer for Ethereum DApps. Using zero knowledge, Ethereum users can prove their membership of a group and send signals such as votes or endorsements without revealing their original identity. |
|
||||
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| Semaphore is a generic privacy layer. Leveraging zero-knowledge technology, users can prove their membership in groups and send messages (extending from votes to endorsements) off-chain or across EVM-compatible blockchains, all without revealing their personal identity. |
|
||||
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||
|
||||
The core of the Semaphore protocol is in the [circuit logic](/packages/circuits/scheme.png). However Semaphore also provides [Solidity contracts](/packages/contracts) and JavaScript libraries to make the steps for offchain proof creation and onchain verification easier. To learn more about Semaphore visit [semaphore.pse.dev](https://semaphore.pse.dev).
|
||||
The core of the Semaphore protocol is in the [circuit logic](/packages/circuits/scheme.png). However, Semaphore also provides [Solidity contracts](/packages/contracts) and JavaScript libraries to make the steps for offchain proof creation and onchain/offchain verification easier. To learn more about Semaphore visit [semaphore.pse.dev](https://semaphore.pse.dev).
|
||||
|
||||
## 📦 Packages
|
||||
|
||||
@@ -233,6 +235,28 @@ The core of the Semaphore protocol is in the [circuit logic](/packages/circuits/
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<a href="/packages/utils">
|
||||
@semaphore-protocol/utils
|
||||
</a>
|
||||
<a href="https://js.semaphore.pse.dev/modules/_semaphore_protocol_utils">
|
||||
(docs)
|
||||
</a>
|
||||
</td>
|
||||
<td>
|
||||
<!-- NPM version -->
|
||||
<a href="https://npmjs.org/package/@semaphore-protocol/utils">
|
||||
<img src="https://img.shields.io/npm/v/@semaphore-protocol/utils.svg?style=flat-square" alt="NPM version" />
|
||||
</a>
|
||||
</td>
|
||||
<td>
|
||||
<!-- Downloads -->
|
||||
<a href="https://npmjs.org/package/@semaphore-protocol/utils">
|
||||
<img src="https://img.shields.io/npm/dm/@semaphore-protocol/utils.svg?style=flat-square" alt="Downloads" />
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<a href="/packages/heyauthn">
|
||||
@@ -312,14 +336,6 @@ yarn commit
|
||||
|
||||
It will also automatically check that the modified files comply with ESLint and Prettier rules.
|
||||
|
||||
### Snark artifacts
|
||||
|
||||
Download the Semaphore snark artifacts needed to generate and verify proofs:
|
||||
|
||||
```bash
|
||||
yarn download:snark-artifacts
|
||||
```
|
||||
|
||||
### Testing
|
||||
|
||||
Run [Jest](https://jestjs.io/) to test the JS libraries:
|
||||
@@ -342,10 +358,10 @@ yarn test
|
||||
|
||||
### Build libraries & compile contracts
|
||||
|
||||
Run [Rollup](https://www.rollupjs.org) to build all the packages:
|
||||
Run [Rollup](https://www.rollupjs.org) and [TheGraph](https://www.npmjs.com/package/@graphprotocol/graph-cli) to build all the packages and the subgraph:
|
||||
|
||||
```bash
|
||||
yarn build:libraries
|
||||
yarn build
|
||||
```
|
||||
|
||||
Compile the smart contracts with [Hardhat](https://hardhat.org/):
|
||||
@@ -363,3 +379,15 @@ yarn docs
|
||||
```
|
||||
|
||||
The output will be placed on the `docs` folder.
|
||||
|
||||
### Releases
|
||||
|
||||
Bump a new version with:
|
||||
|
||||
```bash
|
||||
yarn version:bump <version>
|
||||
# e.g. yarn version:bump 2.0.0
|
||||
```
|
||||
|
||||
It will create a commit and a git tag that will need to pushed on the main branch. A workflow will be triggered and will
|
||||
publish the Semaphore packages on [npm](https://www.npmjs.com/) and release a new version on Github with its changelogs automatically.
|
||||
|
||||
@@ -43,7 +43,8 @@ const config: Config = {
|
||||
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
|
||||
g.async=true; g.src='//cdn.matomo.cloud/psedev.matomo.cloud/matomo.js'; s.parentNode.insertBefore(g,s);
|
||||
})();
|
||||
`
|
||||
`,
|
||||
attributes: {}
|
||||
}
|
||||
],
|
||||
presets: [
|
||||
@@ -54,8 +55,7 @@ const config: Config = {
|
||||
routeBasePath: "/",
|
||||
sidebarPath: require.resolve("./sidebars.js"),
|
||||
editUrl: "https://github.com/semaphore-protocol/semaphore/edit/main/apps/docs",
|
||||
includeCurrentVersion: false,
|
||||
lastVersion: "V3"
|
||||
includeCurrentVersion: false
|
||||
},
|
||||
theme: {
|
||||
customCss: [require.resolve("./src/css/custom.scss")]
|
||||
@@ -65,12 +65,14 @@ const config: Config = {
|
||||
],
|
||||
themeConfig: {
|
||||
announcementBar: {
|
||||
id: "semaphore-v4-alpha",
|
||||
id: "semaphore-v4-beta",
|
||||
content:
|
||||
'<b>Semaphore V4-alpha is out 🎉 <a href="/V4-alpha/getting-started">Try it out</a> and let us know for any feedback on <a href="https://semaphore.pse.dev/discord" target="_blank">Discord</a> or <a href="https://github.com/orgs/semaphore-protocol/discussions" target="_blank">Github</a>!</b>',
|
||||
'<b>Semaphore V4-beta is out 🎉 <a href="/getting-started">Try it out</a> and let us know for any feedback on <a href="https://semaphore.pse.dev/discord" target="_blank">Discord</a> or <a href="https://github.com/orgs/semaphore-protocol/discussions" target="_blank">Github</a>!</b>',
|
||||
backgroundColor: "#dde6fc",
|
||||
textColor: "#000000"
|
||||
},
|
||||
// Social media card
|
||||
image: "img/social-media.png",
|
||||
navbar: {
|
||||
logo: {
|
||||
alt: "Semaphore Logo",
|
||||
@@ -84,7 +86,7 @@ const config: Config = {
|
||||
},
|
||||
{
|
||||
label: "Whitepaper",
|
||||
to: "https://docs.semaphore.pse.dev/whitepaper-v1.pdf",
|
||||
to: "https://semaphore.pse.dev/whitepaper-v1.pdf",
|
||||
position: "left",
|
||||
className: "whitepaper-v1"
|
||||
},
|
||||
|
||||
@@ -40,7 +40,7 @@ For more information, see [Merkle tree in Wikipedia](https://en.wikipedia.org/wi
|
||||
|
||||
A value used to prevent double entry or double signalling.
|
||||
|
||||
See [Circuit nullifier hash](/technical-reference/circuits/#hash-anulador-nullifier-hash).
|
||||
See [Circuit nullifier hash](/V2/technical-reference/circuits/#nullifier-hash).
|
||||
|
||||
## Relay
|
||||
|
||||
@@ -48,7 +48,7 @@ A third-party who receives a fee for including relayed transactions in the block
|
||||
To preserve the anonymity of the user broadcasting a signal with Semaphore, an application may use a relayer to post the signal transaction to Ethereum on behalf of the user.
|
||||
|
||||
Applications may provide rewards for relayers and implement front-running prevention mechanisms, such as requiring the signals to include the relayer’s address, binding the
|
||||
signal to that specific address (https://docs.semaphore.pse.dev/whitepaper-v1.pdf, p.6).
|
||||
signal to that specific address (https://semaphore.pse.dev/whitepaper-v1.pdf, p.6).
|
||||
|
||||
## Trusted setup files
|
||||
|
||||
|
||||
@@ -20,14 +20,14 @@ title: Groups
|
||||
|
||||
Use Semaphore in your application or smart contract to create off-chain and on-chain groups.
|
||||
|
||||
A [Semaphore group](/glossary/#grupo-semaphore) contains [identity commitments](/glossary/#compromiso-de-identidad-identity-commitment) of group members.
|
||||
A [Semaphore group](/V2/glossary/#semaphore-group) contains [identity commitments](/V2/glossary/#identity-commitment) of group members.
|
||||
Example uses of groups include the following:
|
||||
|
||||
- Poll question that attendees join to rate an event.
|
||||
- Ballot that members join to vote on a proposal.
|
||||
- Whistleblowers who are verified employees of an organization.
|
||||
|
||||
A Semaphore group is an [incremental Merkle tree](/glossary/#árbol-de-merkle-merkle-tree), and group members (i.e., identity commitments) are tree leaves.
|
||||
A Semaphore group is an [incremental Merkle tree](/V2/glossary/#merkle-tree), and group members (i.e., identity commitments) are tree leaves.
|
||||
Semaphore groups set the following two parameters:
|
||||
|
||||
- **Tree depth**: the maximum number of members a group can contain (`max size = 2 ^ tree depth`).
|
||||
|
||||
@@ -5,7 +5,7 @@ title: Identities
|
||||
|
||||
# Semaphore identities
|
||||
|
||||
In order to join a [Semaphore group](/glossary#semaphore-group), a user must first create a [Semaphore identity](/glossary#semaphore-identity).
|
||||
In order to join a [Semaphore group](/V2/glossary#semaphore-group), a user must first create a [Semaphore identity](/V2/glossary#semaphore-identity).
|
||||
A Semaphore identity contains two values generated with the identity:
|
||||
|
||||
- Identity trapdoor
|
||||
|
||||
@@ -7,7 +7,7 @@ title: Proofs
|
||||
|
||||
Learn how to use Semaphore to generate and verify zero-knowledge proofs.
|
||||
|
||||
Once a user joins their [Semaphore identity](/glossary#semaphore-identity) to a [Semaphore group](/glossary#semaphore-group), the user can signal anonymously with a zero-knowledge proof that proves the following:
|
||||
Once a user joins their [Semaphore identity](/V2/glossary#semaphore-identity) to a [Semaphore group](/V2/glossary#semaphore-group), the user can signal anonymously with a zero-knowledge proof that proves the following:
|
||||
|
||||
- The user is a member of the group.
|
||||
- The same user created the signal and the proof.
|
||||
@@ -27,11 +27,11 @@ To generate a proof, pass the following properties to the `generateProof` functi
|
||||
- `group`: The group to which the user belongs.
|
||||
- `externalNullifier`: The value that prevents double-signaling.
|
||||
- `signal`: The signal the user wants to send anonymously.
|
||||
- `snarkArtifacts`: The `zkey` and `wasm` [trusted setup files](/glossary/#trusted-setup-files).
|
||||
- `snarkArtifacts`: The `zkey` and `wasm` [trusted setup files](/V2/glossary/#trusted-setup-files).
|
||||
|
||||
In the voting system use case, once all the voters have joined their [identities](/guides/identities#create-an-identity) to the ballot [group](/guides/groups),
|
||||
In the voting system use case, once all the voters have joined their [identities](/V2/guides/identities#create-identities) to the ballot [group](/V2/guides/groups),
|
||||
a voter can generate a proof to vote for a proposal.
|
||||
In the call to `generateProof`, the voting system passes the unique ballot ID (the [Merkle tree](/glossary/#merkle-tree/) root of the group) as the
|
||||
In the call to `generateProof`, the voting system passes the unique ballot ID (the [Merkle tree](/V2/glossary#merkle-tree) root of the group) as the
|
||||
`externalNullifier` to prevent the voter signaling more than once for the ballot.
|
||||
The following code sample shows how to use `generateProof` to generate the voting proof:
|
||||
|
||||
@@ -53,7 +53,7 @@ Use the [`@semaphore-protocol/proof`](https://github.com/semaphore-protocol/sema
|
||||
To verify a proof, pass the following to the `verifyProof` function:
|
||||
|
||||
- _`proof`_: the Semaphore proof.
|
||||
- _`verificationKey`_: the JavaScript object in the `semaphore.json` [trusted setup file](/glossary/#trusted-setup-files).
|
||||
- _`verificationKey`_: the JavaScript object in the `semaphore.json` [trusted setup file](/V2/glossary/#trusted-setup-files).
|
||||
|
||||
The following code sample shows how to parse the verification key object from `semaphore.json`
|
||||
and verify the previously generated proof:
|
||||
|
||||
@@ -213,7 +213,7 @@ and [Chai assertions](https://www.chaijs.com/).
|
||||
wget http://www.trusted-setup-pse.org/semaphore/20/semaphore.wasm
|
||||
```
|
||||
|
||||
Learn more about [trusted setup files](/glossary/#trusted-setup-files).
|
||||
Learn more about [trusted setup files](/V2/glossary/#trusted-setup-files).
|
||||
|
||||
3. Rename the `Lock.js` test file to `Greeter.js` and replace the content with the following:
|
||||
|
||||
|
||||
@@ -6,9 +6,9 @@ sidebar_position: 2
|
||||
|
||||
The [Semaphore circuit](https://github.com/semaphore-protocol/semaphore/tree/v2.6.1/packages/circuits) is the heart of the protocol and consists of three parts:
|
||||
|
||||
- [**Proof of membership**](/technical-reference/circuits#proof-of-membership)
|
||||
- [**Nullifier hash**](/technical-reference/circuits#nullifier-hash)
|
||||
- [**Signal**](/technical-reference/circuits#signal)
|
||||
- [**Proof of membership**](/V2/technical-reference/circuits#proof-of-membership)
|
||||
- [**Nullifier hash**](/V2/technical-reference/circuits#nullifier-hash)
|
||||
- [**Signal**](/V2/technical-reference/circuits#signal)
|
||||
|
||||

|
||||
|
||||
|
||||
@@ -6,9 +6,9 @@ sidebar_position: 3
|
||||
|
||||
Semaphore includes three types of contracts:
|
||||
|
||||
- [**Base contracts**](/technical-reference/contracts#base-contracts)
|
||||
- [**Extension contracts**](/technical-reference/contracts#extension-contracts)
|
||||
- [**Verifiers**](/technical-reference/contracts#verifiers)
|
||||
- [**Base contracts**](/V2/technical-reference/contracts#base-contracts)
|
||||
- [**Extension contracts**](/V2/technical-reference/contracts#extension-contracts)
|
||||
- [**Verifiers**](/V2/technical-reference/contracts#verifiers)
|
||||
|
||||
:::info
|
||||
To use Semaphore contracts and interfaces in your project,
|
||||
@@ -24,7 +24,7 @@ Semaphore provides the following base contracts:
|
||||
|
||||
These contracts are closely related to the protocol.
|
||||
You can inherit them in your contract or you can use [`Semaphore.sol`](https://github.com/semaphore-protocol/semaphore/tree/v2.6.1/packages/contracts/Semaphore.sol), which inherits them for you.
|
||||
See our [deployed contracts](/deployed-contracts#semaphore) to find the addresses for your network.
|
||||
See our [deployed contracts](/V2/deployed-contracts#semaphore) to find the addresses for your network.
|
||||
|
||||
:::info
|
||||
While some dApps may use on-chain groups, others may prefer to use off-chain groups, saving only their tree roots in the contract.
|
||||
@@ -41,7 +41,7 @@ More extensions will be added in the future.
|
||||
## Verifiers
|
||||
|
||||
To verify Semaphore proofs, the [`SemaphoreCore.sol`](https://github.com/semaphore-protocol/semaphore/tree/v2.6.1/packages/contracts/base/SemaphoreCore.sol) contract requires the address of a deployed verifier contract.
|
||||
You can choose to manually deploy the [verifier](https://github.com/semaphore-protocol/semaphore/tree/v2.6.1/packages/contracts/verifiers) you prefer or you can use one of our [deployed verifiers](/deployed-contracts#verifiers).
|
||||
You can choose to manually deploy the [verifier](https://github.com/semaphore-protocol/semaphore/tree/v2.6.1/packages/contracts/verifiers) you prefer or you can use one of our [deployed verifiers](/V2/deployed-contracts#verifiers).
|
||||
|
||||
Each verifier name indicates the tree depth that it can verify.
|
||||
For example, given a Semaphore proof generated with a tree depth `20`:
|
||||
|
||||
@@ -36,7 +36,7 @@ Community members connect their wallets to the dApp to take the following action
|
||||
|
||||
### Relay
|
||||
|
||||
To preserve anonymity and avoid disclosing the member's wallet address, the dApp may use a [relay](/glossary/#relay) to broadcast the vote.
|
||||
To preserve anonymity and avoid disclosing the member's wallet address, the dApp may use a [relay](/V2/glossary/#relay) to broadcast the vote.
|
||||
The relay calls the **contract** function that then posts the member's vote transaction to Ethereum.
|
||||
|
||||
## Private voting
|
||||
@@ -52,7 +52,7 @@ The voting scenario has the following steps:
|
||||
|
||||
### Create a poll
|
||||
|
||||
A community coordinator or dApp administrator uses the deployed smart contract to create an on-chain (Ethereum) poll, a [Semaphore group](/guides/groups/) that members can join and cast votes to.
|
||||
A community coordinator or dApp administrator uses the deployed smart contract to create an on-chain (Ethereum) poll, a [Semaphore group](/V2/guides/groups/) that members can join and cast votes to.
|
||||
|
||||
In the following sample code, the voting contract declares a `createPoll` function that uses the Semaphore base `_createGroup` function:
|
||||
|
||||
@@ -78,11 +78,11 @@ function createPoll(
|
||||
}
|
||||
```
|
||||
|
||||
A poll is a Semaphore [group](/guides/groups/) that stores the following:
|
||||
A poll is a Semaphore [group](/V2/guides/groups/) that stores the following:
|
||||
|
||||
- A topic to vote on.
|
||||
- The public ID of the poll creator.
|
||||
- [Semaphore IDs](/guides/identities/) of members who joined the poll.
|
||||
- [Semaphore IDs](/V2/guides/identities/) of members who joined the poll.
|
||||
|
||||
To create the poll, the administrator calls the smart contract function--for example:
|
||||
|
||||
@@ -128,10 +128,10 @@ With a member registered for a poll, learn how the dApp [records votes](#record-
|
||||
Once members have joined a poll, the coordinator starts the poll to allow voting.
|
||||
When a member votes (for example, by selecting a radio button), then the dApp takes the following actions:
|
||||
|
||||
1. Uses the `@semaphore-protocol/proof` library to create a proof of the vote, the poll identifier, the Semaphore ID, and a [nullifier](/glossary/#nullifier) that prevents double-voting.
|
||||
1. Uses the `@semaphore-protocol/proof` library to create a proof of the vote, the poll identifier, the Semaphore ID, and a [nullifier](/V2/glossary/#nullifier) that prevents double-voting.
|
||||
2. Sends the vote proof to the [relay](#relay).
|
||||
|
||||
### Related
|
||||
|
||||
- To get started developing with Semaphore, see the [Quick setup](/quick-setup/) guide.
|
||||
- To get started developing with Semaphore, see the [Quick setup](/V2/quick-setup/) guide.
|
||||
- For an example app that you can use to start your own project, see [Semaphore boilerplate](https://github.com/semaphore-protocol/boilerplate).
|
||||
|
||||
@@ -15,9 +15,9 @@ Use cases include private voting, whistleblowing, anonymous DAOs and mixers.
|
||||
|
||||
With Semaphore, you can allow your users to do the following:
|
||||
|
||||
1. [Create a Semaphore identity](/guides/identities/).
|
||||
2. [Add their Semaphore identity to a group (i.e. _Merkle tree_)](/guides/groups/).
|
||||
3. [Send a verifiable, anonymous signal (e.g a vote or endorsement)](/guides/proofs/).
|
||||
1. [Create a Semaphore identity](/V2/guides/identities/).
|
||||
2. [Add their Semaphore identity to a group (i.e. _Merkle tree_)](/V2/guides/groups/).
|
||||
3. [Send a verifiable, anonymous signal (e.g a vote or endorsement)](/V2/guides/proofs/).
|
||||
|
||||
When a user broadcasts a signal (for example: a vote), Semaphore zero-knowledge
|
||||
proofs can ensure that the user has joined the group and hasn't already cast a signal with their nullifier.
|
||||
|
||||
@@ -9,18 +9,18 @@ sidebar_position: 7
|
||||
La identidad de un usuario en el protocolo Semaphore.
|
||||
Una identidad contiene los tres valores que se mencionan a continuación:
|
||||
|
||||
- [Compromiso de identidad](#identity-commitment) (identity commitment): el valor público.
|
||||
- [Compromiso de identidad](#compromiso-de-identidad-identity-commitment) (identity commitment): el valor público.
|
||||
- Identidad trampilla (identity trapdoor) y anulador de identidad (identity nullifier): valores secretos que únicamente son del conocimiento del usuario.
|
||||
|
||||
## Compromiso de identidad (Identity commitment)
|
||||
|
||||
El valor público de la [identidad Semaphore](#semaphore-identity) utilizado en los [grupos Semaphore](#semaphore-group).
|
||||
El valor público de la [identidad Semaphore](#identidad-semaphore) utilizado en los [grupos Semaphore](#grupo-semaphore).
|
||||
|
||||
Semaphore utiliza la función hash [Poseidon](https://www.poseidon-hash.info/) para crear un compromiso de identidad a partir de los valores secretos de la identidad Semaphore.
|
||||
|
||||
## Grupo Semaphore
|
||||
|
||||
Un grupo es un [árbol de Merkle](#merkle-tree) binario e incremental en el que cada hoja contiene un [compromiso de identidad](#identity-commitment) para un usuario.
|
||||
Un grupo es un [árbol de Merkle](#árbol-de-merkle-merkle-tree) binario e incremental en el que cada hoja contiene un [compromiso de identidad](#compromiso-de-identidad-identity-commitment) para un usuario.
|
||||
El compromiso de identidad comprueba que un usuario es un miembro del grupo sin revelar la identidad Semaphore del usuario.
|
||||
|
||||
Semaphore utiliza la función hash **Poseidon** para crear árboles de Merkle.
|
||||
@@ -39,14 +39,14 @@ Para más información, vea [árbol de Merkle en Wikipedia](https://es.wikipedia
|
||||
|
||||
Un valor utilizado para prevenir registros dobles o dos señales emitidas por el mismo usuario.
|
||||
|
||||
Ver [hash de circuito nullifier](/technical-reference/circuits/#nullifier-hash).
|
||||
Ver [hash de circuito nullifier](/V3/technical-reference/circuits#hash-anulador-nullifier-hash).
|
||||
|
||||
## Retransmisor (Relayer)
|
||||
|
||||
Un tercero que recibe una comisión por incluir transacciones retransmitidas en la blockchain (McMenamin, Daza, and Fitz. https://eprint.iacr.org/2022/155.pdf, p.3).
|
||||
Para preservar la anonimidad del usuario emitiendo una señal con Semaphore, una aplicación puede utilizar un retransmisor para publicar la transacción de la señal en Ethereum en nombre del usuario.
|
||||
|
||||
Las aplicaciones pueden ofrecer recompensas a los retransmisores e implementar mecanismos para prevenir ventajas maliciosas, como requerir que las señales incluyan la dirección del retransmisor, vinculando así la señal a esa dirección en específico (https://docs.semaphore.pse.dev/whitepaper-v1.pdf, p.6).
|
||||
Las aplicaciones pueden ofrecer recompensas a los retransmisores e implementar mecanismos para prevenir ventajas maliciosas, como requerir que las señales incluyan la dirección del retransmisor, vinculando así la señal a esa dirección en específico (https://semaphore.pse.dev/whitepaper-v1.pdf, p.6).
|
||||
|
||||
## Archivos confiables de configuración (Trusted setup files)
|
||||
|
||||
|
||||
@@ -8,14 +8,14 @@ import TabItem from "@theme/TabItem"
|
||||
|
||||
# Gupos Semaphore
|
||||
|
||||
Un [grupo Semaphore](/glossary/#semaphore-group) contiene los [identity commitments](/glossary/#identity-commitment) (compromisos de identidad) de miembros del grupo.
|
||||
Un [grupo Semaphore](/V3/glossary/#grupo-semaphore) contiene los [identity commitments](/V3/glossary/#compromiso-de-identidad-identity-commitment) (compromisos de identidad) de miembros del grupo.
|
||||
Estos son algunos ejemplos de uso de los grupos:
|
||||
|
||||
- Encuesta con preguntas a la que se unen las personas que acudieron a un evento para calificarlo,
|
||||
- votación a la que se unen los miembros para votar por una propuesta,
|
||||
- Denunciantes que están verificados como empleados de una organización.
|
||||
|
||||
Un grupo Semaphore es un [árbol de Merkle incremental](/glossary/#incremental-merkle-tree), y los miembros del grupo (por ejemplo, [identity commitments](/glossary/#identity-commitments)) son las hojas del árbol.
|
||||
Un grupo Semaphore es un [árbol de Merkle incremental](/V3/glossary/#árbol-de-merkle-merkle-tree), y los miembros del grupo (por ejemplo, [identity commitments](/V3/glossary/#compromiso-de-identidad-identity-commitment)) son las hojas del árbol.
|
||||
Los grupos Semaphore determinan los siguientes tres parámetro:
|
||||
|
||||
- **Group id**: un identificador único para el grupo;
|
||||
@@ -24,14 +24,14 @@ Los grupos Semaphore determinan los siguientes tres parámetro:
|
||||
|
||||
Aprenda cómo trabajar con grupos.
|
||||
|
||||
- [**Grupos off-chain**](#off-chain-groups)
|
||||
- [**Grupos on-chain**](#on-chain-groups)
|
||||
- [**Grupos off-chain**](#grupos-off-chain-externos-a-la-cadena)
|
||||
- [**Grupos on-chain**](#grupos-on-chain)
|
||||
|
||||
## Grupos off-chain (externos a la cadena)
|
||||
|
||||
- [Crear un grupo](#create-a-group)
|
||||
- [Añadir miembros](#add-members)
|
||||
- [Remover o actualizar miembros](#remove-or-update-members)
|
||||
- [Crear un grupo](#crear-un-grupo)
|
||||
- [Añadir miembros](#añadir-miembros)
|
||||
- [Remover o actualizar miembros](#remover-o-actualizar-miembros)
|
||||
|
||||
### Crear un grupo
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import TabItem from "@theme/TabItem"
|
||||
|
||||
# Identidades Semaphore
|
||||
|
||||
Para unirse a un [grupo Semaphore](/glossary#semaphore-group), un usuario primero deberá crear una [identidad Semaphore](/glossary#semaphore-identity).
|
||||
Para unirse a un [grupo Semaphore](/V3/glossary#grupo-semaphore), un usuario primero deberá crear una [identidad Semaphore](/V3/glossary#identidad-semaphore).
|
||||
Una identidad Semaphore contiene dos valores generados junto con la identidad:
|
||||
|
||||
- Identity trapdoor (Identidad trampilla)
|
||||
@@ -21,8 +21,8 @@ Para prevenir fraudes, la persona dueña debe conservar de forma secreta ambos v
|
||||
|
||||
En su código, utilice la librería [`@semaphore-protocol/identity`](https://github.com/semaphore-protocol/semaphore/tree/main/packages/identity) para crear una identidad Semaphore _de forma determinística_ (del hash de un mensaje) o _de forma aleatoria_.
|
||||
|
||||
- [**Crear identidades aleatorias**](#create-random-identities)
|
||||
- [**Crear identidades determinísticas**](#create-deterministic-identities)
|
||||
- [**Crear identidades aleatorias**](#crear-identidades-aleatorias)
|
||||
- [**Crear identidades determinísticas**](#crear-identidades-determinísticas)
|
||||
|
||||
### Instalar librería:
|
||||
|
||||
|
||||
@@ -8,16 +8,16 @@ import TabItem from "@theme/TabItem"
|
||||
|
||||
# Pruebas Semaphore
|
||||
|
||||
Una vez que un usuario liga su [identidad Semaphore](/glossary#semaphore-identity) a un [grupo Semaphore](/glossary#semaphore-group), el usuario puede emitir una señal anónima con una prueba de conocimiento cero (ZKP) que demuestre lo siguiente:
|
||||
Una vez que un usuario liga su [identidad Semaphore](/V3/glossary#identidad-semaphore) a un [grupo Semaphore](/V3/glossary#grupo-semaphore), el usuario puede emitir una señal anónima con una prueba de conocimiento cero (ZKP) que demuestre lo siguiente:
|
||||
|
||||
- el usuario es un miembro del grupo,
|
||||
- el mismo usuario creo tanto la señal como la prueba.
|
||||
|
||||
Las y los desarrolladores pueden utilizar Semaphore para realizar las siguientes acciones:
|
||||
|
||||
- [**Generar una prueba externa a la cadena (off-chain)**](#generate-a-proof-off-chain)
|
||||
- [**Verificar una prueba externa a la cadena (off-chain)**](#verify-a-proof-off-chain)
|
||||
- [**Verificar una prueba interna a la cadena (on-chain)**](#verify-a-proof-on-chain)
|
||||
- [**Generar una prueba externa a la cadena (off-chain)**](#generar-una-prueba-off-chain)
|
||||
- [**Verificar una prueba externa a la cadena (off-chain)**](#verificar-una-prueba-off-chain)
|
||||
- [**Verificar una prueba interna a la cadena (on-chain)**](#verificar-una-prueba-on-chain)
|
||||
|
||||
## Generar una prueba off-chain
|
||||
|
||||
@@ -28,7 +28,7 @@ Para generar una prueba, transforme los siguientes parámetros con la función `
|
||||
- `group`: el grupo al cual pertenece el usuario;
|
||||
- `externalNullifier`: el valor que impide la emisión de dos señales por el mismo usuario;
|
||||
- `signal`: la señal que el usuario quiere enviar de forma anónima;
|
||||
- `snarkArtifacts`: la `zkey` y `wasm` de los [archivos confiables de configuración](/glossary/#trusted-setup-files).
|
||||
- `snarkArtifacts`: la `zkey` y `wasm` de los [archivos confiables de configuración](/V3/glossary/#archivos-confiables-de-configuración-trusted-setup-files).
|
||||
|
||||
#### Instalar librería:
|
||||
|
||||
@@ -62,9 +62,9 @@ pnpm add @semaphore-protocol/proof@^3
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
En el caso de uso de un sistema de votación, una vez que todos los votantes hayan ligado sus [identidades](/guides/identities#create-an-identity) al [grupo](/guides/groups) de la votación,
|
||||
En el caso de uso de un sistema de votación, una vez que todos los votantes hayan ligado sus [identidades](/V3/guides/identities#crear-identidades) al [grupo](/V3/guides/groups) de la votación,
|
||||
un votante puede generar una prueba para votar por una propuesta.
|
||||
En el llamado para `generateProof`(generar la prueba), el sistema de votación envía el ID único de la votación (la raíz del [árbol de Merkle](/glossary/#merkle-tree/) del grupo) como el
|
||||
En el llamado para `generateProof`(generar la prueba), el sistema de votación envía el ID único de la votación (la raíz del [árbol de Merkle](/V3/glossary/#árbol-de-merkle-merkle-tree) del grupo) como el
|
||||
`externalNullifier` para impedir que el votante emita más de una señal para esta votación.
|
||||
La siguiente muestra de código demuestra cómo utilizar `generateProof` para generar una prueba de votación:
|
||||
|
||||
@@ -108,10 +108,10 @@ await verifyProof(fullProof, 20) // verdadero o falso.
|
||||
|
||||
## Verificar una prueba on-chain
|
||||
|
||||
Utilice el contrato [`Semaphore.sol`](/technical-reference/contracts#semaphoresol) para verificar pruebas on-chain.
|
||||
Utilice el contrato [`Semaphore.sol`](/V3/technical-reference/contracts#semaphoresol) para verificar pruebas on-chain.
|
||||
|
||||
:::info
|
||||
Vea nuestros [contratos desplegados](/deployed-contracts) para encontrar las direcciones adecuadas para su red.
|
||||
Vea nuestros [contratos desplegados](/V3/deployed-contracts) para encontrar las direcciones adecuadas para su red.
|
||||
::::
|
||||
|
||||
Para verificar las pruebas Semaphore en su contrato, importe `ISemaphore.sol`, transfórmelo a la dirección `Semaphore.sol` y llame el método `verifyProof` con los siguientes parámetros:
|
||||
@@ -119,9 +119,9 @@ Para verificar las pruebas Semaphore en su contrato, importe `ISemaphore.sol`, t
|
||||
- `groupId`: el identificador del grupo;
|
||||
- `merkleTreeRoot`: la raíz del árbol de Merkle;
|
||||
- `signal`: la señal que el usuario quiere enviar de forma anónima ;
|
||||
- `nullifierHash`: un [nullifier hash](#retrieve-a-nullifier-hash) (hash anulador);
|
||||
- `nullifierHash`: un nullifier hash (hash anulador);
|
||||
- `externalNullifier`: el valor que impide la emisión de dos señales por el mismo usuario;
|
||||
- `proof`: una [prueba Semaphore que es compatible con Solidity](#generate-a-solidity-compatible-proof).
|
||||
- `proof`: una prueba Semaphore que es compatible con Solidity.
|
||||
|
||||
:::info
|
||||
Puede importar `ISemaphore.sol` y otros contratos Semaphore del módulo NPM [`@semaphore-protocol/contracts`](https://github.com/semaphore-protocol/semaphore/tree/main/packages/contracts).
|
||||
|
||||
@@ -293,7 +293,7 @@ En la carpeta raíz del proyecto:
|
||||
</Tabs>
|
||||
|
||||
:::note
|
||||
Revise las direcciones de los contratos de Semaphore [aquí](/deployed-contracts).
|
||||
Revise las direcciones de los contratos de Semaphore [aquí](/V3/deployed-contracts).
|
||||
:::
|
||||
|
||||
:::caution
|
||||
|
||||
@@ -6,7 +6,7 @@ sidebar_position: 9
|
||||
|
||||
## Artículos
|
||||
|
||||
[Propuesta de la comunidad: Semaphore: Señalización de conocimiento cero (ZK) en Ethereum (v1 Whitepaper)](https://docs.semaphore.pse.dev/whitepaper-v1.pdf) - Kobi Gurkan, Koh Wei Jie y Barry WhiteHat
|
||||
[Propuesta de la comunidad: Semaphore: Señalización de conocimiento cero (ZK) en Ethereum (v1 Whitepaper)](https://semaphore.pse.dev/whitepaper-v1.pdf) - Kobi Gurkan, Koh Wei Jie y Barry WhiteHat
|
||||
|
||||
[Para Mezcladores y más allá: presentando Semaphore, una herramienta de privacidad construida en Ethereum](https://medium.com/coinmonks/to-mixers-and-beyond-presenting-semaphore-a-privacy-gadget-built-on-ethereum-4c8b00857c9b) - Koh Wei Jie
|
||||
|
||||
|
||||
@@ -6,9 +6,9 @@ sidebar_position: 2
|
||||
|
||||
El [circuito Semaphore](https://github.com/semaphore-protocol/semaphore/tree/main/packages/circuits) es el corazón del protocolo y está compuesto por tres partes:
|
||||
|
||||
- [**Prueba de membresía**](/technical-reference/circuits#proof-of-membership)
|
||||
- [**Nullifier hash**](/technical-reference/circuits#nullifier-hash) (hash anulador)
|
||||
- [**Señal**](/technical-reference/circuits#signal)
|
||||
- [**Prueba de membresía**](#prueba-de-membresía)
|
||||
- [**Nullifier hash**](#hash-anulador-nullifier-hash) (hash anulador)
|
||||
- [**Señal**](#señal)
|
||||
|
||||

|
||||
|
||||
|
||||
@@ -6,10 +6,10 @@ sidebar_position: 3
|
||||
|
||||
Semaphore incluye dos tipos de contratos:
|
||||
|
||||
- [**Contratos base**](/technical-reference/contracts#base-contracts)
|
||||
- [**Contratos para la extensión**](/technical-reference/contracts#extension-contracts)
|
||||
- [**Contratos base**](#contratos-base)
|
||||
- [**Contratos para la extensión**](#contratos-para-la-extensión)
|
||||
|
||||
así como [**Semaphore.sol**](/technical-reference/contracts#semaphoresol), el principal contrato desplegado en las redes soportadas por Semaphore.
|
||||
así como [**Semaphore.sol**](#semaphoresol), el principal contrato desplegado en las redes soportadas por Semaphore.
|
||||
|
||||
:::info
|
||||
Para utilizar los contratos e interfaces Semaphore en su proyecto, instale el paquete NPM [`@semaphore-protocol/contracts`](https://github.com/semaphore-protocol/semaphore/tree/main/packages/contracts).
|
||||
@@ -23,7 +23,7 @@ Semaphore ofrece los siguientes contratos base:
|
||||
- [`SemaphoreGroups.sol`](https://github.com/semaphore-protocol/semaphore/blob/main/packages/contracts/base/SemaphoreGroups.sol): contiene las funciones para crear grupos y añadir/remover/actualizar miembros.
|
||||
|
||||
Los contratos base están relacionados de forma muy cercana al protocolo.
|
||||
Puede utilizarlos en su contrato o puede utilizar [**Semaphore.sol**](/technical-reference/contracts#semaphoresol) que ya los tiene integrados.
|
||||
Puede utilizarlos en su contrato o puede utilizar [**Semaphore.sol**](/V3/technical-reference/contracts#semaphoresol) que ya los tiene integrados.
|
||||
|
||||
:::info
|
||||
Si bien algunas dApps pueden utilizar grupos internos a la cadena, otros puede que prefieran utilizar grupos externos a la cadena, por lo que únicamente guardarán las raíces de sus árboles en el contrato.
|
||||
@@ -42,9 +42,9 @@ En un futuro se incluirán más extensiones.
|
||||
[`Semaphore.sol`](https://github.com/semaphore-protocol/semaphore/blob/main/packages/contracts/contracts/Semaphore.sol) utiliza los contratos base como punto de partida, los integra y de forma adicional brinda:
|
||||
|
||||
- un sistema que solamente permite que administradores (ej. cuentas de Ethereum o contratos inteligentes) controlen grupos;
|
||||
- un mecanismo que guarda los [hashes anuladores](/technical-reference/circuits#nullifier-hash) (nullifier hashes) de cada grupo y evita que el mismo miembro emita dos señales;
|
||||
- un mecanismo que guarda los [hashes anuladores](/V3/technical-reference/circuits#hash-anulador-nullifier-hash) (nullifier hashes) de cada grupo y evita que el mismo miembro emita dos señales;
|
||||
- un mecanismo que permite que pruebas Semaphore generadas con raíces de Merkle antiguas sean verificadas por un periodo de tiempo determinado por el administrador del grupo.
|
||||
|
||||
:::info
|
||||
Visitando [contratos desplegados](/deployed-contracts) puede encontrar las direcciones correspondientes a su red.
|
||||
Visitando [contratos desplegados](/V3/deployed-contracts) puede encontrar las direcciones correspondientes a su red.
|
||||
::::
|
||||
|
||||
@@ -15,9 +15,9 @@ Algunos de los potenciales casos de uso son: votaciones, denuncias, DAOs anónim
|
||||
|
||||
Con Semaphore puede permitir que sus usuarios realicen las siguientes acciones:
|
||||
|
||||
1. [Crear una identidad Semaphore](/guides/identities/).
|
||||
2. [Agregar su identidad Semaphore a un grupo (es decir: _Árbol de Merkle_)](/guides/groups/).
|
||||
3. [Enviar una señal anónima, verificable (ej. un voto o una aprobación)](/guides/proofs/).
|
||||
1. [Crear una identidad Semaphore](/V3/guides/identities/).
|
||||
2. [Agregar su identidad Semaphore a un grupo (es decir: _Árbol de Merkle_)](/V3/guides/groups/).
|
||||
3. [Enviar una señal anónima, verificable (ej. un voto o una aprobación)](/V3/guides/proofs/).
|
||||
|
||||
Cuando un usuario emite una señal (por ejemplo: un voto), las pruebas de conocimiento cero (ZKP) pueden asegurar que el usuario se ha incorporado al grupo y aún no ha emitido una señal con su nullifier (anulador).
|
||||
|
||||
@@ -39,7 +39,7 @@ y [librerías en JavaScript](https://github.com/semaphore-protocol/semaphore#-pa
|
||||
|
||||
### Ceremonia de configuración de confianza (Trusted Setup Ceremony)
|
||||
|
||||
Los [parámetros seguros](/glossary#trusted-setup-files) para generar pruebas válidas con los circuitos Semaphore fueron generados en una [ceremonia de configuración de confianza](https://storage.googleapis.com/trustedsetup-a86f4.appspot.com/semaphore/semaphore_top_index.html) que se completó con más de 300 participantes el [29 de Marzo de 2022](https://etherscan.io/tx/0xec6dbe68883c7593c2bea82f55af18b3aeb5cc146e026d0083a9b3faa9aa0b65#eventlog).
|
||||
Los [parámetros seguros](/V3/glossary#archivos-confiables-de-configuración-trusted-setup-files) para generar pruebas válidas con los circuitos Semaphore fueron generados en una [ceremonia de configuración de confianza](https://storage.googleapis.com/trustedsetup-a86f4.appspot.com/semaphore/semaphore_top_index.html) que se completó con más de 300 participantes el [29 de Marzo de 2022](https://etherscan.io/tx/0xec6dbe68883c7593c2bea82f55af18b3aeb5cc146e026d0083a9b3faa9aa0b65#eventlog).
|
||||
|
||||
### Auditorías
|
||||
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
"scripts": {
|
||||
"start": "docusaurus start",
|
||||
"start:es": "docusaurus start --locale es",
|
||||
"build": "docusaurus build",
|
||||
"pre-build": "yarn workspace @semaphore-protocol/utils build",
|
||||
"build": "yarn pre-build && docusaurus build",
|
||||
"swizzle": "docusaurus swizzle",
|
||||
"deploy": "docusaurus deploy",
|
||||
"clear": "docusaurus clear",
|
||||
@@ -16,6 +17,7 @@
|
||||
"@docusaurus/core": "3.1.1",
|
||||
"@docusaurus/preset-classic": "3.1.1",
|
||||
"@mdx-js/react": "^3.0.0",
|
||||
"@semaphore-protocol/utils": "4.0.0-beta.7",
|
||||
"@svgr/webpack": "^5.5.0",
|
||||
"clsx": "^1.2.1",
|
||||
"docusaurus-plugin-sass": "^0.2.5",
|
||||
|
||||
@@ -1,39 +1,11 @@
|
||||
import { deployedContracts, supportedNetworks } from "@semaphore-protocol/utils"
|
||||
import Heading from "@theme/Heading"
|
||||
import { useEffect, useState } from "react"
|
||||
|
||||
function capitalizeFirstLetter(s: string): string {
|
||||
return s.charAt(0).toUpperCase() + s.slice(1)
|
||||
}
|
||||
|
||||
function getEtherscanLink(network: string): string {
|
||||
switch (network) {
|
||||
case "sepolia":
|
||||
return "https://sepolia.etherscan.io/address/"
|
||||
case "mumbai":
|
||||
return "https://mumbai.polygonscan.com/address/"
|
||||
case "arbitrum":
|
||||
return "https://arbiscan.io/address/"
|
||||
case "arbitrum-sepolia":
|
||||
return "https://sepolia.arbiscan.io/address/"
|
||||
case "optimism-sepolia":
|
||||
return "https://sepolia-optimism.etherscan.io/address/"
|
||||
default:
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
export default function DeployedContracts() {
|
||||
const [deployedContracts, setDeployedContracts] = useState<any[]>([])
|
||||
|
||||
useEffect(() => {
|
||||
fetch(
|
||||
"https://raw.githubusercontent.com/semaphore-protocol/semaphore/feat/semaphore-v4/packages/contracts/deployed-contracts.json"
|
||||
)
|
||||
.then((response) => response.json())
|
||||
.catch(() => [])
|
||||
.then(setDeployedContracts)
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<div>
|
||||
{deployedContracts.map(({ network, contracts }) => (
|
||||
@@ -43,7 +15,11 @@ export default function DeployedContracts() {
|
||||
{contracts.map(({ name, address }) => (
|
||||
<li key={address}>
|
||||
{name}:{" "}
|
||||
<a href={getEtherscanLink(network) + address} target="_blank" rel="noreferrer">
|
||||
<a
|
||||
href={`${supportedNetworks[network].explorer}/address/${address}`}
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
>
|
||||
{address}
|
||||
</a>
|
||||
</li>
|
||||
|
||||
@@ -6,8 +6,12 @@
|
||||
|
||||
/* You can override the default Infima variables here. */
|
||||
|
||||
@import url("https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600&display=swap");
|
||||
@import url("https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600&display=swap");
|
||||
@font-face {
|
||||
font-family: "DM Sans";
|
||||
src: url("/static/fonts/DMSans.ttf") format("truetype");
|
||||
font-weight: 400;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
:root {
|
||||
--ifm-color-primary: "linear(to-r, #4771ea, #2735a6)";
|
||||
@@ -73,13 +77,17 @@ html[data-theme="light"] {
|
||||
}
|
||||
|
||||
html {
|
||||
font-family: "DMSans", sans-serif;
|
||||
font-family: "DM Sans", sans-serif;
|
||||
font-size: 18px;
|
||||
font-variant: none;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
|
||||
font-feature-settings: "ss01" on, "ss02" on, "cv01" on, "cv03" on;
|
||||
font-feature-settings:
|
||||
"ss01" on,
|
||||
"ss02" on,
|
||||
"cv01" on,
|
||||
"cv03" on;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
@@ -93,7 +101,7 @@ svg.custom-icon circle {
|
||||
}
|
||||
|
||||
p {
|
||||
font-family: "DMSans", sans-serif;
|
||||
font-family: "DM Sans", sans-serif;
|
||||
line-height: 32px;
|
||||
font-weight: 400;
|
||||
}
|
||||
@@ -109,7 +117,6 @@ h2,
|
||||
h3,
|
||||
h4,
|
||||
h5 {
|
||||
font-family: "Outfit", sans-serif;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
@@ -267,18 +274,6 @@ html.docs-version-V1 {
|
||||
box-shadow: none !important;
|
||||
}
|
||||
|
||||
.navbar__title {
|
||||
font-family: "Outfit", sans-serif;
|
||||
color: var(--ifm-color-primary);
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.navbar__link {
|
||||
font-family: "Outfit", sans-serif;
|
||||
color: var(--ifm-color-primary);
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
.menu__link {
|
||||
font-size: 18px;
|
||||
font-weight: 400;
|
||||
|
||||
BIN
apps/docs/static/fonts/DMSans.ttf
vendored
Normal file
BIN
apps/docs/static/fonts/DMSans.ttf
vendored
Normal file
Binary file not shown.
BIN
apps/docs/static/img/social-media.png
vendored
Normal file
BIN
apps/docs/static/img/social-media.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 190 KiB |
3
apps/docs/vercel.json
Normal file
3
apps/docs/vercel.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"cleanUrls": true
|
||||
}
|
||||
@@ -95,7 +95,7 @@ to any question. The user, however, can only vote once per question.
|
||||
## About the code
|
||||
|
||||
This repository contains the code for Semaphore's contracts written in
|
||||
Soliidty, and zk-SNARK circuits written in
|
||||
Solidity, and zk-SNARK circuits written in
|
||||
[circom](https://github.com/iden3/circom). It also contains Typescript code to
|
||||
execute tests.
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ For more information, see [Merkle tree in Wikipedia](https://en.wikipedia.org/wi
|
||||
|
||||
A value used to prevent double entry or double signalling.
|
||||
|
||||
See [Circuit nullifier hash](/technical-reference/circuits/#nullifier-hash).
|
||||
See [Circuit nullifier hash](/V2/technical-reference/circuits/#nullifier-hash).
|
||||
|
||||
## Relay
|
||||
|
||||
@@ -48,7 +48,7 @@ A third-party who receives a fee for including relayed transactions in the block
|
||||
To preserve the anonymity of the user broadcasting a signal with Semaphore, an application may use a relayer to post the signal transaction to Ethereum on behalf of the user.
|
||||
|
||||
Applications may provide rewards for relayers and implement front-running prevention mechanisms, such as requiring the signals to include the relayer’s address, binding the
|
||||
signal to that specific address (https://docs.semaphore.pse.dev/whitepaper-v1.pdf, p.6).
|
||||
signal to that specific address (https://semaphore.pse.dev/whitepaper-v1.pdf, p.6).
|
||||
|
||||
## Trusted setup files
|
||||
|
||||
|
||||
@@ -20,14 +20,14 @@ title: Groups
|
||||
|
||||
Use Semaphore in your application or smart contract to create off-chain and on-chain groups.
|
||||
|
||||
A [Semaphore group](/glossary/#semaphore-group) contains [identity commitments](/glossary/#identity-commitment) of group members.
|
||||
A [Semaphore group](/V2/glossary/#semaphore-group) contains [identity commitments](/V2/glossary/#identity-commitment) of group members.
|
||||
Example uses of groups include the following:
|
||||
|
||||
- Poll question that attendees join to rate an event.
|
||||
- Ballot that members join to vote on a proposal.
|
||||
- Whistleblowers who are verified employees of an organization.
|
||||
|
||||
A Semaphore group is an [incremental Merkle tree](/glossary/#incremental-merkle-tree), and group members (i.e., [identity commitments](/glossary/#identity-commitments)) are tree leaves.
|
||||
A Semaphore group is an [incremental Merkle tree](/V2/glossary/#merkle-tree), and group members (i.e., [identity commitments](/V2/glossary/#identity-commitment)) are tree leaves.
|
||||
Semaphore groups set the following two parameters:
|
||||
|
||||
- **Tree depth**: the maximum number of members a group can contain (`max size = 2 ^ tree depth`).
|
||||
|
||||
@@ -5,7 +5,7 @@ title: Identities
|
||||
|
||||
# Semaphore identities
|
||||
|
||||
In order to join a [Semaphore group](/glossary#semaphore-group), a user must first create a [Semaphore identity](/glossary#semaphore-identity).
|
||||
In order to join a [Semaphore group](/V2/glossary#semaphore-group), a user must first create a [Semaphore identity](/V2/glossary#semaphore-identity).
|
||||
A Semaphore identity contains two values generated with the identity:
|
||||
|
||||
- Identity trapdoor
|
||||
|
||||
@@ -7,7 +7,7 @@ title: Proofs
|
||||
|
||||
Learn how to use Semaphore to generate and verify zero-knowledge proofs.
|
||||
|
||||
Once a user joins their [Semaphore identity](/glossary#semaphore-identity) to a [Semaphore group](/glossary#semaphore-group), the user can signal anonymously with a zero-knowledge proof that proves the following:
|
||||
Once a user joins their [Semaphore identity](/V2/glossary#semaphore-identity) to a [Semaphore group](/V2/glossary#semaphore-group), the user can signal anonymously with a zero-knowledge proof that proves the following:
|
||||
|
||||
- The user is a member of the group.
|
||||
- The same user created the signal and the proof.
|
||||
@@ -27,11 +27,11 @@ To generate a proof, pass the following properties to the `generateProof` functi
|
||||
- `group`: The group to which the user belongs.
|
||||
- `externalNullifier`: The value that prevents double-signaling.
|
||||
- `signal`: The signal the user wants to send anonymously.
|
||||
- `snarkArtifacts`: The `zkey` and `wasm` [trusted setup files](/glossary/#trusted-setup-files).
|
||||
- `snarkArtifacts`: The `zkey` and `wasm` [trusted setup files](/V2/glossary/#trusted-setup-files).
|
||||
|
||||
In the voting system use case, once all the voters have joined their [identities](/guides/identities#create-an-identity) to the ballot [group](/guides/groups),
|
||||
In the voting system use case, once all the voters have joined their [identities](/guides/identities#create-identities) to the ballot [group](/guides/groups),
|
||||
a voter can generate a proof to vote for a proposal.
|
||||
In the call to `generateProof`, the voting system passes the unique ballot ID (the [Merkle tree](/glossary/#merkle-tree/) root of the group) as the
|
||||
In the call to `generateProof`, the voting system passes the unique ballot ID (the [Merkle tree](/V2/glossary/#merkle-tree) root of the group) as the
|
||||
`externalNullifier` to prevent the voter signaling more than once for the ballot.
|
||||
The following code sample shows how to use `generateProof` to generate the voting proof:
|
||||
|
||||
@@ -53,7 +53,7 @@ Use the [`@semaphore-protocol/proof`](https://github.com/semaphore-protocol/sema
|
||||
To verify a proof, pass the following to the `verifyProof` function:
|
||||
|
||||
- _`proof`_: the Semaphore proof.
|
||||
- _`verificationKey`_: the JavaScript object in the `semaphore.json` [trusted setup file](/glossary/#trusted-setup-files).
|
||||
- _`verificationKey`_: the JavaScript object in the `semaphore.json` [trusted setup file](/V2/glossary/#trusted-setup-files).
|
||||
|
||||
The following code sample shows how to parse the verification key object from `semaphore.json`
|
||||
and verify the previously generated proof:
|
||||
|
||||
@@ -213,7 +213,7 @@ and [Chai assertions](https://www.chaijs.com/).
|
||||
wget http://www.trusted-setup-pse.org/semaphore/20/semaphore.wasm
|
||||
```
|
||||
|
||||
Learn more about [trusted setup files](/glossary/#trusted-setup-files).
|
||||
Learn more about [trusted setup files](/V2/glossary/#trusted-setup-files).
|
||||
|
||||
3. Rename the `Lock.js` test file to `Greeter.js` and replace the content with the following:
|
||||
|
||||
|
||||
@@ -6,9 +6,9 @@ sidebar_position: 2
|
||||
|
||||
The [Semaphore circuit](https://github.com/semaphore-protocol/semaphore/tree/v2.6.1/packages/circuits) is the heart of the protocol and consists of three parts:
|
||||
|
||||
- [**Proof of membership**](/technical-reference/circuits#proof-of-membership)
|
||||
- [**Nullifier hash**](/technical-reference/circuits#nullifier-hash)
|
||||
- [**Signal**](/technical-reference/circuits#signal)
|
||||
- [**Proof of membership**](/V2/technical-reference/circuits#proof-of-membership)
|
||||
- [**Nullifier hash**](/V2/technical-reference/circuits#nullifier-hash)
|
||||
- [**Signal**](/V2/technical-reference/circuits#signal)
|
||||
|
||||

|
||||
|
||||
|
||||
@@ -6,9 +6,9 @@ sidebar_position: 3
|
||||
|
||||
Semaphore includes three types of contracts:
|
||||
|
||||
- [**Base contracts**](/technical-reference/contracts#base-contracts)
|
||||
- [**Extension contracts**](/technical-reference/contracts#extension-contracts)
|
||||
- [**Verifiers**](/technical-reference/contracts#verifiers)
|
||||
- [**Base contracts**](/V2/technical-reference/contracts#base-contracts)
|
||||
- [**Extension contracts**](/V2/technical-reference/contracts#extension-contracts)
|
||||
- [**Verifiers**](/V2/technical-reference/contracts#verifiers)
|
||||
|
||||
:::info
|
||||
To use Semaphore contracts and interfaces in your project,
|
||||
@@ -24,7 +24,7 @@ Semaphore provides the following base contracts:
|
||||
|
||||
These contracts are closely related to the protocol.
|
||||
You can inherit them in your contract or you can use [`Semaphore.sol`](https://github.com/semaphore-protocol/semaphore/tree/v2.6.1/packages/contracts/contracts/Semaphore.sol), which inherits them for you.
|
||||
See our [deployed contracts](/deployed-contracts#semaphore) to find the addresses for your network.
|
||||
See our [deployed contracts](/V2/deployed-contracts#semaphore) to find the addresses for your network.
|
||||
|
||||
:::info
|
||||
While some dApps may use on-chain groups, others may prefer to use off-chain groups, saving only their tree roots in the contract.
|
||||
@@ -41,10 +41,10 @@ More extensions will be added in the future.
|
||||
## Verifiers
|
||||
|
||||
To verify Semaphore proofs, the [`SemaphoreCore.sol`](https://github.com/semaphore-protocol/semaphore/tree/v2.6.1/packages/contracts/contracts/base/SemaphoreCore.sol) contract requires the address of a deployed verifier contract.
|
||||
You can choose to manually deploy the [verifier](https://github.com/semaphore-protocol/semaphore/tree/v2.6.1/packages/contracts/contracts/verifiers) you prefer or you can use one of our [deployed verifiers](/deployed-contracts#verifiers).
|
||||
You can choose to manually deploy the [verifier](https://github.com/semaphore-protocol/semaphore/tree/v2.6.1/packages/contracts/contracts/verifiers) you prefer or you can use one of our [deployed verifiers](/V2/deployed-contracts#verifiers).
|
||||
|
||||
Each verifier name indicates the tree depth that it can verify.
|
||||
For example, given a Semaphore proof generated with a tree depth `20`:
|
||||
|
||||
- The `Verifier20.sol` contract can verify the proof.
|
||||
- The [group](/guides/groups) used for the proof can have a maximum `2^20=1048576` members.
|
||||
- The [group](/V2/guides/groups) used for the proof can have a maximum `2^20=1048576` members.
|
||||
|
||||
@@ -36,7 +36,7 @@ Community members connect their wallets to the dApp to take the following action
|
||||
|
||||
### Relay
|
||||
|
||||
To preserve anonymity and avoid disclosing the member's wallet address, the dApp may use a [relay](/glossary/#relay) to broadcast the vote.
|
||||
To preserve anonymity and avoid disclosing the member's wallet address, the dApp may use a [relay](/V2/glossary/#relay) to broadcast the vote.
|
||||
The relay calls the **contract** function that then posts the member's vote transaction to Ethereum.
|
||||
|
||||
## Private voting
|
||||
@@ -52,7 +52,7 @@ The voting scenario has the following steps:
|
||||
|
||||
### Create a poll
|
||||
|
||||
A community coordinator or dApp administrator uses the deployed smart contract to create an on-chain (Ethereum) poll, a [Semaphore group](/guides/groups/) that members can join and cast votes to.
|
||||
A community coordinator or dApp administrator uses the deployed smart contract to create an on-chain (Ethereum) poll, a [Semaphore group](/V2/guides/groups/) that members can join and cast votes to.
|
||||
|
||||
In the following sample code, the voting contract declares a `createPoll` function that uses the Semaphore base `_createGroup` function:
|
||||
|
||||
@@ -77,11 +77,11 @@ function createPoll(
|
||||
}
|
||||
```
|
||||
|
||||
A poll is a Semaphore [group](/guides/groups/) that stores the following:
|
||||
A poll is a Semaphore [group](/V2/guides/groups/) that stores the following:
|
||||
|
||||
- A topic to vote on.
|
||||
- The public ID of the poll creator.
|
||||
- [Semaphore IDs](/guides/identities/) of members who joined the poll.
|
||||
- [Semaphore IDs](/V2/guides/identities/) of members who joined the poll.
|
||||
|
||||
To create the poll, the administrator calls the smart contract function--for example:
|
||||
|
||||
@@ -127,10 +127,10 @@ With a member registered for a poll, learn how the dApp [records votes](#record-
|
||||
Once members have joined a poll, the coordinator starts the poll to allow voting.
|
||||
When a member votes (for example, by selecting a radio button), then the dApp takes the following actions:
|
||||
|
||||
1. Uses the `@semaphore-protocol/proof` library to create a proof of the vote, the poll identifier, the Semaphore ID, and a [nullifier](/glossary/#nullifier) that prevents double-voting.
|
||||
1. Uses the `@semaphore-protocol/proof` library to create a proof of the vote, the poll identifier, the Semaphore ID, and a [nullifier](/V2/glossary/#nullifier) that prevents double-voting.
|
||||
2. Sends the vote proof to the [relay](#relay).
|
||||
|
||||
### Related
|
||||
|
||||
- To get started developing with Semaphore, see the [Quick setup](/quick-setup/) guide.
|
||||
- To get started developing with Semaphore, see the [Quick setup](/V2/quick-setup/) guide.
|
||||
- For an example app that you can use to start your own project, see [Semaphore boilerplate](https://github.com/semaphore-protocol/boilerplate).
|
||||
|
||||
@@ -15,9 +15,9 @@ Use cases include private voting, whistleblowing, anonymous DAOs and mixers.
|
||||
|
||||
With Semaphore, you can allow your users to do the following:
|
||||
|
||||
1. [Create a Semaphore identity](/guides/identities/).
|
||||
2. [Add their Semaphore identity to a group (i.e. _Merkle tree_)](/guides/groups/).
|
||||
3. [Send a verifiable, anonymous signal (e.g a vote or endorsement)](/guides/proofs/).
|
||||
1. [Create a Semaphore identity](/V2/guides/identities/).
|
||||
2. [Add their Semaphore identity to a group (i.e. _Merkle tree_)](/V2/guides/groups/).
|
||||
3. [Send a verifiable, anonymous signal (e.g a vote or endorsement)](/V2/guides/proofs/).
|
||||
|
||||
When a user broadcasts a signal (for example: a vote), Semaphore zero-knowledge
|
||||
proofs can ensure that the user has joined the group and hasn't already cast a signal with their nullifier.
|
||||
|
||||
@@ -30,7 +30,7 @@ Finally, the nullifier hash is just the hash of the identity nullifier and the e
|
||||
|
||||
In the case of a voting application, if you have a group and you want all members of this group to vote only once, you can use the id of the group as an external nullifier. When a user votes the first time, you can save the hash of their identity nullifier and the group id (i.e. the nullifier hash) and prevent double-voting by checking if that hash already exists.
|
||||
|
||||
See the [Semaphore circuits](https://docs.semaphore.pse.dev/technical-reference/circuits) for more technical information, or the [Semaphore boilerplate](https://github.com/semaphore-protocol/boilerplate) for a real use-case.
|
||||
See the [Semaphore circuits](https://docs.semaphore.pse.dev/technical-reference/circuits) for more technical information, or the [Semaphore boilerplate](https://github.com/semaphore-protocol/boilerplate/tree/version/3) for a real use-case.
|
||||
|
||||
## Why should I prevent proofs from being verified twice?
|
||||
|
||||
@@ -44,11 +44,11 @@ You can find some applications that are using Semaphore in [this blog post](http
|
||||
|
||||
## How can I start a project using Semaphore?
|
||||
|
||||
There are three ways you can start using Semaphore in your project: using the [Semaphore CLI](https://github.com/semaphore-protocol/semaphore/tree/main/packages/cli), using the [Semaphore boilerplate](https://github.com/semaphore-protocol/boilerplate) as a template or forking it, or installing the Semaphore packages manually.
|
||||
There are three ways you can start using Semaphore in your project: using the [Semaphore CLI](https://github.com/semaphore-protocol/semaphore/tree/v3.15.2/packages/cli), using the [Semaphore boilerplate](https://github.com/semaphore-protocol/boilerplate/tree/version/3) as a template or forking it, or installing the Semaphore packages manually.
|
||||
|
||||
### Semaphore CLI
|
||||
|
||||
To create a new project you could use `npx` or install the [Semaphore CLI](https://github.com/semaphore-protocol/semaphore/tree/main/packages/cli) globally using `npm` and then create the new project using the `semaphore create` command. See the [Quick Setup](https://docs.semaphore.pse.dev/quick-setup) for more information.
|
||||
To create a new project you could use `npx` or install the [Semaphore CLI](https://github.com/semaphore-protocol/semaphore/tree/v3.15.2/packages/cli) globally using `npm` and then create the new project using the `semaphore create` command. See the [Quick Setup](https://docs.semaphore.pse.dev/quick-setup) for more information.
|
||||
|
||||
There are three supported templates right now: `contracts-hardhat`, `monorepo-ethers` and `monorepo-subgraph`.
|
||||
|
||||
@@ -65,7 +65,7 @@ The Semaphore CLI can also be used to get group data from a supported network. T
|
||||
|
||||
### Semaphore boilerplate
|
||||
|
||||
To create a project, you could also use the [Semaphore boilerplate](https://github.com/semaphore-protocol/boilerplate). You could fork it or use it as a template.
|
||||
To create a project, you could also use the [Semaphore boilerplate](https://github.com/semaphore-protocol/boilerplate/tree/version/3). You could fork it or use it as a template.
|
||||
|
||||
The Semaphore CLI templates and the Semaphore boilerplate contain the same code, which is a feedback application where you can create an identity, join a group, and send your feedback anonymously. They are almost the same, the only difference is that the templates use plain CSS so you can decide the CSS framework or library you want to use and the boilerplate uses [ChakraUI](https://chakra-ui.com/) by default.
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ For more information, see [Merkle tree in Wikipedia](https://en.wikipedia.org/wi
|
||||
|
||||
A value used to prevent double entry or double signalling.
|
||||
|
||||
See [Circuit nullifier hash](/technical-reference/circuits/#nullifier-hash).
|
||||
See [Circuit nullifier hash](/V3/technical-reference/circuits/#nullifier-hash).
|
||||
|
||||
## Relay
|
||||
|
||||
@@ -47,7 +47,7 @@ A third-party who receives a fee for including relayed transactions in the block
|
||||
To preserve the anonymity of the user broadcasting a signal with Semaphore, an application may use a relayer to post the signal transaction to Ethereum on behalf of the user.
|
||||
|
||||
Applications may provide rewards for relayers and implement front-running prevention mechanisms, such as requiring the signals to include the relayer’s address, binding the
|
||||
signal to that specific address (https://docs.semaphore.pse.dev/whitepaper-v1.pdf, p.6).
|
||||
signal to that specific address (https://semaphore.pse.dev/whitepaper-v1.pdf, p.6).
|
||||
|
||||
## Trusted setup files
|
||||
|
||||
|
||||
@@ -8,9 +8,9 @@ import TabItem from "@theme/TabItem"
|
||||
|
||||
# Semaphore data
|
||||
|
||||
To fetch on-chain data from the [Semaphore.sol](https://github.com/semaphore-protocol/semaphore/blob/main/packages/contracts/contracts/Semaphore.sol) contract, you can use the [@semaphore-protocol/data](https://github.com/semaphore-protocol/semaphore/tree/main/packages/data) library.
|
||||
To fetch on-chain data from the [Semaphore.sol](https://github.com/semaphore-protocol/semaphore/blob/v3.15.2/packages/contracts/contracts/Semaphore.sol) contract, you can use the [@semaphore-protocol/data](https://github.com/semaphore-protocol/semaphore/tree/v3.15.2/packages/data) library.
|
||||
|
||||
There are two ways to do this, using [`SemaphoreSubgraph`](https://github.com/semaphore-protocol/semaphore/blob/main/packages/data/src/subgraph.ts) or [`SemaphoreEthers`](https://github.com/semaphore-protocol/semaphore/blob/main/packages/data/src/ethers.ts). The `SemaphoreSubgraph` class uses the [Semaphore subgraph](https://github.com/semaphore-protocol/subgraph), which uses [The Graph Protocol](https://thegraph.com/) under the hood, and the `SemaphoreEthers` class uses [Ethers](https://github.com/ethers-io/ethers.js/).
|
||||
There are two ways to do this, using [`SemaphoreSubgraph`](https://github.com/semaphore-protocol/semaphore/blob/v3.15.2/packages/data/src/subgraph.ts) or [`SemaphoreEthers`](https://github.com/semaphore-protocol/semaphore/blob/v3.15.2/packages/data/src/ethers.ts). The `SemaphoreSubgraph` class uses the [Semaphore subgraph](https://github.com/semaphore-protocol/subgraph), which uses [The Graph Protocol](https://thegraph.com/) under the hood, and the `SemaphoreEthers` class uses [Ethers](https://github.com/ethers-io/ethers.js/).
|
||||
|
||||
- [**Fetch data using SemaphoreSubgraph**](#fetch-data-using-semaphoresubgraph)
|
||||
- [**Fetch data using SemaphoreEthers**](#fetch-data-using-semaphoreethers)
|
||||
@@ -50,7 +50,7 @@ pnpm add @semaphore-protocol/data@^3
|
||||
|
||||
## Fetch data using SemaphoreSubgraph
|
||||
|
||||
To fetch data using the Semaphore subgraph you can use the [`SemaphoreSubgraph`](https://github.com/semaphore-protocol/semaphore/blob/main/packages/data/src/subgraph.ts) class from the [@semaphore-protocol/data](https://github.com/semaphore-protocol/semaphore/tree/main/packages/data) package.
|
||||
To fetch data using the Semaphore subgraph you can use the [`SemaphoreSubgraph`](https://github.com/semaphore-protocol/semaphore/blob/v3.15.2/packages/data/src/subgraph.ts) class from the [@semaphore-protocol/data](https://github.com/semaphore-protocol/semaphore/tree/v3.15.2/packages/data) package.
|
||||
|
||||
```typescript
|
||||
import { SemaphoreSubgraph } from "@semaphore-protocol/data"
|
||||
@@ -117,7 +117,7 @@ const group = new Group(groupId, 20, members)
|
||||
|
||||
## Fetch data using SemaphoreEthers
|
||||
|
||||
To fetch data using Ethers you can use the [`SemaphoreEthers`](https://github.com/semaphore-protocol/semaphore/blob/main/packages/data/src/ethers.ts) class from the [@semaphore-protocol/data](https://github.com/semaphore-protocol/semaphore/tree/main/packages/data) package.
|
||||
To fetch data using Ethers you can use the [`SemaphoreEthers`](https://github.com/semaphore-protocol/semaphore/blob/v3.15.2/packages/data/src/ethers.ts) class from the [@semaphore-protocol/data](https://github.com/semaphore-protocol/semaphore/tree/v3.15.2/packages/data) package.
|
||||
|
||||
```typescript
|
||||
import { SemaphoreEthers } from "@semaphore-protocol/data"
|
||||
|
||||
@@ -8,14 +8,14 @@ import TabItem from "@theme/TabItem"
|
||||
|
||||
# Semaphore groups
|
||||
|
||||
A [Semaphore group](/glossary/#semaphore-group) contains [identity commitments](/glossary/#identity-commitment) of group members.
|
||||
A [Semaphore group](/V3/glossary/#semaphore-group) contains [identity commitments](/V3/glossary/#identity-commitment) of group members.
|
||||
Example uses of groups include the following:
|
||||
|
||||
- poll question that attendees join to rate an event,
|
||||
- ballot that members join to vote on a proposal,
|
||||
- whistleblowers who are verified employees of an organization.
|
||||
|
||||
A Semaphore group is an [incremental Merkle tree](/glossary/#incremental-merkle-tree), and group members (i.e., [identity commitments](/glossary/#identity-commitments)) are tree leaves.
|
||||
A Semaphore group is an [incremental Merkle tree](/V3/glossary/#merkle-tree), and group members (i.e., [identity commitments](/V3/glossary/#identity-commitment)) are tree leaves.
|
||||
Semaphore groups set the following three parameters:
|
||||
|
||||
- **Group id**: a unique identifier for the group;
|
||||
@@ -35,7 +35,7 @@ Learn how to work with groups.
|
||||
|
||||
### Create a group
|
||||
|
||||
Use the [`@semaphore-protocol/group`](https://github.com/semaphore-protocol/semaphore/blob/main/packages/group) library `Group` class to create an off-chain group with the following parameters:
|
||||
Use the [`@semaphore-protocol/group`](https://github.com/semaphore-protocol/semaphore/blob/v3.15.2/packages/group) library `Group` class to create an off-chain group with the following parameters:
|
||||
|
||||
- `Group id`: a unique identifier for the group;
|
||||
- `Tree depth`: (_default `20`_) the maximum number of members a group can contain (`max size = 2 ^ tree depth`).
|
||||
@@ -142,13 +142,13 @@ Given that the node isn't removed, and the length of the `group.members` array d
|
||||
|
||||
## On-chain groups
|
||||
|
||||
The [`SemaphoreGroups`](https://github.com/semaphore-protocol/semaphore/blob/main/packages/contracts/contracts/base/SemaphoreGroups.sol) contract uses the [`IncrementalBinaryTree`](https://github.com/privacy-scaling-explorations/zk-kit/blob/main/packages/incremental-merkle-tree.sol/contracts/IncrementalBinaryTree.sol) library and provides methods to create and manage groups.
|
||||
The [`SemaphoreGroups`](https://github.com/semaphore-protocol/semaphore/blob/v3.15.2/packages/contracts/contracts/base/SemaphoreGroups.sol) contract uses the [`IncrementalBinaryTree`](https://github.com/privacy-scaling-explorations/zk-kit/blob/main/packages/incremental-merkle-tree.sol/contracts/IncrementalBinaryTree.sol) library and provides methods to create and manage groups.
|
||||
|
||||
:::info
|
||||
You can import `SemaphoreGroups.sol` and other Semaphore contracts from the [`@semaphore-protocol/contracts`](https://github.com/semaphore-protocol/semaphore/tree/main/packages/contracts) NPM module.
|
||||
You can import `SemaphoreGroups.sol` and other Semaphore contracts from the [`@semaphore-protocol/contracts`](https://github.com/semaphore-protocol/semaphore/tree/v3.15.2/packages/contracts) NPM module.
|
||||
:::
|
||||
|
||||
Alternatively, you can use an already deployed [`Semaphore.sol`](https://github.com/semaphore-protocol/semaphore/blob/main/packages/contracts/contracts/Semaphore.sol) contract and use its group external functions.
|
||||
Alternatively, you can use an already deployed [`Semaphore.sol`](https://github.com/semaphore-protocol/semaphore/blob/v3.15.2/packages/contracts/contracts/Semaphore.sol) contract and use its group external functions.
|
||||
|
||||
:::caution
|
||||
`Semaphore.sol` does not check if a member with a specific identity commitment already exists in a group. This check must be done off-chain.
|
||||
|
||||
@@ -8,7 +8,7 @@ import TabItem from "@theme/TabItem"
|
||||
|
||||
# Semaphore identities
|
||||
|
||||
In order to join a [Semaphore group](/glossary#semaphore-group), a user must first create a [Semaphore identity](/glossary#semaphore-identity).
|
||||
In order to join a [Semaphore group](/V3/glossary#semaphore-group), a user must first create a [Semaphore identity](/V3/glossary#semaphore-identity).
|
||||
A Semaphore identity contains two values generated with the identity:
|
||||
|
||||
- Identity trapdoor
|
||||
@@ -19,7 +19,7 @@ To prevent fraud, the owner should keep both values secret.
|
||||
|
||||
## Create identities
|
||||
|
||||
In your code, use the [`@semaphore-protocol/identity`](https://github.com/semaphore-protocol/semaphore/tree/main/packages/identity) library to create a Semaphore identity _deterministically_ (from the hash of a message) or _randomly_.
|
||||
In your code, use the [`@semaphore-protocol/identity`](https://github.com/semaphore-protocol/semaphore/tree/v3.15.2/packages/identity) library to create a Semaphore identity _deterministically_ (from the hash of a message) or _randomly_.
|
||||
|
||||
- [**Create random identities**](#create-random-identities)
|
||||
- [**Create deterministic identities**](#create-deterministic-identities)
|
||||
|
||||
@@ -8,7 +8,7 @@ import TabItem from "@theme/TabItem"
|
||||
|
||||
# Semaphore proofs
|
||||
|
||||
Once a user joins their [Semaphore identity](/glossary#semaphore-identity) to a [Semaphore group](/glossary#semaphore-group), the user can signal anonymously with a zero-knowledge proof that proves the following:
|
||||
Once a user joins their [Semaphore identity](/V3/glossary#semaphore-identity) to a [Semaphore group](/V3/glossary#semaphore-group), the user can signal anonymously with a zero-knowledge proof that proves the following:
|
||||
|
||||
- the user is a member of the group,
|
||||
- the same user created the signal and the proof.
|
||||
@@ -21,14 +21,14 @@ Developers can use Semaphore for the following:
|
||||
|
||||
## Generate a proof off-chain
|
||||
|
||||
Use the [`@semaphore-protocol/proof`](https://github.com/semaphore-protocol/semaphore/tree/main/packages/proof) library to generate an off-chain proof.
|
||||
Use the [`@semaphore-protocol/proof`](https://github.com/semaphore-protocol/semaphore/tree/v3.15.2/packages/proof) library to generate an off-chain proof.
|
||||
To generate a proof, pass the following parameters to the `generateProof` function:
|
||||
|
||||
- `identity`: the Semaphore identity of the user broadcasting the signal and generating the proof;
|
||||
- `group`: the group to which the user belongs;
|
||||
- `externalNullifier`: the value that prevents double-signaling;
|
||||
- `signal`: the signal the user wants to send anonymously;
|
||||
- `snarkArtifacts`: the `zkey` and `wasm` [trusted setup files](/glossary/#trusted-setup-files).
|
||||
- `snarkArtifacts`: the `zkey` and `wasm` [trusted setup files](/V3/glossary/#trusted-setup-files).
|
||||
|
||||
#### Install library:
|
||||
|
||||
@@ -63,9 +63,9 @@ pnpm add @semaphore-protocol/proof@^3
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
In the voting system use case, once all the voters have joined their [identities](/guides/identities#create-an-identity) to the ballot [group](/guides/groups),
|
||||
In the voting system use case, once all the voters have joined their [identities](/V3/guides/identities#create-identities) to the ballot [group](/V3/guides/groups),
|
||||
a voter can generate a proof to vote for a proposal.
|
||||
In the call to `generateProof`, the voting system passes the unique ballot ID (the [Merkle tree](/glossary/#merkle-tree/) root of the group) as the
|
||||
In the call to `generateProof`, the voting system passes the unique ballot ID (the [Merkle tree](/V3/glossary#merkle-tree) root of the group) as the
|
||||
`externalNullifier` to prevent the voter signaling more than once for the ballot.
|
||||
The following code sample shows how to use `generateProof` to generate the voting proof:
|
||||
|
||||
@@ -91,7 +91,7 @@ const fullProof = await generateProof(identity, group, externalNullifier, signal
|
||||
|
||||
## Verify a proof off-chain
|
||||
|
||||
Use the [`@semaphore-protocol/proof`](https://github.com/semaphore-protocol/semaphore/tree/main/packages/proof) library to verify a Semaphore proof off-chain.
|
||||
Use the [`@semaphore-protocol/proof`](https://github.com/semaphore-protocol/semaphore/tree/v3.15.2/packages/proof) library to verify a Semaphore proof off-chain.
|
||||
To verify a proof, pass the following to the `verifyProof` function:
|
||||
|
||||
- `fullProof`: the Semaphore proof;
|
||||
@@ -109,10 +109,10 @@ await verifyProof(fullProof, 20) // true or false.
|
||||
|
||||
## Verify a proof on-chain
|
||||
|
||||
Use the [`Semaphore.sol`](/technical-reference/contracts#semaphoresol) contract to verify proofs on-chain.
|
||||
Use the [`Semaphore.sol`](/V3/technical-reference/contracts#semaphoresol) contract to verify proofs on-chain.
|
||||
|
||||
:::info
|
||||
See our [deployed contracts](/deployed-contracts) to find the addresses for your network.
|
||||
See our [deployed contracts](/V3/deployed-contracts) to find the addresses for your network.
|
||||
::::
|
||||
|
||||
To verify Semaphore proofs in your contract, import `ISemaphore.sol`, pass it the `Semaphore.sol` address and call the `verifyProof` method with following parameters:
|
||||
@@ -120,10 +120,10 @@ To verify Semaphore proofs in your contract, import `ISemaphore.sol`, pass it th
|
||||
- `groupId`: the identifier of the group;
|
||||
- `merkleTreeRoot`: the root of the Merkle tree;
|
||||
- `signal`: the signal the user wants to send anonymously;
|
||||
- `nullifierHash`: a [nullifier hash](#retrieve-a-nullifier-hash);
|
||||
- `nullifierHash`: a nullifier hash;
|
||||
- `externalNullifier`: the value that prevents double-signaling;
|
||||
- `proof`: a [Solidity-compatible Semaphore proof](#generate-a-solidity-compatible-proof).
|
||||
- `proof`: a Solidity-compatible Semaphore proof.
|
||||
|
||||
:::info
|
||||
You can import `ISemaphore.sol` and other Semaphore contracts from the [`@semaphore-protocol/contracts`](https://github.com/semaphore-protocol/semaphore/tree/main/packages/contracts) NPM module.
|
||||
You can import `ISemaphore.sol` and other Semaphore contracts from the [`@semaphore-protocol/contracts`](https://github.com/semaphore-protocol/semaphore/tree/v3.15.2/packages/contracts) NPM module.
|
||||
:::
|
||||
|
||||
@@ -21,11 +21,11 @@ semaphore create my-app --template monorepo-ethers
|
||||
```
|
||||
|
||||
:::info
|
||||
The supported templates are: [`contracts-hardhat`](https://github.com/semaphore-protocol/semaphore/tree/main/packages/cli-template-contracts-hardhat), [`monorepo-ethers`](https://github.com/semaphore-protocol/semaphore/tree/main/packages/cli-template-monorepo-ethers), [`monorepo-subgraph`](https://github.com/semaphore-protocol/semaphore/tree/main/packages/cli-template-monorepo-subgraph).
|
||||
The supported templates are: [`contracts-hardhat`](https://github.com/semaphore-protocol/semaphore/tree/v3.15.2/packages/cli-template-contracts-hardhat), [`monorepo-ethers`](https://github.com/semaphore-protocol/semaphore/tree/v3.15.2/packages/cli-template-monorepo-ethers), [`monorepo-subgraph`](https://github.com/semaphore-protocol/semaphore/tree/v3.15.2/packages/cli-template-monorepo-subgraph).
|
||||
:::
|
||||
|
||||
:::info
|
||||
The [`semaphore CLI`](https://github.com/semaphore-protocol/semaphore/tree/main/packages/cli) can also be used to get group data from a supported network (e.g `semaphore get-groups --network arbitrum-goerli`).
|
||||
The [`semaphore CLI`](https://github.com/semaphore-protocol/semaphore/tree/v3.15.2/packages/cli) can also be used to get group data from a supported network (e.g `semaphore get-groups --network arbitrum-goerli`).
|
||||
:::
|
||||
|
||||
To start working on your project, install the dependencies:
|
||||
@@ -293,7 +293,7 @@ In the project root folder:
|
||||
</Tabs>
|
||||
|
||||
:::note
|
||||
Check the Semaphore contract addresses [here](/deployed-contracts).
|
||||
Check the Semaphore contract addresses [here](/V3/deployed-contracts).
|
||||
:::
|
||||
|
||||
:::caution
|
||||
|
||||
@@ -6,7 +6,7 @@ sidebar_position: 9
|
||||
|
||||
## Articles
|
||||
|
||||
[Community Proposal: Semaphore: Zero-Knowledge Signaling on Ethereum (Whitepaper v1)](https://docs.semaphore.pse.dev/whitepaper-v1.pdf) - Kobi Gurkan, Koh Wei Jie and Barry WhiteHat
|
||||
[Community Proposal: Semaphore: Zero-Knowledge Signaling on Ethereum (Whitepaper v1)](https://semaphore.pse.dev/whitepaper-v1.pdf) - Kobi Gurkan, Koh Wei Jie and Barry WhiteHat
|
||||
|
||||
[To Mixers and Beyond: presenting Semaphore, a privacy gadget built on Ethereum](https://medium.com/coinmonks/to-mixers-and-beyond-presenting-semaphore-a-privacy-gadget-built-on-ethereum-4c8b00857c9b) - Koh Wei Jie
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ sidebar_position: 6
|
||||
|
||||
[The Graph](https://thegraph.com/) is a protocol for indexing networks like Ethereum and IPFS.
|
||||
Site owners publish _subgraphs_ that expose site data for anyone to query.
|
||||
Semaphore's subgraph allows you to retrieve data from the [`Semaphore.sol`](https://github.com/semaphore-protocol/semaphore/blob/main/packages/contracts/Semaphore.sol) smart contract.
|
||||
Semaphore's subgraph allows you to retrieve data from the [`Semaphore.sol`](https://github.com/semaphore-protocol/semaphore/blob/v3.15.2/packages/contracts/Semaphore.sol) smart contract.
|
||||
|
||||
:::tip
|
||||
The Graph protocol uses the [GraphQL](https://graphql.org/) query language. For examples, see the [GraphQL API documentation](https://thegraph.com/docs/developer/graphql-api). Visit the [subgraph repository](https://github.com/semaphore-protocol/subgraph) to see the list of Semaphore subgraphs.
|
||||
|
||||
@@ -4,13 +4,13 @@ sidebar_position: 2
|
||||
|
||||
# Circuits
|
||||
|
||||
The [Semaphore circuit](https://github.com/semaphore-protocol/semaphore/tree/main/packages/circuits) is the heart of the protocol and consists of three parts:
|
||||
The [Semaphore circuit](https://github.com/semaphore-protocol/semaphore/tree/v3.15.2/packages/circuits) is the heart of the protocol and consists of three parts:
|
||||
|
||||
- [**Proof of membership**](/technical-reference/circuits#proof-of-membership)
|
||||
- [**Nullifier hash**](/technical-reference/circuits#nullifier-hash)
|
||||
- [**Signal**](/technical-reference/circuits#signal)
|
||||
- [**Proof of membership**](/V3/technical-reference/circuits#proof-of-membership)
|
||||
- [**Nullifier hash**](/V3/technical-reference/circuits#nullifier-hash)
|
||||
- [**Signal**](/V3/technical-reference/circuits#signal)
|
||||
|
||||

|
||||

|
||||
|
||||
The diagram above shows how the input signals are used in the Semaphore circuit and how the outputs are calculated.
|
||||
|
||||
|
||||
@@ -6,25 +6,25 @@ sidebar_position: 3
|
||||
|
||||
Semaphore includes two types of contracts:
|
||||
|
||||
- [**Base contracts**](/technical-reference/contracts#base-contracts)
|
||||
- [**Extension contracts**](/technical-reference/contracts#extension-contracts)
|
||||
- [**Base contracts**](/V3/technical-reference/contracts#base-contracts)
|
||||
- [**Extension contracts**](/V3/technical-reference/contracts#extension-contracts)
|
||||
|
||||
And [**Semaphore.sol**](/technical-reference/contracts#semaphoresol), the main contract deployed on the networks supported by Semaphore.
|
||||
And [**Semaphore.sol**](/V3/technical-reference/contracts#semaphoresol), the main contract deployed on the networks supported by Semaphore.
|
||||
|
||||
:::info
|
||||
To use Semaphore contracts and interfaces in your project,
|
||||
install the [`@semaphore-protocol/contracts`](https://github.com/semaphore-protocol/semaphore/tree/main/packages/contracts) NPM package.
|
||||
install the [`@semaphore-protocol/contracts`](https://github.com/semaphore-protocol/semaphore/tree/v3.15.2/packages/contracts) NPM package.
|
||||
:::
|
||||
|
||||
## Base contracts
|
||||
|
||||
Semaphore provides the following base contracts:
|
||||
|
||||
- [`SemaphoreVerifier.sol`](https://github.com/semaphore-protocol/semaphore/blob/main/packages/contracts/contracts/base/SemaphoreVerifier.sol): contains a function to verify Semaphore proofs;
|
||||
- [`SemaphoreGroups.sol`](https://github.com/semaphore-protocol/semaphore/blob/main/packages/contracts/contracts/base/SemaphoreGroups.sol): contains the functions to create groups and add/remove/update members.
|
||||
- [`SemaphoreVerifier.sol`](https://github.com/semaphore-protocol/semaphore/blob/v3.15.2/packages/contracts/contracts/base/SemaphoreVerifier.sol): contains a function to verify Semaphore proofs;
|
||||
- [`SemaphoreGroups.sol`](https://github.com/semaphore-protocol/semaphore/blob/v3.15.2/packages/contracts/contracts/base/SemaphoreGroups.sol): contains the functions to create groups and add/remove/update members.
|
||||
|
||||
These contracts are closely related to the protocol.
|
||||
You can use them in your contract or you can use [**Semaphore.sol**](/technical-reference/contracts#semaphoresol), which integrates them for you.
|
||||
You can use them in your contract or you can use [**Semaphore.sol**](/V3/technical-reference/contracts#semaphoresol), which integrates them for you.
|
||||
|
||||
:::info
|
||||
While some DApps may use on-chain groups, others may prefer to use off-chain groups, saving only their tree roots in the contract.
|
||||
@@ -32,20 +32,20 @@ While some DApps may use on-chain groups, others may prefer to use off-chain gro
|
||||
|
||||
## Extension contracts
|
||||
|
||||
- [`SemaphoreVoting.sol`](https://github.com/semaphore-protocol/semaphore/blob/main/packages/contracts/contracts/extensions/SemaphoreVoting.sol): voting contract that contains the essential functions to create polls, add voters, and anonymously cast votes;
|
||||
- [`SemaphoreWhistleblowing.sol`](https://github.com/semaphore-protocol/semaphore/blob/main/packages/contracts/contracts/extensions/SemaphoreWhistleblowing.sol): whistleblowing contract that contains the essential functions to create entities (for example: non-profit organizations), add whistleblowers, and anonymously publish leaks.
|
||||
- [`SemaphoreVoting.sol`](https://github.com/semaphore-protocol/semaphore/blob/v3.15.2/packages/contracts/contracts/extensions/SemaphoreVoting.sol): voting contract that contains the essential functions to create polls, add voters, and anonymously cast votes;
|
||||
- [`SemaphoreWhistleblowing.sol`](https://github.com/semaphore-protocol/semaphore/blob/v3.15.2/packages/contracts/contracts/extensions/SemaphoreWhistleblowing.sol): whistleblowing contract that contains the essential functions to create entities (for example: non-profit organizations), add whistleblowers, and anonymously publish leaks.
|
||||
|
||||
These contracts extend the protocol to provide application logic for specific use-cases.
|
||||
More extensions will be added in the future.
|
||||
|
||||
## Semaphore.sol
|
||||
|
||||
[`Semaphore.sol`](https://github.com/semaphore-protocol/semaphore/blob/main/packages/contracts/contracts/Semaphore.sol) is based on the base contracts. It integrates them and additionally provides:
|
||||
[`Semaphore.sol`](https://github.com/semaphore-protocol/semaphore/blob/v3.15.2/packages/contracts/contracts/Semaphore.sol) is based on the base contracts. It integrates them and additionally provides:
|
||||
|
||||
- a system to allow only admins (i.e. Ethereum accounts or smart contracts) to manage groups;
|
||||
- a mechanism to save the [nullifier hashes](/technical-reference/circuits#nullifier-hash) of each group and prevent double-signaling;
|
||||
- a mechanism to save the [nullifier hashes](/V3/technical-reference/circuits#nullifier-hash) of each group and prevent double-signaling;
|
||||
- a mechanism to allow Semaphore proofs generated with old Merkle roots to be verified for a certain period of time defined by the group admin.
|
||||
|
||||
:::info
|
||||
See our [deployed contracts](/deployed-contracts) to find the addresses for your network.
|
||||
See our [deployed contracts](/V3/deployed-contracts) to find the addresses for your network.
|
||||
::::
|
||||
|
||||
@@ -11,7 +11,7 @@ If these suggestions do not work, feel free to ask in the [Semaphore Discussions
|
||||
|
||||
## Using Semaphore in the frontend
|
||||
|
||||
Semaphore works with any JavaScript frontend framework, but the [`@semaphore-protocol/proof`](https://github.com/semaphore-protocol/semaphore/tree/main/packages/proof) package is using [snarkjs](https://github.com/iden3/snarkjs), which uses Node.js modules which are not compatible with frontend frameworks and there are some changes that we need to do to make it work on the client side.
|
||||
Semaphore works with any JavaScript frontend framework, but the [`@semaphore-protocol/proof`](https://github.com/semaphore-protocol/semaphore/tree/v3.15.2/packages/proof) package is using [snarkjs](https://github.com/iden3/snarkjs), which uses Node.js modules which are not compatible with frontend frameworks and there are some changes that we need to do to make it work on the client side.
|
||||
|
||||
### Semaphore with Nextjs
|
||||
|
||||
@@ -229,10 +229,10 @@ Your `tsconfig.json` file would be something like this:
|
||||
|
||||
When you create a group and the transaction is reverted, make sure that the group id you are using does not exist on the network you are using.
|
||||
|
||||
To check that, you can use the [Semaphore CLI](https://github.com/semaphore-protocol/semaphore/tree/main/packages/cli) with the command `get-groups` and the network you are using and then, make sure that your group id is not part of that list. You can also use the [Semaphore explorer](https://explorer.semaphore.pse.dev/).
|
||||
To check that, you can use the [Semaphore CLI](https://github.com/semaphore-protocol/semaphore/tree/v3.15.2/packages/cli) with the command `get-groups` and the network you are using and then, make sure that your group id is not part of that list. You can also use the [Semaphore explorer](https://explorer.semaphore.pse.dev/).
|
||||
|
||||
## Semaphore Proofs
|
||||
|
||||
### Transaction reverted when using the same external nullifier
|
||||
|
||||
When you generate a proof using the same external nullifier you used to verify a proof before, the transaction will be reverted because that external nullifier was already used. If you want to send and verify several proofs from the same identity, you should use a different external nullifier each time you generate a proof.
|
||||
When you generate a proof using the same external nullifier you used to verify a proof before, the transaction will be reverted because that external nullifier was already used. If you want to send and verify several proofs from the same identity, you should use a different external nullifier each time you generate a proof.
|
||||
|
||||
@@ -7,7 +7,7 @@ slug: /
|
||||
|
||||
## Overview
|
||||
|
||||
[Semaphore](https://github.com/semaphore-protocol/semaphore) is a [zero-knowledge](https://z.cash/technology/zksnarks) protocol that allows you to cast a signal (for example, a vote or endorsement) as a provable group member without revealing your identity.
|
||||
[Semaphore](https://github.com/semaphore-protocol/semaphore/tree/v3.15.2) is a [zero-knowledge](https://z.cash/technology/zksnarks) protocol that allows you to cast a signal (for example, a vote or endorsement) as a provable group member without revealing your identity.
|
||||
Additionally, it provides a simple mechanism to prevent double-signaling.
|
||||
Use cases include private voting, whistleblowing, anonymous DAOs and mixers.
|
||||
|
||||
@@ -15,9 +15,9 @@ Use cases include private voting, whistleblowing, anonymous DAOs and mixers.
|
||||
|
||||
With Semaphore, you can allow your users to do the following:
|
||||
|
||||
1. [Create a Semaphore identity](/guides/identities/).
|
||||
2. [Add their Semaphore identity to a group (i.e. _Merkle tree_)](/guides/groups/).
|
||||
3. [Send a verifiable, anonymous signal (e.g a vote or endorsement)](/guides/proofs/).
|
||||
1. [Create a Semaphore identity](/V3/guides/identities/).
|
||||
2. [Add their Semaphore identity to a group (i.e. _Merkle tree_)](/V3/guides/groups/).
|
||||
3. [Send a verifiable, anonymous signal (e.g a vote or endorsement)](/V3/guides/proofs/).
|
||||
|
||||
When a user broadcasts a signal (for example: a vote), Semaphore zero-knowledge
|
||||
proofs can ensure that the user has joined the group and hasn't already cast a signal with their nullifier.
|
||||
@@ -33,14 +33,14 @@ Semaphore is designed to be a simple and generic _privacy layer_ for decentraliz
|
||||
|
||||
## About the code
|
||||
|
||||
The core of the protocol is the [circuit logic](https://github.com/semaphore-protocol/semaphore/tree/main/packages/circuits/scheme.png).
|
||||
The core of the protocol is the [circuit logic](https://github.com/semaphore-protocol/semaphore/tree/v3.15.2/packages/circuits/scheme.png).
|
||||
In addition to circuits,
|
||||
Semaphore provides [Solidity contracts](https://github.com/semaphore-protocol/semaphore/tree/main/packages/contracts)
|
||||
and [JavaScript libraries](https://github.com/semaphore-protocol/semaphore#-packages) that allow developers to generate zero-knowledge proofs and verify them with minimal effort.
|
||||
Semaphore provides [Solidity contracts](https://github.com/semaphore-protocol/semaphore/tree/v3.15.2/packages/contracts)
|
||||
and [JavaScript libraries](https://github.com/semaphore-protocol/semaphore/tree/v3.15.2#-packages) that allow developers to generate zero-knowledge proofs and verify them with minimal effort.
|
||||
|
||||
### Trusted Setup Ceremony
|
||||
|
||||
The [secure parameters](/glossary#trusted-setup-files) for generating valid proofs with Semaphore circuits were generated in a [Trusted Setup Ceremony](https://storage.googleapis.com/trustedsetup-a86f4.appspot.com/semaphore/semaphore_top_index.html) that was completed with over 300 participants on [29 March 2022](https://etherscan.io/tx/0xec6dbe68883c7593c2bea82f55af18b3aeb5cc146e026d0083a9b3faa9aa0b65#eventlog).
|
||||
The [secure parameters](/V3/glossary#trusted-setup-files) for generating valid proofs with Semaphore circuits were generated in a [Trusted Setup Ceremony](https://storage.googleapis.com/trustedsetup-a86f4.appspot.com/semaphore/semaphore_top_index.html) that was completed with over 300 participants on [29 March 2022](https://etherscan.io/tx/0xec6dbe68883c7593c2bea82f55af18b3aeb5cc146e026d0083a9b3faa9aa0b65#eventlog).
|
||||
|
||||
### Audits
|
||||
|
||||
|
||||
@@ -1,336 +0,0 @@
|
||||
---
|
||||
sidebar_position: 2
|
||||
---
|
||||
|
||||
import Tabs from "@theme/Tabs"
|
||||
import TabItem from "@theme/TabItem"
|
||||
|
||||
# Getting started
|
||||
|
||||
Semaphore provides an official CLI to set up your project with Hardhat. If your NPM version is 5.2 or higher you can use NPX:
|
||||
|
||||
```bash
|
||||
npx @semaphore-protocol/cli create my-app --template monorepo-ethers
|
||||
```
|
||||
|
||||
Otherwise, install `@semaphore-protocol/cli` globally and run the `create` command:
|
||||
|
||||
```bash
|
||||
npm i -g @semaphore-protocol/cli
|
||||
semaphore create my-app --template monorepo-ethers
|
||||
```
|
||||
|
||||
:::info
|
||||
The supported templates are: [`contracts-hardhat`](https://github.com/semaphore-protocol/semaphore/tree/feat/semaphore-v4/packages/cli-template-contracts-hardhat), [`monorepo-ethers`](https://github.com/semaphore-protocol/semaphore/tree/feat/semaphore-v4/packages/cli-template-monorepo-ethers), [`monorepo-subgraph`](https://github.com/semaphore-protocol/semaphore/tree/feat/semaphore-v4/packages/cli-template-monorepo-subgraph).
|
||||
:::
|
||||
|
||||
:::info
|
||||
The [`semaphore CLI`](https://github.com/semaphore-protocol/semaphore/tree/feat/semaphore-v4/packages/cli) can also be used to get group data from a supported network (e.g. `semaphore get-groups --network sepolia`).
|
||||
:::
|
||||
|
||||
To start working on your project, install the dependencies:
|
||||
|
||||
<Tabs
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
{label: 'npm', value: 'npm'},
|
||||
{label: 'Yarn', value: 'yarn'},
|
||||
{label: 'pnpm', value: 'pnpm'}
|
||||
]}>
|
||||
<TabItem value="npm">
|
||||
|
||||
```bash
|
||||
cd my-app
|
||||
npm i
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="yarn">
|
||||
|
||||
```bash
|
||||
cd my-app
|
||||
yarn
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
|
||||
```bash
|
||||
cd my-app
|
||||
pnpm install
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
## Output
|
||||
|
||||
The `create` command will create a directory called my-app (or whatever name you choose) inside the current folder. That directory will contain the initial project structure, which includes a simple contract, a task to deploy it, some tests and a Next.js application (the web-app folder) to interact with that contract.
|
||||
|
||||
```
|
||||
my-app
|
||||
├── .yarn
|
||||
├── apps
|
||||
│ └── contracts
|
||||
│ │ └── contracts
|
||||
| │ │ └── Feedback.sol
|
||||
│ │ └── tasks
|
||||
| │ │ └── deploy.ts
|
||||
│ │ └── test
|
||||
| │ │ └── Feedback.ts
|
||||
│ │ └── hardhat.config.ts
|
||||
│ │ └── package.json
|
||||
│ │ └── tsconfig.json
|
||||
│ └── web-app
|
||||
├── .editorconfig
|
||||
├── .env
|
||||
├── .env.example
|
||||
├── .eslintignore
|
||||
├── .eslintrc.json
|
||||
├── .gitignore
|
||||
├── .prettierignore
|
||||
├── .prettierrc.json
|
||||
├── .yarnrc.yml
|
||||
├── package.json
|
||||
├── README.md
|
||||
└── tsconfig.json
|
||||
```
|
||||
|
||||
The `Feedback.sol` contract creates a Semaphore group, allows users to join that group with their Semaphore identity, and finally allows group members to send an anonymous feedback.
|
||||
|
||||
## Usage
|
||||
|
||||
### Compile contracts
|
||||
|
||||
Go to the `contracts` folder:
|
||||
|
||||
```bash
|
||||
cd apps/contracts
|
||||
```
|
||||
|
||||
And compile your contracts:
|
||||
|
||||
<Tabs
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
{label: 'npm', value: 'npm'},
|
||||
{label: 'Yarn', value: 'yarn'},
|
||||
{label: 'pnpm', value: 'pnpm'}
|
||||
]}>
|
||||
<TabItem value="npm">
|
||||
|
||||
```bash
|
||||
npm run compile
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="yarn">
|
||||
|
||||
```bash
|
||||
yarn compile
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
|
||||
```bash
|
||||
pnpm compile
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
### Test contracts
|
||||
|
||||
Test your contracts:
|
||||
|
||||
<Tabs
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
{label: 'npm', value: 'npm'},
|
||||
{label: 'Yarn', value: 'yarn'},
|
||||
{label: 'pnpm', value: 'pnpm'}
|
||||
]}>
|
||||
<TabItem value="npm">
|
||||
|
||||
```bash
|
||||
npm test
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="yarn">
|
||||
|
||||
```bash
|
||||
yarn test
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
|
||||
```bash
|
||||
pnpm test
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
Generate a test coverage report:
|
||||
|
||||
<Tabs
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
{label: 'npm', value: 'npm'},
|
||||
{label: 'Yarn', value: 'yarn'},
|
||||
{label: 'pnpm', value: 'pnpm'}
|
||||
]}>
|
||||
<TabItem value="npm">
|
||||
|
||||
```bash
|
||||
npm run test:coverage
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="yarn">
|
||||
|
||||
```bash
|
||||
yarn test:coverage
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
|
||||
```bash
|
||||
pnpm test:coverage
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
Or a test gas report:
|
||||
|
||||
<Tabs
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
{label: 'npm', value: 'npm'},
|
||||
{label: 'Yarn', value: 'yarn'},
|
||||
{label: 'pnpm', value: 'pnpm'}
|
||||
]}>
|
||||
<TabItem value="npm">
|
||||
|
||||
```bash
|
||||
npm run test:report-gas
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="yarn">
|
||||
|
||||
```bash
|
||||
yarn test:report-gas
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
|
||||
```bash
|
||||
pnpm test:report-gas
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
### Deploy contracts
|
||||
|
||||
Follow the instructions below to deploy your contracts:
|
||||
|
||||
In the project root folder:
|
||||
|
||||
1. Add your environment variables in the `.env` file.
|
||||
|
||||
:::note
|
||||
You should at least set a valid Infura API Key (you could use Alchemy as well) and a private key with some ethers.
|
||||
:::
|
||||
|
||||
2. Go to the `apps/contracts` folder and deploy your contract.
|
||||
|
||||
<Tabs
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
{label: 'npm', value: 'npm'},
|
||||
{label: 'Yarn', value: 'yarn'},
|
||||
{label: 'pnpm', value: 'pnpm'}
|
||||
]}>
|
||||
<TabItem value="npm">
|
||||
|
||||
```bash
|
||||
npm run deploy -- --semaphore <semaphore-address> --group <group-id> --network sepolia
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="yarn">
|
||||
|
||||
```bash
|
||||
yarn deploy --semaphore <semaphore-address> --group <group-id> --network sepolia
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
|
||||
```bash
|
||||
pnpm deploy --semaphore <semaphore-address> --group <group-id> --network sepolia
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
:::note
|
||||
Check the Semaphore contract addresses [here](/V4-alpha/deployed-contracts).
|
||||
:::
|
||||
|
||||
:::caution
|
||||
The group id is a number.
|
||||
:::
|
||||
|
||||
### Start app
|
||||
|
||||
Start the application:
|
||||
|
||||
<Tabs
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
{label: 'npm', value: 'npm'},
|
||||
{label: 'Yarn', value: 'yarn'},
|
||||
{label: 'pnpm', value: 'pnpm'}
|
||||
]}>
|
||||
<TabItem value="npm">
|
||||
|
||||
```bash
|
||||
npm run dev
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="yarn">
|
||||
|
||||
```bash
|
||||
yarn dev
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
|
||||
```bash
|
||||
pnpm dev
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
:::info
|
||||
If you want to see the code of a comprehensive application built on top of Semaphore see the [boilerplate](https://github.com/semaphore-protocol/boilerplate/tree/version/4). For more info about the core libraries, keep reading the next guides.
|
||||
:::
|
||||
@@ -1,20 +0,0 @@
|
||||
---
|
||||
sidebar_position: 9
|
||||
---
|
||||
|
||||
import Tabs from "@theme/Tabs"
|
||||
import TabItem from "@theme/TabItem"
|
||||
|
||||
# Troubleshooting
|
||||
|
||||
If these suggestions do not work, feel free to ask for more help and support on [Github Discussions](https://github.com/semaphore-protocol/semaphore/discussions) or [Discord](https://semaphore.pse.dev/discord) ("dev-chat" channel).
|
||||
|
||||
## Creating a Group
|
||||
|
||||
When you create a group and the transaction is reverted, make sure that the group id you are using does not exist on the network you are using.
|
||||
|
||||
To check that, you can use the [Semaphore CLI](https://github.com/semaphore-protocol/semaphore/tree/feat/semaphore-v4/packages/cli) with the command `get-groups` and the network you are using and then, make sure that your group id is not part of that list. You can also use the [Semaphore explorer](https://explorer.semaphore.pse.dev/).
|
||||
|
||||
## Transaction reverted when using the same nullifier
|
||||
|
||||
When you generate a proof using the same [scope](/V4-alpha/glossary#scope) you used to validate a proof before, the transaction will be reverted because that scope (and thus the [nullifier](/V4-alpha/glossary#nullifier)) has already been used. If you want to send and validate several proofs from the same identity, you need to use a different scope for each time you generate a proof.
|
||||
@@ -16,13 +16,13 @@ For example, in an anonymous voting application a valid proof could be reused to
|
||||
|
||||
## What is the difference between the "nullifier" and "scope"?
|
||||
|
||||
The [scope](/V4-alpha/glossary#scope) is used like a topic on which users can generate a valid proof only once. The scope is a public value and every one can see what the scope of a proof is.
|
||||
The [scope](/glossary#scope) is used like a topic on which users can generate a valid proof only once. The scope is a public value and every one can see what the scope of a proof is.
|
||||
|
||||
The [nullifier](/V4-alpha/glossary#nullifier) is the hash of the private key of the identity and the scope, and it is used to check if the same proof with that specific scope has already been generated by the same user. The nullifier is also a public value and it is what is actually stored to prevent, for example, double-voting.
|
||||
The [nullifier](/glossary#nullifier) is the hash of the private key of the identity and the scope, and it is used to check if the same proof with that specific scope has already been generated by the same user. The nullifier is also a public value and it is what is actually stored to prevent, for example, double-voting.
|
||||
|
||||
In the case of a voting application, if you have a group and you want all members of this group to vote only once, you can use the id of the group as the scope. When a user votes the first time, you can store the hash of voter's private key and the group id (i.e., the nullifier) and prevent double-voting by checking if that hash already exists.
|
||||
|
||||
See the [Semaphore circuits](/V4-alpha/technical-reference/circuits) for more technical information, or the [Semaphore boilerplate](https://github.com/semaphore-protocol/boilerplate/tree/version/4) for a real use-case.
|
||||
See the [Semaphore circuits](/technical-reference/circuits) for more technical information, or the [Semaphore boilerplate](https://github.com/semaphore-protocol/boilerplate/tree/main) for a real use-case.
|
||||
|
||||
## Where can I find examples of applications using Semaphore?
|
||||
|
||||
@@ -30,7 +30,7 @@ You can find a complete list of applications that are using Semaphore on the [Se
|
||||
|
||||
## How can I start a project using Semaphore?
|
||||
|
||||
There are three ways you can start using Semaphore in your project: using the [CLI](https://github.com/semaphore-protocol/semaphore/tree/feat/semaphore-v4/packages/cli), using the [boilerplate](https://github.com/semaphore-protocol/boilerplate/tree/version/4) as a template or forking it, or installing the Semaphore [packages](/V4-alpha/guides/identities) manually.
|
||||
There are three ways you can start using Semaphore in your project: using the [CLI](https://github.com/semaphore-protocol/semaphore/tree/main/packages/cli), using the [boilerplate](https://github.com/semaphore-protocol/boilerplate/tree/main) as a template or forking it, or installing the Semaphore [packages](/guides/identities) manually.
|
||||
|
||||
## How can I contribute to the protocol?
|
||||
|
||||
142
apps/docs/versioned_docs/version-V4-beta/getting-started.mdx
Normal file
142
apps/docs/versioned_docs/version-V4-beta/getting-started.mdx
Normal file
@@ -0,0 +1,142 @@
|
||||
---
|
||||
sidebar_position: 2
|
||||
---
|
||||
|
||||
# Getting started
|
||||
|
||||
Semaphore provides an official CLI to set up your project with Hardhat. If your NPM version is 5.2 or higher you can use NPX:
|
||||
|
||||
```bash
|
||||
npx @semaphore-protocol/cli create my-app --template monorepo-ethers
|
||||
```
|
||||
|
||||
Otherwise, install `@semaphore-protocol/cli` globally and run the `create` command:
|
||||
|
||||
```bash
|
||||
npm i -g @semaphore-protocol/cli
|
||||
semaphore create my-app --template monorepo-ethers
|
||||
```
|
||||
|
||||
:::info
|
||||
The supported templates are: [`contracts-hardhat`](https://github.com/semaphore-protocol/semaphore/tree/main/packages/cli-template-contracts-hardhat), [`monorepo-ethers`](https://github.com/semaphore-protocol/semaphore/tree/main/packages/cli-template-monorepo-ethers), [`monorepo-subgraph`](https://github.com/semaphore-protocol/semaphore/tree/main/packages/cli-template-monorepo-subgraph).
|
||||
:::
|
||||
|
||||
:::info
|
||||
The [`semaphore CLI`](https://github.com/semaphore-protocol/semaphore/tree/main/packages/cli) can also be used to get group data from a supported network (e.g. `semaphore get-groups --network sepolia`).
|
||||
:::
|
||||
|
||||
To start working on your project, install the dependencies:
|
||||
|
||||
```bash
|
||||
cd my-app
|
||||
yarn
|
||||
```
|
||||
|
||||
## Output
|
||||
|
||||
The `create` command will create a directory called my-app (or whatever name you choose) inside the current folder. That directory will contain the initial project structure, which includes a simple contract, a task to deploy it, some tests and a Next.js application (the web-app folder) to interact with that contract.
|
||||
|
||||
```
|
||||
my-app
|
||||
├── .yarn
|
||||
├── apps
|
||||
│ └── contracts
|
||||
│ │ └── contracts
|
||||
| │ │ └── Feedback.sol
|
||||
│ │ └── tasks
|
||||
| │ │ └── deploy.ts
|
||||
│ │ └── test
|
||||
| │ │ └── Feedback.ts
|
||||
│ │ └── hardhat.config.ts
|
||||
│ │ └── package.json
|
||||
│ │ └── tsconfig.json
|
||||
│ └── web-app
|
||||
├── .editorconfig
|
||||
├── .env
|
||||
├── .env.example
|
||||
├── .eslintignore
|
||||
├── .eslintrc.json
|
||||
├── .gitignore
|
||||
├── .prettierignore
|
||||
├── .prettierrc.json
|
||||
├── .yarnrc.yml
|
||||
├── package.json
|
||||
├── README.md
|
||||
└── tsconfig.json
|
||||
```
|
||||
|
||||
The `Feedback.sol` contract creates a Semaphore group, allows users to join that group with their Semaphore identity, and finally allows group members to send an anonymous feedback.
|
||||
|
||||
## Usage
|
||||
|
||||
### Compile contracts
|
||||
|
||||
Go to the `contracts` folder:
|
||||
|
||||
```bash
|
||||
cd apps/contracts
|
||||
```
|
||||
|
||||
And compile your contracts:
|
||||
|
||||
```bash
|
||||
yarn compile
|
||||
```
|
||||
|
||||
### Test contracts
|
||||
|
||||
Test your contracts:
|
||||
|
||||
```bash
|
||||
yarn test
|
||||
```
|
||||
|
||||
Generate a test coverage report:
|
||||
|
||||
```bash
|
||||
yarn test:coverage
|
||||
```
|
||||
|
||||
Or a test gas report:
|
||||
|
||||
```bash
|
||||
yarn test:report-gas
|
||||
```
|
||||
|
||||
### Deploy contracts
|
||||
|
||||
Follow the instructions below to deploy your contracts:
|
||||
|
||||
In the project root folder:
|
||||
|
||||
1. Add your environment variables in the `.env` file.
|
||||
|
||||
:::note
|
||||
You should at least set a valid Infura API Key (you could use Alchemy as well) and a private key with some ethers.
|
||||
:::
|
||||
|
||||
2. Go to the `apps/contracts` folder and deploy your contract.
|
||||
|
||||
```bash
|
||||
yarn deploy --semaphore <semaphore-address> --group <group-id> --network sepolia
|
||||
```
|
||||
|
||||
:::note
|
||||
Check the Semaphore contract addresses [here](/deployed-contracts).
|
||||
:::
|
||||
|
||||
:::caution
|
||||
The group id is a number.
|
||||
:::
|
||||
|
||||
### Start app
|
||||
|
||||
Start the application:
|
||||
|
||||
```bash
|
||||
yarn dev
|
||||
```
|
||||
|
||||
:::info
|
||||
If you want to see the code of a comprehensive application built on top of Semaphore see the [boilerplate](https://github.com/semaphore-protocol/boilerplate/tree/main). For more info about the core libraries, keep reading the next guides.
|
||||
:::
|
||||
@@ -46,4 +46,4 @@ A trusted setup in the context of zero-knowledge proofs, particularly zk-SNARKs,
|
||||
|
||||
## Trusted setup files
|
||||
|
||||
The secure, verifiable parameters generated by Semaphore's trusted setup ceremony. Semaphore uses the trusted setup files to generate and verify valid zero-knowledge proofs. The [Semaphore circuit](/V4-alpha/technical-reference/circuits) includes a parameter to set the tree's maximum depth (MAX_DEPTH). During the trusted setup, parameters are specifically generated for each circuit instance, aligning with their designated MAX_DEPTH (from 1 to 32).
|
||||
The secure, verifiable parameters generated by Semaphore's trusted setup ceremony. Semaphore uses the trusted setup files to generate and verify valid zero-knowledge proofs. The [Semaphore circuit](/technical-reference/circuits) includes a parameter to set the tree's maximum depth (MAX_DEPTH). During the trusted setup, parameters are specifically generated for each circuit instance, aligning with their designated MAX_DEPTH (from 1 to 32).
|
||||
@@ -8,7 +8,7 @@ import TabItem from "@theme/TabItem"
|
||||
|
||||
# Semaphore groups
|
||||
|
||||
A [Semaphore group](/V4-alpha/glossary/#group) contains [identity commitments](/V4-alpha/glossary/#commitment) of group members.
|
||||
A [Semaphore group](/glossary/#group) contains [identity commitments](/glossary/#identity-commitment) of group members.
|
||||
Example uses of groups include the following:
|
||||
|
||||
- poll question that attendees join to rate an event,
|
||||
@@ -23,7 +23,7 @@ Merkle Tree) [Solidity](https://github.com/privacy-scaling-explorations/zk-kit/t
|
||||
|
||||
## Off-chain groups
|
||||
|
||||
Use the [`@semaphore-protocol/group`](https://github.com/semaphore-protocol/semaphore/blob/feat/semaphore-v4/packages/group) package to manage off-chain groups.
|
||||
Use the [`@semaphore-protocol/group`](https://github.com/semaphore-protocol/semaphore/blob/main/packages/group) package to manage off-chain groups.
|
||||
|
||||
### Install package
|
||||
|
||||
@@ -58,6 +58,10 @@ pnpm add @semaphore-protocol/group
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
:::info
|
||||
Semaphore also provides `@semaphore-protocol/core`, which includes the functions of the following core packages: `@semaphore-protocol/identity`, `@semaphore-protocol/group`, `@semaphore-protocol/proof`.
|
||||
:::
|
||||
|
||||
### Create a group
|
||||
|
||||
To create a group instantiate `Group` without any parameters. For example:
|
||||
@@ -72,9 +76,9 @@ You can also initialize a group with multiple members by passing the list of ide
|
||||
|
||||
```ts
|
||||
const members = [
|
||||
"11237622825477336339577122413451117718539783476837539122310492284566644730311",
|
||||
"9332663527862709610616009715800254142772436825222910251631161087138559093425",
|
||||
"13255821893820536903335282929376140649646180444238593676033702344407594536519"
|
||||
11237622825477336339577122413451117718539783476837539122310492284566644730311n,
|
||||
9332663527862709610616009715800254142772436825222910251631161087138559093425n,
|
||||
13255821893820536903335282929376140649646180444238593676033702344407594536519n
|
||||
]
|
||||
|
||||
const group2 = new Group(members)
|
||||
@@ -113,7 +117,7 @@ group.removeMember(0)
|
||||
To update members in a group, pass the member index and the new value to the `updateMember` method. For example:
|
||||
|
||||
```ts
|
||||
group.updateMember(0, 2)
|
||||
group.updateMember(0, 2n)
|
||||
```
|
||||
|
||||
:::caution
|
||||
@@ -123,7 +127,7 @@ Given that the member isn't removed, the number of members (i.e., `group.size` o
|
||||
|
||||
### Generate a Merkle proof
|
||||
|
||||
Semaphore groups are [Merkle trees](/V4-alpha/glossary#merkle-tree), and it is therefore possible to calculate the Merkle proof of a group member (i.e., tree leaf) by passing the index of the member to the `generateMerkleProof`. For example:
|
||||
Semaphore groups are [Merkle trees](/glossary#merkle-tree), and it is therefore possible to calculate the Merkle proof of a group member (i.e., tree leaf) by passing the index of the member to the `generateMerkleProof`. For example:
|
||||
|
||||
```ts
|
||||
group.generateMerkleProof(0)
|
||||
@@ -131,9 +135,9 @@ group.generateMerkleProof(0)
|
||||
|
||||
## On-chain groups
|
||||
|
||||
Semaphore provides [`Semaphore.sol`](https://github.com/semaphore-protocol/semaphore/blob/feat/semaphore-v4/packages/contracts/contracts/Semaphore.sol), a contract designed for managing on-chain groups ([deployed](/V4-alpha/deployed-contracts) on major testnets).
|
||||
Semaphore provides [`Semaphore.sol`](https://github.com/semaphore-protocol/semaphore/blob/main/packages/contracts/contracts/Semaphore.sol), a contract designed for managing on-chain groups ([deployed](/deployed-contracts) on major testnets).
|
||||
|
||||
Use the [`@semaphore-protocol/contracts`](https://github.com/semaphore-protocol/semaphore/blob/feat/semaphore-v4/packages/contracts) package to import the `ISemaphore.sol` interface in your contract and start using its functions.
|
||||
Use the [`@semaphore-protocol/contracts`](https://github.com/semaphore-protocol/semaphore/blob/main/packages/contracts) package to import the `ISemaphore.sol` interface in your contract and start using its functions.
|
||||
|
||||
### Install package
|
||||
|
||||
@@ -235,6 +239,6 @@ function removeMember(uint256 identityCommitment, uint256[] calldata merkleProof
|
||||
```
|
||||
|
||||
:::info
|
||||
If you want to see an example of a working contract, have a look at the [`contracts-hardhat`](https://github.com/semaphore-protocol/semaphore/tree/feat/semaphore-v4/packages/cli-template-contracts-hardhat) CLI template. You can also create a project with that template by running `semaphore create my-app --template contracts-hardhat`.
|
||||
If you want to see an example of a working contract, have a look at the [`contracts-hardhat`](https://github.com/semaphore-protocol/semaphore/tree/main/packages/cli-template-contracts-hardhat) CLI template. You can also create a project with that template by running `semaphore create my-app --template contracts-hardhat`.
|
||||
:::
|
||||
|
||||
@@ -8,7 +8,7 @@ import TabItem from "@theme/TabItem"
|
||||
|
||||
# Semaphore identities
|
||||
|
||||
In order to join a [Semaphore group](/V4-alpha/glossary#group), a user must first create a [Semaphore identity](/V4-alpha/glossary#identity).
|
||||
In order to join a [Semaphore group](/glossary#group), a user must first create a [Semaphore identity](/glossary#identity).
|
||||
A Semaphore identity contains three values generated with the identity:
|
||||
|
||||
- Private key
|
||||
@@ -20,7 +20,7 @@ To prevent fraud, the owner should keep their private key secret.
|
||||
|
||||
## Install package
|
||||
|
||||
In your code, use the [`@semaphore-protocol/identity`](https://github.com/semaphore-protocol/semaphore/tree/feat/semaphore-v4/packages/identity) package to manage Semaphore identites.
|
||||
In your code, use the [`@semaphore-protocol/identity`](https://github.com/semaphore-protocol/semaphore/tree/main/packages/identity) package to manage Semaphore identites.
|
||||
|
||||
<Tabs
|
||||
defaultValue="npm"
|
||||
@@ -53,6 +53,10 @@ pnpm add @semaphore-protocol/identity
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
:::info
|
||||
Semaphore also provides `@semaphore-protocol/core`, which includes the functions of the following core packages: `@semaphore-protocol/identity`, `@semaphore-protocol/group`, `@semaphore-protocol/proof`.
|
||||
:::
|
||||
|
||||
## Create identities
|
||||
|
||||
### Create random identities
|
||||
@@ -8,16 +8,16 @@ import TabItem from "@theme/TabItem"
|
||||
|
||||
# Semaphore proofs
|
||||
|
||||
Once a user joins a [Semaphore group](/V4-alpha/glossary#group) with their [Semaphore identity](/V4-alpha/glossary#identity), the user can send their anonymous [message](/V4-alpha/glossary#message) with a zero-knowledge proof that proves the following:
|
||||
Once a user joins a [Semaphore group](/glossary#group) with their [Semaphore identity](/glossary#identity), the user can send their anonymous [message](/glossary#message) with a zero-knowledge proof that proves the following:
|
||||
|
||||
- the user is a member of the group,
|
||||
- the same user created the message and the proof.
|
||||
|
||||
A unique [nullifier](/V4-alpha/glossary#nullifier) is also generated for each proof that can be used to check whether that proof has already been validated.
|
||||
A unique [nullifier](/glossary#nullifier) is also generated for each proof that can be used to check whether that proof has already been validated.
|
||||
|
||||
## Install package
|
||||
|
||||
In your code, use the [`@semaphore-protocol/proof`](https://github.com/semaphore-protocol/semaphore/tree/feat/semaphore-v4/packages/proof) package to generate and verify a proof.
|
||||
In your code, use the [`@semaphore-protocol/proof`](https://github.com/semaphore-protocol/semaphore/tree/main/packages/proof) package to generate and verify a proof.
|
||||
|
||||
<Tabs
|
||||
defaultValue="npm"
|
||||
@@ -50,18 +50,22 @@ pnpm add @semaphore-protocol/proof
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
:::info
|
||||
Semaphore also provides `@semaphore-protocol/core`, which includes the functions of the following core packages: `@semaphore-protocol/identity`, `@semaphore-protocol/group`, `@semaphore-protocol/proof`.
|
||||
:::
|
||||
|
||||
## Generate a proof
|
||||
|
||||
### 1. Create the identity
|
||||
|
||||
In order for a user to generate a proof, it is necessary to create a Semaphore identity. If you do not know how to
|
||||
create an identity, see the previous [guide](/V4-alpha/guides/identities) on identities.
|
||||
create an identity, see the previous [guide](/guides/identities) on identities.
|
||||
|
||||
### 2. Create the group
|
||||
|
||||
Before generating a proof you also need to create a Semaphore group containing the commitment of the Semaphore identity of the user who will generate the proof. If you do not know how to create a group, see the previous [guide](/V4-alpha/guides/groups) on groups.
|
||||
Before generating a proof you also need to create a Semaphore group containing the commitment of the Semaphore identity of the user who will generate the proof. If you do not know how to create a group, see the previous [guide](/guides/groups) on groups.
|
||||
|
||||
If your group is on-chain, you can use the [`@semaphore-protocol/data`](https://github.com/semaphore-protocol/semaphore/tree/feat/semaphore-v4/packages/data) library to fetch the group members and re-create the off-chain group. For example:
|
||||
If your group is on-chain, you can use the [`@semaphore-protocol/data`](https://github.com/semaphore-protocol/semaphore/tree/main/packages/data) library to fetch the group members and re-create the off-chain group. For example:
|
||||
|
||||
```ts
|
||||
import { SemaphoreSubgraph } from "@semaphore-protocol/data"
|
||||
@@ -76,7 +80,7 @@ const group = new Group(members)
|
||||
|
||||
### 3. Choose the scope
|
||||
|
||||
Each proof requires a [scope](/V4-alpha/glossary#scope), on which each user may only generate one valid proof. The scope, together with the user's private key, is used to generate the nullifier, which is the value you can actually use to check whether a proof with that scope has already been generated by that user. In a voting application where double-voting must be prevented, the scope could be the ballot id, or the Merkle root of the group.
|
||||
Each proof requires a [scope](/glossary#scope), on which each user may only generate one valid proof. The scope, together with the user's private key, is used to generate the nullifier, which is the value you can actually use to check whether a proof with that scope has already been generated by that user. In a voting application where double-voting must be prevented, the scope could be the ballot id, or the Merkle root of the group.
|
||||
|
||||
### 4. Generate the anomymous message
|
||||
|
||||
@@ -88,7 +92,7 @@ import { generateProof } from "@semaphore-protocol/proof"
|
||||
const scope = group.root
|
||||
const message = 1
|
||||
|
||||
const proof = await generateProof(identity, group, externalNullifier, message)
|
||||
const proof = await generateProof(identity, group, message, scope)
|
||||
```
|
||||
|
||||
## Verify a proof
|
||||
@@ -101,7 +105,7 @@ import { verifyProof } from "@semaphore-protocol/proof"
|
||||
await verifyProof(proof) // true or false.
|
||||
```
|
||||
|
||||
If you want to validate a proof on-chain, you can use [`@semaphore-protocol/contracts`](https://github.com/semaphore-protocol/semaphore/blob/feat/semaphore-v4/packages/contracts) and the [`Semaphore.sol`](https://github.com/semaphore-protocol/semaphore/blob/feat/semaphore-v4/packages/contracts/contracts/Semaphore.sol) contract, as explained in the previous [guide](/V4-alpha/guides/groups#install-package-1), and use the `validateProof` function. For example:
|
||||
If you want to validate a proof on-chain, you can use [`@semaphore-protocol/contracts`](https://github.com/semaphore-protocol/semaphore/blob/main/packages/contracts) and the [`Semaphore.sol`](https://github.com/semaphore-protocol/semaphore/blob/main/packages/contracts/contracts/Semaphore.sol) contract, as explained in the previous [guide](/guides/groups#install-package-1), and use the `validateProof` function. For example:
|
||||
|
||||
```solidity
|
||||
function validateProof(ISemaphore.SemaphoreProof calldata proof) external {
|
||||
@@ -8,13 +8,13 @@ import RemoteCode from '@site/src/components/RemoteCode';
|
||||
|
||||
[The Graph](https://thegraph.com/) is a protocol for indexing networks like Ethereum and IPFS.
|
||||
Site owners publish _subgraphs_ that expose site data for anyone to query.
|
||||
Semaphore's subgraph allows you to retrieve data from the [`Semaphore.sol`](https://github.com/semaphore-protocol/semaphore/blob/feat/semaphore-v4/packages/contracts/contracts/Semaphore.sol) smart contract.
|
||||
Semaphore's subgraph allows you to retrieve data from the [`Semaphore.sol`](https://github.com/semaphore-protocol/semaphore/blob/main/packages/contracts/contracts/Semaphore.sol) smart contract.
|
||||
|
||||
:::tip
|
||||
The Graph protocol uses the [GraphQL](https://graphql.org/) query language. For examples, see the [GraphQL API documentation](https://thegraph.com/docs/developer/graphql-api). Visit the [Semaphore subgraph](https://github.com/semaphore-protocol/semaphore/tree/feat/semaphore-v4/apps/subgraph) to see the list of networks supported by Semaphore and its URLs.
|
||||
The Graph protocol uses the [GraphQL](https://graphql.org/) query language. For examples, see the [GraphQL API documentation](https://thegraph.com/docs/developer/graphql-api). Visit the [Semaphore subgraph](https://github.com/semaphore-protocol/semaphore/tree/main/apps/subgraph) to see the list of networks supported by Semaphore and its URLs.
|
||||
:::
|
||||
|
||||
## Schema
|
||||
|
||||
<RemoteCode url="https://raw.githubusercontent.com/semaphore-protocol/semaphore/feat/semaphore-v4/apps/subgraph/schema.graphql"
|
||||
<RemoteCode url="https://raw.githubusercontent.com/semaphore-protocol/semaphore/main/apps/subgraph/schema.graphql"
|
||||
title="apps/subgraph/schema.graphql" language="graphql" />
|
||||
@@ -4,13 +4,13 @@ sidebar_position: 2
|
||||
|
||||
# Circuits
|
||||
|
||||
The [Semaphore circuit](https://github.com/semaphore-protocol/semaphore/tree/feat/semaphore-v4/packages/circuits/semaphore.circom) is the heart of the protocol and consists of three parts:
|
||||
The [Semaphore circuit](https://github.com/semaphore-protocol/semaphore/tree/main/packages/circuits/semaphore.circom) is the heart of the protocol and consists of three parts:
|
||||
|
||||
- [Proof of membership](#proof-of-membership)
|
||||
- [Nullifier](#nullifier)
|
||||
- [Message](#message)
|
||||
|
||||

|
||||

|
||||
|
||||
The diagram above shows how the input signals are used in the Semaphore circuit and how the outputs are calculated.
|
||||
|
||||
@@ -7,20 +7,20 @@ sidebar_position: 3
|
||||
Semaphore contracts are designed with minimal yet essential code, enabling developers to efficiently manage on-chain groups and verify or validate zero-knowledge proofs.
|
||||
There are three contracts:
|
||||
|
||||
- [`SemaphoreVerifier.sol`](https://github.com/semaphore-protocol/semaphore/blob/feat/semaphore-v4/packages/contracts/contracts/base/SemaphoreVerifier.sol)
|
||||
- [`SemaphoreGroups.sol`](https://github.com/semaphore-protocol/semaphore/blob/feat/semaphore-v4/packages/contracts/contracts/base/SemaphoreGroups.sol)
|
||||
- [`Semaphore.sol`](https://github.com/semaphore-protocol/semaphore/blob/feat/semaphore-v4/packages/contracts/contracts/Semaphore.sol)
|
||||
- [`SemaphoreVerifier.sol`](https://github.com/semaphore-protocol/semaphore/blob/main/packages/contracts/contracts/base/SemaphoreVerifier.sol)
|
||||
- [`SemaphoreGroups.sol`](https://github.com/semaphore-protocol/semaphore/blob/main/packages/contracts/contracts/base/SemaphoreGroups.sol)
|
||||
- [`Semaphore.sol`](https://github.com/semaphore-protocol/semaphore/blob/main/packages/contracts/contracts/Semaphore.sol)
|
||||
|
||||
:::info
|
||||
To use Semaphore contracts and interfaces in your project,
|
||||
install the [`@semaphore-protocol/contracts`](https://github.com/semaphore-protocol/semaphore/tree/feat/semaphore-v4/packages/contracts) NPM package.
|
||||
install the [`@semaphore-protocol/contracts`](https://github.com/semaphore-protocol/semaphore/tree/main/packages/contracts) NPM package.
|
||||
:::
|
||||
|
||||
## SemaphoreVerifier.sol
|
||||
|
||||
`SemaphoreVerifier.sol` is an extended version of the Groth16 verifier generated by default with [SnarkJS](https://github.com/iden3/snarkjs). It contains a function for verifying proofs and a list of verification keys parameters.
|
||||
|
||||
Since the Semaphore circuit is compiled with a `MAX_DEPTH` range from 1 to 32 during the [trusted setup](/V4-alpha/glossary#trusted-setup), the verifier must contain the parameters of the verification keys of each instance.
|
||||
Since the Semaphore circuit is compiled with a `MAX_DEPTH` range from 1 to 32 during the [trusted setup](/glossary#trusted-setup), the verifier must contain the parameters of the verification keys of each instance.
|
||||
|
||||
## SemaphoreGroups.sol
|
||||
|
||||
@@ -37,5 +37,5 @@ The `verifyProof` function contains code for checking whether a Semaphore proof
|
||||
The `validateProof` function first checks whether a proof with the same nullifier has already been validated, and then verifies the proof with the `verifyProof` function and saves the nullifier. This function also creates a log with the group id and the proof, which can then additionally be verified off-chain.
|
||||
|
||||
:::info
|
||||
Semaphore contracts are deployed on the main testnets and Arbitrum One. See the [deployed contracts](/V4-alpha/deployed-contracts) to check the addresses.
|
||||
Semaphore contracts are deployed on the main testnets and Arbitrum One. See the [deployed contracts](/deployed-contracts) to check the addresses.
|
||||
::::
|
||||
20
apps/docs/versioned_docs/version-V4-beta/troubleshooting.md
Normal file
20
apps/docs/versioned_docs/version-V4-beta/troubleshooting.md
Normal file
@@ -0,0 +1,20 @@
|
||||
---
|
||||
sidebar_position: 9
|
||||
---
|
||||
|
||||
import Tabs from "@theme/Tabs"
|
||||
import TabItem from "@theme/TabItem"
|
||||
|
||||
# Troubleshooting
|
||||
|
||||
If these suggestions do not work, feel free to ask for more help and support on [Github Discussions](https://github.com/semaphore-protocol/semaphore/discussions) or [Discord](https://semaphore.pse.dev/discord) ("dev-chat" channel).
|
||||
|
||||
## Creating a Group
|
||||
|
||||
When you create a group and the transaction is reverted, make sure that the group id you are using does not exist on the network you are using.
|
||||
|
||||
To check that, you can use the [Semaphore CLI](https://github.com/semaphore-protocol/semaphore/tree/main/packages/cli) with the command `get-groups` and the network you are using and then, make sure that your group id is not part of that list. You can also use the [Semaphore explorer](https://explorer.semaphore.pse.dev/).
|
||||
|
||||
## Transaction reverted when using the same nullifier
|
||||
|
||||
When you generate a proof using the same [scope](/glossary#scope) you used to validate a proof before, the transaction will be reverted because that scope (and thus the [nullifier](/glossary#nullifier)) has already been used. If you want to send and validate several proofs from the same identity, you need to use a different scope for each time you generate a proof.
|
||||
@@ -7,7 +7,7 @@ slug: /
|
||||
|
||||
## Overview
|
||||
|
||||
[Semaphore](https://github.com/semaphore-protocol/semaphore/tree/feat/semaphore-v4) is a [zero-knowledge](https://z.cash/technology/zksnarks) protocol that allows you to cast a message (for example, a vote or endorsement) as a provable group member without revealing your identity.
|
||||
[Semaphore](https://github.com/semaphore-protocol/semaphore/tree/main) is a [zero-knowledge](https://z.cash/technology/zksnarks) protocol that allows you to cast a message (for example, a vote or endorsement) as a provable group member without revealing your identity.
|
||||
Additionally, it provides a simple mechanism to prevent double-signaling.
|
||||
Use cases include private voting, whistleblowing, anonymous DAOs and mixers.
|
||||
|
||||
@@ -15,9 +15,9 @@ Use cases include private voting, whistleblowing, anonymous DAOs and mixers.
|
||||
|
||||
With Semaphore, you can allow your users to do the following:
|
||||
|
||||
1. [Create a Semaphore identity](/V4-alpha/guides/identities/).
|
||||
2. [Add their Semaphore identity to a group (i.e. _Merkle tree_)](/V4-alpha/guides/groups/).
|
||||
3. [Send a verifiable, anonymous message (e.g a vote or endorsement)](/V4-alpha/guides/proofs/).
|
||||
1. [Create a Semaphore identity](/guides/identities/).
|
||||
2. [Add their Semaphore identity to a group (i.e. _Merkle tree_)](/guides/groups/).
|
||||
3. [Send a verifiable, anonymous message (e.g a vote or endorsement)](/guides/proofs/).
|
||||
|
||||
When a user broadcasts a message, Semaphore zero-knowledge
|
||||
proofs can ensure that the user has joined the group and hasn't already cast a message with their nullifier.
|
||||
@@ -33,10 +33,10 @@ Semaphore is designed to be a simple and generic _privacy layer_ for decentraliz
|
||||
|
||||
## About the code
|
||||
|
||||
The core of the protocol is the [circuit logic](https://github.com/semaphore-protocol/semaphore/tree/feat/semaphore-v4/packages/circuits/semaphore.circom).
|
||||
The core of the protocol is the [circuit logic](https://github.com/semaphore-protocol/semaphore/tree/main/packages/circuits/semaphore.circom).
|
||||
In addition to circuits,
|
||||
Semaphore provides [Solidity contracts](https://github.com/semaphore-protocol/semaphore/tree/feat/semaphore-v4/packages/contracts)
|
||||
and [JavaScript libraries](https://github.com/semaphore-protocol/semaphore/tree/feat/semaphore-v4#-packages) that allow developers to generate zero-knowledge proofs and verify them with minimal effort.
|
||||
Semaphore provides [Solidity contracts](https://github.com/semaphore-protocol/semaphore/tree/main/packages/contracts)
|
||||
and [JavaScript libraries](https://github.com/semaphore-protocol/semaphore/tree/main#-packages) that allow developers to generate zero-knowledge proofs and verify them with minimal effort.
|
||||
|
||||
### Audits
|
||||
|
||||
@@ -1 +1 @@
|
||||
["V4-alpha", "V3", "V2", "V1"]
|
||||
["V4-beta", "V3", "V2", "V1"]
|
||||
|
||||
@@ -42,13 +42,14 @@
|
||||
|
||||
## Networks
|
||||
|
||||
| Semaphore version | Sepolia | Mumbai | Optimism Sepolia | Arbitrum Sepolia | Arbitrum One |
|
||||
| ----------------- | ----------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- | ---------------- | ---------------- | --------------------------------------------------------------------------------------------------------------------- |
|
||||
| v2.0 | N/A | N/A | N/A | N/A | [semaphore-protocol/arbitrum](https://thegraph.com/hosted-service/subgraph/semaphore-protocol/arbitrum) |
|
||||
| v2.5 | N/A | N/A | N/A | N/A | N/A |
|
||||
| v2.6 | N/A | N/A | N/A | N/A | [semaphore-protocol/arbitrum-86337c](https://thegraph.com/hosted-service/subgraph/semaphore-protocol/arbitrum-86337c) |
|
||||
| v3.0 - v3.1 | N/A | N/A | N/A | N/A | [semaphore-protocol/arbitrum-72dca3](https://thegraph.com/hosted-service/subgraph/semaphore-protocol/arbitrum-72dca3) |
|
||||
| >= v3.2 | [semaphore-sepolia](https://api.studio.thegraph.com/query/14377/semaphore-sepolia/v3.6.1) | [semaphore-mumbai](https://api.studio.thegraph.com/query/14377/semaphore-mumbai/v3.6.1) | N/A | N/A | [semaphore-arbitrum](https://api.studio.thegraph.com/query/14377/semaphore-arbitrum/v3.6.1) |
|
||||
| Semaphore version | Sepolia | Mumbai | Optimism Sepolia | Arbitrum Sepolia | Arbitrum One |
|
||||
| ----------------- | ---------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------- |
|
||||
| v2.0 | N/A | N/A | N/A | N/A | [semaphore-protocol/arbitrum](https://thegraph.com/hosted-service/subgraph/semaphore-protocol/arbitrum) |
|
||||
| v2.5 | N/A | N/A | N/A | N/A | N/A |
|
||||
| v2.6 | N/A | N/A | N/A | N/A | [semaphore-protocol/arbitrum-86337c](https://thegraph.com/hosted-service/subgraph/semaphore-protocol/arbitrum-86337c) |
|
||||
| v3.0 - v3.1 | N/A | N/A | N/A | N/A | [semaphore-protocol/arbitrum-72dca3](https://thegraph.com/hosted-service/subgraph/semaphore-protocol/arbitrum-72dca3) |
|
||||
| >= v3.2 | [semaphore-sepolia](https://api.studio.thegraph.com/query/14377/semaphore-sepolia/v3.6.1) | [semaphore-mumbai](https://api.studio.thegraph.com/query/14377/semaphore-mumbai/v3.6.1) | N/A | N/A | [semaphore-arbitrum](https://api.studio.thegraph.com/query/14377/semaphore-arbitrum/v3.6.1) |
|
||||
| >= v4.0.0-beta | [semaphore-sepolia](https://api.studio.thegraph.com/query/14377/semaphore-sepolia/v4.0.0-beta) | [semaphore-matic-mumbai](https://api.studio.thegraph.com/query/14377/semaphore-matic-mumbai/v4.0.0-beta) | [semaphore-optimism-sepolia](https://api.studio.thegraph.com/query/14377/semaphore-optimism-sepolia/v4.0.0-beta) | [semaphore-arbitrum-sepolia](https://api.studio.thegraph.com/query/14377/semaphore-arbitrum-sepolia/v4.0.0-beta) | N/A |
|
||||
|
||||
## 🛠 Install
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1,38 +0,0 @@
|
||||
{
|
||||
"sepolia": {
|
||||
"Semaphore": {
|
||||
"address": "0x5B8e7cC7bAC61A4b952d472b67056B2f260ba6dc",
|
||||
"startBlock": 5150903
|
||||
}
|
||||
},
|
||||
"mumbai": {
|
||||
"Semaphore": {
|
||||
"address": "",
|
||||
"startBlock": 0
|
||||
}
|
||||
},
|
||||
"optimism-sepolia": {
|
||||
"Semaphore": {
|
||||
"address": "",
|
||||
"startBlock": 0
|
||||
}
|
||||
},
|
||||
"arbitrum-sepolia": {
|
||||
"Semaphore": {
|
||||
"address": "",
|
||||
"startBlock": 0
|
||||
}
|
||||
},
|
||||
"arbitrum-one": {
|
||||
"Semaphore": {
|
||||
"address": "",
|
||||
"startBlock": 0
|
||||
}
|
||||
},
|
||||
"localhost": {
|
||||
"Semaphore": {
|
||||
"address": "0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0",
|
||||
"startBlock": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,8 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@graphprotocol/graph-cli": "0.67.0",
|
||||
"@graphprotocol/graph-ts": "0.32.0"
|
||||
"@graphprotocol/graph-ts": "0.32.0",
|
||||
"@semaphore-protocol/utils": "workspace:packages/utils"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/mustache": "^4.2.2",
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import Mustache from "mustache"
|
||||
import { getDeployedContract } from "@semaphore-protocol/utils"
|
||||
import { readFileSync, writeFileSync } from "fs"
|
||||
import Mustache from "mustache"
|
||||
|
||||
const network = process.argv.at(2)
|
||||
|
||||
const template = readFileSync("./subgraph.template.yaml", "utf-8")
|
||||
const networks = JSON.parse(readFileSync("./networks.json", "utf-8"))
|
||||
const subgraph = Mustache.render(template, { network, ...networks[network].Semaphore })
|
||||
|
||||
const subgraph = Mustache.render(template, { network, ...getDeployedContract(network) })
|
||||
|
||||
writeFileSync("./subgraph.yaml", subgraph)
|
||||
|
||||
@@ -95,27 +95,32 @@ export default function Learn() {
|
||||
{
|
||||
title: "Semaphore identities",
|
||||
description:
|
||||
"Given to all Semaphore group members, it is comprised of three parts - identity commitment, trapdoor, and nullifier.",
|
||||
"A Semaphore identity is an EdDSA key-pair plus the commitment (i.e. the hash of the public key), which is used as the public value of the Semaphore group members.",
|
||||
linkText: "Create Semaphore identities",
|
||||
linkUrl: "https://docs.semaphore.pse.dev/guides/identities",
|
||||
codeText: `import { Identity } from "@semaphore-protocol/identity"
|
||||
|
||||
const { trapdoor, nullifier, commitment } = new Identity()`,
|
||||
// Random identity.
|
||||
const identity1 = new Identity()
|
||||
|
||||
// Passing a secret.
|
||||
const identity2 = new Identity("secret")
|
||||
`,
|
||||
itemList: [
|
||||
{
|
||||
icon: <IconEyelash w="24px" h="24px" color="primary.600" />,
|
||||
heading: "Private values",
|
||||
body: "Trapdoor and nullifier values are the private values of the Semaphore identity. To avoid fraud, the owner must keep both values secret."
|
||||
heading: "Private value",
|
||||
body: "The private key is a secret that identity owners must keep private. It can either be generated randomly or passed as a parameter."
|
||||
},
|
||||
{
|
||||
icon: <IconEye w="24px" h="24px" color="primary.600" />,
|
||||
heading: "Public values",
|
||||
body: "Semaphore uses the Poseidon hash function to create the identity commitment from the identity private values. Identity commitments can be made public, similarly to Ethereum addresses."
|
||||
body: "Semaphore uses the Poseidon hash function to derive the identity commitment from the identity public key. Identity commitments can be made public, similarly to Ethereum addresses."
|
||||
},
|
||||
{
|
||||
icon: <IconUser w="24px" h="24px" color="primary.600" />,
|
||||
heading: "Generate identities",
|
||||
body: "Semaphore identities can be generated deterministically or randomly. Deterministic identities can be generated from the hash of a secret message."
|
||||
heading: "Storing identities",
|
||||
body: "Building a system to save or recover secret values of Semaphore identities is nontrivial. You may choose to delegate such functionality, for example by using a signature as a secret."
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -127,45 +132,41 @@ const { trapdoor, nullifier, commitment } = new Identity()`,
|
||||
linkUrl: "https://docs.semaphore.pse.dev/guides/groups",
|
||||
codeText: `import { Group } from "@semaphore-protocol/group"
|
||||
|
||||
const group = new Group(1)
|
||||
const members = [identity1.commitment, identity2.commitment]
|
||||
|
||||
group.addMember(commitment)`,
|
||||
const group = new Group(members)
|
||||
`,
|
||||
itemList: [
|
||||
{
|
||||
icon: <IconTree w="24px" h="24px" color="primary.600" />,
|
||||
heading: "Merkle trees",
|
||||
body: "Each leaf contains an identity commitment for a user. The identity commitment proves that the user is a group member without revealing the private identity of the user."
|
||||
body: "Each leaf contains an identity commitment for a user. The structure of Merkle trees ensures that it can be efficiently proved that an identity commitment is a member of the group."
|
||||
},
|
||||
{
|
||||
icon: <IconGroup w="24px" h="24px" color="primary.600" />,
|
||||
heading: "Types of groups",
|
||||
body: "Groups can be created and managed in a decentralized fashion with Semaphore contracts or off-chain with our JavaScript libraries."
|
||||
body: "Groups can be created and managed in a decentralized fashion with Semaphore contracts or off-chain with the JavaScript libraries."
|
||||
},
|
||||
{
|
||||
icon: <IconManageUsers w="24px" h="24px" color="primary.600" />,
|
||||
heading: "Group management",
|
||||
body: "Users can join and leave groups by themselves, or an admin can add and remove them. Admins can be centralized authorities, Ethereum accounts, multi-sig wallets or smart contracts."
|
||||
body: "Users could join and leave groups by themselves, or an admin could add and remove them. Admins can be centralized authorities, Ethereum accounts, multi-sig wallets or smart contracts."
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
title: "Semaphore proofs",
|
||||
description:
|
||||
"Semaphore group members can anonymously prove that they are part of a group and that they are generating their own proofs and signals.",
|
||||
description: "Semaphore group members can prove that they are part of a group and send anonymous messages.",
|
||||
linkText: "Generate Semaphore proofs",
|
||||
linkUrl: "https://docs.semaphore.pse.dev/guides/proofs",
|
||||
codeText: `import { generateProof, verifyProof } from "@semaphore-protocol/proof"
|
||||
import { utils } from "ethers"
|
||||
|
||||
const externalNullifier = utils.formatBytes32String("Topic")
|
||||
const signal = utils.formatBytes32String("Hello world")
|
||||
const scope = "Semaphore"
|
||||
const message = "Hello world"
|
||||
|
||||
const fullProof = await generateProof(identity, group, externalNullifier, signal, {
|
||||
zkeyFilePath: "./semaphore.zkey",
|
||||
wasmFilePath: "./semaphore.wasm"
|
||||
})
|
||||
const proof = await generateProof(identity1, group, scope, message)
|
||||
|
||||
await verifyProof(fullProof, group.depth)`,
|
||||
await verifyProof(proof)`,
|
||||
itemList: [
|
||||
{
|
||||
icon: <IconBadge w="24px" h="24px" color="primary.600" />,
|
||||
@@ -174,13 +175,13 @@ await verifyProof(fullProof, group.depth)`,
|
||||
},
|
||||
{
|
||||
icon: <IconFlag w="24px" h="24px" color="primary.600" />,
|
||||
heading: "Signals",
|
||||
body: "Group users can anonymously broadcast signals such as votes or endorsements without revealing their original identity."
|
||||
heading: "Messages",
|
||||
body: "Group users can anonymously share messages such as votes or endorsements without revealing their original identity."
|
||||
},
|
||||
{
|
||||
icon: <IconCheck w="24px" h="24px" color="primary.600" />,
|
||||
heading: "Verifiers",
|
||||
body: "Semaphore proofs can be verified with our contracts or off-chain with our JavaScript libraries."
|
||||
heading: "Proof verification",
|
||||
body: "Semaphore proofs can be verified both on-chain with the Semaphore contracts, or off-chain with the JavaScript libraries."
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ export default function Home() {
|
||||
</VStack>
|
||||
|
||||
<Stack direction={{ base: "column", sm: "row" }} spacing="6" align="center">
|
||||
<Link href="https://docs.semaphore.pse.dev/quick-setup" isExternal>
|
||||
<Link href="https://docs.semaphore.pse.dev/getting-started" isExternal>
|
||||
<Button size={{ base: "md", md: "lg" }}>Get Started</Button>
|
||||
</Link>
|
||||
<Link href="https://demo.semaphore.pse.dev" isExternal>
|
||||
|
||||
@@ -13,7 +13,8 @@ const projects: any = fs
|
||||
displayName: name,
|
||||
setupFiles: ["dotenv/config"],
|
||||
moduleNameMapper: {
|
||||
"@semaphore-protocol/(.*)": "<rootDir>/../$1/src/index.ts" // Interdependency packages.
|
||||
"@semaphore-protocol/(.*)/(.*)": "<rootDir>/../$1/src/$2",
|
||||
"@semaphore-protocol/(.*)": "<rootDir>/../$1/src"
|
||||
}
|
||||
}))
|
||||
|
||||
|
||||
53
package.json
53
package.json
@@ -7,11 +7,13 @@
|
||||
"bugs": "https://github.com/semaphore-protocol/semaphore/issues",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"build:libraries": "yarn workspaces foreach -t --no-private run build",
|
||||
"build": "yarn build:libraries && yarn build:subgraph",
|
||||
"build:libraries": "yarn workspaces foreach -A -t --no-private run build",
|
||||
"build:subgraph": "yarn workspace semaphore-subgraph codegen sepolia && yarn workspace semaphore-subgraph build",
|
||||
"compile:contracts": "yarn workspace semaphore-contracts compile",
|
||||
"test": "yarn test:libraries && yarn test:contracts && yarn test:circuits && yarn test:subgraph",
|
||||
"test:libraries": "jest --coverage",
|
||||
"test:library": "jest packages/${0}",
|
||||
"test:subgraph": "yarn workspace semaphore-subgraph test",
|
||||
"test:contracts": "yarn workspace semaphore-contracts test:coverage",
|
||||
"test:circuits": "yarn workspace @semaphore-protocol/circuits test",
|
||||
@@ -19,12 +21,12 @@
|
||||
"prettier": "prettier -c .",
|
||||
"prettier:write": "prettier -w .",
|
||||
"docs": "typedoc --cname js.semaphore.pse.dev --githubPages true",
|
||||
"version:bump": "yarn workspaces foreach --no-private version -d ${0} && yarn version apply --all && git commit -am \"chore: v${0}\" && git tag v${0}",
|
||||
"version:publish": "yarn build:libraries && yarn clean:cli-templates && yarn workspaces foreach --no-private npm publish --tolerate-republish --access public",
|
||||
"version:bump": "yarn workspaces foreach -A --no-private version -d ${0} && yarn version apply --all && yarn remove:stable-version-field && NO_HOOK=1 git commit -am \"chore: v${0}\" && git tag v${0}",
|
||||
"version:publish": "yarn build:libraries && yarn clean:cli-templates && yarn workspaces foreach -A --no-private npm publish --tolerate-republish --access public",
|
||||
"version:release": "changelogithub",
|
||||
"clean": "ts-node scripts/clean-apps.ts && ts-node scripts/clean-packages.ts && yarn clean:cli-templates && rimraf node_modules",
|
||||
"clean:cli-templates": "ts-node scripts/clean-cli-templates.ts",
|
||||
"commit": "cz",
|
||||
"remove:stable-version-field": "ts-node scripts/remove-stable-version-field.ts && yarn prettier:write",
|
||||
"precommit": "lint-staged",
|
||||
"postinstall": "husky install"
|
||||
},
|
||||
@@ -46,49 +48,44 @@
|
||||
"packages/*",
|
||||
"packages/contracts/contracts"
|
||||
],
|
||||
"packageManager": "yarn@3.2.1",
|
||||
"packageManager": "yarn@4.1.0",
|
||||
"devDependencies": {
|
||||
"@commitlint/cli": "^16.0.2",
|
||||
"@commitlint/config-conventional": "^16.0.0",
|
||||
"@rollup/plugin-typescript": "^11.1.6",
|
||||
"@types/circomlibjs": "^0.1.4",
|
||||
"@types/download": "^8.0.1",
|
||||
"@commitlint/cli": "^18.6.1",
|
||||
"@commitlint/config-conventional": "^18.6.2",
|
||||
"@types/glob": "^7.2.0",
|
||||
"@types/jest": "^29.5.12",
|
||||
"@types/node": "^20",
|
||||
"@types/rimraf": "^3.0.2",
|
||||
"@typescript-eslint/eslint-plugin": "^5.9.1",
|
||||
"@typescript-eslint/parser": "^5.9.1",
|
||||
"@typescript-eslint/eslint-plugin": "^7.0.2",
|
||||
"@typescript-eslint/parser": "^7.0.2",
|
||||
"changelogithub": "0.12.7",
|
||||
"commitizen": "^4.2.4",
|
||||
"cz-conventional-changelog": "^3.3.0",
|
||||
"commitizen": "^4.3.0",
|
||||
"cz-git": "^1.9.0",
|
||||
"dotenv": "^16.0.2",
|
||||
"eslint": "^8.2.0",
|
||||
"eslint": "^8.56.0",
|
||||
"eslint-config-airbnb": "^19.0.4",
|
||||
"eslint-config-airbnb-typescript": "^16.1.0",
|
||||
"eslint-config-prettier": "^8.3.0",
|
||||
"eslint-plugin-import": "^2.25.2",
|
||||
"eslint-plugin-jest": "^27.8.0",
|
||||
"eslint-config-airbnb-typescript": "^17.1.0",
|
||||
"eslint-config-prettier": "^9.1.0",
|
||||
"eslint-plugin-import": "^2.29.1",
|
||||
"eslint-plugin-jest": "^27.9.0",
|
||||
"eslint-plugin-jsx-a11y": "^6.8.0",
|
||||
"eslint-plugin-react": "^7.33.2",
|
||||
"eslint-plugin-react": "^7.34.0",
|
||||
"eslint-plugin-react-hooks": "^4.6.0",
|
||||
"husky": "^8.0.3",
|
||||
"husky": "^9.0.11",
|
||||
"jest": "^29.7.0",
|
||||
"jest-config": "^29.7.0",
|
||||
"lint-staged": "^12.1.7",
|
||||
"prettier": "^2.5.1",
|
||||
"rimraf": "^3.0.2",
|
||||
"rollup": "^4.9.6",
|
||||
"lint-staged": "^15.2.2",
|
||||
"prettier": "^3.2.5",
|
||||
"rimraf": "^5.0.5",
|
||||
"snarkjs": "^0.7.2",
|
||||
"ts-jest": "^29.1.2",
|
||||
"ts-node": "^10.9.2",
|
||||
"tslib": "^2.6.2",
|
||||
"typedoc": "^0.25.7",
|
||||
"typedoc": "^0.25.8",
|
||||
"typescript": "^5.3.3"
|
||||
},
|
||||
"config": {
|
||||
"commitizen": {
|
||||
"path": "./node_modules/cz-conventional-changelog"
|
||||
"path": "./node_modules/cz-git"
|
||||
}
|
||||
},
|
||||
"resolutions": {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<h1 align="center">
|
||||
Semaphore circuits
|
||||
</h1>
|
||||
<p align="center">Semaphore circuits to create and verify zero-knowledge proofs.</p>
|
||||
<p align="center">Semaphore circuits to generate and verify zero-knowledge proofs.</p>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@semaphore-protocol/circuits",
|
||||
"version": "4.0.0-alpha.8",
|
||||
"version": "4.0.0-beta.7",
|
||||
"description": "Semaphore Circom circuits to generate zero-knowledge proofs.",
|
||||
"license": "MIT",
|
||||
"files": [
|
||||
@@ -29,11 +29,10 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/mocha": "^10.0.6",
|
||||
"@zk-kit/eddsa-poseidon": "0.3.1",
|
||||
"@zk-kit/imt": "^2.0.0-beta.1",
|
||||
"@zk-kit/eddsa-poseidon": "0.6.0",
|
||||
"@zk-kit/imt": "^2.0.0-beta.2",
|
||||
"circomkit": "^0.0.19",
|
||||
"mocha": "^10.2.0",
|
||||
"poseidon-lite": "^0.2.0"
|
||||
},
|
||||
"stableVersion": "4.0.0-alpha.7"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,22 +4,64 @@ include "babyjub.circom";
|
||||
include "poseidon.circom";
|
||||
include "binary-merkle-root.circom";
|
||||
|
||||
// The Semaphore circuit can be divided into 3 main parts.
|
||||
// The first part involves the generation of the Semaphore identity,
|
||||
// i.e. the public key and its hash, which is called the commitment
|
||||
// and is used as a public value.
|
||||
// In the second part, it is verified whether or not the identity commitment is part
|
||||
// of the Merkle tree, i.e. the Semaphore group. That is, a proof of membership is verified.
|
||||
// The third part covers the generation of a nullifier, i.e. the hash of the scope of the proof
|
||||
// and the secret used to derive the public key (secret scalar). The nullifier is used to prevent the same
|
||||
// proof from being verified twice.
|
||||
// The circuit lastly includes the message, which is an arbitrary anonymous value defined by
|
||||
// the user, or the hash of that value.
|
||||
template Semaphore(MAX_DEPTH) {
|
||||
// Input signals.
|
||||
// The input signals are all private except 'message' and 'scope'.
|
||||
// The secret is the scalar generated from the EdDSA private key.
|
||||
// Using the secret scalar instead of the private key allows this circuit
|
||||
// to skip steps 1, 2, 3 in the generation of the public key defined here:
|
||||
// https://www.rfc-editor.org/rfc/rfc8032#section-5.1.5, making the circuit
|
||||
// more efficient and simple.
|
||||
// See the Semaphore identity package to know more about how the identity is generated:
|
||||
// https://github.com/semaphore-protocol/semaphore/tree/main/packages/identity.
|
||||
signal input secret;
|
||||
signal input merkleProofLength, merkleProofIndices[MAX_DEPTH], merkleProofSiblings[MAX_DEPTH];
|
||||
signal input message;
|
||||
signal input scope;
|
||||
|
||||
// Output signals.
|
||||
// The output signals are all public.
|
||||
signal output merkleRoot, nullifier;
|
||||
|
||||
// Identity generation.
|
||||
// The circuit derives the EdDSA public key from a secret using
|
||||
// Baby Jubjub (https://eips.ethereum.org/EIPS/eip-2494),
|
||||
// which is basically nothing more than a point with two coordinates.
|
||||
// It then calculates the hash of the public key, which is used
|
||||
// as the commitment, i.e. the public value of the Semaphore identity.
|
||||
var Ax, Ay;
|
||||
(Ax, Ay) = BabyPbk()(secret);
|
||||
|
||||
var identityCommitment = Poseidon(2)([Ax, Ay]);
|
||||
|
||||
// Proof of membership verification.
|
||||
// The Merkle root passed as output must be equal to that calculated within
|
||||
// the circuit through the inputs of the Merkle proof.
|
||||
// See https://github.com/privacy-scaling-explorations/zk-kit/blob/main/packages/circuits/circom/binary-merkle-root.circom
|
||||
// to know more about how the 'BinaryMerkleRoot' template works.
|
||||
merkleRoot <== BinaryMerkleRoot(MAX_DEPTH)(identityCommitment, merkleProofLength, merkleProofIndices, merkleProofSiblings);
|
||||
|
||||
// Nullifier generation.
|
||||
// The nullifier is a value that essentially identifies the proof generated in a specific scope
|
||||
// and by a specific identity, so that externally anyone can check if another proof with the same
|
||||
// nullifier has already been generated. This mechanism can be particularly useful in cases
|
||||
// where one wants to prevent double-spending or double-voting, for example.
|
||||
nullifier <== Poseidon(2)([scope, secret]);
|
||||
|
||||
// Dummy constraint to prevent compiler from optimizing it.
|
||||
// The message is not really used within the circuit.
|
||||
// The square applied to it is a way to force Circom's compiler to add a constraint and
|
||||
// prevent its value from being changed by an attacker.
|
||||
// More information here: https://geometry.xyz/notebook/groth16-malleability.
|
||||
signal dummySquare <== message * message;
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ describe("semaphore", () => {
|
||||
}
|
||||
|
||||
const INPUT = {
|
||||
secret: deriveSecretScalar(secret),
|
||||
secret: deriveSecretScalar(secret) as `${number}`,
|
||||
merkleProofLength: tree.depth,
|
||||
merkleProofIndices,
|
||||
merkleProofSiblings,
|
||||
|
||||
13
packages/cli-template-contracts-hardhat/.editorconfig
Normal file
13
packages/cli-template-contracts-hardhat/.editorconfig
Normal file
@@ -0,0 +1,13 @@
|
||||
#root = true
|
||||
|
||||
[*]
|
||||
indent_style = space
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
max_line_length = 120
|
||||
indent_size = 4
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user