Compare commits

..

88 Commits

Author SHA1 Message Date
cedoor
35e994d8ab chore: v4.0.0-alpha
Former-commit-id: dfc0629b04
2024-01-23 17:02:21 +00:00
Cedoor
09f4671112 Merge pull request #571 from semaphore-protocol/chore/update-rem-pkgs
Update subgraph and data/CLI libraries with new contracts

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

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

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


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


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

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

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


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


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


Former-commit-id: 4a01dfb179
2024-01-12 10:54:42 +00:00
505 changed files with 7900 additions and 49900 deletions

View File

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

3
.commitlintrc.json Normal file
View File

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

View File

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

View File

@@ -26,13 +26,5 @@
"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
View File

@@ -1 +0,0 @@
* @semaphore-protocol/core-devs

View File

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

View File

@@ -1,40 +1,24 @@
<!-- Please refer to our CONTRIBUTING documentation for any questions on submitting a pull request. -->
<!-- Provide a general summary of your changes in the Title above. -->
<!-- Please refer to our contributing documentation for any questions on submitting a pull request -->
<!--- Provide a general summary of your changes in the Title above -->
## Description
<!-- Describe your changes in detail. -->
<!-- You may want to answer some of the following questions: -->
<!-- What kind of change does this PR introduce?** (Bug fix, feature, docs update, ...) -->
<!-- What is the current behavior?** (You can also link to an open issue here) -->
<!-- What is the new behavior (if this is a feature change)? -->
<!-- Does this PR introduce a breaking change?** (What changes might users need to make in their application due to this PR?) -->
<!--- Describe your changes in detail -->
## Related Issue(s)
## Related Issue
<!-- This project accepts pull requests related to open issues. -->
<!-- If suggesting a new feature or change, please discuss it in an issue first. -->
<!-- If fixing a bug, there should be an issue describing it with steps to reproduce. -->
<!-- Please link to the issue(s) here -->
<!--- This project accepts pull requests related to open issues -->
<!--- If suggesting a new feature or change, please discuss it in an issue first -->
<!--- If fixing a bug, there should be an issue describing it with steps to reproduce -->
<!--- Please link to the issue here: -->
<!-- Closes # -->
<!-- Fixes # -->
## Does this introduce a breaking change?
- [ ] Yes
- [ ] No
<!-- If this introduces a breaking change, please describe the impact and migration path for existing applications below. -->
## Other information
<!-- Any other information that is important to this PR such as screenshots of how the component looks before and after the change. -->
<!-- Feel free to remove this section if you will not use it. -->
## Checklist
<!-- Please check if the PR fulfills these requirements. -->
- [ ] I have performed a self-review of my code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] My changes generate no new warnings
- [ ] 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
> [!IMPORTANT]
> We do not accept pull requests for minor grammatical fixes (e.g., correcting typos, rewording sentences) or for fixing broken links, unless they significantly improve clarity or functionality. These contributions, while appreciated, are not a priority for merging. If you notice any of these issues, please create a [GitHub Issue](https://github.com/semaphore-protocol/semaphore/issues/new?template=BLANK_ISSUE) to report them so they can be properly tracked and addressed.

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

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

View File

@@ -2,16 +2,8 @@ name: docs
on:
push:
branches: [main]
paths:
[
"apps/docs/**",
"packages/data/**",
"packages/group/**",
"packages/identity/**",
"packages/proof/**",
"packages/utils/**"
]
branches:
- main
jobs:
gh-pages:
@@ -29,9 +21,6 @@ jobs:
- name: Install dependencies
run: yarn
- name: Build libraries
run: yarn build:libraries
- name: Generate doc website
run: yarn docs

View File

@@ -24,17 +24,23 @@ jobs:
- name: Install dependencies
run: yarn
- name: Build packages and apps
run: yarn build
- name: Compile contracts
run: yarn compile:contracts
- name: Format
run: yarn format
- name: Build libraries
run: yarn build:libraries
- name: Build subgraph
run: yarn build:subgraph
- name: Run Prettier
run: yarn prettier
- name: Run Eslint
run: yarn lint
test-subgraph:
runs-on: ubuntu-22.04 # Context: https://github.com/graphprotocol/graph-tooling/issues/1546#issuecomment-2589680195
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
@@ -48,9 +54,6 @@ jobs:
- name: Install dependencies
run: yarn
- name: Build libraries
run: yarn build:libraries
- name: Build subgraph
run: yarn build:subgraph
@@ -76,14 +79,11 @@ 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 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
run: sudo apt-get update && sudo apt-get install -y wget nlohmann-json3-dev libgmp-dev nasm g++ build-essential
- name: Setup 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
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

View File

@@ -22,60 +22,23 @@ jobs:
- name: Install dependencies
run: yarn
- 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: Compile contracts
run: yarn compile:contracts
- 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
- name: Build libraries
run: yarn build:libraries
- if: steps.changed-files.outputs.subgraph_any_changed == 'true'
name: Build subgraph
run: |
yarn workspace @semaphore-protocol/utils build
yarn build:subgraph
- name: Build subgraph
run: yarn build:subgraph
- 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 Prettier
run: yarn prettier
- 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
- name: Run Eslint
run: yarn lint
test:
runs-on: ubuntu-22.04 # Context: https://github.com/graphprotocol/graph-tooling/issues/1546#issuecomment-2589680195
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
@@ -86,55 +49,21 @@ 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: 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 libraries
run: yarn build:libraries
# 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: Build subgraph
run: yarn build:subgraph
- 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
- name: Test contracts, libraries, circuits and subgraph
run: yarn test

View File

@@ -4,7 +4,6 @@ permissions:
contents: write
on:
workflow_dispatch:
push:
tags:
- "v*"
@@ -18,38 +17,15 @@ 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:
node-version: 20
cache: yarn
registry-url: "https://registry.npmjs.org"
- name: Authentication
run: |
echo npmAuthToken: "$NODE_AUTH_TOKEN" >> ./.yarnrc.yml
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Install dependencies
run: yarn
- name: Publish packages
run: yarn version:publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
SOLDEER_LOGIN_FILE: ${{ github.workspace }}/soldeer_login
- run: yarn version:release
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

11
.gitignore vendored
View File

@@ -73,6 +73,9 @@ dist
artifacts
cache
typechain-types
packages/contracts/deployed-contracts/undefined.json
packages/contracts/deployed-contracts/hardhat.json
packages/contracts/deployed-contracts/localhost.json
# Stores VSCode versions used for testing VSCode extensions
.vscode-test
@@ -86,13 +89,5 @@ typechain-types
!.yarn/sdks
!.yarn/versions
# asdf
.tool-versions
# direnv
.envrc
# Other
snark-artifacts
*.zip

View File

@@ -1,4 +0,0 @@
#!/usr/bin/env sh
. "$(dirname "$0")/_/husky.sh"
npx lint-staged

View File

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

View File

@@ -1,4 +1,3 @@
{
"**/*.{js,ts,jsx,tsx,md,json,sol,yaml,yml}": "prettier --write",
"**/*.{js,ts,jsx,tsx}": "eslint"
"**/*.{js,ts}": ["prettier --write", "eslint --fix"]
}

View File

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

View File

@@ -1 +0,0 @@
package.json

View File

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

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
b3cadff6efb37a12712d12c2553ec703dbcaa4dd

File diff suppressed because one or more lines are too long

View File

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

View File

@@ -22,16 +22,13 @@ Pull requests are great if you want to add a feature or fix a bug. Here's a quic
3. Add a test for your change. Only refactoring and documentation changes require no new tests.
4. Make sure to check out the [Style Guide](/CONTRIBUTING.md#style-guide) and ensure that your code complies with the rules.
4. Make sure to check out the [Style Guide](/CONTRIBUTING#style-guide) and ensure that your code complies with the rules.
5. Make the test pass.
6. Commit your changes.
7. Push to your fork and submit a pull request on our `main` branch. Please provide us with some explanation of why you made the changes you made. For new features make sure to explain a standard use case to us.
> [!IMPORTANT]
> We do not accept pull requests for minor grammatical fixes (e.g., correcting typos, rewording sentences) or for fixing broken links, unless they significantly improve clarity or functionality. These contributions, while appreciated, are not a priority for merging. If you notice any of these issues, please create a [GitHub Issue](https://github.com/semaphore-protocol/semaphore/issues/new?template=BLANK_ISSUE) to report them so they can be properly tracked and addressed.
7. Push to your fork and submit a pull request on our `dev` branch. Please provide us with some explanation of why you made the changes you made. For new features make sure to explain a standard use case to us.
## CI (Github Actions) Tests
@@ -45,11 +42,11 @@ 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`.
### Commit rules
### Commits rules
For commits it is recommended to use [Conventional Commits](https://www.conventionalcommits.org).
Don't worry if it looks complicated, in our repositories, `git commit` opens an interactive app to create your conventional commit.
Don't worry if it looks complicated, in our repositories, after `git add`, you can usually run the npm script `yarn commit` to make many of these steps interactive.
Each commit message consists of a **header**, a **body** and a **footer**. The **header** has a special format that includes a **type**, a **scope** and a **subject**:
@@ -96,6 +93,7 @@ Just as in the subject, use the imperative, present tense: "change" not "changed
### Branch rules
- There must be a `main` branch, used only for the releases.
- There must be a `dev` branch, used to merge all the branches under it.
- Avoid long descriptive names for long-lived branches.
- Use kebab-case (no CamelCase).
- Use grouping tokens (words) at the beginning of your branch names (in a similar way to the `type` of commit).

114
README.md
View File

@@ -1,9 +1,9 @@
<p align="center">
<h1 align="center">
<picture>
<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">
<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">
</picture>
</h1>
</p>
@@ -34,9 +34,7 @@
<a href="https://www.gitpoap.io/gh/semaphore-protocol/semaphore" target="_blank">
<img src="https://public-api.gitpoap.io/v1/repo/semaphore-protocol/semaphore/badge">
</a>
<a href="http://commitizen.github.io/cz-cli/">
<img alt="Commitizen friendly" src="https://img.shields.io/badge/commitizen-friendly-586D76?style=flat-square">
</a>
</p>
<div align="center">
@@ -53,23 +51,16 @@
🔎 Issues
</a>
<span>&nbsp;&nbsp;|&nbsp;&nbsp;</span>
<a href="https://semaphore.pse.dev/telegram">
<a href="https://semaphore.pse.dev/discord">
🗣️ Chat &amp; Support
</a>
<span>&nbsp;&nbsp;|&nbsp;&nbsp;</span>
<a href="https://js.semaphore.pse.dev">
💻 API Reference
</a>
</h4>
</div>
| 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. |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| Semaphore is a protocol, designed to be a simple and generic privacy layer for Ethereum DApps. Using zero knowledge, Ethereum users can prove their membership of a group and send signals such as votes or endorsements without revealing their original identity. |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
The core of the Semaphore protocol is in the [circuit logic](/packages/circuits/scheme.png). However, Semaphore also provides [Solidity contracts](/packages/contracts) 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).
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).
## 📦 Packages
@@ -78,25 +69,6 @@ The core of the Semaphore protocol is in the [circuit logic](/packages/circuits/
<th>Version</th>
<th>Downloads</th>
<tbody>
<tr>
<td>
<a href="/packages/core">
@semaphore-protocol/core
</a>
</td>
<td>
<!-- NPM version -->
<a href="https://npmjs.org/package/@semaphore-protocol/core">
<img src="https://img.shields.io/npm/v/@semaphore-protocol/core.svg?style=flat-square" alt="NPM version" />
</a>
</td>
<td>
<!-- Downloads -->
<a href="https://npmjs.org/package/@semaphore-protocol/core">
<img src="https://img.shields.io/npm/dm/@semaphore-protocol/core.svg?style=flat-square" alt="Downloads" />
</a>
</td>
</tr>
<tr>
<td>
<a href="/packages/contracts">
@@ -244,27 +216,27 @@ The core of the Semaphore protocol is in the [circuit logic](/packages/circuits/
</tr>
<tr>
<td>
<a href="/packages/utils">
@semaphore-protocol/utils
<a href="/packages/heyauthn">
@semaphore-protocol/heyauthn
</a>
<a href="https://js.semaphore.pse.dev/modules/_semaphore_protocol_utils">
<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/utils">
<img src="https://img.shields.io/npm/v/@semaphore-protocol/utils.svg?style=flat-square" alt="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/utils">
<img src="https://img.shields.io/npm/dm/@semaphore-protocol/utils.svg?style=flat-square" alt="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
@@ -275,18 +247,12 @@ Clone this repository:
git clone https://github.com/semaphore-protocol/semaphore.git
```
Install the dependencies:
And install the dependencies:
```bash
cd semaphore && yarn
```
And build the repository:
```bash
yarn build
```
## 📜 Usage
Copy the `.env.example` file as `.env`:
@@ -308,13 +274,13 @@ yarn lint
Run [Prettier](https://prettier.io/) to check formatting rules:
```bash
yarn format
yarn prettier
```
Or to automatically format the code:
```bash
yarn format:write
yarn prettier:write
```
### Conventional commits
@@ -322,11 +288,19 @@ yarn format: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
git commit
yarn commit
```
It will also automatically check that the modified files comply with ESLint and Prettier rules.
### Snark artifacts
Download the Semaphore snark artifacts needed to generate and verify proofs:
```bash
yarn download:snark-artifacts
```
### Testing
Run [Jest](https://jestjs.io/) to test the JS libraries:
@@ -349,10 +323,10 @@ yarn test
### Build libraries & compile contracts
Run [Rollup](https://www.rollupjs.org) and [TheGraph](https://www.npmjs.com/package/@graphprotocol/graph-cli) to build all the packages and the subgraph:
Run [Rollup](https://www.rollupjs.org) to build all the packages:
```bash
yarn build
yarn build:libraries
```
Compile the smart contracts with [Hardhat](https://hardhat.org/):
@@ -370,31 +344,3 @@ yarn docs
```
The output will be placed on the `docs` folder.
### Releases
Steps:
1. Bump a new version with:
```bash
yarn version:bump <version>
# e.g. yarn version:bump 2.0.0
```
This step creates a commit and a git tag.
2. Push the changes to main:
```bash
git push origin main
```
3. Push the new git tag:
```bash
git push origin <version>
# e.g. git push origin v2.0.0
```
After pushing the new git tag, a workflow will be triggered to publish the Semaphore packages on [npm](https://www.npmjs.com/) and release a new version on GitHub with its changelogs automatically.

View File

@@ -34,7 +34,7 @@
🔎 Issues
</a>
<span>&nbsp;&nbsp;|&nbsp;&nbsp;</span>
<a href="https://semaphore.pse.dev/telegram">
<a href="https://semaphore.pse.dev/discord">
🗣️ Chat &amp; Support
</a>
</h4>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 315 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 223 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 182 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 201 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 126 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 133 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 130 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 134 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 125 KiB

View File

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

View File

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

View File

@@ -386,9 +386,12 @@
"message": "Connect"
},
"footer.right.connect.link1": {
"message": "Telegram"
"message": "Discord"
},
"footer.right.connect.link2": {
"message": "X (Twitter)"
},
"footer.copyright": {
"message": "Copyright © 2024 Ethereum Foundation"
}
}

View File

@@ -42,7 +42,7 @@
"message": "Valores públicos"
},
"section.identities.box2.description": {
"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."
"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."
},
"section.identities.box3.title": {
"message": "Generar identidades"
@@ -386,9 +386,12 @@
"message": "Conecta con nosotros"
},
"footer.right.connect.link1": {
"message": "Telegram"
"message": "Discord"
},
"footer.right.connect.link2": {
"message": "X (Twitter)"
},
"footer.copyright": {
"message": "Copyright © 2024 Ethereum Foundation"
}
}

View File

@@ -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/semaphore-protocol/semaphore/blob/main/apps/docs/versioned_docs/version-V1/audit.md). After three
[here](https://github.com/appliedzkp/semaphore/tree/master/audit). After three
rounds of fixes, all security and performance issues were fixed, and the few
remaining issues are minor and do not affect security.

View File

@@ -40,7 +40,7 @@ For more information, see [Merkle tree in Wikipedia](https://en.wikipedia.org/wi
A value used to prevent double entry or double signalling.
See [Circuit nullifier hash](/V2/technical-reference/circuits/#nullifier-hash).
See [Circuit nullifier hash](/technical-reference/circuits/#nullifier-hash).
## Relay
@@ -48,7 +48,7 @@ A third-party who receives a fee for including relayed transactions in the block
To preserve the anonymity of the user broadcasting a signal with Semaphore, an application may use a relayer to post the signal transaction to Ethereum on behalf of the user.
Applications may provide rewards for relayers and implement front-running prevention mechanisms, such as requiring the signals to include the relayers address, binding the
signal to that specific address (https://semaphore.pse.dev/whitepaper-v1.pdf, p.6).
signal to that specific address (https://docs.semaphore.pse.dev/whitepaper-v1.pdf, p.6).
## Trusted setup files
@@ -60,5 +60,5 @@ To generate or verify valid zero-knowledge proofs with Semaphore, applications m
- semaphore.wasm
- semaphore.json
For a complete list of ready-to-use files, see [trusted-setup-pse.org](https://www.trusted-setup-pse.org).
For a complete list of ready-to-use files, see <http://www.trusted-setup-pse.org>.
To learn more, see the [trusted setup ceremony](https://storage.googleapis.com/trustedsetup-a86f4.appspot.com/semaphore/semaphore_top_index.html).

View File

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

View File

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

View File

@@ -7,7 +7,7 @@ title: Proofs
Learn how to use Semaphore to generate and verify zero-knowledge proofs.
Once a user joins their [Semaphore identity](/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:
Once a user joins their [Semaphore identity](/glossary#semaphore-identity) to a [Semaphore group](/glossary#semaphore-group), the user can signal anonymously with a zero-knowledge proof that proves the following:
- The user is a member of the group.
- The same user created the signal and the proof.
@@ -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](/V2/glossary/#trusted-setup-files).
- `snarkArtifacts`: The `zkey` and `wasm` [trusted setup files](/glossary/#trusted-setup-files).
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),
In the voting system use case, once all the voters have joined their [identities](/guides/identities#create-an-identity) to the ballot [group](/guides/groups),
a voter can generate a proof to vote for a proposal.
In the call to `generateProof`, the voting system passes the unique ballot ID (the [Merkle tree](/V2/glossary#merkle-tree) root of the group) as the
In the call to `generateProof`, the voting system passes the unique ballot ID (the [Merkle tree](/glossary/#merkle-tree/) root of the group) as the
`externalNullifier` to prevent the voter signaling more than once for the ballot.
The following code sample shows how to use `generateProof` to generate the voting proof:
@@ -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](/V2/glossary/#trusted-setup-files).
- _`verificationKey`_: the JavaScript object in the `semaphore.json` [trusted setup file](/glossary/#trusted-setup-files).
The following code sample shows how to parse the verification key object from `semaphore.json`
and verify the previously generated proof:

View File

@@ -58,7 +58,7 @@ Hardhat includes the Hardhat Network, a local Ethereum network for development.
## Install Semaphore packages
Semaphore provides contracts, JavaScript libraries and a Hardhat plugin for developers building zero-knowledge applications.
Semaphore provides contracts, JavaScript libraries and an 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](/V2/glossary/#trusted-setup-files).
Learn more about [trusted setup files](/glossary/#trusted-setup-files).
3. Rename the `Lock.js` test file to `Greeter.js` and replace the content with the following:

View File

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

View File

@@ -6,9 +6,9 @@ sidebar_position: 3
Semaphore includes three types of contracts:
- [**Base contracts**](/V2/technical-reference/contracts#base-contracts)
- [**Extension contracts**](/V2/technical-reference/contracts#extension-contracts)
- [**Verifiers**](/V2/technical-reference/contracts#verifiers)
- [**Base contracts**](/technical-reference/contracts#base-contracts)
- [**Extension contracts**](/technical-reference/contracts#extension-contracts)
- [**Verifiers**](/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](/V2/deployed-contracts#semaphore) to find the addresses for your network.
See our [deployed contracts](/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](/V2/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](/deployed-contracts#verifiers).
Each verifier name indicates the tree depth that it can verify.
For example, given a Semaphore proof generated with a tree depth `20`:

View File

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

View File

@@ -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](/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/).
1. [Create a Semaphore identity](/guides/identities/).
2. [Add their Semaphore identity to a group (i.e. _Merkle tree_)](/guides/groups/).
3. [Send a verifiable, anonymous signal (e.g a vote or endorsement)](/guides/proofs/).
When a user broadcasts a signal (for example: a vote), Semaphore zero-knowledge
proofs can ensure that the user has joined the group and hasn't already cast a signal with their nullifier.

View File

@@ -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 [Telegram](https://semaphore.pse.dev/telegram) o abriendo un [Semaphore Discussion](https://github.com/semaphore-protocol/semaphore/discussions).
Puede hacer preguntas sobre Semaphore en [Discord](https://semaphore.pse.dev/discord) o abriendo un [Semaphore Discussion](https://github.com/semaphore-protocol/semaphore/discussions).
## ¿Por qué las identidades requieren tanto `identity trapdoor` como `identity nullifier`?

View File

@@ -9,18 +9,18 @@ sidebar_position: 7
La identidad de un usuario en el protocolo Semaphore.
Una identidad contiene los tres valores que se mencionan a continuación:
- [Compromiso de identidad](#compromiso-de-identidad-identity-commitment) (identity commitment): el valor público.
- [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](#identidad-semaphore) utilizado en los [grupos Semaphore](#grupo-semaphore).
El valor público de la [identidad Semaphore](#semaphore-identity) utilizado en los [grupos Semaphore](#semaphore-group).
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](#á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.
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.
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](/V3/technical-reference/circuits#hash-anulador-nullifier-hash).
Ver [hash de circuito nullifier](/technical-reference/circuits/#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://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://docs.semaphore.pse.dev/whitepaper-v1.pdf, p.6).
## Archivos confiables de configuración (Trusted setup files)
@@ -58,7 +58,7 @@ Para generar o verificar pruebas válidas de conocimiento cero con Semaphore, la
- semaphore.wasm
- semaphore.json
Para ver una lista completa de archivos listos para utilizarse, vea [trusted-setup-pse.org](https://www.trusted-setup-pse.org).
Para ver una lista completa de archivos listos para utilizarse, vea <http://www.trusted-setup-pse.org>.
Para aprender más, vea la [ceremonia de configuración de confianza](https://storage.googleapis.com/trustedsetup-a86f4.appspot.com/semaphore/semaphore_top_index.html) (trusted setup ceremony).
## Señales (Signals)

View File

@@ -18,31 +18,34 @@ 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">
```bash
npm install @semaphore-protocol/data@^3
```
</TabItem>
]}>
<TabItem value="npm">
<TabItem value="yarn">
```bash
yarn add @semaphore-protocol/data@^3
```
</TabItem>
```bash
npm install @semaphore-protocol/data
```
<TabItem value="pnpm">
```bash
pnpm add @semaphore-protocol/data@^3
```
</TabItem>
</TabItem>
<TabItem value="yarn">
```bash
yarn add @semaphore-protocol/data
```
</TabItem>
<TabItem value="pnpm">
```bash
pnpm add @semaphore-protocol/data
```
</TabItem>
</Tabs>
## Obtener datos usando SemaphoreSubgraph
@@ -110,7 +113,6 @@ const semaphoreSubgraph = new SemaphoreSubgraph("sepolia")
const { members } = await semaphoreSubgraph.getGroup(groupId, { members: true })
const group = new Group(groupId, 20, members)
```
:::
## Obtener datos usando SemaphoreEthers
@@ -176,5 +178,4 @@ const semaphoreEthers = new SemaphoreEthers("sepolia")
const members = await semaphoreEthers.getGroupMembers(groupId)
const group = new Group(groupId, 20, members)
```
:::
:::

View File

@@ -8,70 +8,73 @@ import TabItem from "@theme/TabItem"
# Gupos Semaphore
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.
Un [grupo Semaphore](/glossary/#semaphore-group) contiene los [identity commitments](/glossary/#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](/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.
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.
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**](#grupos-off-chain-externos-a-la-cadena)
- [**Grupos on-chain**](#grupos-on-chain)
- [**Grupos off-chain**](#off-chain-groups)
- [**Grupos on-chain**](#on-chain-groups)
## Grupos off-chain (externos a la cadena)
- [Crear un grupo](#crear-un-grupo)
- [Añadir miembros](#añadir-miembros)
- [Remover o actualizar miembros](#remover-o-actualizar-miembros)
- [Crear un grupo](#create-a-group)
- [Añadir miembros](#add-members)
- [Remover o actualizar miembros](#remove-or-update-members)
### 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">
```bash
npm install @semaphore-protocol/group@^3
```
</TabItem>
]}>
<TabItem value="npm">
<TabItem value="yarn">
```bash
yarn add @semaphore-protocol/group@^3
```
</TabItem>
```bash
npm install @semaphore-protocol/group
```
<TabItem value="pnpm">
```bash
pnpm add @semaphore-protocol/group@^3
```
</TabItem>
</TabItem>
<TabItem value="yarn">
```bash
yarn add @semaphore-protocol/group
```
</TabItem>
<TabItem value="pnpm">
```bash
pnpm add @semaphore-protocol/group
```
</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"
@@ -79,7 +82,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"
@@ -153,4 +156,4 @@ Alternativamente, puede utilizar un contrato [`Semaphore.sol`](https://github.co
:::caution
`Semaphore.sol` incluye un mecanismo para verificar pruebas Semaphore creadas con raíces de árboles de Merkle antiguas. La duración de este mecanismo puede ser definido por el admin en la función `createGroup`. Por lo tanto, los miembros de un grupo pueden continuar generando pruebas válidas incluso después de ser removidos. Para más información ver el issue [#98](https://github.com/semaphore-protocol/semaphore/issues/98).
:::
:::

View File

@@ -8,50 +8,51 @@ import TabItem from "@theme/TabItem"
# Identidades Semaphore
Para unirse a un [grupo Semaphore](/V3/glossary#grupo-semaphore), un usuario primero deberá crear una [identidad Semaphore](/V3/glossary#identidad-semaphore).
Para unirse a un [grupo Semaphore](/glossary#semaphore-group), un usuario primero deberá crear una [identidad Semaphore](/glossary#semaphore-identity).
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**](#crear-identidades-aleatorias)
- [**Crear identidades determinísticas**](#crear-identidades-determinísticas)
- [**Crear identidades aleatorias**](#create-random-identities)
- [**Crear identidades determinísticas**](#create-deterministic-identities)
### 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">
```bash
npm install @semaphore-protocol/identity@^3
```
</TabItem>
]}>
<TabItem value="npm">
<TabItem value="yarn">
```bash
yarn add @semaphore-protocol/identity@^3
```
</TabItem>
```bash
npm install @semaphore-protocol/identity
```
</TabItem>
<TabItem value="yarn">
```bash
yarn add @semaphore-protocol/identity
```
<TabItem value="pnpm">
```bash
pnpm add @semaphore-protocol/identity@^3
```
</TabItem>
</TabItem>
<TabItem value="pnpm">
```bash
pnpm add @semaphore-protocol/identity
```
</TabItem>
</Tabs>
### Crear identidades aleatorias
@@ -66,8 +67,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
@@ -76,7 +77,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.

View File

@@ -8,61 +8,63 @@ import TabItem from "@theme/TabItem"
# Pruebas Semaphore
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:
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:
- 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)**](#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 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 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](/V3/glossary/#archivos-confiables-de-configuración-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](/glossary/#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">
```bash
npm install @semaphore-protocol/proof@^3
```
</TabItem>
]}>
<TabItem value="npm">
<TabItem value="yarn">
```bash
yarn add @semaphore-protocol/proof@^3
```
</TabItem>
```bash
npm install @semaphore-protocol/proof
```
<TabItem value="pnpm">
```bash
pnpm add @semaphore-protocol/proof@^3
```
</TabItem>
</TabItem>
<TabItem value="yarn">
```bash
yarn add @semaphore-protocol/proof
```
</TabItem>
<TabItem value="pnpm">
```bash
pnpm add @semaphore-protocol/proof
```
</TabItem>
</Tabs>
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,
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,
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](/V3/glossary/#árbol-de-merkle-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](/glossary/#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:
@@ -84,7 +86,6 @@ 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
@@ -92,8 +93,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:
@@ -107,20 +108,20 @@ await verifyProof(fullProof, 20) // verdadero o falso.
## Verificar una prueba on-chain
Utilice el contrato [`Semaphore.sol`](/V3/technical-reference/contracts#semaphoresol) para verificar pruebas on-chain.
Utilice el contrato [`Semaphore.sol`](/technical-reference/contracts#semaphoresol) para verificar pruebas on-chain.
:::info
Vea nuestros [contratos desplegados](/V3/deployed-contracts) para encontrar las direcciones adecuadas para su red.
Vea nuestros [contratos desplegados](/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 (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.
- `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).
:::info
Puede importar `ISemaphore.sol` y otros contratos Semaphore del módulo NPM [`@semaphore-protocol/contracts`](https://github.com/semaphore-protocol/semaphore/tree/main/packages/contracts).

View File

@@ -10,13 +10,13 @@ import TabItem from "@theme/TabItem"
Semaphore ofrece un CLI oficial para configurar su proyecto con Hardhat. Si su NPM es versión 5.2 or más reciente puede utilizar NPX:
```bash
npx @semaphore-protocol/cli@^3 create my-app --template monorepo-ethers
npx @semaphore-protocol/cli@latest create my-app --template monorepo-ethers
```
De lo contrario, instale `@semaphore-protocol/cli@^3` de forma global y corra el comando `init`:
De lo contrario, instale `@semaphore-protocol/cli` de forma global y corra el comando `init`:
```bash
npm i -g @semaphore-protocol/cli@^3
npm i -g @semaphore-protocol/cli@latest
semaphore create my-app --template monorepo-ethers
```
@@ -31,34 +31,37 @@ 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">
```bash
cd my-app
npm i
```
</TabItem>
]}>
<TabItem value="npm">
<TabItem value="yarn">
```bash
cd my-app
yarn
```
</TabItem>
```bash
cd my-app
npm i
```
<TabItem value="pnpm">
```bash
cd my-app
pnpm install
```
</TabItem>
</TabItem>
<TabItem value="yarn">
```bash
cd my-app
yarn
```
</TabItem>
<TabItem value="pnpm">
```bash
cd my-app
pnpm install
```
</TabItem>
</Tabs>
## Output
@@ -113,31 +116,34 @@ 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">
```bash
npm run compile
```
</TabItem>
]}>
<TabItem value="npm">
<TabItem value="yarn">
```bash
yarn compile
```
</TabItem>
```bash
npm run compile
```
<TabItem value="pnpm">
```bash
pnpm compile
```
</TabItem>
</TabItem>
<TabItem value="yarn">
```bash
yarn compile
```
</TabItem>
<TabItem value="pnpm">
```bash
pnpm compile
```
</TabItem>
</Tabs>
### Pruebe los contratos
@@ -145,91 +151,100 @@ Y compile sus contratos al correr:
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">
```bash
npm test
```
</TabItem>
]}>
<TabItem value="npm">
<TabItem value="yarn">
```bash
yarn test
```
</TabItem>
```bash
npm test
```
<TabItem value="pnpm">
```bash
pnpm test
```
</TabItem>
</TabItem>
<TabItem value="yarn">
```bash
yarn 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">
```bash
npm run test:coverage
```
</TabItem>
]}>
<TabItem value="npm">
<TabItem value="yarn">
```bash
yarn test:coverage
```
</TabItem>
```bash
npm run test:coverage
```
<TabItem value="pnpm">
```bash
pnpm test:coverage
```
</TabItem>
</TabItem>
<TabItem value="yarn">
```bash
yarn 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">
```bash
npm run test:report-gas
```
</TabItem>
]}>
<TabItem value="npm">
<TabItem value="yarn">
```bash
yarn test:report-gas
```
</TabItem>
```bash
npm run test:report-gas
```
<TabItem value="pnpm">
```bash
pnpm test:report-gas
```
</TabItem>
</TabItem>
<TabItem value="yarn">
```bash
yarn test:report-gas
```
</TabItem>
<TabItem value="pnpm">
```bash
pnpm test:report-gas
```
</TabItem>
</Tabs>
### Desplegar contratos
@@ -240,76 +255,82 @@ 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">
```bash
npm run deploy -- --semaphore <semaphore-address> --group <group-id> --network goerli
```
</TabItem>
]}>
<TabItem value="npm">
<TabItem value="yarn">
```bash
yarn deploy --semaphore <semaphore-address> --group <group-id> --network goerli
```
</TabItem>
```bash
npm run deploy -- --semaphore <semaphore-address> --group <group-id> --network goerli
```
<TabItem value="pnpm">
```bash
pnpm deploy --semaphore <semaphore-address> --group <group-id> --network goerli
```
</TabItem>
</Tabs>
</TabItem>
<TabItem value="yarn">
:::note
Revise las direcciones de los contratos de Semaphore [aquí](/V3/deployed-contracts).
:::
```bash
yarn deploy --semaphore <semaphore-address> --group <group-id> --network goerli
```
:::caution
El group id (id del grupo) es un número.
:::
</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.
:::
### 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">
```bash
npm run dev
```
</TabItem>
]}>
<TabItem value="npm">
<TabItem value="yarn">
```bash
yarn dev
```
</TabItem>
```bash
npm run dev
```
<TabItem value="pnpm">
```bash
pnpm dev
```
</TabItem>
</Tabs>
</TabItem>
<TabItem value="yarn">
```bash
yarn dev
```
</TabItem>
<TabItem value="pnpm">
```bash
pnpm dev
```
</TabItem>
</Tabs>

View File

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

View File

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

View File

@@ -6,10 +6,10 @@ sidebar_position: 3
Semaphore incluye dos tipos de contratos:
- [**Contratos base**](#contratos-base)
- [**Contratos para la extensión**](#contratos-para-la-extensión)
- [**Contratos base**](/technical-reference/contracts#base-contracts)
- [**Contratos para la extensión**](/technical-reference/contracts#extension-contracts)
así como [**Semaphore.sol**](#semaphoresol), el principal contrato desplegado en las redes soportadas por Semaphore.
así como [**Semaphore.sol**](/technical-reference/contracts#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).
@@ -19,11 +19,11 @@ Para utilizar los contratos e interfaces Semaphore en su proyecto, instale el pa
Semaphore ofrece los siguientes contratos base:
- [`SemaphoreVerifier.sol`](https://github.com/semaphore-protocol/semaphore/blob/v3.15.2/packages/contracts/contracts/base/SemaphoreVerifier.sol): contiene una función para verificar pruebas Semaphore;
- [`SemaphoreVerifier.sol`](https://github.com/semaphore-protocol/semaphore/blob/main/packages/contracts/base/SemaphoreVerifier.sol): contiene una función para verificar pruebas Semaphore;
- [`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**](/V3/technical-reference/contracts#semaphoresol) que ya los tiene integrados.
Puede utilizarlos en su contrato o puede utilizar [**Semaphore.sol**](/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](/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 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 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](/V3/deployed-contracts) puede encontrar las direcciones correspondientes a su red.
Visitando [contratos desplegados](/deployed-contracts) puede encontrar las direcciones correspondientes a su red.
::::

View File

@@ -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 [Semaphore Telegram](https://semaphore.pse.dev/telegram).
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).
## Usando Semaphore en the frontend
@@ -70,59 +70,65 @@ 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">
```bash
npm install @esbuild-plugins/node-globals-polyfill
```
</TabItem>
]}>
<TabItem value="npm">
<TabItem value="yarn">
```bash
yarn add @esbuild-plugins/node-globals-polyfill
```
</TabItem>
```bash
npm install @esbuild-plugins/node-globals-polyfill
```
<TabItem value="pnpm">
```bash
pnpm 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>
</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">
```bash
npm install @esbuild-plugins/node-modules-polyfill
```
</TabItem>
]}>
<TabItem value="npm">
<TabItem value="yarn">
```bash
yarn add @esbuild-plugins/node-modules-polyfill
```
</TabItem>
```bash
npm install @esbuild-plugins/node-modules-polyfill
```
<TabItem value="pnpm">
```bash
pnpm 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>
</Tabs>
2- Modifique `vite.config.ts` para añadirlos:
@@ -230,4 +236,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.

View File

@@ -15,9 +15,9 @@ Algunos de los potenciales casos de uso son: votaciones, denuncias, DAOs anónim
Con Semaphore puede permitir que sus usuarios realicen las siguientes acciones:
1. [Crear una identidad Semaphore](/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/).
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/).
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](/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).
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).
### Auditorías

View File

@@ -1,45 +1,39 @@
{
"name": "semaphore-docs",
"version": "2.0.0",
"private": true,
"scripts": {
"start": "docusaurus start",
"start:es": "docusaurus start --locale es",
"pre-build": "yarn workspace @semaphore-protocol/utils build",
"build": "yarn pre-build && docusaurus build",
"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",
"format": "remark ./**/*.mdx --frail --quiet",
"format:write": "remark ./**/*.mdx --output"
"write-heading-ids": "docusaurus write-heading-ids"
},
"dependencies": {
"@docusaurus/core": "3.5.2",
"@docusaurus/preset-classic": "3.5.2",
"@mdx-js/react": "^3.0.0",
"@semaphore-protocol/utils": "4.12.1",
"@docusaurus/core": "2.2.0",
"@docusaurus/preset-classic": "2.2.0",
"@mdx-js/react": "^1.6.22",
"@svgr/webpack": "^5.5.0",
"clsx": "^1.2.1",
"docusaurus-plugin-sass": "^0.2.5",
"docusaurus-plugin-sass": "^0.2.2",
"file-loader": "^6.2.0",
"prism-react-renderer": "^2.1.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"prism-react-renderer": "^1.3.5",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"sass": "^1.52.3",
"url-loader": "^4.1.1"
},
"devDependencies": {
"@docusaurus/module-type-aliases": "3.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"
"@docusaurus/module-type-aliases": "2.2.0",
"@tsconfig/docusaurus": "^1.0.6",
"@types/react": "^17.0.14",
"@types/react-helmet": "^6.1.2",
"@types/react-router-dom": "^5.1.8",
"typescript": "^4.3.5"
},
"browserslist": {
"production": [
@@ -52,25 +46,5 @@
"last 1 firefox version",
"last 1 safari version"
]
},
"engines": {
"node": ">=18.0"
},
"remarkConfig": {
"settings": {
"bullet": "-"
},
"plugins": [
"remark-mdx",
"remark-preset-lint-consistent",
"remark-preset-lint-recommended",
[
"remark-frontmatter",
{
"type": "yaml",
"marker": "-"
}
]
]
}
}

View File

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

View File

@@ -1,32 +0,0 @@
import { deployedContracts, supportedNetworks } from "@semaphore-protocol/utils"
import Heading from "@theme/Heading"
function capitalizeFirstLetter(s: string): string {
return s.charAt(0).toUpperCase() + s.slice(1)
}
export default function DeployedContracts() {
return (
<div>
{deployedContracts.map(({ network, contracts }) => (
<div key={network}>
<Heading as="h2">{capitalizeFirstLetter(network)}</Heading>
<ul>
{contracts.map(({ name, address }) => (
<li key={address}>
{name}:{" "}
<a
href={`${supportedNetworks[network].explorer}/address/${address}`}
target="_blank"
rel="noreferrer"
>
{address}
</a>
</li>
))}
</ul>
</div>
))}
</div>
)
}

View File

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

View File

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

View File

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

View File

@@ -32,7 +32,7 @@ function Footer() {
id: "footer.right.connect.title"
})}
</h3>
<Link href="https://semaphore.pse.dev/telegram" target="_blank">
<Link href="https://semaphore.pse.dev/discord" target="_blank">
{translate({
id: "footer.right.connect.link1"
})}
@@ -54,7 +54,11 @@ function Footer() {
<hr />
<div>
<p>Copyright © {new Date().getFullYear()} Ethereum Foundation</p>
<p>
{translate({
id: "footer.copyright"
})}
</p>
<Logo
style={{ marginRight: -8 }}

View File

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

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 190 KiB

View File

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

View File

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

View File

@@ -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/semaphore-protocol/semaphore/blob/main/apps/docs/versioned_docs/version-V1/audit.md). After three
[here](https://github.com/appliedzkp/semaphore/tree/master/audit). After three
rounds of fixes, all security and performance issues were fixed, and the few
remaining issues are minor and do not affect security.

View File

@@ -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 nullifiers
## Add, deactivate, or reactivate external nullifiiers
**Contract ABI**:

View File

@@ -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, which is a random 32-byte value.
3. An identity trapdoor, which is a random 32-byte value.
2. An identity nullifier, whih is a random 32-byte value.
3. An identity trapdoor, whih 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 commitments for the identity
Semaphore uses MiMC for the Merkle tree, Pedersen commmitments 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

View File

@@ -145,7 +145,7 @@ Returns `false` otherwise.
**`signMsg(privKey: EddsaPrivateKey, msg: SnarkBigInt): EdDSAMiMcSpongeSignature)`**
Encapsulates `circomlib.eddsa.signMiMCSponge` to sign a message `msg` using private key `privKey`.
Encapsualtes `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 commitments; i.e. the
- `idCommitments` is an array of registered identity commmitments; 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 commitment
- `identityPath`: The Merkle path to the identity commmitment
- `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.

View File

@@ -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 nullifiers
## Add, deactivate, or reactivate external nullifiiers
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

View File

@@ -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 at the same booth, that vote is
one vote. If they try to cast a second vote a 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 arbitrary response (e.g. yes, no, or maybe)
This allows any user to vote with an arbitary 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
Solidity, and zk-SNARK circuits written in
Soliidty, and zk-SNARK circuits written in
[circom](https://github.com/iden3/circom). It also contains Typescript code to
execute tests.

View File

@@ -40,7 +40,7 @@ For more information, see [Merkle tree in Wikipedia](https://en.wikipedia.org/wi
A value used to prevent double entry or double signalling.
See [Circuit nullifier hash](/V2/technical-reference/circuits/#nullifier-hash).
See [Circuit nullifier hash](/technical-reference/circuits/#nullifier-hash).
## Relay
@@ -48,7 +48,7 @@ A third-party who receives a fee for including relayed transactions in the block
To preserve the anonymity of the user broadcasting a signal with Semaphore, an application may use a relayer to post the signal transaction to Ethereum on behalf of the user.
Applications may provide rewards for relayers and implement front-running prevention mechanisms, such as requiring the signals to include the relayers address, binding the
signal to that specific address (https://semaphore.pse.dev/whitepaper-v1.pdf, p.6).
signal to that specific address (https://docs.semaphore.pse.dev/whitepaper-v1.pdf, p.6).
## Trusted setup files
@@ -60,5 +60,5 @@ To generate or verify valid zero-knowledge proofs with Semaphore, applications m
- semaphore.wasm
- semaphore.json
For a complete list of ready-to-use files, see [trusted-setup-pse.org](https://www.trusted-setup-pse.org).
For a complete list of ready-to-use files, see <http://www.trusted-setup-pse.org>.
To learn more, see the [trusted setup ceremony](https://storage.googleapis.com/trustedsetup-a86f4.appspot.com/semaphore/semaphore_top_index.html).

View File

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

View File

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

View File

@@ -7,7 +7,7 @@ title: Proofs
Learn how to use Semaphore to generate and verify zero-knowledge proofs.
Once a user joins their [Semaphore identity](/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:
Once a user joins their [Semaphore identity](/glossary#semaphore-identity) to a [Semaphore group](/glossary#semaphore-group), the user can signal anonymously with a zero-knowledge proof that proves the following:
- The user is a member of the group.
- The same user created the signal and the proof.
@@ -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](/V2/glossary/#trusted-setup-files).
- `snarkArtifacts`: The `zkey` and `wasm` [trusted setup files](/glossary/#trusted-setup-files).
In the voting system use case, once all the voters have joined their [identities](/guides/identities#create-identities) to the ballot [group](/guides/groups),
In the voting system use case, once all the voters have joined their [identities](/guides/identities#create-an-identity) to the ballot [group](/guides/groups),
a voter can generate a proof to vote for a proposal.
In the call to `generateProof`, the voting system passes the unique ballot ID (the [Merkle tree](/V2/glossary/#merkle-tree) root of the group) as the
In the call to `generateProof`, the voting system passes the unique ballot ID (the [Merkle tree](/glossary/#merkle-tree/) root of the group) as the
`externalNullifier` to prevent the voter signaling more than once for the ballot.
The following code sample shows how to use `generateProof` to generate the voting proof:
@@ -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](/V2/glossary/#trusted-setup-files).
- _`verificationKey`_: the JavaScript object in the `semaphore.json` [trusted setup file](/glossary/#trusted-setup-files).
The following code sample shows how to parse the verification key object from `semaphore.json`
and verify the previously generated proof:

View File

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

View File

@@ -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 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.
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.
:::
## Schema

View File

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

View File

@@ -6,9 +6,9 @@ sidebar_position: 3
Semaphore includes three types of contracts:
- [**Base contracts**](/V2/technical-reference/contracts#base-contracts)
- [**Extension contracts**](/V2/technical-reference/contracts#extension-contracts)
- [**Verifiers**](/V2/technical-reference/contracts#verifiers)
- [**Base contracts**](/technical-reference/contracts#base-contracts)
- [**Extension contracts**](/technical-reference/contracts#extension-contracts)
- [**Verifiers**](/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](/V2/deployed-contracts#semaphore) to find the addresses for your network.
See our [deployed contracts](/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](/V2/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](/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](/V2/guides/groups) used for the proof can have a maximum `2^20=1048576` members.
- The [group](/guides/groups) used for the proof can have a maximum `2^20=1048576` members.

View File

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

View File

@@ -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](/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/).
1. [Create a Semaphore identity](/guides/identities/).
2. [Add their Semaphore identity to a group (i.e. _Merkle tree_)](/guides/groups/).
3. [Send a verifiable, anonymous signal (e.g a vote or endorsement)](/guides/proofs/).
When a user broadcasts a signal (for example: a vote), Semaphore zero-knowledge
proofs can ensure that the user has joined the group and hasn't already cast a signal with their nullifier.

View File

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

View File

@@ -37,9 +37,9 @@ For more information, see [Merkle tree in Wikipedia](https://en.wikipedia.org/wi
## Nullifier
A value used to prevent double entry or double signaling.
A value used to prevent double entry or double signalling.
See [Circuit nullifier hash](/V3/technical-reference/circuits/#nullifier-hash).
See [Circuit nullifier hash](/technical-reference/circuits/#nullifier-hash).
## Relay
@@ -47,7 +47,7 @@ A third-party who receives a fee for including relayed transactions in the block
To preserve the anonymity of the user broadcasting a signal with Semaphore, an application may use a relayer to post the signal transaction to Ethereum on behalf of the user.
Applications may provide rewards for relayers and implement front-running prevention mechanisms, such as requiring the signals to include the relayers address, binding the
signal to that specific address (https://semaphore.pse.dev/whitepaper-v1.pdf, p.6).
signal to that specific address (https://docs.semaphore.pse.dev/whitepaper-v1.pdf, p.6).
## Trusted setup files
@@ -59,7 +59,7 @@ To generate or verify valid zero-knowledge proofs with Semaphore, applications m
- semaphore.wasm
- semaphore.json
For a complete list of ready-to-use files, see [trusted-setup-pse.org](https://www.trusted-setup-pse.org).
For a complete list of ready-to-use files, see <http://www.trusted-setup-pse.org>.
To learn more, see the [trusted setup ceremony](https://storage.googleapis.com/trustedsetup-a86f4.appspot.com/semaphore/semaphore_top_index.html).
## Signals

View File

@@ -8,9 +8,9 @@ import TabItem from "@theme/TabItem"
# Semaphore data
To fetch on-chain data from the [Semaphore.sol](https://github.com/semaphore-protocol/semaphore/blob/v3.15.2/packages/contracts/contracts/Semaphore.sol) contract, you can use the [@semaphore-protocol/data](https://github.com/semaphore-protocol/semaphore/tree/v3.15.2/packages/data) library.
To fetch on-chain data from the [Semaphore.sol](https://github.com/semaphore-protocol/semaphore/blob/main/packages/contracts/contracts/Semaphore.sol) contract, you can use the [@semaphore-protocol/data](https://github.com/semaphore-protocol/semaphore/tree/main/packages/data) library.
There are two ways to do this, using [`SemaphoreSubgraph`](https://github.com/semaphore-protocol/semaphore/blob/v3.15.2/packages/data/src/subgraph.ts) or [`SemaphoreEthers`](https://github.com/semaphore-protocol/semaphore/blob/v3.15.2/packages/data/src/ethers.ts). The `SemaphoreSubgraph` class uses the [Semaphore subgraph](https://github.com/semaphore-protocol/subgraph), which uses [The Graph Protocol](https://thegraph.com/) under the hood, and the `SemaphoreEthers` class uses [Ethers](https://github.com/ethers-io/ethers.js/).
There are two ways to do this, using [`SemaphoreSubgraph`](https://github.com/semaphore-protocol/semaphore/blob/main/packages/data/src/subgraph.ts) or [`SemaphoreEthers`](https://github.com/semaphore-protocol/semaphore/blob/main/packages/data/src/ethers.ts). The `SemaphoreSubgraph` class uses the [Semaphore subgraph](https://github.com/semaphore-protocol/subgraph), which uses [The Graph Protocol](https://thegraph.com/) under the hood, and the `SemaphoreEthers` class uses [Ethers](https://github.com/ethers-io/ethers.js/).
- [**Fetch data using SemaphoreSubgraph**](#fetch-data-using-semaphoresubgraph)
- [**Fetch data using SemaphoreEthers**](#fetch-data-using-semaphoreethers)
@@ -18,36 +18,39 @@ 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">
```bash
npm install @semaphore-protocol/data@^3
```
</TabItem>
]}>
<TabItem value="npm">
<TabItem value="yarn">
```bash
yarn add @semaphore-protocol/data@^3
```
</TabItem>
```bash
npm install @semaphore-protocol/data
```
<TabItem value="pnpm">
```bash
pnpm add @semaphore-protocol/data@^3
```
</TabItem>
</TabItem>
<TabItem value="yarn">
```bash
yarn add @semaphore-protocol/data
```
</TabItem>
<TabItem value="pnpm">
```bash
pnpm add @semaphore-protocol/data
```
</TabItem>
</Tabs>
## Fetch data using SemaphoreSubgraph
To fetch data using the Semaphore subgraph you can use the [`SemaphoreSubgraph`](https://github.com/semaphore-protocol/semaphore/blob/v3.15.2/packages/data/src/subgraph.ts) class from the [@semaphore-protocol/data](https://github.com/semaphore-protocol/semaphore/tree/v3.15.2/packages/data) package.
To fetch data using the Semaphore subgraph you can use the [`SemaphoreSubgraph`](https://github.com/semaphore-protocol/semaphore/blob/main/packages/data/src/subgraph.ts) class from the [@semaphore-protocol/data](https://github.com/semaphore-protocol/semaphore/tree/main/packages/data) package.
```typescript
import { SemaphoreSubgraph } from "@semaphore-protocol/data"
@@ -110,12 +113,11 @@ const semaphoreSubgraph = new SemaphoreSubgraph("sepolia")
const { members } = await semaphoreSubgraph.getGroup(groupId, { members: true })
const group = new Group(groupId, 20, members)
```
:::
## Fetch data using SemaphoreEthers
To fetch data using Ethers you can use the [`SemaphoreEthers`](https://github.com/semaphore-protocol/semaphore/blob/v3.15.2/packages/data/src/ethers.ts) class from the [@semaphore-protocol/data](https://github.com/semaphore-protocol/semaphore/tree/v3.15.2/packages/data) package.
To fetch data using Ethers you can use the [`SemaphoreEthers`](https://github.com/semaphore-protocol/semaphore/blob/main/packages/data/src/ethers.ts) class from the [@semaphore-protocol/data](https://github.com/semaphore-protocol/semaphore/tree/main/packages/data) package.
```typescript
import { SemaphoreEthers } from "@semaphore-protocol/data"
@@ -176,5 +178,4 @@ const semaphoreEthers = new SemaphoreEthers("sepolia")
const members = await semaphoreEthers.getGroupMembers(groupId)
const group = new Group(groupId, 20, members)
```
:::
:::

View File

@@ -8,70 +8,73 @@ import TabItem from "@theme/TabItem"
# Semaphore groups
A [Semaphore group](/V3/glossary/#semaphore-group) contains [identity commitments](/V3/glossary/#identity-commitment) of group members.
A [Semaphore group](/glossary/#semaphore-group) contains [identity commitments](/glossary/#identity-commitment) of group members.
Example uses of groups include the following:
- poll question that attendees join to rate an event,
- ballot that members join to vote on a proposal,
- whistleblowers who are verified employees of an organization.
- 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/#merkle-tree), and group members (i.e., [identity commitments](/V3/glossary/#identity-commitment)) are tree leaves.
A Semaphore group is an [incremental Merkle tree](/glossary/#incremental-merkle-tree), and group members (i.e., [identity commitments](/glossary/#identity-commitments)) are tree leaves.
Semaphore groups set the following three parameters:
- **Group id**: a unique identifier for the group;
- **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:
Use the [`@semaphore-protocol/group`](https://github.com/semaphore-protocol/semaphore/blob/main/packages/group) library `Group` class to create an off-chain group with the following parameters:
- `Group id`: a unique identifier for the group;
- `Tree depth`: (*default `20`*) the maximum number of members a group can contain (`max size = 2 ^ tree depth`).
- `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">
```bash
npm install @semaphore-protocol/group@^3
```
</TabItem>
]}>
<TabItem value="npm">
<TabItem value="yarn">
```bash
yarn add @semaphore-protocol/group@^3
```
</TabItem>
```bash
npm install @semaphore-protocol/group
```
<TabItem value="pnpm">
```bash
pnpm add @semaphore-protocol/group@^3
```
</TabItem>
</TabItem>
<TabItem value="yarn">
```bash
yarn add @semaphore-protocol/group
```
</TabItem>
<TabItem value="pnpm">
```bash
pnpm add @semaphore-protocol/group
```
</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"
@@ -79,7 +82,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"
@@ -139,13 +142,13 @@ Given that the node isn't removed, and the length of the `group.members` array d
## On-chain groups
The [`SemaphoreGroups`](https://github.com/semaphore-protocol/semaphore/blob/v3.15.2/packages/contracts/contracts/base/SemaphoreGroups.sol) contract uses the [`IncrementalBinaryTree`](https://github.com/privacy-scaling-explorations/zk-kit/blob/main/packages/incremental-merkle-tree.sol/contracts/IncrementalBinaryTree.sol) library and provides methods to create and manage groups.
The [`SemaphoreGroups`](https://github.com/semaphore-protocol/semaphore/blob/main/packages/contracts/contracts/base/SemaphoreGroups.sol) contract uses the [`IncrementalBinaryTree`](https://github.com/privacy-scaling-explorations/zk-kit/blob/main/packages/incremental-merkle-tree.sol/contracts/IncrementalBinaryTree.sol) library and provides methods to create and manage groups.
:::info
You can import `SemaphoreGroups.sol` and other Semaphore contracts from the [`@semaphore-protocol/contracts`](https://github.com/semaphore-protocol/semaphore/tree/v3.15.2/packages/contracts) NPM module.
You can import `SemaphoreGroups.sol` and other Semaphore contracts from the [`@semaphore-protocol/contracts`](https://github.com/semaphore-protocol/semaphore/tree/main/packages/contracts) NPM module.
:::
Alternatively, you can use an already deployed [`Semaphore.sol`](https://github.com/semaphore-protocol/semaphore/blob/v3.15.2/packages/contracts/contracts/Semaphore.sol) contract and use its group external functions.
Alternatively, you can use an already deployed [`Semaphore.sol`](https://github.com/semaphore-protocol/semaphore/blob/main/packages/contracts/contracts/Semaphore.sol) contract and use its group external functions.
:::caution
`Semaphore.sol` does not check if a member with a specific identity commitment already exists in a group. This check must be done off-chain.
@@ -153,4 +156,4 @@ Alternatively, you can use an already deployed [`Semaphore.sol`](https://github.
:::caution
`Semaphore.sol` includes a mechanism to verify Semaphore proofs created with old Merkle tree roots, the duration of which can be defined by the admin in the `createGroup` function. Members of a group could then continue to generate valid proofs even after being removed. For more info see the issue [#98](https://github.com/semaphore-protocol/semaphore/issues/98).
:::
:::

View File

@@ -8,50 +8,53 @@ import TabItem from "@theme/TabItem"
# Semaphore identities
In order to join a [Semaphore group](/V3/glossary#semaphore-group), a user must first create a [Semaphore identity](/V3/glossary#semaphore-identity).
In order to join a [Semaphore group](/glossary#semaphore-group), a user must first create a [Semaphore identity](/glossary#semaphore-identity).
A Semaphore identity contains two values generated with the identity:
- Identity trapdoor
- 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/main/packages/identity) library to create a Semaphore identity _deterministically_ (from the hash of a message) or _randomly_.
- [**Create random identities**](#create-random-identities)
- [**Create deterministic identities**](#create-deterministic-identities)
- [**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">
```bash
npm install @semaphore-protocol/identity@^3
```
</TabItem>
]}>
<TabItem value="npm">
<TabItem value="yarn">
```bash
yarn add @semaphore-protocol/identity@^3
```
</TabItem>
```bash
npm install @semaphore-protocol/identity
```
<TabItem value="pnpm">
```bash
pnpm add @semaphore-protocol/identity@^3
```
</TabItem>
</TabItem>
<TabItem value="yarn">
```bash
yarn add @semaphore-protocol/identity
```
</TabItem>
<TabItem value="pnpm">
```bash
pnpm add @semaphore-protocol/identity
```
</TabItem>
</Tabs>
### Create random identities
@@ -66,8 +69,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
@@ -76,7 +79,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.
@@ -113,4 +116,4 @@ To reuse the saved identity, pass the JSON to the `Identity()` constructor.
```ts
const identity2 = new Identity(identity.toString())
```
```

View File

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

View File

@@ -10,55 +10,58 @@ import TabItem from "@theme/TabItem"
Semaphore provides an official CLI to set up your project with Hardhat. If your NPM version is 5.2 or higher you can use NPX:
```bash
npx @semaphore-protocol/cli@^3 create my-app --template monorepo-ethers
npx @semaphore-protocol/cli@latest create my-app --template monorepo-ethers
```
Otherwise, install `@semaphore-protocol/cli@^3` globally and run the `create` command:
Otherwise, install `@semaphore-protocol/cli` globally and run the `create` command:
```bash
npm i -g @semaphore-protocol/cli@^3
npm i -g @semaphore-protocol/cli@latest
semaphore create my-app --template monorepo-ethers
```
:::info
The supported templates are: [`contracts-hardhat`](https://github.com/semaphore-protocol/semaphore/tree/v3.15.2/packages/cli-template-contracts-hardhat), [`monorepo-ethers`](https://github.com/semaphore-protocol/semaphore/tree/v3.15.2/packages/cli-template-monorepo-ethers), [`monorepo-subgraph`](https://github.com/semaphore-protocol/semaphore/tree/v3.15.2/packages/cli-template-monorepo-subgraph).
The supported templates are: [`contracts-hardhat`](https://github.com/semaphore-protocol/semaphore/tree/main/packages/cli-template-contracts-hardhat), [`monorepo-ethers`](https://github.com/semaphore-protocol/semaphore/tree/main/packages/cli-template-monorepo-ethers), [`monorepo-subgraph`](https://github.com/semaphore-protocol/semaphore/tree/main/packages/cli-template-monorepo-subgraph).
:::
:::info
The [`semaphore CLI`](https://github.com/semaphore-protocol/semaphore/tree/v3.15.2/packages/cli) can also be used to get group data from a supported network (e.g `semaphore get-groups --network arbitrum-goerli`).
The [`semaphore CLI`](https://github.com/semaphore-protocol/semaphore/tree/main/packages/cli) can also be used to get group data from a supported network (e.g `semaphore get-groups --network arbitrum-goerli`).
:::
To start working on your project, install the dependencies:
<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">
```bash
cd my-app
npm i
```
</TabItem>
]}>
<TabItem value="npm">
<TabItem value="yarn">
```bash
cd my-app
yarn
```
</TabItem>
```bash
cd my-app
npm i
```
<TabItem value="pnpm">
```bash
cd my-app
pnpm install
```
</TabItem>
</TabItem>
<TabItem value="yarn">
```bash
cd my-app
yarn
```
</TabItem>
<TabItem value="pnpm">
```bash
cd my-app
pnpm install
```
</TabItem>
</Tabs>
## Output
@@ -113,31 +116,34 @@ 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">
```bash
npm run compile
```
</TabItem>
]}>
<TabItem value="npm">
<TabItem value="yarn">
```bash
yarn compile
```
</TabItem>
```bash
npm run compile
```
<TabItem value="pnpm">
```bash
pnpm compile
```
</TabItem>
</TabItem>
<TabItem value="yarn">
```bash
yarn compile
```
</TabItem>
<TabItem value="pnpm">
```bash
pnpm compile
```
</TabItem>
</Tabs>
### Test contracts
@@ -145,91 +151,100 @@ And compile your contracts:
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">
```bash
npm test
```
</TabItem>
]}>
<TabItem value="npm">
<TabItem value="yarn">
```bash
yarn test
```
</TabItem>
```bash
npm test
```
<TabItem value="pnpm">
```bash
pnpm test
```
</TabItem>
</TabItem>
<TabItem value="yarn">
```bash
yarn test
```
</TabItem>
<TabItem value="pnpm">
```bash
pnpm test
```
</TabItem>
</Tabs>
Generate a test coverage report:
<Tabs
defaultValue="npm"
groupId="package-managers"
values={[
defaultValue="npm"
groupId="package-managers"
values={[
{label: 'npm', value: 'npm'},
{label: 'Yarn', value: 'yarn'},
{label: 'pnpm', value: 'pnpm'}
]}
>
<TabItem value="npm">
```bash
npm run test:coverage
```
</TabItem>
]}>
<TabItem value="npm">
<TabItem value="yarn">
```bash
yarn test:coverage
```
</TabItem>
```bash
npm run test:coverage
```
<TabItem value="pnpm">
```bash
pnpm test:coverage
```
</TabItem>
</TabItem>
<TabItem value="yarn">
```bash
yarn test:coverage
```
</TabItem>
<TabItem value="pnpm">
```bash
pnpm test:coverage
```
</TabItem>
</Tabs>
Or a test gas report:
<Tabs
defaultValue="npm"
groupId="package-managers"
values={[
defaultValue="npm"
groupId="package-managers"
values={[
{label: 'npm', value: 'npm'},
{label: 'Yarn', value: 'yarn'},
{label: 'pnpm', value: 'pnpm'}
]}
>
<TabItem value="npm">
```bash
npm run test:report-gas
```
</TabItem>
]}>
<TabItem value="npm">
<TabItem value="yarn">
```bash
yarn test:report-gas
```
</TabItem>
```bash
npm run test:report-gas
```
<TabItem value="pnpm">
```bash
pnpm test:report-gas
```
</TabItem>
</TabItem>
<TabItem value="yarn">
```bash
yarn test:report-gas
```
</TabItem>
<TabItem value="pnpm">
```bash
pnpm test:report-gas
```
</TabItem>
</Tabs>
### Deploy contracts
@@ -240,76 +255,82 @@ 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">
```bash
npm run deploy -- --semaphore <semaphore-address> --group <group-id> --network arbitrum-goerli
```
</TabItem>
]}>
<TabItem value="npm">
<TabItem value="yarn">
```bash
yarn 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="pnpm">
```bash
pnpm deploy --semaphore <semaphore-address> --group <group-id> --network arbitrum-goerli
```
</TabItem>
</Tabs>
</TabItem>
<TabItem value="yarn">
:::note
Check the Semaphore contract addresses [here](/V3/deployed-contracts).
:::
```bash
yarn deploy --semaphore <semaphore-address> --group <group-id> --network arbitrum-goerli
```
:::caution
The group id is a number.
:::
</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](/deployed-contracts).
:::
:::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">
```bash
npm run dev
```
</TabItem>
]}>
<TabItem value="npm">
<TabItem value="yarn">
```bash
yarn dev
```
</TabItem>
```bash
npm run dev
```
<TabItem value="pnpm">
```bash
pnpm dev
```
</TabItem>
</Tabs>
</TabItem>
<TabItem value="yarn">
```bash
yarn dev
```
</TabItem>
<TabItem value="pnpm">
```bash
pnpm dev
```
</TabItem>
</Tabs>

View File

@@ -6,7 +6,7 @@ sidebar_position: 9
## Articles
[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
[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
[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

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