Compare commits
235 Commits
test/more-
...
v4.7.2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
53967a9a3c | ||
|
|
5b92c0a2bc | ||
|
|
31c776ea68 | ||
|
|
8d83d59220 | ||
|
|
9e4fb5376c | ||
|
|
745edb8e92 | ||
|
|
e732992952 | ||
|
|
3fcce15375 | ||
|
|
ebb6731d89 | ||
|
|
0c23acf9cf | ||
|
|
3e7db08eeb | ||
|
|
8adfc30da8 | ||
|
|
42639662c3 | ||
|
|
64025516c0 | ||
|
|
91f8a4be2a | ||
|
|
ebd9a27c1b | ||
|
|
bada8b8792 | ||
|
|
e93b19c566 | ||
|
|
862f715d05 | ||
|
|
3ed6c38587 | ||
|
|
7e183f3d2c | ||
|
|
901d0954c0 | ||
|
|
caebc1a4ab | ||
|
|
9b419f0c78 | ||
|
|
c67b888eb6 | ||
|
|
376cd11808 | ||
|
|
58132a9478 | ||
|
|
fadcf19206 | ||
|
|
3be17268ab | ||
|
|
82cdc60af6 | ||
|
|
6c9ede6931 | ||
|
|
e6576cdc47 | ||
|
|
c07dc88490 | ||
|
|
67060dd412 | ||
|
|
a4e540d8f4 | ||
|
|
79976f33cb | ||
|
|
822530f2cf | ||
|
|
b3f862979d | ||
|
|
06e11d5c34 | ||
|
|
88d4470b11 | ||
|
|
bb1c6984b2 | ||
|
|
5841327477 | ||
|
|
eab3ab30c6 | ||
|
|
cd6dc38f9e | ||
|
|
3cb1b5757d | ||
|
|
a8db8393c1 | ||
|
|
391b571c31 | ||
|
|
4c2769099f | ||
|
|
29cabb49d6 | ||
|
|
48b0694586 | ||
|
|
28684fdb1a | ||
|
|
49a16635d8 | ||
|
|
4bfe6d8791 | ||
|
|
a3d97795fe | ||
|
|
4c8d297902 | ||
|
|
fdbadf5b71 | ||
|
|
4496eee137 | ||
|
|
215a12e25c | ||
|
|
87331114c1 | ||
|
|
0d41562dad | ||
|
|
c435712656 | ||
|
|
7d48311474 | ||
|
|
5ef73e2819 | ||
|
|
de7bdd6d17 | ||
|
|
21c2739f19 | ||
|
|
1ed170d0db | ||
|
|
bc041486b0 | ||
|
|
5db1bccb84 | ||
|
|
b2da0a685a | ||
|
|
9329eed754 | ||
|
|
75563ee0d5 | ||
|
|
368bbd4bcd | ||
|
|
da2fae673d | ||
|
|
ff61aae040 | ||
|
|
44ad964beb | ||
|
|
d54d67345d | ||
|
|
b5f8ee7929 | ||
|
|
698cef0a80 | ||
|
|
af4aec2127 | ||
|
|
af4fe8de82 | ||
|
|
90caadf5dc | ||
|
|
1e4e63cc31 | ||
|
|
4e54c159e6 | ||
|
|
0d55ccbb15 | ||
|
|
57747467bd | ||
|
|
d9fff6129c | ||
|
|
0f6505c014 | ||
|
|
6c9be1bb5e | ||
|
|
fe5cf653c1 | ||
|
|
ced5f6a2d5 | ||
|
|
1b046fd8d1 | ||
|
|
5fe6e4cd5f | ||
|
|
e63209914d | ||
|
|
504c0f7f9c | ||
|
|
a1628f635a | ||
|
|
bb1975a949 | ||
|
|
b9a163e613 | ||
|
|
7ec35c22f8 | ||
|
|
f19daf7896 | ||
|
|
3572f4493d | ||
|
|
2830d3d0dc | ||
|
|
62b6b170a6 | ||
|
|
5d513f92fb | ||
|
|
0c942220b6 | ||
|
|
9237e147b8 | ||
|
|
1dbc310333 | ||
|
|
4870175577 | ||
|
|
55e887c111 | ||
|
|
f934c02214 | ||
|
|
43fba00845 | ||
|
|
7b3621a701 | ||
|
|
f3f3688476 | ||
|
|
0fa785bc58 | ||
|
|
51ebe9db4d | ||
|
|
c88175bb2d | ||
|
|
ea175fa90c | ||
|
|
f9e41fb306 | ||
|
|
47bfebd4ed | ||
|
|
9e5b2285fc | ||
|
|
de15989638 | ||
|
|
2e56ab6b07 | ||
|
|
3329922077 | ||
|
|
6b6bc6a98e | ||
|
|
b9fa75cba3 | ||
|
|
1b34ad312d | ||
|
|
74df3c204d | ||
|
|
08af4a315f | ||
|
|
ddfe4ffd56 | ||
|
|
87f63451e3 | ||
|
|
f8deb64285 | ||
|
|
82bc47fb24 | ||
|
|
5ced7db5f8 | ||
|
|
5c224f214c | ||
|
|
0b9ba376db | ||
|
|
a9410fa6d1 | ||
|
|
79bd8d6305 | ||
|
|
c5448fe1f0 | ||
|
|
cf1cffdf65 | ||
|
|
41a85e0e45 | ||
|
|
6502c17f7b | ||
|
|
1849055e88 | ||
|
|
e536debb16 | ||
|
|
4ba367bee4 | ||
|
|
ce6d622202 | ||
|
|
3b08b67175 | ||
|
|
68181aa1fb | ||
|
|
6225b9b7c0 | ||
|
|
940db25a87 | ||
|
|
9dc768376c | ||
|
|
ba8132561a | ||
|
|
5aaa9e4f69 | ||
|
|
f19b632e1e | ||
|
|
b40f9f13e9 | ||
|
|
e884186488 | ||
|
|
a4a6837f5a | ||
|
|
2aee16e082 | ||
|
|
7c99c74fac | ||
|
|
8e246c48bf | ||
|
|
75eac56e9f | ||
|
|
d9d5de1569 | ||
|
|
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 | ||
|
|
25847c4422 | ||
|
|
7b8a35470a |
@@ -2,11 +2,12 @@ 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],
|
||||
scopes: [...packages, ...apps],
|
||||
markBreakingChangeMode: true,
|
||||
allowCustomIssuePrefix: false,
|
||||
allowEmptyIssuePrefix: false,
|
||||
|
||||
@@ -1,10 +1,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
|
||||
|
||||
@@ -26,5 +26,13 @@
|
||||
"no-console": ["warn", { "allow": ["info", "warn", "error"] }],
|
||||
"@typescript-eslint/lines-between-class-members": "off",
|
||||
"no-param-reassign": "off"
|
||||
}
|
||||
},
|
||||
"overrides": [
|
||||
{
|
||||
"files": ["./scripts/*"],
|
||||
"rules": {
|
||||
"no-console": "off"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
1
.github/CODEOWNERS
vendored
Normal file
@@ -0,0 +1 @@
|
||||
* @semaphore-protocol/core-devs
|
||||
4
.github/pull_request_template.md
vendored
@@ -32,9 +32,7 @@
|
||||
- [ ] My code follows the style guidelines of this project
|
||||
- [ ] I have performed a self-review of my code
|
||||
- [ ] I have commented my code, particularly in hard-to-understand areas
|
||||
- [ ] I have made corresponding changes to the documentation
|
||||
- [ ] My changes generate no new warnings
|
||||
- [ ] I have run `yarn prettier` and `yarn lint` without getting any errors
|
||||
- [ ] I have run `yarn format` 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
|
||||
|
||||
14
.github/workflows/auto-assign.yml
vendored
@@ -1,14 +0,0 @@
|
||||
name: auto-assign
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types: [opened]
|
||||
|
||||
jobs:
|
||||
run:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: wow-actions/auto-assign@v3
|
||||
with:
|
||||
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
|
||||
reviewers: org/core-devs
|
||||
12
.github/workflows/docs.yml
vendored
@@ -2,8 +2,16 @@ name: docs
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
branches: [main]
|
||||
paths:
|
||||
[
|
||||
"apps/docs/**",
|
||||
"packages/data/**",
|
||||
"packages/group/**",
|
||||
"packages/identity/**",
|
||||
"packages/proof/**",
|
||||
"packages/utils/**"
|
||||
]
|
||||
|
||||
jobs:
|
||||
gh-pages:
|
||||
|
||||
24
.github/workflows/production.yml
vendored
@@ -24,17 +24,11 @@ jobs:
|
||||
- name: Install dependencies
|
||||
run: yarn
|
||||
|
||||
- name: Compile contracts
|
||||
run: yarn compile:contracts
|
||||
- name: Build packages and apps
|
||||
run: yarn build
|
||||
|
||||
- name: Build libraries
|
||||
run: yarn build:libraries
|
||||
|
||||
- name: Build subgraph
|
||||
run: yarn build:subgraph
|
||||
|
||||
- name: Run Prettier
|
||||
run: yarn prettier
|
||||
- name: Format
|
||||
run: yarn format
|
||||
|
||||
- name: Run Eslint
|
||||
run: yarn lint
|
||||
@@ -54,6 +48,9 @@ jobs:
|
||||
- name: Install dependencies
|
||||
run: yarn
|
||||
|
||||
- name: Build libraries
|
||||
run: yarn build:libraries
|
||||
|
||||
- name: Build subgraph
|
||||
run: yarn build:subgraph
|
||||
|
||||
@@ -79,11 +76,14 @@ jobs:
|
||||
cache: yarn
|
||||
|
||||
# https://github.com/iden3/circuits/blob/8fffb6609ecad0b7bcda19bb908bdb544bdb3cf7/.github/workflows/main.yml#L18-L22
|
||||
# https://stackoverflow.com/a/78377916
|
||||
- name: Setup Circom deps
|
||||
run: sudo apt-get update && sudo apt-get install -y wget nlohmann-json3-dev libgmp-dev nasm g++ build-essential
|
||||
run: |
|
||||
sudo rm /etc/apt/sources.list.d/microsoft-prod.list
|
||||
sudo apt-get update && sudo apt-get install -y wget nlohmann-json3-dev libgmp-dev nasm g++ build-essential
|
||||
|
||||
- name: Setup Circom
|
||||
run: wget https://github.com/iden3/circom/releases/latest/download/circom-linux-amd64 && sudo mv ./circom-linux-amd64 /usr/bin/circom && sudo chmod +x /usr/bin/circom
|
||||
run: sudo wget https://github.com/iden3/circom/releases/download/v2.1.9/circom-linux-amd64 -O /usr/bin/circom && sudo chmod +x /usr/bin/circom
|
||||
|
||||
- name: Install dependencies
|
||||
run: yarn
|
||||
|
||||
115
.github/workflows/pull-requests.yml
vendored
@@ -22,20 +22,57 @@ jobs:
|
||||
- name: Install dependencies
|
||||
run: yarn
|
||||
|
||||
- name: Compile contracts
|
||||
run: yarn compile:contracts
|
||||
- name: Get changed files
|
||||
id: changed-files
|
||||
uses: tj-actions/changed-files@v44
|
||||
with:
|
||||
files_yaml: |
|
||||
circuits:
|
||||
- packages/circuits/**/*.{circom,json,ts}
|
||||
contracts:
|
||||
- packages/contracts/**/*.{js,json,ts,sol}
|
||||
docs:
|
||||
- apps/docs/**/*
|
||||
libraries:
|
||||
- packages/**/*.{js,json,ts}
|
||||
- '!packages/{circuits,contracts}/**/*'
|
||||
subgraph:
|
||||
- apps/subgraph/**/*
|
||||
to_format:
|
||||
- '**/*.{cjs,js,json,jsx,md,mdx,sol,ts,tsx,yaml,yml}'
|
||||
to_lint:
|
||||
- '**/*.{cjs,js,jsx,ts,tsx}'
|
||||
|
||||
- name: Build libraries
|
||||
- if: steps.changed-files.outputs.contracts_any_changed == 'true'
|
||||
name: Compile and lint contracts
|
||||
run: |
|
||||
yarn workspace @semaphore-protocol/utils build
|
||||
yarn compile:contracts
|
||||
yarn workspace semaphore-contracts lint
|
||||
|
||||
- if: steps.changed-files.outputs.docs_any_changed == 'true'
|
||||
name: Build and format docs
|
||||
run: |
|
||||
yarn workspace semaphore-docs build
|
||||
yarn workspace semaphore-docs format
|
||||
|
||||
- if: steps.changed-files.outputs.libraries_any_changed == 'true'
|
||||
name: Build libraries
|
||||
run: yarn build:libraries
|
||||
|
||||
- name: Build subgraph
|
||||
run: yarn build:subgraph
|
||||
- if: steps.changed-files.outputs.subgraph_any_changed == 'true'
|
||||
name: Build subgraph
|
||||
run: |
|
||||
yarn workspace @semaphore-protocol/utils build
|
||||
yarn build:subgraph
|
||||
|
||||
- name: Run Prettier
|
||||
run: yarn prettier
|
||||
- if: steps.changed-files.outputs.to_format_any_changed == 'true'
|
||||
name: Format
|
||||
run: yarn run prettier --check ${{ steps.changed-files.outputs.to_format_all_changed_files }}
|
||||
|
||||
- name: Run Eslint
|
||||
run: yarn lint
|
||||
- if: steps.changed-files.outputs.to_lint_any_changed == 'true'
|
||||
name: Run Eslint
|
||||
run: yarn run eslint ${{ steps.changed-files.outputs.to_lint_all_changed_files }} --ext .cjs,.js,.jsx,.ts,.tsx
|
||||
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
@@ -49,21 +86,55 @@ jobs:
|
||||
node-version: 20
|
||||
cache: yarn
|
||||
|
||||
# https://github.com/iden3/circuits/blob/8fffb6609ecad0b7bcda19bb908bdb544bdb3cf7/.github/workflows/main.yml#L18-L22
|
||||
- name: Setup Circom deps
|
||||
run: sudo apt-get update && sudo apt-get install -y wget nlohmann-json3-dev libgmp-dev nasm g++ build-essential
|
||||
|
||||
- name: Setup Circom
|
||||
run: wget https://github.com/iden3/circom/releases/latest/download/circom-linux-amd64 && sudo mv ./circom-linux-amd64 /usr/bin/circom && sudo chmod +x /usr/bin/circom
|
||||
|
||||
- name: Install dependencies
|
||||
run: yarn
|
||||
|
||||
- name: Build libraries
|
||||
run: yarn build:libraries
|
||||
- name: Get changed files
|
||||
id: changed-files
|
||||
uses: tj-actions/changed-files@v44
|
||||
with:
|
||||
files_yaml: |
|
||||
circuits:
|
||||
- packages/circuits/**/*.{circom,json,ts}
|
||||
contracts:
|
||||
- packages/contracts/**/*.{js,json,ts,sol}
|
||||
libraries:
|
||||
- packages/**/*.{js,json,ts}
|
||||
- '!packages/{circuits,contracts}/**/*'
|
||||
subgraph:
|
||||
- apps/subgraph/**/*
|
||||
|
||||
- name: Build subgraph
|
||||
run: yarn build:subgraph
|
||||
# https://github.com/iden3/circuits/blob/8fffb6609ecad0b7bcda19bb908bdb544bdb3cf7/.github/workflows/main.yml#L18-L22
|
||||
# https://stackoverflow.com/a/78377916
|
||||
- if: steps.changed-files.outputs.circuits_any_changed == 'true'
|
||||
name: Setup Circom and Test circuits
|
||||
run: |
|
||||
sudo rm /etc/apt/sources.list.d/microsoft-prod.list
|
||||
sudo apt-get update && sudo apt-get install -y wget nlohmann-json3-dev libgmp-dev nasm g++ build-essential
|
||||
sudo wget https://github.com/iden3/circom/releases/download/v2.1.9/circom-linux-amd64 -O /usr/bin/circom && sudo chmod +x /usr/bin/circom
|
||||
yarn workspace @semaphore-protocol/group build
|
||||
yarn workspace @semaphore-protocol/identity build
|
||||
yarn workspace @semaphore-protocol/proof build
|
||||
yarn workspace @semaphore-protocol/utils build
|
||||
yarn test:circuits
|
||||
|
||||
- name: Test contracts, libraries, circuits and subgraph
|
||||
run: yarn test
|
||||
- if: steps.changed-files.outputs.contracts_any_changed == 'true'
|
||||
name: Build and Test contracts
|
||||
run: |
|
||||
yarn workspace @semaphore-protocol/group build
|
||||
yarn workspace @semaphore-protocol/identity build
|
||||
yarn workspace @semaphore-protocol/proof build
|
||||
yarn workspace @semaphore-protocol/utils build
|
||||
yarn compile:contracts
|
||||
yarn test:contracts
|
||||
|
||||
- if: steps.changed-files.outputs.libraries_any_changed == 'true'
|
||||
name: Build and Test libraries
|
||||
run: yarn build:libraries && yarn test:libraries
|
||||
|
||||
- if: steps.changed-files.outputs.subgraph_any_changed == 'true'
|
||||
name: Build and Test Subgraph
|
||||
run: |
|
||||
yarn workspace @semaphore-protocol/utils build
|
||||
yarn build:subgraph
|
||||
yarn test:subgraph
|
||||
|
||||
12
.github/workflows/release.yml
vendored
@@ -4,6 +4,7 @@ permissions:
|
||||
contents: write
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
tags:
|
||||
- "v*"
|
||||
@@ -17,6 +18,16 @@ jobs:
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Install soldeer
|
||||
uses: taiki-e/install-action@v2
|
||||
with:
|
||||
tool: soldeer
|
||||
- name: Store soldeer login credential
|
||||
env:
|
||||
SOLDEER_TOKEN: ${{ secrets.SOLDEER_TOKEN }}
|
||||
run: |
|
||||
echo "$SOLDEER_TOKEN" > "$GITHUB_WORKSPACE"/soldeer_login
|
||||
|
||||
- name: Install Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
@@ -37,6 +48,7 @@ jobs:
|
||||
run: yarn version:publish
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
SOLDEER_LOGIN_FILE: ${{ github.workspace }}/soldeer_login
|
||||
|
||||
- run: yarn version:release
|
||||
env:
|
||||
|
||||
8
.gitignore
vendored
@@ -86,5 +86,13 @@ typechain-types
|
||||
!.yarn/sdks
|
||||
!.yarn/versions
|
||||
|
||||
# asdf
|
||||
.tool-versions
|
||||
|
||||
# direnv
|
||||
.envrc
|
||||
|
||||
# Other
|
||||
snark-artifacts
|
||||
|
||||
*.zip
|
||||
|
||||
4
.husky/pre-commit
Normal file
@@ -0,0 +1,4 @@
|
||||
#!/usr/bin/env sh
|
||||
. "$(dirname "$0")/_/husky.sh"
|
||||
|
||||
npx lint-staged
|
||||
@@ -2,5 +2,5 @@
|
||||
. "$(dirname -- "$0")/_/husky.sh"
|
||||
|
||||
if [ "$NO_HOOK" != "1" ]; then
|
||||
exec < /dev/tty && yarn cz --hook || true
|
||||
exec < /dev/tty && npx czg --hook || true
|
||||
fi
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
{
|
||||
"**/*.{js,ts}": ["prettier --write", "eslint --fix"]
|
||||
"**/*.{js,ts,jsx,tsx,md,json,sol,yaml,yml}": "prettier --write",
|
||||
"**/*.{js,ts,jsx,tsx}": "eslint"
|
||||
}
|
||||
|
||||
1
.soldeerignore
Normal file
@@ -0,0 +1 @@
|
||||
package.json
|
||||
893
.yarn/releases/yarn-4.1.0.cjs
vendored
Executable file
1
.yarn/releases/yarn-4.1.0.cjs.REMOVED.git-id
vendored
@@ -1 +0,0 @@
|
||||
738adce5914a0e193f2e1255e4dcf7042256a1c1
|
||||
@@ -42,7 +42,7 @@ When you submit your PR (or later change that code), a CI build will automatical
|
||||
|
||||
We always use ESLint and Prettier. To check that your code follows the rules, simply run the npm script `yarn lint`.
|
||||
|
||||
### Commits rules
|
||||
### Commit rules
|
||||
|
||||
For commits it is recommended to use [Conventional Commits](https://www.conventionalcommits.org).
|
||||
|
||||
|
||||
53
README.md
@@ -1,9 +1,9 @@
|
||||
<p align="center">
|
||||
<h1 align="center">
|
||||
<picture>
|
||||
<source media="(prefers-color-scheme: dark)" srcset="https://github.com/semaphore-protocol/.github/blob/main/assets/semaphore-logo-light.svg">
|
||||
<source media="(prefers-color-scheme: light)" srcset="https://github.com/semaphore-protocol/.github/blob/main/assets/semaphore-logo-dark.svg">
|
||||
<img width="250" alt="Semaphore icon" src="https://github.com/semaphore-protocol/.github/blob/main/assets/semaphore-logo-dark.svg">
|
||||
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/semaphore-protocol/.github/main/assets/semaphore-logo-light.svg">
|
||||
<source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/semaphore-protocol/.github/main/assets/semaphore-logo-dark.svg">
|
||||
<img width="250" alt="Semaphore icon" src="https://raw.githubusercontent.com/semaphore-protocol/.github/main/assets/semaphore-logo-dark.svg">
|
||||
</picture>
|
||||
</h1>
|
||||
</p>
|
||||
@@ -53,16 +53,23 @@
|
||||
🔎 Issues
|
||||
</a>
|
||||
<span> | </span>
|
||||
<a href="https://semaphore.pse.dev/discord">
|
||||
<a href="https://semaphore.pse.dev/telegram">
|
||||
🗣️ Chat & Support
|
||||
</a>
|
||||
<span> | </span>
|
||||
<a href="https://js.semaphore.pse.dev">
|
||||
💻 API Reference
|
||||
</a>
|
||||
</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).
|
||||
|
||||
> [!IMPORTANT]
|
||||
> Help Semaphore prosper by sharing your ideas with the PSE [acceleration program](https://github.com/privacy-scaling-explorations/acceleration-program).
|
||||
|
||||
## 📦 Packages
|
||||
|
||||
@@ -257,29 +264,7 @@ The core of the Semaphore protocol is in the [circuit logic](/packages/circuits/
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<a href="/packages/heyauthn">
|
||||
@semaphore-protocol/heyauthn
|
||||
</a>
|
||||
<a href="https://js.semaphore.pse.dev/modules/_semaphore_protocol_heyauthn">
|
||||
(docs)
|
||||
</a>
|
||||
</td>
|
||||
<td>
|
||||
<!-- NPM version -->
|
||||
<a href="https://npmjs.org/package/@semaphore-protocol/heyauthn">
|
||||
<img src="https://img.shields.io/npm/v/@semaphore-protocol/heyauthn.svg?style=flat-square" alt="NPM version" />
|
||||
</a>
|
||||
</td>
|
||||
<td>
|
||||
<!-- Downloads -->
|
||||
<a href="https://npmjs.org/package/@semaphore-protocol/heyauthn">
|
||||
<img src="https://img.shields.io/npm/dm/@semaphore-protocol/heyauthn.svg?style=flat-square" alt="Downloads" />
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tbody>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
## 🛠 Install
|
||||
@@ -317,13 +302,13 @@ yarn lint
|
||||
Run [Prettier](https://prettier.io/) to check formatting rules:
|
||||
|
||||
```bash
|
||||
yarn prettier
|
||||
yarn format
|
||||
```
|
||||
|
||||
Or to automatically format the code:
|
||||
|
||||
```bash
|
||||
yarn prettier:write
|
||||
yarn format:write
|
||||
```
|
||||
|
||||
### Conventional commits
|
||||
@@ -331,7 +316,7 @@ yarn prettier:write
|
||||
Semaphore uses [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/). A [command line utility](https://github.com/commitizen/cz-cli) to commit using the correct syntax can be used by running:
|
||||
|
||||
```bash
|
||||
yarn commit
|
||||
git commit
|
||||
```
|
||||
|
||||
It will also automatically check that the modified files comply with ESLint and Prettier rules.
|
||||
@@ -389,5 +374,5 @@ 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
|
||||
It will create a commit and a git tag that will need to be 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.
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
🔎 Issues
|
||||
</a>
|
||||
<span> | </span>
|
||||
<a href="https://semaphore.pse.dev/discord">
|
||||
<a href="https://semaphore.pse.dev/telegram">
|
||||
🗣️ Chat & Support
|
||||
</a>
|
||||
</h4>
|
||||
|
||||
BIN
apps/docs/assets/img-benchmarks/browser/browser-benchmarks.png
Normal file
|
After Width: | Height: | Size: 315 KiB |
|
After Width: | Height: | Size: 30 KiB |
|
After Width: | Height: | Size: 30 KiB |
|
After Width: | Height: | Size: 223 KiB |
|
After Width: | Height: | Size: 182 KiB |
|
After Width: | Height: | Size: 201 KiB |
|
After Width: | Height: | Size: 126 KiB |
|
After Width: | Height: | Size: 133 KiB |
|
After Width: | Height: | Size: 130 KiB |
|
After Width: | Height: | Size: 134 KiB |
|
After Width: | Height: | Size: 125 KiB |
@@ -67,10 +67,12 @@ const config: Config = {
|
||||
announcementBar: {
|
||||
id: "semaphore-v4-beta",
|
||||
content:
|
||||
'<b>Semaphore V4-beta is out 🎉 <a href="/getting-started">Try it out</a> and let us know for any feedback on <a href="https://semaphore.pse.dev/discord" target="_blank">Discord</a> or <a href="https://github.com/orgs/semaphore-protocol/discussions" target="_blank">Github</a>!</b>',
|
||||
'<b><a href="https://github.com/semaphore-protocol/semaphore/releases/tag/v4.0.0" target="_blank">Semaphore V4</a> is out 🎉 <a href="/getting-started">Try it out</a> and let us know if you have any feedback on <a href="https://semaphore.pse.dev/telegram" target="_blank">Telegram</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"
|
||||
},
|
||||
|
||||
@@ -386,7 +386,7 @@
|
||||
"message": "Connect"
|
||||
},
|
||||
"footer.right.connect.link1": {
|
||||
"message": "Discord"
|
||||
"message": "Telegram"
|
||||
},
|
||||
"footer.right.connect.link2": {
|
||||
"message": "X (Twitter)"
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
"message": "Valores públicos"
|
||||
},
|
||||
"section.identities.box2.description": {
|
||||
"message": "Semaphore utiliza la función hash Poseidon para crear el identtity commitment a partir de los valores privados. Los identity commitments se pueden compartir públicamente, de forma similar a las direcciones Ethereum."
|
||||
"message": "Semaphore utiliza la función hash Poseidon para crear el identity commitment a partir de los valores privados. Los identity commitments se pueden compartir públicamente, de forma similar a las direcciones Ethereum."
|
||||
},
|
||||
"section.identities.box3.title": {
|
||||
"message": "Generar identidades"
|
||||
@@ -386,7 +386,7 @@
|
||||
"message": "Conecta con nosotros"
|
||||
},
|
||||
"footer.right.connect.link1": {
|
||||
"message": "Discord"
|
||||
"message": "Telegram"
|
||||
},
|
||||
"footer.right.connect.link2": {
|
||||
"message": "X (Twitter)"
|
||||
|
||||
@@ -12,6 +12,6 @@ as well as relevant circuits in
|
||||
which the Semaphore zk-SNARK uses.
|
||||
|
||||
The summary of the audit results can be found
|
||||
[here](https://github.com/appliedzkp/semaphore/tree/master/audit). After three
|
||||
[here](https://github.com/semaphore-protocol/semaphore/blob/main/apps/docs/versioned_docs/version-V1/audit.md). After three
|
||||
rounds of fixes, all security and performance issues were fixed, and the few
|
||||
remaining issues are minor and do not affect security.
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -58,7 +58,7 @@ Hardhat includes the Hardhat Network, a local Ethereum network for development.
|
||||
|
||||
## Install Semaphore packages
|
||||
|
||||
Semaphore provides contracts, JavaScript libraries and an Hardhat plugin for developers building zero-knowledge applications.
|
||||
Semaphore provides contracts, JavaScript libraries and a Hardhat plugin for developers building zero-knowledge applications.
|
||||
|
||||
- `@semaphore-protocol/contracts` provides contracts to manage groups and verify Semaphore proofs on-chain.
|
||||
- JavaScript libraries help developers build zero-knowledge applications.
|
||||
@@ -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,7 +128,7 @@ 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
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -14,7 +14,7 @@ También proporciona un mecanismo simple para evitar la doble señalización, lo
|
||||
|
||||
## ¿Dónde puedo hacer preguntas sobre Semaphore?
|
||||
|
||||
Puede hacer preguntas sobre Semaphore en [Discord](https://semaphore.pse.dev/discord) o abriendo un [Semaphore Discussion](https://github.com/semaphore-protocol/semaphore/discussions).
|
||||
Puede hacer preguntas sobre Semaphore en [Telegram](https://semaphore.pse.dev/telegram) o abriendo un [Semaphore Discussion](https://github.com/semaphore-protocol/semaphore/discussions).
|
||||
|
||||
## ¿Por qué las identidades requieren tanto `identity trapdoor` como `identity 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)
|
||||
|
||||
|
||||
@@ -18,34 +18,31 @@ Hay dos formas para hacer esto, usando [`SemaphoreSubgraph`](https://github.com/
|
||||
## Instalar librería
|
||||
|
||||
<Tabs
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
{label: 'npm', value: 'npm'},
|
||||
{label: 'Yarn', value: 'yarn'},
|
||||
{label: 'pnpm', value: 'pnpm'}
|
||||
]}>
|
||||
<TabItem value="npm">
|
||||
]}
|
||||
>
|
||||
<TabItem value="npm">
|
||||
```bash
|
||||
npm install @semaphore-protocol/data@^3
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
```bash
|
||||
npm install @semaphore-protocol/data@^3
|
||||
```
|
||||
<TabItem value="yarn">
|
||||
```bash
|
||||
yarn add @semaphore-protocol/data@^3
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="yarn">
|
||||
|
||||
```bash
|
||||
yarn add @semaphore-protocol/data@^3
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
|
||||
```bash
|
||||
pnpm add @semaphore-protocol/data@^3
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
```bash
|
||||
pnpm add @semaphore-protocol/data@^3
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
## Obtener datos usando SemaphoreSubgraph
|
||||
@@ -113,6 +110,7 @@ const semaphoreSubgraph = new SemaphoreSubgraph("sepolia")
|
||||
const { members } = await semaphoreSubgraph.getGroup(groupId, { members: true })
|
||||
const group = new Group(groupId, 20, members)
|
||||
```
|
||||
|
||||
:::
|
||||
|
||||
## Obtener datos usando SemaphoreEthers
|
||||
@@ -178,4 +176,5 @@ const semaphoreEthers = new SemaphoreEthers("sepolia")
|
||||
const members = await semaphoreEthers.getGroupMembers(groupId)
|
||||
const group = new Group(groupId, 20, members)
|
||||
```
|
||||
|
||||
:::
|
||||
|
||||
@@ -8,73 +8,70 @@ 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.
|
||||
- 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;
|
||||
- **Tree depth**: el número máximo de miembros que puede contener un grupo (`max size = 2 ^ tree depth`);
|
||||
- **Members** la lista de miembros para inicializar el grupo.
|
||||
- **Group id**: un identificador único para el grupo;
|
||||
- **Tree depth**: el número máximo de miembros que puede contener un grupo (`max size = 2 ^ tree depth`);
|
||||
- **Members** la lista de miembros para inicializar el grupo.
|
||||
|
||||
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
|
||||
|
||||
Utilice la clase `Group` de la librería [`@semaphore-protocol/group`](https://github.com/semaphore-protocol/semaphore/blob/main/packages/group) para crear un grupo off-chain con los siguientes parámetros:
|
||||
|
||||
- `Group id`: un identificar único para el grupo;
|
||||
- `Tree depth`: (_default `20`_) el número máximo de usuarios que puede contener un grupo, el valor por defecto es 20 (`max size = 2 ^ tree depth`).
|
||||
- `Members`: (_default `[]`_) la lista de miembros para inicializar el grupo.
|
||||
- `Group id`: un identificar único para el grupo;
|
||||
- `Tree depth`: (*default `20`*) el número máximo de usuarios que puede contener un grupo, el valor por defecto es 20 (`max size = 2 ^ tree depth`).
|
||||
- `Members`: (*default `[]`*) la lista de miembros para inicializar el grupo.
|
||||
|
||||
#### Instalar librería:
|
||||
|
||||
<Tabs
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
{label: 'npm', value: 'npm'},
|
||||
{label: 'Yarn', value: 'yarn'},
|
||||
{label: 'pnpm', value: 'pnpm'}
|
||||
]}>
|
||||
<TabItem value="npm">
|
||||
]}
|
||||
>
|
||||
<TabItem value="npm">
|
||||
```bash
|
||||
npm install @semaphore-protocol/group@^3
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
```bash
|
||||
npm install @semaphore-protocol/group@^3
|
||||
```
|
||||
<TabItem value="yarn">
|
||||
```bash
|
||||
yarn add @semaphore-protocol/group@^3
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="yarn">
|
||||
|
||||
```bash
|
||||
yarn add @semaphore-protocol/group@^3
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
|
||||
```bash
|
||||
pnpm add @semaphore-protocol/group@^3
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
```bash
|
||||
pnpm add @semaphore-protocol/group@^3
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
Para crear un grupo con el número de usuarios que aparece por defecto (20) _`treeDepth`_, llame la función para construir un `Group` sin el segundo parámetro. Por ejemplo:
|
||||
Para crear un grupo con el número de usuarios que aparece por defecto (20) *`treeDepth`*, llame la función para construir un `Group` sin el segundo parámetro. Por ejemplo:
|
||||
|
||||
```ts
|
||||
import { Group } from "@semaphore-protocol/group"
|
||||
@@ -82,7 +79,7 @@ import { Group } from "@semaphore-protocol/group"
|
||||
const group = new Group(1)
|
||||
```
|
||||
|
||||
El siguiente código de ejemplo pasa por _`treeDepth`_ para crear un grupo para `2 ^ 30 = 1073741824` miembros:
|
||||
El siguiente código de ejemplo pasa por *`treeDepth`* para crear un grupo para `2 ^ 30 = 1073741824` miembros:
|
||||
|
||||
```ts
|
||||
import { Group } from "@semaphore-protocol/group"
|
||||
|
||||
@@ -8,51 +8,50 @@ 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)
|
||||
- Identity nullifier (Anulador de identidad)
|
||||
- Identity trapdoor (Identidad trampilla)
|
||||
- Identity nullifier (Anulador de identidad)
|
||||
|
||||
Para utilizar y verificar su identidad, la persona dueña de la identidad (usuario) debe conocer los valores trapdoor y nullifier.
|
||||
Para prevenir fraudes, la persona dueña debe conservar de forma secreta ambos valores.
|
||||
|
||||
## Crear identidades
|
||||
|
||||
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_.
|
||||
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:
|
||||
|
||||
<Tabs
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
{label: 'npm', value: 'npm'},
|
||||
{label: 'Yarn', value: 'yarn'},
|
||||
{label: 'pnpm', value: 'pnpm'}
|
||||
]}>
|
||||
<TabItem value="npm">
|
||||
]}
|
||||
>
|
||||
<TabItem value="npm">
|
||||
```bash
|
||||
npm install @semaphore-protocol/identity@^3
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
```bash
|
||||
npm install @semaphore-protocol/identity@^3
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="yarn">
|
||||
```bash
|
||||
yarn add @semaphore-protocol/identity@^3
|
||||
```
|
||||
<TabItem value="yarn">
|
||||
```bash
|
||||
yarn add @semaphore-protocol/identity@^3
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
|
||||
```bash
|
||||
pnpm add @semaphore-protocol/identity@^3
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
```bash
|
||||
pnpm add @semaphore-protocol/identity@^3
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
### Crear identidades aleatorias
|
||||
@@ -67,8 +66,8 @@ const { trapdoor, nullifier, commitment } = new Identity()
|
||||
|
||||
La nueva identidad contiene dos valores aleatorios secretos: `trapdoor` y `nullifier`, y un valor público: `commitment`.
|
||||
|
||||
El hash Poseidon del identity nullifier y trapdoor se conoce como _identity secret_ (el secreto de identidad),
|
||||
y su hash es el _identity commitment_ (compromiso de identidad).
|
||||
El hash Poseidon del identity nullifier y trapdoor se conoce como *identity secret* (el secreto de identidad),
|
||||
y su hash es el *identity commitment* (compromiso de identidad).
|
||||
|
||||
Un identity commitment (compromiso de identidad), de forma similar a las direcciones Ethereum, es un valor público que se utiliza en los grupos Semaphore para representar la
|
||||
identidad de un miembro del grupo. Los valores secretos son similares a las llaves privadas
|
||||
@@ -77,7 +76,7 @@ Ethereum y se utilizan para generar pruebas de conocimiento cero (ZKP) Semaphore
|
||||
### Crear identidades determinísticas
|
||||
|
||||
Si transmite un mensaje como un parámetro, Semaphore genera `trapdoor` y `nullifier`
|
||||
del hash _SHA256_ del mensaje.
|
||||
del hash *SHA256* del mensaje.
|
||||
El mensaje puede ser una contraseña o un mensaje que el usuario firma de forma criptográfica con una llave privada.
|
||||
|
||||
Al utilizar identidades determinísticas siempre deberá mantener secreto el mensaje.
|
||||
|
||||
@@ -8,63 +8,61 @@ 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.
|
||||
- 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
|
||||
|
||||
Utilice la librería [`@semaphore-protocol/proof`](https://github.com/semaphore-protocol/semaphore/tree/main/packages/proof) para generar una prueba off-chain.
|
||||
Para generar una prueba, transforme los siguientes parámetros con la función `generateProof`:
|
||||
|
||||
- `identity`: la identidad Semaphore del usuario emitiendo la señal y generando la prueba;
|
||||
- `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).
|
||||
- `identity`: la identidad Semaphore del usuario emitiendo la señal y generando la prueba;
|
||||
- `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](/V3/glossary/#archivos-confiables-de-configuración-trusted-setup-files).
|
||||
|
||||
#### Instalar librería:
|
||||
|
||||
<Tabs
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
{label: 'npm', value: 'npm'},
|
||||
{label: 'Yarn', value: 'yarn'},
|
||||
{label: 'pnpm', value: 'pnpm'}
|
||||
]}>
|
||||
<TabItem value="npm">
|
||||
]}
|
||||
>
|
||||
<TabItem value="npm">
|
||||
```bash
|
||||
npm install @semaphore-protocol/proof@^3
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
```bash
|
||||
npm install @semaphore-protocol/proof@^3
|
||||
```
|
||||
<TabItem value="yarn">
|
||||
```bash
|
||||
yarn add @semaphore-protocol/proof@^3
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="yarn">
|
||||
|
||||
```bash
|
||||
yarn add @semaphore-protocol/proof@^3
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
|
||||
```bash
|
||||
pnpm add @semaphore-protocol/proof@^3
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
```bash
|
||||
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:
|
||||
|
||||
@@ -86,6 +84,7 @@ Si estás generando la prueba en el lado del cliente, puedes evitar agregar los
|
||||
```ts
|
||||
const fullProof = await generateProof(identity, group, externalNullifier, signal)
|
||||
```
|
||||
|
||||
:::
|
||||
|
||||
## Verificar una prueba off-chain
|
||||
@@ -93,8 +92,8 @@ const fullProof = await generateProof(identity, group, externalNullifier, signal
|
||||
Utilice la librería [`@semaphore-protocol/proof`](https://github.com/semaphore-protocol/semaphore/tree/main/packages/proof) para verificar una prueba Semaphore off-chain.
|
||||
Para verificar una prueba, transforme los siguientes parámetros con la función `verifyProof`:
|
||||
|
||||
- `fullProof`: la prueba Semaphore;
|
||||
- `treeDepth`: la profundidad del árbol de Merkle.
|
||||
- `fullProof`: la prueba Semaphore;
|
||||
- `treeDepth`: la profundidad del árbol de Merkle.
|
||||
|
||||
La siguiente muestra de código demuestra cómo verificar la prueba generada previamente:
|
||||
|
||||
@@ -108,20 +107,20 @@ 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:
|
||||
|
||||
- `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);
|
||||
- `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).
|
||||
- `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 (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.
|
||||
|
||||
:::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).
|
||||
|
||||
@@ -31,37 +31,34 @@ El CLI [`semaphore`](https://github.com/semaphore-protocol/semaphore/tree/main/p
|
||||
Para comenzar a trabajar en su proyecto, instale las siguientes dependencias:
|
||||
|
||||
<Tabs
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
{label: 'npm', value: 'npm'},
|
||||
{label: 'Yarn', value: 'yarn'},
|
||||
{label: 'pnpm', value: 'pnpm'}
|
||||
]}>
|
||||
<TabItem value="npm">
|
||||
]}
|
||||
>
|
||||
<TabItem value="npm">
|
||||
```bash
|
||||
cd my-app
|
||||
npm i
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
```bash
|
||||
cd my-app
|
||||
npm i
|
||||
```
|
||||
<TabItem value="yarn">
|
||||
```bash
|
||||
cd my-app
|
||||
yarn
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="yarn">
|
||||
|
||||
```bash
|
||||
cd my-app
|
||||
yarn
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
<TabItem value="pnpm">
|
||||
|
||||
```bash
|
||||
cd my-app
|
||||
pnpm install
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
```bash
|
||||
cd my-app
|
||||
pnpm install
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
## Output
|
||||
@@ -116,34 +113,31 @@ cd apps/contracts
|
||||
Y compile sus contratos al correr:
|
||||
|
||||
<Tabs
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
{label: 'npm', value: 'npm'},
|
||||
{label: 'Yarn', value: 'yarn'},
|
||||
{label: 'pnpm', value: 'pnpm'}
|
||||
]}>
|
||||
<TabItem value="npm">
|
||||
]}
|
||||
>
|
||||
<TabItem value="npm">
|
||||
```bash
|
||||
npm run compile
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
```bash
|
||||
npm run compile
|
||||
```
|
||||
<TabItem value="yarn">
|
||||
```bash
|
||||
yarn compile
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="yarn">
|
||||
|
||||
```bash
|
||||
yarn compile
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
|
||||
```bash
|
||||
pnpm compile
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
```bash
|
||||
pnpm compile
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
### Pruebe los contratos
|
||||
@@ -151,100 +145,91 @@ pnpm compile
|
||||
Pruebe sus contratos al correr:
|
||||
|
||||
<Tabs
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
{label: 'npm', value: 'npm'},
|
||||
{label: 'Yarn', value: 'yarn'},
|
||||
{label: 'pnpm', value: 'pnpm'}
|
||||
]}>
|
||||
<TabItem value="npm">
|
||||
]}
|
||||
>
|
||||
<TabItem value="npm">
|
||||
```bash
|
||||
npm test
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
```bash
|
||||
npm test
|
||||
```
|
||||
<TabItem value="yarn">
|
||||
```bash
|
||||
yarn test
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="yarn">
|
||||
|
||||
```bash
|
||||
yarn test
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
|
||||
```bash
|
||||
pnpm test
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
```bash
|
||||
pnpm test
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
Genere un reporte de la prueba de cobertura:
|
||||
|
||||
<Tabs
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
{label: 'npm', value: 'npm'},
|
||||
{label: 'Yarn', value: 'yarn'},
|
||||
{label: 'pnpm', value: 'pnpm'}
|
||||
]}>
|
||||
<TabItem value="npm">
|
||||
]}
|
||||
>
|
||||
<TabItem value="npm">
|
||||
```bash
|
||||
npm run test:coverage
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
```bash
|
||||
npm run test:coverage
|
||||
```
|
||||
<TabItem value="yarn">
|
||||
```bash
|
||||
yarn test:coverage
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="yarn">
|
||||
|
||||
```bash
|
||||
yarn test:coverage
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
|
||||
```bash
|
||||
pnpm test:coverage
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
```bash
|
||||
pnpm test:coverage
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
O un reporte de la prueba de gas:
|
||||
|
||||
<Tabs
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
{label: 'npm', value: 'npm'},
|
||||
{label: 'Yarn', value: 'yarn'},
|
||||
{label: 'pnpm', value: 'pnpm'}
|
||||
]}>
|
||||
<TabItem value="npm">
|
||||
]}
|
||||
>
|
||||
<TabItem value="npm">
|
||||
```bash
|
||||
npm run test:report-gas
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
```bash
|
||||
npm run test:report-gas
|
||||
```
|
||||
<TabItem value="yarn">
|
||||
```bash
|
||||
yarn test:report-gas
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="yarn">
|
||||
|
||||
```bash
|
||||
yarn test:report-gas
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
|
||||
```bash
|
||||
pnpm test:report-gas
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
```bash
|
||||
pnpm test:report-gas
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
### Desplegar contratos
|
||||
@@ -255,82 +240,76 @@ En la carpeta raíz del proyecto:
|
||||
|
||||
1. Agregue sus variables de entorno en el archivo `.env`.
|
||||
|
||||
:::note
|
||||
Deberá por lo menos configurar un URL válido en Ethereum (ejemplo: Infura) y una llave privada con algunos ethers.
|
||||
:::
|
||||
:::note
|
||||
Deberá por lo menos configurar un URL válido en Ethereum (ejemplo: Infura) y una llave privada con algunos ethers.
|
||||
:::
|
||||
|
||||
2. Vaya a la carpeta `apps/contracts` y desplegue su contrato.
|
||||
|
||||
<Tabs
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
<Tabs
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
{label: 'npm', value: 'npm'},
|
||||
{label: 'Yarn', value: 'yarn'},
|
||||
{label: 'pnpm', value: 'pnpm'}
|
||||
]}>
|
||||
<TabItem value="npm">
|
||||
]}
|
||||
>
|
||||
<TabItem value="npm">
|
||||
```bash
|
||||
npm run deploy -- --semaphore <semaphore-address> --group <group-id> --network goerli
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
```bash
|
||||
npm run deploy -- --semaphore <semaphore-address> --group <group-id> --network goerli
|
||||
```
|
||||
<TabItem value="yarn">
|
||||
```bash
|
||||
yarn deploy --semaphore <semaphore-address> --group <group-id> --network goerli
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="yarn">
|
||||
<TabItem value="pnpm">
|
||||
```bash
|
||||
pnpm deploy --semaphore <semaphore-address> --group <group-id> --network goerli
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
```bash
|
||||
yarn deploy --semaphore <semaphore-address> --group <group-id> --network goerli
|
||||
```
|
||||
:::note
|
||||
Revise las direcciones de los contratos de Semaphore [aquí](/V3/deployed-contracts).
|
||||
:::
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
|
||||
```bash
|
||||
pnpm deploy --semaphore <semaphore-address> --group <group-id> --network goerli
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
:::note
|
||||
Revise las direcciones de los contratos de Semaphore [aquí](/deployed-contracts).
|
||||
:::
|
||||
|
||||
:::caution
|
||||
El group id (id del grupo) es un número.
|
||||
:::
|
||||
:::caution
|
||||
El group id (id del grupo) es un número.
|
||||
:::
|
||||
|
||||
### Inicie la app
|
||||
|
||||
Inicie la aplicación:
|
||||
|
||||
<Tabs
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
{label: 'npm', value: 'npm'},
|
||||
{label: 'Yarn', value: 'yarn'},
|
||||
{label: 'pnpm', value: 'pnpm'}
|
||||
]}>
|
||||
<TabItem value="npm">
|
||||
]}
|
||||
>
|
||||
<TabItem value="npm">
|
||||
```bash
|
||||
npm run dev
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
```bash
|
||||
npm run dev
|
||||
```
|
||||
<TabItem value="yarn">
|
||||
```bash
|
||||
yarn dev
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="yarn">
|
||||
|
||||
```bash
|
||||
yarn dev
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
|
||||
```bash
|
||||
pnpm dev
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
```bash
|
||||
pnpm dev
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
@@ -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.
|
||||
::::
|
||||
|
||||
@@ -7,7 +7,7 @@ import TabItem from "@theme/TabItem"
|
||||
|
||||
# Solución de problemas
|
||||
|
||||
Si estas sugerencias no funcionan, no dude en preguntar en las [Semaphore Discussions](https://github.com/semaphore-protocol/semaphore/discussions) o en el canal `dev-chat` en el [Semaphore Discord](https://semaphore.pse.dev/discord).
|
||||
Si estas sugerencias no funcionan, no dude en preguntar en las [Semaphore Discussions](https://github.com/semaphore-protocol/semaphore/discussions) o en el canal [Semaphore Telegram](https://semaphore.pse.dev/telegram).
|
||||
|
||||
## Usando Semaphore en the frontend
|
||||
|
||||
@@ -70,65 +70,59 @@ Para resolver eso:
|
||||
1- Instale `@esbuild-plugins/node-globals-polyfill` y `@esbuild-plugins/node-modules-polyfill`
|
||||
|
||||
<Tabs
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
{label: 'npm', value: 'npm'},
|
||||
{label: 'Yarn', value: 'yarn'},
|
||||
{label: 'pnpm', value: 'pnpm'}
|
||||
]}>
|
||||
<TabItem value="npm">
|
||||
]}
|
||||
>
|
||||
<TabItem value="npm">
|
||||
```bash
|
||||
npm install @esbuild-plugins/node-globals-polyfill
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
```bash
|
||||
npm install @esbuild-plugins/node-globals-polyfill
|
||||
```
|
||||
<TabItem value="yarn">
|
||||
```bash
|
||||
yarn add @esbuild-plugins/node-globals-polyfill
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="yarn">
|
||||
|
||||
```bash
|
||||
yarn add @esbuild-plugins/node-globals-polyfill
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
|
||||
```bash
|
||||
pnpm add @esbuild-plugins/node-globals-polyfill
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
```bash
|
||||
pnpm add @esbuild-plugins/node-globals-polyfill
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
<Tabs
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
{label: 'npm', value: 'npm'},
|
||||
{label: 'Yarn', value: 'yarn'},
|
||||
{label: 'pnpm', value: 'pnpm'}
|
||||
]}>
|
||||
<TabItem value="npm">
|
||||
]}
|
||||
>
|
||||
<TabItem value="npm">
|
||||
```bash
|
||||
npm install @esbuild-plugins/node-modules-polyfill
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
```bash
|
||||
npm install @esbuild-plugins/node-modules-polyfill
|
||||
```
|
||||
<TabItem value="yarn">
|
||||
```bash
|
||||
yarn add @esbuild-plugins/node-modules-polyfill
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="yarn">
|
||||
|
||||
```bash
|
||||
yarn add @esbuild-plugins/node-modules-polyfill
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
|
||||
```bash
|
||||
pnpm add @esbuild-plugins/node-modules-polyfill
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
```bash
|
||||
pnpm add @esbuild-plugins/node-modules-polyfill
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
2- Modifique `vite.config.ts` para añadirlos:
|
||||
@@ -236,4 +230,4 @@ Para comprobarlo, puede utilizar la [Semaphore CLI](https://github.com/semaphore
|
||||
|
||||
### Transacción revertida al usar el mismo external nullifier
|
||||
|
||||
Cuando genera una prueba usando el mismo external nullifier que usó para verificar una prueba antes, la transacción se revertirá porque ese external nullifier ya se usó. Si desea enviar y verificar varias pruebas de la misma identidad, debe usar un external nullifier diferente cada vez que genere una prueba.
|
||||
Cuando genera una prueba usando el mismo external nullifier que usó para verificar una prueba antes, la transacción se revertirá porque ese external nullifier ya se usó. Si desea enviar y verificar varias pruebas de la misma identidad, debe usar un external nullifier diferente cada vez que genere una prueba.
|
||||
|
||||
@@ -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,18 +4,22 @@
|
||||
"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",
|
||||
"serve": "docusaurus serve",
|
||||
"write-translations": "docusaurus write-translations",
|
||||
"write-heading-ids": "docusaurus write-heading-ids"
|
||||
"write-heading-ids": "docusaurus write-heading-ids",
|
||||
"format": "remark ./**/*.mdx --frail --quiet",
|
||||
"format:write": "remark ./**/*.mdx --output"
|
||||
},
|
||||
"dependencies": {
|
||||
"@docusaurus/core": "3.1.1",
|
||||
"@docusaurus/preset-classic": "3.1.1",
|
||||
"@docusaurus/core": "3.5.2",
|
||||
"@docusaurus/preset-classic": "3.5.2",
|
||||
"@mdx-js/react": "^3.0.0",
|
||||
"@semaphore-protocol/utils": "4.7.2",
|
||||
"@svgr/webpack": "^5.5.0",
|
||||
"clsx": "^1.2.1",
|
||||
"docusaurus-plugin-sass": "^0.2.5",
|
||||
@@ -27,9 +31,14 @@
|
||||
"url-loader": "^4.1.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@docusaurus/module-type-aliases": "3.1.1",
|
||||
"@docusaurus/tsconfig": "3.1.1",
|
||||
"@docusaurus/module-type-aliases": "3.5.2",
|
||||
"@docusaurus/tsconfig": "3.5.2",
|
||||
"@types/react": "^18.2.29",
|
||||
"remark-cli": "^12.0.0",
|
||||
"remark-frontmatter": "^5.0.0",
|
||||
"remark-mdx": "^3.0.1",
|
||||
"remark-preset-lint-consistent": "^6.0.0",
|
||||
"remark-preset-lint-recommended": "^7.0.0",
|
||||
"typescript": "~5.2.2"
|
||||
},
|
||||
"browserslist": {
|
||||
@@ -46,5 +55,22 @@
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18.0"
|
||||
},
|
||||
"remarkConfig": {
|
||||
"settings": {
|
||||
"bullet": "-"
|
||||
},
|
||||
"plugins": [
|
||||
"remark-mdx",
|
||||
"remark-preset-lint-consistent",
|
||||
"remark-preset-lint-recommended",
|
||||
[
|
||||
"remark-frontmatter",
|
||||
{
|
||||
"type": "yaml",
|
||||
"marker": "-"
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -32,7 +32,7 @@ function Footer() {
|
||||
id: "footer.right.connect.title"
|
||||
})}
|
||||
</h3>
|
||||
<Link href="https://semaphore.pse.dev/discord" target="_blank">
|
||||
<Link href="https://semaphore.pse.dev/telegram" target="_blank">
|
||||
{translate({
|
||||
id: "footer.right.connect.link1"
|
||||
})}
|
||||
|
||||
BIN
apps/docs/static/img/social-media.png
vendored
Normal file
|
After Width: | Height: | Size: 190 KiB |
3
apps/docs/vercel.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"cleanUrls": true
|
||||
}
|
||||
@@ -12,6 +12,6 @@ as well as relevant circuits in
|
||||
which the Semaphore zk-SNARK uses.
|
||||
|
||||
The summary of the audit results can be found
|
||||
[here](https://github.com/appliedzkp/semaphore/tree/master/audit). After three
|
||||
[here](https://github.com/semaphore-protocol/semaphore/blob/main/apps/docs/versioned_docs/version-V1/audit.md). After three
|
||||
rounds of fixes, all security and performance issues were fixed, and the few
|
||||
remaining issues are minor and do not affect security.
|
||||
|
||||
@@ -21,7 +21,7 @@ The first external nullifier will be added as an external nullifier to the
|
||||
contract, and this external nullifier will be active once the deployment
|
||||
completes.
|
||||
|
||||
## Add, deactivate, or reactivate external nullifiiers
|
||||
## Add, deactivate, or reactivate external nullifiers
|
||||
|
||||
**Contract ABI**:
|
||||
|
||||
|
||||
@@ -10,8 +10,8 @@ An identity is comprised of the following information:
|
||||
|
||||
1. An [EdDSA](https://en.wikipedia.org/wiki/EdDSA) private key. Note that it is
|
||||
_not_ an Ethereum private key.
|
||||
2. An identity nullifier, whih is a random 32-byte value.
|
||||
3. An identity trapdoor, whih is a random 32-byte value.
|
||||
2. An identity nullifier, which is a random 32-byte value.
|
||||
3. An identity trapdoor, which is a random 32-byte value.
|
||||
|
||||
An identity commitment is the Pedersen hash of:
|
||||
|
||||
@@ -121,7 +121,7 @@ authenticity of the signal and prevents front-running attacks.
|
||||
|
||||
## Cryptographic primitives
|
||||
|
||||
Semaphore uses MiMC for the Merkle tree, Pedersen commmitments for the identity
|
||||
Semaphore uses MiMC for the Merkle tree, Pedersen commitments for the identity
|
||||
commitments, Blake2 for the nullifiers hash, and EdDSA for the signature.
|
||||
|
||||
MiMC is a relatively new hash function. We use the recommended MiMC
|
||||
|
||||
@@ -145,7 +145,7 @@ Returns `false` otherwise.
|
||||
|
||||
**`signMsg(privKey: EddsaPrivateKey, msg: SnarkBigInt): EdDSAMiMcSpongeSignature)`**
|
||||
|
||||
Encapsualtes `circomlib.eddsa.signMiMCSponge` to sign a message `msg` using private key `privKey`.
|
||||
Encapsulates `circomlib.eddsa.signMiMCSponge` to sign a message `msg` using private key `privKey`.
|
||||
|
||||
**`verifySignature(msg: SnarkBigInt, signature: EdDSAMiMcSpongeSignature, pubKey: EddsaPublicKey)`: boolean**
|
||||
|
||||
@@ -190,7 +190,7 @@ const genWitness = async (
|
||||
- `circuit` is the output of `genCircuit()`.
|
||||
- `identity` is the `Identity` whose identity commitment you want to prove is
|
||||
in the set of registered identities.
|
||||
- `idCommitments` is an array of registered identity commmitments; i.e. the
|
||||
- `idCommitments` is an array of registered identity commitments; i.e. the
|
||||
leaves of the tree.
|
||||
- `treeDepth` is the number of levels which the Merkle tree used has
|
||||
- `externalNullifier` is the current external nullifier
|
||||
@@ -204,7 +204,7 @@ It returns an object as such:
|
||||
- `msg`: The hash of the external nullifier and the signal hash
|
||||
- `signature`: The signature on the above msg.
|
||||
- `tree`: The Merkle tree object after it has been updated with the identity commitment
|
||||
- `identityPath`: The Merkle path to the identity commmitment
|
||||
- `identityPath`: The Merkle path to the identity commitment
|
||||
- `identityPathIndex`: The leaf index of the identity commitment
|
||||
- `identityPathElements`: The elements along the above Merkle path
|
||||
|
||||
@@ -212,7 +212,7 @@ Only `witness` is essential to generate the proof; the other data is only
|
||||
useful for debugging and additional off-chain checks, such as verifying the
|
||||
signature and the Merkle tree root.
|
||||
|
||||
**`formatForVerifierContract = (proof: SnarkProof, publicSignals: SnarkPublicSignals`**
|
||||
**`formatForVerifierContract = (proof: SnarkProof, publicSignals: SnarkPublicSignals)`**
|
||||
|
||||
Converts the data in `proof` and `publicSignals` to strings and rearranges
|
||||
elements of `proof.pi_b` so that `snarkjs`'s `verifier.sol` will accept it.
|
||||
|
||||
@@ -26,7 +26,7 @@ With the Client contract as the owner of the Semaphore contract, the Client
|
||||
contract may call owner-only Semaphore functions such as
|
||||
`addExternalNullifier()`.
|
||||
|
||||
## Add, deactivate, or reactivate external nullifiiers
|
||||
## Add, deactivate, or reactivate external nullifiers
|
||||
|
||||
These functions add, deactivate, and reactivate an external nullifier respectively.
|
||||
As each identity can only signal once to an external nullifier, and as a signal
|
||||
|
||||
@@ -55,7 +55,7 @@ In sum, Semaphore provides the ability to:
|
||||
### External nullifiers
|
||||
|
||||
Think of an external nullifier as a voting booth where each user may only cast
|
||||
one vote. If they try to cast a second vote a the same booth, that vote is
|
||||
one vote. If they try to cast a second vote at the same booth, that vote is
|
||||
invalid.
|
||||
|
||||
An external nullifier is any 29-byte value. Semaphore always starts with one
|
||||
@@ -89,13 +89,13 @@ An anonymous voting app would be configured differently:
|
||||
| ----------------------------------- | ------------------------ |
|
||||
| The hash of the respondent's answer | The hash of the question |
|
||||
|
||||
This allows any user to vote with an arbitary response (e.g. yes, no, or maybe)
|
||||
This allows any user to vote with an arbitrary response (e.g. yes, no, or maybe)
|
||||
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:
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ 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/tree/v2.6.1/packages/contracts/Semaphore.sol) smart contract.
|
||||
|
||||
:::tip
|
||||
The Graph protocol uses the [GraphQL](https://graphql.org/) query lanaguage. 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.
|
||||
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.
|
||||
:::
|
||||
|
||||
## Schema
|
||||
|
||||
@@ -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,7 +127,7 @@ 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
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -14,7 +14,7 @@ It also provides a simple mechanism to prevent double-signaling, which means you
|
||||
|
||||
## Where can I ask questions about Semaphore?
|
||||
|
||||
You can ask questions about Semaphore on [Discord](https://semaphore.pse.dev/discord) or by opening a [Semaphore Discussion](https://github.com/semaphore-protocol/semaphore/discussions).
|
||||
You can ask questions about Semaphore on [Telegram](https://semaphore.pse.dev/telegram) or by opening a [Semaphore Discussion](https://github.com/semaphore-protocol/semaphore/discussions).
|
||||
|
||||
## Why do identities require both the `identity trapdoor` and the `identity nullifier`?
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ For more information, see [Merkle tree in Wikipedia](https://en.wikipedia.org/wi
|
||||
|
||||
## Nullifier
|
||||
|
||||
A value used to prevent double entry or double signalling.
|
||||
A value used to prevent double entry or double signaling.
|
||||
|
||||
See [Circuit nullifier hash](/V3/technical-reference/circuits/#nullifier-hash).
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -18,34 +18,31 @@ There are two ways to do this, using [`SemaphoreSubgraph`](https://github.com/se
|
||||
## Install library
|
||||
|
||||
<Tabs
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
{label: 'npm', value: 'npm'},
|
||||
{label: 'Yarn', value: 'yarn'},
|
||||
{label: 'pnpm', value: 'pnpm'}
|
||||
]}>
|
||||
<TabItem value="npm">
|
||||
]}
|
||||
>
|
||||
<TabItem value="npm">
|
||||
```bash
|
||||
npm install @semaphore-protocol/data@^3
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
```bash
|
||||
npm install @semaphore-protocol/data@^3
|
||||
```
|
||||
<TabItem value="yarn">
|
||||
```bash
|
||||
yarn add @semaphore-protocol/data@^3
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="yarn">
|
||||
|
||||
```bash
|
||||
yarn add @semaphore-protocol/data@^3
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
|
||||
```bash
|
||||
pnpm add @semaphore-protocol/data@^3
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
```bash
|
||||
pnpm add @semaphore-protocol/data@^3
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
## Fetch data using SemaphoreSubgraph
|
||||
@@ -113,6 +110,7 @@ const semaphoreSubgraph = new SemaphoreSubgraph("sepolia")
|
||||
const { members } = await semaphoreSubgraph.getGroup(groupId, { members: true })
|
||||
const group = new Group(groupId, 20, members)
|
||||
```
|
||||
|
||||
:::
|
||||
|
||||
## Fetch data using SemaphoreEthers
|
||||
@@ -178,4 +176,5 @@ const semaphoreEthers = new SemaphoreEthers("sepolia")
|
||||
const members = await semaphoreEthers.getGroupMembers(groupId)
|
||||
const group = new Group(groupId, 20, members)
|
||||
```
|
||||
|
||||
:::
|
||||
|
||||
@@ -11,70 +11,67 @@ import TabItem from "@theme/TabItem"
|
||||
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.
|
||||
- poll question that attendees join to rate an event,
|
||||
- ballot that members join to vote on a proposal,
|
||||
- whistleblowers who are verified employees of an organization.
|
||||
|
||||
A Semaphore group is an [incremental Merkle tree](/V3/glossary/#incremental-merkle-tree), and group members (i.e., [identity commitments](/V3/glossary/#identity-commitments)) are tree leaves.
|
||||
A Semaphore group is an [incremental Merkle tree](/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;
|
||||
- **Tree depth**: the maximum number of members a group can contain (`max size = 2 ^ tree depth`);
|
||||
- **Members**: the list of members to initialize the group.
|
||||
- **Group id**: a unique identifier for the group;
|
||||
- **Tree depth**: the maximum number of members a group can contain (`max size = 2 ^ tree depth`);
|
||||
- **Members**: the list of members to initialize the group.
|
||||
|
||||
Learn how to work with groups.
|
||||
|
||||
- [**Off-chain groups**](#off-chain-groups)
|
||||
- [**On-chain groups**](#on-chain-groups)
|
||||
- [**Off-chain groups**](#off-chain-groups)
|
||||
- [**On-chain groups**](#on-chain-groups)
|
||||
|
||||
## Off-chain groups
|
||||
|
||||
- [Create a group](#create-a-group)
|
||||
- [Add members](#add-members)
|
||||
- [Remove or update members](#remove-or-update-members)
|
||||
- [Create a group](#create-a-group)
|
||||
- [Add members](#add-members)
|
||||
- [Remove or update members](#remove-or-update-members)
|
||||
|
||||
### Create a group
|
||||
|
||||
Use the [`@semaphore-protocol/group`](https://github.com/semaphore-protocol/semaphore/blob/v3.15.2/packages/group) library `Group` class to create an off-chain group with the following parameters:
|
||||
|
||||
- `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`).
|
||||
- `Members`: (_default `[]`_) the list of members to initialize the group.
|
||||
- `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`).
|
||||
- `Members`: (*default `[]`*) the list of members to initialize the group.
|
||||
|
||||
#### Install library:
|
||||
|
||||
<Tabs
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
{label: 'npm', value: 'npm'},
|
||||
{label: 'Yarn', value: 'yarn'},
|
||||
{label: 'pnpm', value: 'pnpm'}
|
||||
]}>
|
||||
<TabItem value="npm">
|
||||
]}
|
||||
>
|
||||
<TabItem value="npm">
|
||||
```bash
|
||||
npm install @semaphore-protocol/group@^3
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
```bash
|
||||
npm install @semaphore-protocol/group@^3
|
||||
```
|
||||
<TabItem value="yarn">
|
||||
```bash
|
||||
yarn add @semaphore-protocol/group@^3
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="yarn">
|
||||
|
||||
```bash
|
||||
yarn add @semaphore-protocol/group@^3
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
|
||||
```bash
|
||||
pnpm add @semaphore-protocol/group@^3
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
```bash
|
||||
pnpm add @semaphore-protocol/group@^3
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
To create a group with default _`treeDepth`_, call the `Group` constructor without the second parameter. For example:
|
||||
To create a group with default *`treeDepth`*, call the `Group` constructor without the second parameter. For example:
|
||||
|
||||
```ts
|
||||
import { Group } from "@semaphore-protocol/group"
|
||||
@@ -82,7 +79,7 @@ import { Group } from "@semaphore-protocol/group"
|
||||
const group = new Group(1)
|
||||
```
|
||||
|
||||
The following example code passes _`treeDepth`_ to create a group for `2 ^ 30 = 1073741824` members:
|
||||
The following example code passes *`treeDepth`* to create a group for `2 ^ 30 = 1073741824` members:
|
||||
|
||||
```ts
|
||||
import { Group } from "@semaphore-protocol/group"
|
||||
|
||||
@@ -11,50 +11,47 @@ import TabItem from "@theme/TabItem"
|
||||
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
|
||||
- identity nullifier
|
||||
- Identity trapdoor
|
||||
- identity nullifier
|
||||
|
||||
To use and verify the identity, the identity owner (user) must know the trapdoor and nullifier values.
|
||||
To prevent fraud, the owner should keep both values secret.
|
||||
|
||||
## Create identities
|
||||
|
||||
In your code, use the [`@semaphore-protocol/identity`](https://github.com/semaphore-protocol/semaphore/tree/v3.15.2/packages/identity) library to create a Semaphore identity _deterministically_ (from the hash of a message) or _randomly_.
|
||||
In your code, use the [`@semaphore-protocol/identity`](https://github.com/semaphore-protocol/semaphore/tree/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)
|
||||
- [**Create random identities**](#create-random-identities)
|
||||
- [**Create deterministic identities**](#create-deterministic-identities)
|
||||
|
||||
### Install library:
|
||||
|
||||
<Tabs
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
{label: 'npm', value: 'npm'},
|
||||
{label: 'Yarn', value: 'yarn'},
|
||||
{label: 'pnpm', value: 'pnpm'}
|
||||
]}>
|
||||
<TabItem value="npm">
|
||||
]}
|
||||
>
|
||||
<TabItem value="npm">
|
||||
```bash
|
||||
npm install @semaphore-protocol/identity@^3
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
```bash
|
||||
npm install @semaphore-protocol/identity@^3
|
||||
```
|
||||
<TabItem value="yarn">
|
||||
```bash
|
||||
yarn add @semaphore-protocol/identity@^3
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="yarn">
|
||||
|
||||
```bash
|
||||
yarn add @semaphore-protocol/identity@^3
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
|
||||
```bash
|
||||
pnpm add @semaphore-protocol/identity@^3
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
```bash
|
||||
pnpm add @semaphore-protocol/identity@^3
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
### Create random identities
|
||||
@@ -69,8 +66,8 @@ const { trapdoor, nullifier, commitment } = new Identity()
|
||||
|
||||
The new identity contains two random secret values: `trapdoor` and `nullifier`, and one public value: `commitment`.
|
||||
|
||||
The Poseidon hash of the identity nullifier and trapdoor is called the _identity secret_,
|
||||
and its hash is the _identity commitment_.
|
||||
The Poseidon hash of the identity nullifier and trapdoor is called the *identity secret*,
|
||||
and its hash is the *identity commitment*.
|
||||
|
||||
An identity commitment, similarly to Ethereum addresses, is a public value used
|
||||
in Semaphore groups to represent the identity of a group member. The secret values are similar to
|
||||
@@ -79,7 +76,7 @@ Ethereum private keys and are used to generate Semaphore zero-knowledge proofs a
|
||||
### Create deterministic identities
|
||||
|
||||
If you pass a message as a parameter, Semaphore generates `trapdoor` and `nullifier`
|
||||
from the _SHA256_ hash of the message.
|
||||
from the *SHA256* hash of the message.
|
||||
The message might be a password or a message that the user cryptographically signs with a private key.
|
||||
|
||||
When using deterministic identities, you should always keep the message secret.
|
||||
|
||||
@@ -10,62 +10,59 @@ import TabItem from "@theme/TabItem"
|
||||
|
||||
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.
|
||||
- the user is a member of the group,
|
||||
- the same user created the signal and the proof.
|
||||
|
||||
Developers can use Semaphore for the following:
|
||||
|
||||
- [**Generate a proof off-chain**](#generate-a-proof-off-chain)
|
||||
- [**Verify a proof off-chain**](#verify-a-proof-off-chain)
|
||||
- [**Verify a proof on-chain**](#verify-a-proof-on-chain)
|
||||
- [**Generate a proof off-chain**](#generate-a-proof-off-chain)
|
||||
- [**Verify a proof off-chain**](#verify-a-proof-off-chain)
|
||||
- [**Verify a proof on-chain**](#verify-a-proof-on-chain)
|
||||
|
||||
## Generate a proof off-chain
|
||||
|
||||
Use the [`@semaphore-protocol/proof`](https://github.com/semaphore-protocol/semaphore/tree/v3.15.2/packages/proof) library to generate an off-chain proof.
|
||||
To generate a proof, pass the following parameters to the `generateProof` function:
|
||||
|
||||
- `identity`: the Semaphore identity of the user broadcasting the signal and generating the proof;
|
||||
- `group`: the group to which the user belongs;
|
||||
- `externalNullifier`: the value that prevents double-signaling;
|
||||
- `signal`: the signal the user wants to send anonymously;
|
||||
- `snarkArtifacts`: the `zkey` and `wasm` [trusted setup files](/V3/glossary/#trusted-setup-files).
|
||||
- `identity`: the Semaphore identity of the user broadcasting the signal and generating the proof;
|
||||
- `group`: the group to which the user belongs;
|
||||
- `externalNullifier`: the value that prevents double-signaling;
|
||||
- `signal`: the signal the user wants to send anonymously;
|
||||
- `snarkArtifacts`: the `zkey` and `wasm` [trusted setup files](/V3/glossary/#trusted-setup-files).
|
||||
|
||||
#### Install library:
|
||||
|
||||
<Tabs
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
{label: 'npm', value: 'npm'},
|
||||
{label: 'Yarn', value: 'yarn'},
|
||||
{label: 'pnpm', value: 'pnpm'}
|
||||
]}>
|
||||
<TabItem value="npm">
|
||||
]}
|
||||
>
|
||||
<TabItem value="npm">
|
||||
```bash
|
||||
npm install @semaphore-protocol/proof@^3
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
```bash
|
||||
npm install @semaphore-protocol/proof@^3
|
||||
```
|
||||
<TabItem value="yarn">
|
||||
```bash
|
||||
yarn add @semaphore-protocol/proof@^3
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="yarn">
|
||||
|
||||
```bash
|
||||
yarn add @semaphore-protocol/proof@^3
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
|
||||
```bash
|
||||
pnpm add @semaphore-protocol/proof@^3
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
```bash
|
||||
pnpm add @semaphore-protocol/proof@^3
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
In the voting system use case, once all the voters have joined their [identities](/V3/guides/identities#create-an-identity) to the ballot [group](/V3/guides/groups),
|
||||
In the voting system use case, once all the voters have joined their [identities](/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](/V3/glossary/#merkle-tree/) root of the group) as the
|
||||
In the call to `generateProof`, the voting system passes the unique ballot ID (the [Merkle tree](/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:
|
||||
|
||||
@@ -87,6 +84,7 @@ If you are generating the proof on the client side, you can avoid adding the sna
|
||||
```ts
|
||||
const fullProof = await generateProof(identity, group, externalNullifier, signal)
|
||||
```
|
||||
|
||||
:::
|
||||
|
||||
## Verify a proof off-chain
|
||||
@@ -94,8 +92,8 @@ const fullProof = await generateProof(identity, group, externalNullifier, signal
|
||||
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;
|
||||
- `treeDepth`: the Merkle tree depth.
|
||||
- `fullProof`: the Semaphore proof;
|
||||
- `treeDepth`: the Merkle tree depth.
|
||||
|
||||
The following code sample shows how to verify the previously generated proof:
|
||||
|
||||
@@ -117,12 +115,12 @@ See our [deployed contracts](/V3/deployed-contracts) to find the addresses for y
|
||||
|
||||
To verify Semaphore proofs in your contract, import `ISemaphore.sol`, pass it the `Semaphore.sol` address and call the `verifyProof` method with following parameters:
|
||||
|
||||
- `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);
|
||||
- `externalNullifier`: the value that prevents double-signaling;
|
||||
- `proof`: a [Solidity-compatible Semaphore proof](#generate-a-solidity-compatible-proof).
|
||||
- `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;
|
||||
- `externalNullifier`: the value that prevents double-signaling;
|
||||
- `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/v3.15.2/packages/contracts) NPM module.
|
||||
|
||||
@@ -31,37 +31,34 @@ The [`semaphore CLI`](https://github.com/semaphore-protocol/semaphore/tree/v3.15
|
||||
To start working on your project, install the dependencies:
|
||||
|
||||
<Tabs
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
{label: 'npm', value: 'npm'},
|
||||
{label: 'Yarn', value: 'yarn'},
|
||||
{label: 'pnpm', value: 'pnpm'}
|
||||
]}>
|
||||
<TabItem value="npm">
|
||||
]}
|
||||
>
|
||||
<TabItem value="npm">
|
||||
```bash
|
||||
cd my-app
|
||||
npm i
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
```bash
|
||||
cd my-app
|
||||
npm i
|
||||
```
|
||||
<TabItem value="yarn">
|
||||
```bash
|
||||
cd my-app
|
||||
yarn
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="yarn">
|
||||
|
||||
```bash
|
||||
cd my-app
|
||||
yarn
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
|
||||
```bash
|
||||
cd my-app
|
||||
pnpm install
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
```bash
|
||||
cd my-app
|
||||
pnpm install
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
## Output
|
||||
@@ -116,34 +113,31 @@ cd apps/contracts
|
||||
And compile your contracts:
|
||||
|
||||
<Tabs
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
{label: 'npm', value: 'npm'},
|
||||
{label: 'Yarn', value: 'yarn'},
|
||||
{label: 'pnpm', value: 'pnpm'}
|
||||
]}>
|
||||
<TabItem value="npm">
|
||||
]}
|
||||
>
|
||||
<TabItem value="npm">
|
||||
```bash
|
||||
npm run compile
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
```bash
|
||||
npm run compile
|
||||
```
|
||||
<TabItem value="yarn">
|
||||
```bash
|
||||
yarn compile
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="yarn">
|
||||
|
||||
```bash
|
||||
yarn compile
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
|
||||
```bash
|
||||
pnpm compile
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
```bash
|
||||
pnpm compile
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
### Test contracts
|
||||
@@ -151,100 +145,91 @@ pnpm compile
|
||||
Test your contracts:
|
||||
|
||||
<Tabs
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
{label: 'npm', value: 'npm'},
|
||||
{label: 'Yarn', value: 'yarn'},
|
||||
{label: 'pnpm', value: 'pnpm'}
|
||||
]}>
|
||||
<TabItem value="npm">
|
||||
]}
|
||||
>
|
||||
<TabItem value="npm">
|
||||
```bash
|
||||
npm test
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
```bash
|
||||
npm test
|
||||
```
|
||||
<TabItem value="yarn">
|
||||
```bash
|
||||
yarn test
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="yarn">
|
||||
|
||||
```bash
|
||||
yarn test
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
|
||||
```bash
|
||||
pnpm test
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
```bash
|
||||
pnpm test
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
Generate a test coverage report:
|
||||
|
||||
<Tabs
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
{label: 'npm', value: 'npm'},
|
||||
{label: 'Yarn', value: 'yarn'},
|
||||
{label: 'pnpm', value: 'pnpm'}
|
||||
]}>
|
||||
<TabItem value="npm">
|
||||
]}
|
||||
>
|
||||
<TabItem value="npm">
|
||||
```bash
|
||||
npm run test:coverage
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
```bash
|
||||
npm run test:coverage
|
||||
```
|
||||
<TabItem value="yarn">
|
||||
```bash
|
||||
yarn test:coverage
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="yarn">
|
||||
|
||||
```bash
|
||||
yarn test:coverage
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
|
||||
```bash
|
||||
pnpm test:coverage
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
```bash
|
||||
pnpm test:coverage
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
Or a test gas report:
|
||||
|
||||
<Tabs
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
{label: 'npm', value: 'npm'},
|
||||
{label: 'Yarn', value: 'yarn'},
|
||||
{label: 'pnpm', value: 'pnpm'}
|
||||
]}>
|
||||
<TabItem value="npm">
|
||||
]}
|
||||
>
|
||||
<TabItem value="npm">
|
||||
```bash
|
||||
npm run test:report-gas
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
```bash
|
||||
npm run test:report-gas
|
||||
```
|
||||
<TabItem value="yarn">
|
||||
```bash
|
||||
yarn test:report-gas
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="yarn">
|
||||
|
||||
```bash
|
||||
yarn test:report-gas
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
|
||||
```bash
|
||||
pnpm test:report-gas
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
```bash
|
||||
pnpm test:report-gas
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
### Deploy contracts
|
||||
@@ -255,82 +240,76 @@ 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.
|
||||
:::
|
||||
:::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={[
|
||||
<Tabs
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
{label: 'npm', value: 'npm'},
|
||||
{label: 'Yarn', value: 'yarn'},
|
||||
{label: 'pnpm', value: 'pnpm'}
|
||||
]}>
|
||||
<TabItem value="npm">
|
||||
]}
|
||||
>
|
||||
<TabItem value="npm">
|
||||
```bash
|
||||
npm run deploy -- --semaphore <semaphore-address> --group <group-id> --network arbitrum-goerli
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
```bash
|
||||
npm run deploy -- --semaphore <semaphore-address> --group <group-id> --network arbitrum-goerli
|
||||
```
|
||||
<TabItem value="yarn">
|
||||
```bash
|
||||
yarn deploy --semaphore <semaphore-address> --group <group-id> --network arbitrum-goerli
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="yarn">
|
||||
<TabItem value="pnpm">
|
||||
```bash
|
||||
pnpm deploy --semaphore <semaphore-address> --group <group-id> --network arbitrum-goerli
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
```bash
|
||||
yarn deploy --semaphore <semaphore-address> --group <group-id> --network arbitrum-goerli
|
||||
```
|
||||
:::note
|
||||
Check the Semaphore contract addresses [here](/V3/deployed-contracts).
|
||||
:::
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
|
||||
```bash
|
||||
pnpm deploy --semaphore <semaphore-address> --group <group-id> --network arbitrum-goerli
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
:::note
|
||||
Check the Semaphore contract addresses [here](/V3/deployed-contracts).
|
||||
:::
|
||||
|
||||
:::caution
|
||||
The group id is a number.
|
||||
:::
|
||||
:::caution
|
||||
The group id is a number.
|
||||
:::
|
||||
|
||||
### Start app
|
||||
|
||||
Start the application:
|
||||
|
||||
<Tabs
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
{label: 'npm', value: 'npm'},
|
||||
{label: 'Yarn', value: 'yarn'},
|
||||
{label: 'pnpm', value: 'pnpm'}
|
||||
]}>
|
||||
<TabItem value="npm">
|
||||
]}
|
||||
>
|
||||
<TabItem value="npm">
|
||||
```bash
|
||||
npm run dev
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
```bash
|
||||
npm run dev
|
||||
```
|
||||
<TabItem value="yarn">
|
||||
```bash
|
||||
yarn dev
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="yarn">
|
||||
|
||||
```bash
|
||||
yarn dev
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
|
||||
```bash
|
||||
pnpm dev
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
```bash
|
||||
pnpm dev
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import TabItem from "@theme/TabItem"
|
||||
|
||||
# Troubleshooting
|
||||
|
||||
If these suggestions do not work, feel free to ask in the [Semaphore Discussions](https://github.com/semaphore-protocol/semaphore/discussions) or in the `dev-chat` channel in the [Semaphore Discord](https://semaphore.pse.dev/discord).
|
||||
If these suggestions do not work, feel free to ask in the [Semaphore Discussions](https://github.com/semaphore-protocol/semaphore/discussions) or in the [Semaphore Telegram](https://semaphore.pse.dev/telegram).
|
||||
|
||||
## Using Semaphore in the frontend
|
||||
|
||||
@@ -70,65 +70,59 @@ To solve that:
|
||||
1- Install `@esbuild-plugins/node-globals-polyfill` and `@esbuild-plugins/node-modules-polyfill`
|
||||
|
||||
<Tabs
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
{label: 'npm', value: 'npm'},
|
||||
{label: 'Yarn', value: 'yarn'},
|
||||
{label: 'pnpm', value: 'pnpm'}
|
||||
]}>
|
||||
<TabItem value="npm">
|
||||
]}
|
||||
>
|
||||
<TabItem value="npm">
|
||||
```bash
|
||||
npm install @esbuild-plugins/node-globals-polyfill
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
```bash
|
||||
npm install @esbuild-plugins/node-globals-polyfill
|
||||
```
|
||||
<TabItem value="yarn">
|
||||
```bash
|
||||
yarn add @esbuild-plugins/node-globals-polyfill
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="yarn">
|
||||
|
||||
```bash
|
||||
yarn add @esbuild-plugins/node-globals-polyfill
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
|
||||
```bash
|
||||
pnpm add @esbuild-plugins/node-globals-polyfill
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
```bash
|
||||
pnpm add @esbuild-plugins/node-globals-polyfill
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
<Tabs
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
{label: 'npm', value: 'npm'},
|
||||
{label: 'Yarn', value: 'yarn'},
|
||||
{label: 'pnpm', value: 'pnpm'}
|
||||
]}>
|
||||
<TabItem value="npm">
|
||||
]}
|
||||
>
|
||||
<TabItem value="npm">
|
||||
```bash
|
||||
npm install @esbuild-plugins/node-modules-polyfill
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
```bash
|
||||
npm install @esbuild-plugins/node-modules-polyfill
|
||||
```
|
||||
<TabItem value="yarn">
|
||||
```bash
|
||||
yarn add @esbuild-plugins/node-modules-polyfill
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="yarn">
|
||||
|
||||
```bash
|
||||
yarn add @esbuild-plugins/node-modules-polyfill
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
|
||||
```bash
|
||||
pnpm add @esbuild-plugins/node-modules-polyfill
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
```bash
|
||||
pnpm add @esbuild-plugins/node-modules-polyfill
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
2- Modify the `vite.config.ts` to add them:
|
||||
|
||||
131
apps/docs/versioned_docs/version-V4/benchmarks.md
Normal file
@@ -0,0 +1,131 @@
|
||||
---
|
||||
sidebar_position: 8
|
||||
---
|
||||
|
||||
# Benchmarks
|
||||
|
||||
Semaphore v4 introduces new features and performance improvements. Detailed changes are available in the [release changelog](https://github.com/semaphore-protocol/semaphore/releases/tag/v4.0.0).
|
||||
|
||||
The primary changes in benchmark values are driven by the two major protocol updates:
|
||||
|
||||
- New [Identity schema](https://github.com/semaphore-protocol/semaphore/tree/main/packages/identity).
|
||||
|
||||
- [LeanIMT](https://github.com/privacy-scaling-explorations/zk-kit/tree/main/packages/lean-imt): New optimized IMT.
|
||||
|
||||
## New Identity schema
|
||||
|
||||
Semaphore v4 includes a new schema for the identities allowing the creation and verification of signatures.
|
||||
|
||||
Although the new Identity package is slightly slower than the one in Semaphore v3 (by just a few milliseconds), the trade-off is minimal considering the included functionality.
|
||||
|
||||
The new identity schema adds additional constraints to the Semaphore v4 circuit; however, this does not negatively impact overall performance of the protocol.
|
||||
|
||||
## LeanIMT
|
||||
|
||||
Semaphore v4 uses the LeanIMT data structure for group operations, an improvement over the IMT used in v3.
|
||||
|
||||
For further details, see the [LeanIMT paper](https://github.com/privacy-scaling-explorations/zk-kit/tree/main/papers/leanimt).
|
||||
|
||||
The LeanIMT offers dynamic depth, resulting in faster and more cost-effective group operations, across Node.js, browser and smart contracts.
|
||||
|
||||
Semaphore v4 support tree depths from 1 to 32, while v3 supports depths from 16 to 32, both for proof generation and verification.
|
||||
|
||||
## System Specifications and Software environment
|
||||
|
||||
All the benchmarks were run in an environment with these properties:
|
||||
|
||||
**System Specifications**
|
||||
|
||||
Computer: MacBook Pro
|
||||
|
||||
Chip: Apple M2 Pro
|
||||
|
||||
Memory (RAM): 16 GB
|
||||
|
||||
Operating System: macOS Sequoia version 15.0.1
|
||||
|
||||
**Software environment**
|
||||
|
||||
Node.js version: 20.18.0
|
||||
|
||||
Browser: Google Chrome Version 130.0.6723.92 (Official Build) (arm64)
|
||||
|
||||
## Running the benchmarks
|
||||
|
||||
### Javascript and Circom
|
||||
|
||||
GitHub repository to the run Node.js, browser and Circom benchmarks: https://github.com/vplasencia/semaphore-benchmarks
|
||||
|
||||
### Solidity
|
||||
|
||||
GitHub repository to run the Solidity benchmarks: https://github.com/semaphore-protocol/semaphore
|
||||
|
||||
## Node.js benchmarks
|
||||
|
||||
### Identities
|
||||
|
||||

|
||||
|
||||
### Create Group
|
||||
|
||||
Create group, either empty or with initial members.
|
||||
|
||||

|
||||
|
||||
### Add Member
|
||||
|
||||
Add a member to groups with different sizes.
|
||||
|
||||

|
||||
|
||||
### Generate Proof
|
||||
|
||||
Generate a proof using groups with different numbers of members.
|
||||
|
||||

|
||||
|
||||
### Verify Proof
|
||||
|
||||
Verify a proof using groups with different numbers of members.
|
||||
|
||||

|
||||
|
||||
## Browser benchmarks
|
||||
|
||||
Main functions used in the browser.
|
||||
|
||||

|
||||
|
||||
## Circuit benchmarks
|
||||
|
||||
### Semaphore V3
|
||||
|
||||
<img
|
||||
src={require('../../assets/img-benchmarks/circuits/semaphore-v3-circuits-benchmarks.png').default}
|
||||
alt="Circuit benchmarks Semaphore v3"
|
||||
style={{ width: '300px', height: 'auto' }}
|
||||
/>
|
||||
|
||||
### Semaphore V4
|
||||
|
||||
<img
|
||||
src={require('../../assets/img-benchmarks/circuits/semaphore-v4-circuits-benchmarks.png').default}
|
||||
alt="Circuit benchmarks Semaphore v4"
|
||||
style={{ width: '300px', height: 'auto' }}
|
||||
/>
|
||||
|
||||
## Contracts
|
||||
|
||||
<img
|
||||
src={require('../../assets/img-benchmarks/contracts/contract-benchmarks.png').default}
|
||||
alt="Contract Benchmarks"
|
||||
style={{ width: '590px', height: 'auto' }}
|
||||
/>
|
||||
|
||||
### Semaphore V3 gas report
|
||||
|
||||

|
||||
|
||||
### Semaphore V4 gas report
|
||||
|
||||

|
||||
@@ -1,5 +1,5 @@
|
||||
---
|
||||
sidebar_position: 11
|
||||
sidebar_position: 13
|
||||
---
|
||||
|
||||
# Credits
|
||||
@@ -17,3 +17,4 @@ Semaphore is the work of several people, for a complete list of contributors you
|
||||
- [LauNaMu](https://github.com/0xyNaMu)
|
||||
- [0xjei](https://github.com/0xjei)
|
||||
- [Mari Poveda](https://github.com/maripoveda)
|
||||
- [Gauthier](https://github.com/sripwoud)
|
||||
@@ -1,12 +1,12 @@
|
||||
---
|
||||
sidebar_position: 10
|
||||
sidebar_position: 12
|
||||
---
|
||||
|
||||
# FAQ
|
||||
|
||||
## Where can I ask questions about Semaphore?
|
||||
|
||||
You can ask questions about Semaphore on [Discord](https://semaphore.pse.dev/discord) or by opening a [Semaphore Discussion](https://github.com/semaphore-protocol/semaphore/discussions). The most frequent questions will be listed below.
|
||||
You can ask questions about Semaphore on [Telegram](https://semaphore.pse.dev/telegram) or by opening a [Semaphore Discussion](https://github.com/semaphore-protocol/semaphore/discussions). The most frequent questions will be listed below.
|
||||
|
||||
## Why should I prevent proofs from being verified twice?
|
||||
|
||||
@@ -111,23 +111,23 @@ 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.
|
||||
:::
|
||||
:::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
|
||||
```
|
||||
```bash
|
||||
yarn deploy --semaphore <semaphore-address> --group <group-id> --network sepolia
|
||||
```
|
||||
|
||||
:::note
|
||||
Check the Semaphore contract addresses [here](/deployed-contracts).
|
||||
:::
|
||||
:::note
|
||||
Check the Semaphore contract addresses [here](/deployed-contracts).
|
||||
:::
|
||||
|
||||
:::caution
|
||||
The group id is a number.
|
||||
:::
|
||||
:::caution
|
||||
The group id is a number.
|
||||
:::
|
||||
|
||||
### Start app
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
---
|
||||
sidebar_position: 7
|
||||
sidebar_position: 9
|
||||
---
|
||||
|
||||
# Glossary
|
||||
@@ -8,12 +8,12 @@ import TabItem from "@theme/TabItem"
|
||||
|
||||
# Semaphore groups
|
||||
|
||||
A [Semaphore group](/glossary/#group) contains [identity commitments](/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,
|
||||
- ballot that members join to vote on a proposal,
|
||||
- whistleblowers who are verified employees of an organization.
|
||||
- poll question that attendees join to rate an event,
|
||||
- ballot that members join to vote on a proposal,
|
||||
- whistleblowers who are verified employees of an organization.
|
||||
|
||||
:::info
|
||||
Semaphore V4 uses the [ZK-Kit](https://github.com/privacy-scaling-explorations/zk-kit) LeanIMT (i.e., Lean Incremental
|
||||
@@ -28,34 +28,31 @@ Use the [`@semaphore-protocol/group`](https://github.com/semaphore-protocol/sema
|
||||
### Install package
|
||||
|
||||
<Tabs
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
{label: 'npm', value: 'npm'},
|
||||
{label: 'Yarn', value: 'yarn'},
|
||||
{label: 'pnpm', value: 'pnpm'}
|
||||
]}>
|
||||
<TabItem value="npm">
|
||||
]}
|
||||
>
|
||||
<TabItem value="npm">
|
||||
```bash
|
||||
npm install @semaphore-protocol/group
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
```bash
|
||||
npm install @semaphore-protocol/group
|
||||
```
|
||||
<TabItem value="yarn">
|
||||
```bash
|
||||
yarn add @semaphore-protocol/group
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="yarn">
|
||||
|
||||
```bash
|
||||
yarn add @semaphore-protocol/group
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
|
||||
```bash
|
||||
pnpm add @semaphore-protocol/group
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
```bash
|
||||
pnpm add @semaphore-protocol/group
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
:::info
|
||||
@@ -76,9 +73,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)
|
||||
@@ -117,7 +114,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
|
||||
@@ -142,39 +139,36 @@ Use the [`@semaphore-protocol/contracts`](https://github.com/semaphore-protocol/
|
||||
### Install package
|
||||
|
||||
<Tabs
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
{label: 'npm', value: 'npm'},
|
||||
{label: 'Yarn', value: 'yarn'},
|
||||
{label: 'pnpm', value: 'pnpm'}
|
||||
]}>
|
||||
<TabItem value="npm">
|
||||
]}
|
||||
>
|
||||
<TabItem value="npm">
|
||||
```bash
|
||||
npm install @semaphore-protocol/contracts
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
```bash
|
||||
npm install @semaphore-protocol/contracts
|
||||
```
|
||||
<TabItem value="yarn">
|
||||
```bash
|
||||
yarn add @semaphore-protocol/contracts
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="yarn">
|
||||
|
||||
```bash
|
||||
yarn add @semaphore-protocol/contracts
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
|
||||
```bash
|
||||
pnpm add @semaphore-protocol/contracts
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
```bash
|
||||
pnpm add @semaphore-protocol/contracts
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
### Create a group
|
||||
|
||||
To create a group initialize your contract with the `Semaphore.sol` address and a group ID.
|
||||
To create a group initialize your contract with the `Semaphore.sol` address.
|
||||
The `createGroup` function can be used to create a Semaphore group. For example:
|
||||
|
||||
```solidity
|
||||
@@ -187,16 +181,15 @@ contract YourContract {
|
||||
|
||||
uint256 public groupId;
|
||||
|
||||
constructor(ISemaphore _semaphore, uint256 _groupId) {
|
||||
constructor(ISemaphore _semaphore) {
|
||||
semaphore = _semaphore;
|
||||
groupId = _groupId;
|
||||
|
||||
semaphore.createGroup(groupId, address(this));
|
||||
groupId = semaphore.createGroup();
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
`Semaphore.sol` also includes a mechanism to verify Semaphore proofs created with old Merkle tree roots, the duration of which can optionally be defined by the admin in the `createGroup` function as the third parameter. The default value duration is 1 hour and it should be fine for most use-cases. For more context see the issue [#98](https://github.com/semaphore-protocol/semaphore/issues/98).
|
||||
`Semaphore.sol` also includes a mechanism to verify Semaphore proofs created with old Merkle tree roots, the duration of which can optionally be defined by the admin in the `createGroup` function. The default value duration is 1 hour and it should be fine for most use-cases. For more context see the issue [#98](https://github.com/semaphore-protocol/semaphore/issues/98).
|
||||
|
||||
### Add members
|
||||
|
||||
@@ -241,4 +234,3 @@ 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/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`.
|
||||
:::
|
||||
|
||||
@@ -11,46 +11,43 @@ import TabItem from "@theme/TabItem"
|
||||
In order to join a [Semaphore group](/glossary#group), a user must first create a [Semaphore identity](/glossary#identity).
|
||||
A Semaphore identity contains three values generated with the identity:
|
||||
|
||||
- Private key
|
||||
- Public key
|
||||
- Commitment
|
||||
- Private key
|
||||
- Public key
|
||||
- Commitment
|
||||
|
||||
To use and verify the identity, the identity owner (user) must know its private key.
|
||||
To prevent fraud, the owner should keep their private key secret.
|
||||
|
||||
## Install package
|
||||
|
||||
In your code, use the [`@semaphore-protocol/identity`](https://github.com/semaphore-protocol/semaphore/tree/main/packages/identity) package to manage Semaphore identites.
|
||||
In your code, use the [`@semaphore-protocol/identity`](https://github.com/semaphore-protocol/semaphore/tree/main/packages/identity) package to manage Semaphore identities.
|
||||
|
||||
<Tabs
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
{label: 'npm', value: 'npm'},
|
||||
{label: 'Yarn', value: 'yarn'},
|
||||
{label: 'pnpm', value: 'pnpm'}
|
||||
]}>
|
||||
<TabItem value="npm">
|
||||
]}
|
||||
>
|
||||
<TabItem value="npm">
|
||||
```bash
|
||||
npm install @semaphore-protocol/identity
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
```bash
|
||||
npm install @semaphore-protocol/identity
|
||||
```
|
||||
<TabItem value="yarn">
|
||||
```bash
|
||||
yarn add @semaphore-protocol/identity
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="yarn">
|
||||
|
||||
```bash
|
||||
yarn add @semaphore-protocol/identity
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
|
||||
```bash
|
||||
pnpm add @semaphore-protocol/identity
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
```bash
|
||||
pnpm add @semaphore-protocol/identity
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
:::info
|
||||
@@ -88,7 +85,7 @@ You may choose to delegate such functionality to existing wallets such as Metama
|
||||
1. In Metamask, a user signs a message with the private key of their Ethereum account.
|
||||
2. In your application, the user creates a deterministic identity with the signed message that acts as your Semaphore private key.
|
||||
3. The user can now recreate their Semaphore identity whenever they want by signing the same message with their Ethereum account in Metamask.
|
||||
:::
|
||||
:::
|
||||
|
||||
## Sign and verify messages
|
||||
|
||||
@@ -112,3 +109,33 @@ After a message is signed, anyone can verify the signature using the message its
|
||||
// Static method.
|
||||
Identity.verifySignature(message, signature, identity1.publicKey)
|
||||
```
|
||||
|
||||
## Export and import an identity
|
||||
|
||||
A Semaphore Identity can be exported and then imported later for reuse.
|
||||
|
||||
### Export an identity
|
||||
|
||||
Returns the private key encoded as a base64 string.
|
||||
|
||||
```ts
|
||||
import { Identity } from "@semaphore-protocol/identity"
|
||||
|
||||
const identity = new Identity()
|
||||
|
||||
const privateKey = identity.export()
|
||||
```
|
||||
|
||||
### Import an identity
|
||||
|
||||
Returns a Semaphore identity based on a private key encoded as a base64 string.
|
||||
|
||||
```ts
|
||||
import { Identity } from "@semaphore-protocol/identity"
|
||||
|
||||
const identity = new Identity()
|
||||
|
||||
const privateKey = identity.export()
|
||||
|
||||
const identity2 = Identity.import(privateKey)
|
||||
```
|
||||
@@ -10,8 +10,8 @@ import TabItem from "@theme/TabItem"
|
||||
|
||||
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.
|
||||
- the user is a member of the group,
|
||||
- the same user created the message and the proof.
|
||||
|
||||
A unique [nullifier](/glossary#nullifier) is also generated for each proof that can be used to check whether that proof has already been validated.
|
||||
|
||||
@@ -20,34 +20,31 @@ A unique [nullifier](/glossary#nullifier) is also generated for each proof that
|
||||
In your code, use the [`@semaphore-protocol/proof`](https://github.com/semaphore-protocol/semaphore/tree/main/packages/proof) package to generate and verify a proof.
|
||||
|
||||
<Tabs
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
{label: 'npm', value: 'npm'},
|
||||
{label: 'Yarn', value: 'yarn'},
|
||||
{label: 'pnpm', value: 'pnpm'}
|
||||
]}>
|
||||
<TabItem value="npm">
|
||||
]}
|
||||
>
|
||||
<TabItem value="npm">
|
||||
```bash
|
||||
npm install @semaphore-protocol/proof
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
```bash
|
||||
npm install @semaphore-protocol/proof
|
||||
```
|
||||
<TabItem value="yarn">
|
||||
```bash
|
||||
yarn add @semaphore-protocol/proof
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="yarn">
|
||||
|
||||
```bash
|
||||
yarn add @semaphore-protocol/proof
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
|
||||
```bash
|
||||
pnpm add @semaphore-protocol/proof
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
```bash
|
||||
pnpm add @semaphore-protocol/proof
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
:::info
|
||||
@@ -73,7 +70,7 @@ import { Group } from "@semaphore-protocol/group"
|
||||
|
||||
const semaphoreSubgraph = new SemaphoreSubgraph("sepolia")
|
||||
|
||||
const { members } = semaphoreSubgraph.getGroup("42", { members: true })
|
||||
const { members } = await semaphoreSubgraph.getGroup("42", { members: true })
|
||||
|
||||
const group = new Group(members)
|
||||
```
|
||||
@@ -82,7 +79,7 @@ const group = new Group(members)
|
||||
|
||||
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
|
||||
### 4. Generate the anonymous message
|
||||
|
||||
Finally, you can generate the proof with the anonymous message using the `generateProof` function. For example:
|
||||
|
||||
@@ -92,7 +89,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
|
||||
@@ -1,5 +1,5 @@
|
||||
---
|
||||
sidebar_position: 8
|
||||
sidebar_position: 10
|
||||
---
|
||||
|
||||
import Articles from '@site/src/components/Articles';
|
||||
@@ -1,5 +1,5 @@
|
||||
---
|
||||
sidebar_position: 6
|
||||
sidebar_position: 7
|
||||
---
|
||||
|
||||
import RemoteCode from '@site/src/components/RemoteCode';
|
||||
@@ -7,7 +7,7 @@ import RemoteCode from '@site/src/components/RemoteCode';
|
||||
# Subgraph
|
||||
|
||||
[The Graph](https://thegraph.com/) is a protocol for indexing networks like Ethereum and IPFS.
|
||||
Site owners publish _subgraphs_ that expose site data for anyone to query.
|
||||
Site owners publish *subgraphs* that expose site data for anyone to query.
|
||||
Semaphore's subgraph allows you to retrieve data from the [`Semaphore.sol`](https://github.com/semaphore-protocol/semaphore/blob/main/packages/contracts/contracts/Semaphore.sol) smart contract.
|
||||
|
||||
:::tip
|
||||
@@ -16,5 +16,4 @@ The Graph protocol uses the [GraphQL](https://graphql.org/) query language. For
|
||||
|
||||
## Schema
|
||||
|
||||
<RemoteCode url="https://raw.githubusercontent.com/semaphore-protocol/semaphore/main/apps/subgraph/schema.graphql"
|
||||
title="apps/subgraph/schema.graphql" language="graphql" />
|
||||
<RemoteCode url="https://raw.githubusercontent.com/semaphore-protocol/semaphore/main/apps/subgraph/schema.graphql" title="apps/subgraph/schema.graphql" language="graphql" />
|
||||
@@ -4,7 +4,7 @@ sidebar_position: 2
|
||||
|
||||
# Circuits
|
||||
|
||||
The [Semaphore circuit](https://github.com/semaphore-protocol/semaphore/tree/main/packages/circuits/semaphore.circom) is the heart of the protocol and consists of three parts:
|
||||
The [Semaphore circuit](https://github.com/semaphore-protocol/semaphore/blob/main/packages/circuits/src/semaphore.circom) is the heart of the protocol and consists of three parts:
|
||||
|
||||
- [Proof of membership](#proof-of-membership)
|
||||
- [Nullifier](#nullifier)
|
||||