Compare commits

..

103 Commits

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

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

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

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

re #717


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


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


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

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


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


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

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

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

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

re #688


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


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


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

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

re #686


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

re #712


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


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


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


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


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


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


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

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

re #690


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

re #713


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

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

re #713


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

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

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

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

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


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


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


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

re #642, #641


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

re #700


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

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


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


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

re #683


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

re #683


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

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


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

re #708


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

re #704


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

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

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

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


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

re #682


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

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

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


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


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


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


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

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

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

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


Former-commit-id: 09c842f9dc
2024-03-12 21:59:48 +01:00
zkFriendly
4a0ea1201c refactor(contracts): use returned new merkle tree root instead of calling getMerkleTreeRoot
Former-commit-id: f06ddd32e4
2024-03-12 16:41:15 +01:00
zkFriendly
634c2b11e6 refactor(contracts): return new merkle tree root after modifying group members
Former-commit-id: 7e2c208efd
2024-03-12 16:39:17 +01:00
179 changed files with 33911 additions and 1833 deletions

21
.commitlintrc.js Normal file
View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

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

File diff suppressed because one or more lines are too long

View File

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

View File

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

View File

@@ -34,7 +34,9 @@
<a href="https://www.gitpoap.io/gh/semaphore-protocol/semaphore" target="_blank">
<img src="https://public-api.gitpoap.io/v1/repo/semaphore-protocol/semaphore/badge">
</a>
<a href="http://commitizen.github.io/cz-cli/">
<img alt="Commitizen friendly" src="https://img.shields.io/badge/commitizen-friendly-586D76?style=flat-square">
</a>
</p>
<div align="center">
@@ -57,10 +59,10 @@
</h4>
</div>
| Semaphore is a protocol, designed to be a simple and generic privacy layer for Ethereum DApps. Using zero knowledge, Ethereum users can prove their membership of a group and send signals such as votes or endorsements without revealing their original identity. |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Semaphore is a generic privacy layer. Leveraging zero-knowledge technology, users can prove their membership in groups and send messages (extending from votes to endorsements) off-chain or across EVM-compatible blockchains, all without revealing their personal identity. |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
The core of the Semaphore protocol is in the [circuit logic](/packages/circuits/scheme.png). However Semaphore also provides [Solidity contracts](/packages/contracts) and JavaScript libraries to make the steps for offchain proof creation and onchain verification easier. To learn more about Semaphore visit [semaphore.pse.dev](https://semaphore.pse.dev).
The core of the Semaphore protocol is in the [circuit logic](/packages/circuits/scheme.png). However, Semaphore also provides [Solidity contracts](/packages/contracts) and JavaScript libraries to make the steps for offchain proof creation and onchain/offchain verification easier. To learn more about Semaphore visit [semaphore.pse.dev](https://semaphore.pse.dev).
## 📦 Packages
@@ -377,3 +379,15 @@ yarn docs
```
The output will be placed on the `docs` folder.
### Releases
Bump a new version with:
```bash
yarn version:bump <version>
# e.g. yarn version:bump 2.0.0
```
It will create a commit and a git tag that will need to pushed on the main branch. A workflow will be triggered and will
publish the Semaphore packages on [npm](https://www.npmjs.com/) and release a new version on Github with its changelogs automatically.

View File

@@ -71,6 +71,8 @@ const config: Config = {
backgroundColor: "#dde6fc",
textColor: "#000000"
},
// Social media card
image: "img/social-media.png",
navbar: {
logo: {
alt: "Semaphore Logo",
@@ -84,7 +86,7 @@ const config: Config = {
},
{
label: "Whitepaper",
to: "https://docs.semaphore.pse.dev/whitepaper-v1.pdf",
to: "https://semaphore.pse.dev/whitepaper-v1.pdf",
position: "left",
className: "whitepaper-v1"
},

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -83,7 +83,11 @@ html {
-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;
}

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 190 KiB

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

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -47,7 +47,7 @@ A third-party who receives a fee for including relayed transactions in the block
To preserve the anonymity of the user broadcasting a signal with Semaphore, an application may use a relayer to post the signal transaction to Ethereum on behalf of the user.
Applications may provide rewards for relayers and implement front-running prevention mechanisms, such as requiring the signals to include the relayers address, binding the
signal to that specific address (https://docs.semaphore.pse.dev/whitepaper-v1.pdf, p.6).
signal to that specific address (https://semaphore.pse.dev/whitepaper-v1.pdf, p.6).
## Trusted setup files

View File

@@ -15,7 +15,7 @@ Example uses of groups include the following:
- ballot that members join to vote on a proposal,
- whistleblowers who are verified employees of an organization.
A Semaphore group is an [incremental Merkle tree](/V3/glossary/#incremental-merkle-tree), and group members (i.e., [identity commitments](/V3/glossary/#identity-commitments)) are tree leaves.
A Semaphore group is an [incremental Merkle tree](/V3/glossary/#merkle-tree), and group members (i.e., [identity commitments](/V3/glossary/#identity-commitment)) are tree leaves.
Semaphore groups set the following three parameters:
- **Group id**: a unique identifier for the group;

View File

@@ -63,9 +63,9 @@ pnpm add @semaphore-protocol/proof@^3
</TabItem>
</Tabs>
In the voting system use case, once all the voters have joined their [identities](/V3/guides/identities#create-an-identity) to the ballot [group](/V3/guides/groups),
In the voting system use case, once all the voters have joined their [identities](/V3/guides/identities#create-identities) to the ballot [group](/V3/guides/groups),
a voter can generate a proof to vote for a proposal.
In the call to `generateProof`, the voting system passes the unique ballot ID (the [Merkle tree](/V3/glossary/#merkle-tree/) root of the group) as the
In the call to `generateProof`, the voting system passes the unique ballot ID (the [Merkle tree](/V3/glossary#merkle-tree) root of the group) as the
`externalNullifier` to prevent the voter signaling more than once for the ballot.
The following code sample shows how to use `generateProof` to generate the voting proof:
@@ -120,9 +120,9 @@ To verify Semaphore proofs in your contract, import `ISemaphore.sol`, pass it th
- `groupId`: the identifier of the group;
- `merkleTreeRoot`: the root of the Merkle tree;
- `signal`: the signal the user wants to send anonymously;
- `nullifierHash`: a [nullifier hash](#retrieve-a-nullifier-hash);
- `nullifierHash`: a nullifier hash;
- `externalNullifier`: the value that prevents double-signaling;
- `proof`: a [Solidity-compatible Semaphore proof](#generate-a-solidity-compatible-proof).
- `proof`: a Solidity-compatible Semaphore proof.
:::info
You can import `ISemaphore.sol` and other Semaphore contracts from the [`@semaphore-protocol/contracts`](https://github.com/semaphore-protocol/semaphore/tree/v3.15.2/packages/contracts) NPM module.

View File

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

View File

@@ -8,7 +8,7 @@ import TabItem from "@theme/TabItem"
# Semaphore groups
A [Semaphore group](/glossary/#group) contains [identity commitments](/glossary/#commitment) of group members.
A [Semaphore group](/glossary/#group) contains [identity commitments](/glossary/#identity-commitment) of group members.
Example uses of groups include the following:
- poll question that attendees join to rate an event,
@@ -76,9 +76,9 @@ You can also initialize a group with multiple members by passing the list of ide
```ts
const members = [
"11237622825477336339577122413451117718539783476837539122310492284566644730311",
"9332663527862709610616009715800254142772436825222910251631161087138559093425",
"13255821893820536903335282929376140649646180444238593676033702344407594536519"
11237622825477336339577122413451117718539783476837539122310492284566644730311n,
9332663527862709610616009715800254142772436825222910251631161087138559093425n,
13255821893820536903335282929376140649646180444238593676033702344407594536519n
]
const group2 = new Group(members)
@@ -117,7 +117,7 @@ group.removeMember(0)
To update members in a group, pass the member index and the new value to the `updateMember` method. For example:
```ts
group.updateMember(0, 2)
group.updateMember(0, 2n)
```
:::caution

View File

@@ -92,7 +92,7 @@ import { generateProof } from "@semaphore-protocol/proof"
const scope = group.root
const message = 1
const proof = await generateProof(identity, group, externalNullifier, message)
const proof = await generateProof(identity, group, message, scope)
```
## Verify a proof

View File

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

File diff suppressed because one or more lines are too long

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,6 +1,6 @@
{
"name": "@semaphore-protocol/circuits",
"version": "4.0.0-beta.2",
"version": "4.0.0-beta.7",
"description": "Semaphore Circom circuits to generate zero-knowledge proofs.",
"license": "MIT",
"files": [

View File

@@ -62,6 +62,6 @@ template Semaphore(MAX_DEPTH) {
// The message is not really used within the circuit.
// The square applied to it is a way to force Circom's compiler to add a constraint and
// prevent its value from being changed by an attacker.
// More information here: https://geometryresearch.xyz/notebook/groth16-malleability.
// More information here: https://geometry.xyz/notebook/groth16-malleability.
signal dummySquare <== message * message;
}

View File

@@ -1,4 +1,3 @@
INFURA_API_KEY=
ETHEREUM_PRIVATE_KEY=
REPORT_GAS=false
ETHERSCAN_API_KEY=

File diff suppressed because one or more lines are too long

View File

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

View File

@@ -8,11 +8,10 @@ contract Feedback {
uint256 public groupId;
constructor(address semaphoreAddress, uint256 _groupId) {
constructor(address semaphoreAddress) {
semaphore = ISemaphore(semaphoreAddress);
groupId = _groupId;
semaphore.createGroup(groupId, address(this));
groupId = semaphore.createGroup();
}
function joinGroup(uint256 identityCommitment) external {

View File

@@ -1,54 +1,17 @@
import { HardhatUserConfig } from "hardhat/config"
import { NetworksUserConfig } from "hardhat/types"
import "@nomicfoundation/hardhat-toolbox"
import "dotenv/config"
import "@semaphore-protocol/hardhat"
import { getHardhatNetworks } from "@semaphore-protocol/utils"
import "dotenv/config"
import { HardhatUserConfig } from "hardhat/config"
import "./tasks/deploy"
function getNetworks(): NetworksUserConfig {
if (!process.env.INFURA_API_KEY || !process.env.ETHEREUM_PRIVATE_KEY) {
return {}
}
const accounts = [`0x${process.env.ETHEREUM_PRIVATE_KEY}`]
const infuraApiKey = process.env.INFURA_API_KEY
return {
sepolia: {
url: `https://sepolia.infura.io/v3/${infuraApiKey}`,
chainId: 11155111,
accounts
},
mumbai: {
url: `https://polygon-mumbai.infura.io/v3/${infuraApiKey}`,
chainId: 80001,
accounts
},
"optimism-sepolia": {
url: `https://optimism-sepolia.infura.io/v3/${infuraApiKey}`,
chainId: 11155420,
accounts
},
"arbitrum-sepolia": {
url: "https://sepolia-rollup.arbitrum.io/rpc",
chainId: 421614,
accounts
},
arbitrum: {
url: "https://arb1.arbitrum.io/rpc",
chainId: 42161,
accounts
}
}
}
const config: HardhatUserConfig = {
solidity: "0.8.23",
networks: {
hardhat: {
chainId: 1337
},
...getNetworks()
...getHardhatNetworks(process.env.ETHEREUM_PRIVATE_KEY)
},
gasReporter: {
currency: "USD",

View File

@@ -1,6 +1,6 @@
{
"name": "@semaphore-protocol/cli-template-contracts-hardhat",
"version": "4.0.0-beta.2",
"version": "4.0.0-beta.7",
"description": "Semaphore Hardhat template.",
"license": "Unlicense",
"files": [
@@ -41,8 +41,9 @@
"@nomicfoundation/hardhat-network-helpers": "^1.0.0",
"@nomicfoundation/hardhat-toolbox": "^4.0.0",
"@nomicfoundation/hardhat-verify": "^2.0.0",
"@semaphore-protocol/core": "4.0.0-beta.2",
"@semaphore-protocol/hardhat": "4.0.0-beta.2",
"@semaphore-protocol/core": "4.0.0-beta.7",
"@semaphore-protocol/hardhat": "4.0.0-beta.7",
"@semaphore-protocol/utils": "4.0.0-beta.7",
"@typechain/ethers-v6": "^0.5.0",
"@typechain/hardhat": "^9.0.0",
"@types/chai": "^4.2.0",
@@ -70,7 +71,7 @@
"typescript": "^5.3.3"
},
"dependencies": {
"@semaphore-protocol/contracts": "4.0.0-beta.2"
"@semaphore-protocol/contracts": "4.0.0-beta.7"
},
"packageManager": "yarn@4.1.0"
}

View File

@@ -2,9 +2,8 @@ import { task, types } from "hardhat/config"
task("deploy", "Deploy a Feedback contract")
.addOptionalParam("semaphore", "Semaphore contract address", undefined, types.string)
.addOptionalParam("group", "Group id", "42", types.string)
.addOptionalParam("logs", "Print the logs", true, types.boolean)
.setAction(async ({ logs, semaphore: semaphoreAddress, group: groupId }, { ethers, run }) => {
.setAction(async ({ logs, semaphore: semaphoreAddress }, { ethers, run }) => {
if (!semaphoreAddress) {
const { semaphore } = await run("deploy:semaphore", {
logs
@@ -13,13 +12,9 @@ task("deploy", "Deploy a Feedback contract")
semaphoreAddress = await semaphore.getAddress()
}
if (!groupId) {
groupId = process.env.GROUP_ID
}
const FeedbackFactory = await ethers.getContractFactory("Feedback")
const feedbackContract = await FeedbackFactory.deploy(semaphoreAddress, groupId)
const feedbackContract = await FeedbackFactory.deploy(semaphoreAddress)
if (logs) {
console.info(`Feedback contract has been deployed to: ${await feedbackContract.getAddress()}`)

View File

@@ -9,8 +9,6 @@ import { Feedback, ISemaphore } from "../typechain-types"
describe("Feedback", () => {
async function deployFeedbackFixture() {
const groupId = "42"
const { semaphore } = await run("deploy:semaphore", {
logs: false
})
@@ -19,10 +17,11 @@ describe("Feedback", () => {
const feedbackContract: Feedback = await run("deploy", {
logs: false,
group: groupId,
semaphore: await semaphoreContract.getAddress()
})
const groupId = await feedbackContract.groupId()
return { semaphoreContract, feedbackContract, groupId }
}

View File

@@ -1,5 +1,4 @@
DEFAULT_NETWORK=localhost
INFURA_API_KEY=
DEFAULT_NETWORK=hardhat
ETHEREUM_PRIVATE_KEY=ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
REPORT_GAS=false
COINMARKETCAP_API_KEY=

File diff suppressed because one or more lines are too long

View File

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

View File

@@ -8,11 +8,10 @@ contract Feedback {
uint256 public groupId;
constructor(address semaphoreAddress, uint256 _groupId) {
constructor(address semaphoreAddress) {
semaphore = ISemaphore(semaphoreAddress);
groupId = _groupId;
semaphore.createGroup(groupId, address(this));
groupId = semaphore.createGroup();
}
function joinGroup(uint256 identityCommitment) external {

View File

@@ -1,58 +1,21 @@
import { HardhatUserConfig } from "hardhat/config"
import { NetworksUserConfig } from "hardhat/types"
import "@nomicfoundation/hardhat-toolbox"
import { config as dotenvConfig } from "dotenv"
import { resolve } from "path"
import "@semaphore-protocol/hardhat"
import { getHardhatNetworks } from "@semaphore-protocol/utils"
import { config as dotenvConfig } from "dotenv"
import { HardhatUserConfig } from "hardhat/config"
import { resolve } from "path"
import "./tasks/deploy"
dotenvConfig({ path: resolve(__dirname, "../../.env") })
function getNetworks(): NetworksUserConfig {
if (!process.env.INFURA_API_KEY || !process.env.ETHEREUM_PRIVATE_KEY) {
return {}
}
const accounts = [`0x${process.env.ETHEREUM_PRIVATE_KEY}`]
const infuraApiKey = process.env.INFURA_API_KEY
return {
sepolia: {
url: `https://sepolia.infura.io/v3/${infuraApiKey}`,
chainId: 11155111,
accounts
},
mumbai: {
url: `https://polygon-mumbai.infura.io/v3/${infuraApiKey}`,
chainId: 80001,
accounts
},
"optimism-sepolia": {
url: `https://optimism-sepolia.infura.io/v3/${infuraApiKey}`,
chainId: 11155420,
accounts
},
"arbitrum-sepolia": {
url: "https://sepolia-rollup.arbitrum.io/rpc",
chainId: 421614,
accounts
},
arbitrum: {
url: "https://arb1.arbitrum.io/rpc",
chainId: 42161,
accounts
}
}
}
const config: HardhatUserConfig = {
solidity: "0.8.23",
defaultNetwork: process.env.DEFAULT_NETWORK || "localhost",
defaultNetwork: process.env.DEFAULT_NETWORK || "hardhat",
networks: {
hardhat: {
chainId: 1337
},
...getNetworks()
...getHardhatNetworks(process.env.ETHEREUM_PRIVATE_KEY)
},
gasReporter: {
currency: "USD",

View File

@@ -1,5 +1,6 @@
{
"name": "monorepo-ethers-contracts",
"private": true,
"scripts": {
"dev": "hardhat node & yarn deploy --network localhost",
"compile": "hardhat compile",
@@ -19,8 +20,9 @@
"@nomicfoundation/hardhat-network-helpers": "^1.0.0",
"@nomicfoundation/hardhat-toolbox": "^4.0.0",
"@nomicfoundation/hardhat-verify": "^2.0.0",
"@semaphore-protocol/core": "4.0.0-beta.2",
"@semaphore-protocol/hardhat": "4.0.0-beta.2",
"@semaphore-protocol/core": "4.0.0-beta.7",
"@semaphore-protocol/hardhat": "4.0.0-beta.7",
"@semaphore-protocol/utils": "4.0.0-beta.7",
"@typechain/ethers-v6": "^0.5.0",
"@typechain/hardhat": "^9.0.0",
"@types/chai": "^4.2.0",
@@ -48,7 +50,7 @@
"typescript": "^5.3.3"
},
"dependencies": {
"@semaphore-protocol/contracts": "4.0.0-beta.2"
"@semaphore-protocol/contracts": "4.0.0-beta.7"
},
"packageManager": "yarn@4.1.0"
}

View File

@@ -2,9 +2,8 @@ import { task, types } from "hardhat/config"
task("deploy", "Deploy a Feedback contract")
.addOptionalParam("semaphore", "Semaphore contract address", undefined, types.string)
.addOptionalParam("group", "Group id", "42", types.string)
.addOptionalParam("logs", "Print the logs", true, types.boolean)
.setAction(async ({ logs, semaphore: semaphoreAddress, group: groupId }, { ethers, run }) => {
.setAction(async ({ logs, semaphore: semaphoreAddress }, { ethers, run }) => {
if (!semaphoreAddress) {
const { semaphore } = await run("deploy:semaphore", {
logs
@@ -13,13 +12,9 @@ task("deploy", "Deploy a Feedback contract")
semaphoreAddress = await semaphore.getAddress()
}
if (!groupId) {
groupId = process.env.GROUP_ID
}
const FeedbackFactory = await ethers.getContractFactory("Feedback")
const feedbackContract = await FeedbackFactory.deploy(semaphoreAddress, groupId)
const feedbackContract = await FeedbackFactory.deploy(semaphoreAddress)
if (logs) {
console.info(`Feedback contract has been deployed to: ${await feedbackContract.getAddress()}`)

View File

@@ -9,8 +9,6 @@ import { Feedback, ISemaphore } from "../typechain-types"
describe("Feedback", () => {
async function deployFeedbackFixture() {
const groupId = "42"
const { semaphore } = await run("deploy:semaphore", {
logs: false
})
@@ -19,10 +17,11 @@ describe("Feedback", () => {
const feedbackContract: Feedback = await run("deploy", {
logs: false,
group: groupId,
semaphore: await semaphoreContract.getAddress()
})
const groupId = await feedbackContract.groupId()
return { semaphoreContract, feedbackContract, groupId }
}

View File

@@ -1,4 +1,4 @@
NEXT_PUBLIC_DEFAULT_NETWORK=localhost
NEXT_PUBLIC_FEEDBACK_CONTRACT_ADDRESS=0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9
NEXT_PUBLIC_SEMAPHORE_CONTRACT_ADDRESS=0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0
NEXT_PUBLIC_GROUP_ID=42
NEXT_PUBLIC_GROUP_ID=0

View File

@@ -0,0 +1,5 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />
// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.

View File

@@ -9,8 +9,9 @@
"lint": "next lint"
},
"dependencies": {
"@semaphore-protocol/core": "4.0.0-beta.2",
"@semaphore-protocol/data": "4.0.0-beta.2",
"@semaphore-protocol/core": "4.0.0-beta.7",
"@semaphore-protocol/data": "4.0.0-beta.7",
"@semaphore-protocol/utils": "4.0.0-beta.7",
"ethers": "^6.11.1",
"next": "14.1.0",
"next-pwa": "^5.6.0",

View File

@@ -74,7 +74,7 @@ export default function GroupsPage() {
setLoading(false)
}, [_identity])
const userHasJoined = useCallback((identity: Identity) => _users.includes(identity.commitment), [_users])
const userHasJoined = useCallback((identity: Identity) => _users.includes(identity.commitment.toString()), [_users])
return (
<>

View File

@@ -4,7 +4,7 @@ import LogsContext from "@/context/LogsContext"
import SemaphoreContext from "@/context/SemaphoreContext"
import useSemaphore from "@/hooks/useSemaphore"
import shortenString from "@/utils/shortenString"
import { SupportedNetwork } from "@semaphore-protocol/data"
import { SupportedNetwork } from "@semaphore-protocol/utils"
import { usePathname } from "next/navigation"
import { useEffect, useState } from "react"
import Link from "next/link"
@@ -52,7 +52,7 @@ export default function PageContainer({
<div>{shortenString(process.env.NEXT_PUBLIC_FEEDBACK_CONTRACT_ADDRESS as string, [6, 4])}</div>
</a>
<a
href="https://github.com/semaphore-protocol/boilerplate"
href="https://github.com/semaphore-protocol/semaphore"
target="_blank"
rel="noreferrer noopener nofollow"
>

View File

@@ -9,7 +9,7 @@ const ethereumNetwork =
: process.env.NEXT_PUBLIC_DEFAULT_NETWORK
export default function useSemaphore(): SemaphoreContextType {
const [_users, setUsers] = useState<any[]>([])
const [_users, setUsers] = useState<string[]>([])
const [_feedback, setFeedback] = useState<string[]>([])
const refreshUsers = useCallback(async (): Promise<void> => {
@@ -19,7 +19,7 @@ export default function useSemaphore(): SemaphoreContextType {
const members = await semaphore.getGroupMembers(process.env.NEXT_PUBLIC_GROUP_ID as string)
setUsers(members.map((member) => member.toString()))
setUsers(members)
}, [])
const addUser = useCallback(

View File

@@ -1,6 +1,6 @@
{
"name": "@semaphore-protocol/cli-template-monorepo-ethers",
"version": "4.0.0-beta.2",
"version": "4.0.0-beta.7",
"description": "Semaphore Hardhat + Next.js + SemaphoreEthers template.",
"license": "Unlicense",
"files": [

View File

@@ -1,5 +1,4 @@
DEFAULT_NETWORK=localhost
INFURA_API_KEY=
DEFAULT_NETWORK=hardhat
ETHEREUM_PRIVATE_KEY=ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
REPORT_GAS=false
COINMARKETCAP_API_KEY=

File diff suppressed because one or more lines are too long

View File

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

View File

@@ -8,11 +8,10 @@ contract Feedback {
uint256 public groupId;
constructor(address semaphoreAddress, uint256 _groupId) {
constructor(address semaphoreAddress) {
semaphore = ISemaphore(semaphoreAddress);
groupId = _groupId;
semaphore.createGroup(groupId, address(this));
groupId = semaphore.createGroup();
}
function joinGroup(uint256 identityCommitment) external {

View File

@@ -1,58 +1,21 @@
import { HardhatUserConfig } from "hardhat/config"
import { NetworksUserConfig } from "hardhat/types"
import "@nomicfoundation/hardhat-toolbox"
import { config as dotenvConfig } from "dotenv"
import { resolve } from "path"
import "@semaphore-protocol/hardhat"
import { getHardhatNetworks } from "@semaphore-protocol/utils"
import { config as dotenvConfig } from "dotenv"
import { HardhatUserConfig } from "hardhat/config"
import { resolve } from "path"
import "./tasks/deploy"
dotenvConfig({ path: resolve(__dirname, "../../.env") })
function getNetworks(): NetworksUserConfig {
if (!process.env.INFURA_API_KEY || !process.env.ETHEREUM_PRIVATE_KEY) {
return {}
}
const accounts = [`0x${process.env.ETHEREUM_PRIVATE_KEY}`]
const infuraApiKey = process.env.INFURA_API_KEY
return {
sepolia: {
url: `https://sepolia.infura.io/v3/${infuraApiKey}`,
chainId: 11155111,
accounts
},
mumbai: {
url: `https://polygon-mumbai.infura.io/v3/${infuraApiKey}`,
chainId: 80001,
accounts
},
"optimism-sepolia": {
url: `https://optimism-sepolia.infura.io/v3/${infuraApiKey}`,
chainId: 11155420,
accounts
},
"arbitrum-sepolia": {
url: "https://sepolia-rollup.arbitrum.io/rpc",
chainId: 421614,
accounts
},
arbitrum: {
url: "https://arb1.arbitrum.io/rpc",
chainId: 42161,
accounts
}
}
}
const config: HardhatUserConfig = {
solidity: "0.8.23",
defaultNetwork: process.env.DEFAULT_NETWORK || "localhost",
defaultNetwork: process.env.DEFAULT_NETWORK || "hardhat",
networks: {
hardhat: {
chainId: 1337
},
...getNetworks()
...getHardhatNetworks(process.env.ETHEREUM_PRIVATE_KEY)
},
gasReporter: {
currency: "USD",

View File

@@ -1,5 +1,6 @@
{
"name": "monorepo-subgraph-contracts",
"private": true,
"scripts": {
"dev": "hardhat node & yarn deploy --network localhost",
"compile": "hardhat compile",
@@ -19,8 +20,9 @@
"@nomicfoundation/hardhat-network-helpers": "^1.0.0",
"@nomicfoundation/hardhat-toolbox": "^4.0.0",
"@nomicfoundation/hardhat-verify": "^2.0.0",
"@semaphore-protocol/core": "4.0.0-beta.2",
"@semaphore-protocol/hardhat": "4.0.0-beta.2",
"@semaphore-protocol/core": "4.0.0-beta.7",
"@semaphore-protocol/hardhat": "4.0.0-beta.7",
"@semaphore-protocol/utils": "4.0.0-beta.7",
"@typechain/ethers-v6": "^0.5.0",
"@typechain/hardhat": "^9.0.0",
"@types/chai": "^4.2.0",
@@ -48,7 +50,7 @@
"typescript": "^5.3.3"
},
"dependencies": {
"@semaphore-protocol/contracts": "4.0.0-beta.2"
"@semaphore-protocol/contracts": "4.0.0-beta.7"
},
"packageManager": "yarn@4.1.0"
}

View File

@@ -2,9 +2,8 @@ import { task, types } from "hardhat/config"
task("deploy", "Deploy a Feedback contract")
.addOptionalParam("semaphore", "Semaphore contract address", undefined, types.string)
.addOptionalParam("group", "Group id", "42", types.string)
.addOptionalParam("logs", "Print the logs", true, types.boolean)
.setAction(async ({ logs, semaphore: semaphoreAddress, group: groupId }, { ethers, run }) => {
.setAction(async ({ logs, semaphore: semaphoreAddress }, { ethers, run }) => {
if (!semaphoreAddress) {
const { semaphore } = await run("deploy:semaphore", {
logs
@@ -13,13 +12,9 @@ task("deploy", "Deploy a Feedback contract")
semaphoreAddress = await semaphore.getAddress()
}
if (!groupId) {
groupId = process.env.GROUP_ID
}
const FeedbackFactory = await ethers.getContractFactory("Feedback")
const feedbackContract = await FeedbackFactory.deploy(semaphoreAddress, groupId)
const feedbackContract = await FeedbackFactory.deploy(semaphoreAddress)
if (logs) {
console.info(`Feedback contract has been deployed to: ${await feedbackContract.getAddress()}`)

View File

@@ -9,8 +9,6 @@ import { Feedback, ISemaphore } from "../typechain-types"
describe("Feedback", () => {
async function deployFeedbackFixture() {
const groupId = "42"
const { semaphore } = await run("deploy:semaphore", {
logs: false
})
@@ -19,10 +17,11 @@ describe("Feedback", () => {
const feedbackContract: Feedback = await run("deploy", {
logs: false,
group: groupId,
semaphore: await semaphoreContract.getAddress()
})
const groupId = await feedbackContract.groupId()
return { semaphoreContract, feedbackContract, groupId }
}

View File

@@ -1,4 +1,4 @@
NEXT_PUBLIC_DEFAULT_NETWORK=localhost
NEXT_PUBLIC_FEEDBACK_CONTRACT_ADDRESS=0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9
NEXT_PUBLIC_SEMAPHORE_CONTRACT_ADDRESS=0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0
NEXT_PUBLIC_GROUP_ID=42
NEXT_PUBLIC_GROUP_ID=0

View File

@@ -9,8 +9,9 @@
"lint": "next lint"
},
"dependencies": {
"@semaphore-protocol/core": "4.0.0-beta.2",
"@semaphore-protocol/data": "4.0.0-beta.2",
"@semaphore-protocol/core": "4.0.0-beta.7",
"@semaphore-protocol/data": "4.0.0-beta.7",
"@semaphore-protocol/utils": "4.0.0-beta.7",
"ethers": "^6.11.1",
"next": "14.1.0",
"next-pwa": "^5.6.0",

View File

@@ -1,12 +1,12 @@
"use client"
import Stepper from "@/components/Stepper"
import LogsContext from "@/context/LogsContext"
import SemaphoreContext from "@/context/SemaphoreContext"
import { Identity } from "@semaphore-protocol/core"
import { useRouter } from "next/navigation"
import { useCallback, useContext, useEffect, useState } from "react"
import Feedback from "../../../contract-artifacts/Feedback.json"
import Stepper from "@/components/Stepper"
import LogsContext from "@/context/LogsContext"
import SemaphoreContext from "@/context/SemaphoreContext"
export default function GroupsPage() {
const router = useRouter()
@@ -74,7 +74,7 @@ export default function GroupsPage() {
setLoading(false)
}, [_identity])
const userHasJoined = useCallback((identity: Identity) => _users.includes(identity.commitment), [_users])
const userHasJoined = useCallback((identity: Identity) => _users.includes(identity.commitment.toString()), [_users])
return (
<>

View File

@@ -52,7 +52,7 @@ export default function PageContainer({
<div>{shortenString(process.env.NEXT_PUBLIC_FEEDBACK_CONTRACT_ADDRESS as string, [6, 4])}</div>
</a>
<a
href="https://github.com/semaphore-protocol/boilerplate"
href="https://github.com/semaphore-protocol/semaphore"
target="_blank"
rel="noreferrer noopener nofollow"
>

View File

@@ -1,6 +1,6 @@
{
"name": "@semaphore-protocol/cli-template-monorepo-subgraph",
"version": "4.0.0-beta.2",
"version": "4.0.0-beta.7",
"description": "Semaphore Hardhat + Next.js + SemaphoreSubgraph template.",
"license": "Unlicense",
"files": [

View File

@@ -1,7 +1,7 @@
{
"name": "@semaphore-protocol/cli",
"type": "module",
"version": "4.0.0-beta.2",
"version": "4.0.0-beta.7",
"description": "A command line tool to set up your Semaphore project and get group data.",
"license": "MIT",
"bin": {
@@ -31,15 +31,18 @@
"access": "public"
},
"devDependencies": {
"@rollup/plugin-typescript": "^11.1.6",
"@types/figlet": "^1.5.8",
"@types/inquirer": "^9.0.7",
"@types/pacote": "^11.1.8",
"@types/semver": "^7.5.8",
"rollup-plugin-cleanup": "^3.2.1",
"rollup-plugin-typescript2": "^0.36.0"
"rimraf": "^5.0.5",
"rollup": "^4.12.0",
"rollup-plugin-cleanup": "^3.2.1"
},
"dependencies": {
"@semaphore-protocol/data": "4.0.0-beta.2",
"@semaphore-protocol/data": "4.0.0-beta.7",
"@semaphore-protocol/utils": "4.0.0-beta.7",
"axios": "^1.6.7",
"boxen": "^7.1.1",
"chalk": "^5.3.0",

View File

@@ -1,4 +1,4 @@
import typescript from "rollup-plugin-typescript2"
import typescript from "@rollup/plugin-typescript"
import fs from "fs"
import cleanup from "rollup-plugin-cleanup"
@@ -9,7 +9,7 @@ const banner = `#!/usr/bin/env node
* @module ${pkg.name}
* @version ${pkg.version}
* @file ${pkg.description}
* @copyright Ethereum Foundation 2024
* @copyright Ethereum Foundation ${new Date().getFullYear()}
* @license ${pkg.license}
* @see [Github]{@link ${pkg.homepage}}
*/
@@ -18,11 +18,17 @@ const banner = `#!/usr/bin/env node
export default {
input: "src/index.ts",
output: [{ file: pkg.bin.semaphore, format: "es", banner }],
external: [...Object.keys(pkg.dependencies), "url", "fs", "path", "child_process"],
external: [
...Object.keys(pkg.dependencies),
"url",
"fs",
"path",
"child_process",
"@semaphore-protocol/utils/networks"
],
plugins: [
(typescript as any)({
tsconfig: "./build.tsconfig.json",
useTsconfigDeclarationDir: true
typescript({
tsconfig: "./build.tsconfig.json"
}),
cleanup({ comments: "jsdoc" })
]

View File

@@ -1,4 +1,5 @@
import { GroupResponse, SemaphoreEthers, SemaphoreSubgraph, getSupportedNetworks } from "@semaphore-protocol/data"
import { GroupResponse, SemaphoreEthers, SemaphoreSubgraph } from "@semaphore-protocol/data"
import { isSupportedNetwork, supportedNetworks } from "@semaphore-protocol/utils/networks"
import chalk from "chalk"
import { program } from "commander"
import decompress from "decompress"
@@ -16,8 +17,6 @@ import Spinner from "./spinner.js"
const packagePath = `${dirname(fileURLToPath(import.meta.url))}/..`
const { description, version } = JSON.parse(readFileSync(`${packagePath}/package.json`, "utf8"))
const supportedNetworks = getSupportedNetworks()
const supportedTemplates = [
{
value: "monorepo-ethers",
@@ -122,10 +121,10 @@ program
.allowExcessArguments(false)
.action(async ({ network }) => {
if (!network) {
network = await getSupportedNetwork(supportedNetworks)
network = await getSupportedNetwork(Object.keys(supportedNetworks))
}
if (!supportedNetworks.includes(network)) {
if (!isSupportedNetwork(network)) {
console.info(`\n ${logSymbols.error}`, `error: the network '${network}' is not supported\n`)
return
}
@@ -152,10 +151,10 @@ program
.allowExcessArguments(false)
.action(async (groupId, { network }) => {
if (!network) {
network = await getSupportedNetwork(supportedNetworks)
network = await getSupportedNetwork(Object.keys(supportedNetworks))
}
if (!supportedNetworks.includes(network)) {
if (!isSupportedNetwork(network)) {
console.info(`\n ${logSymbols.error}`, `error: the network '${network}' is not supported\n`)
return
}
@@ -220,10 +219,10 @@ program
.allowExcessArguments(false)
.action(async (groupId, { network }) => {
if (!network) {
network = await getSupportedNetwork(supportedNetworks)
network = await getSupportedNetwork(Object.keys(supportedNetworks))
}
if (!supportedNetworks.includes(network)) {
if (!isSupportedNetwork(network)) {
console.info(`\n ${logSymbols.error}`, `error: the network '${network}' is not supported\n`)
return
}
@@ -286,10 +285,10 @@ program
.allowExcessArguments(false)
.action(async (groupId, { network }) => {
if (!network) {
network = await getSupportedNetwork(supportedNetworks)
network = await getSupportedNetwork(Object.keys(supportedNetworks))
}
if (!supportedNetworks.includes(network)) {
if (!isSupportedNetwork(network)) {
console.info(`\n ${logSymbols.error}`, `error: the network '${network}' is not supported\n`)
return
}

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