Compare commits

..

32 Commits

Author SHA1 Message Date
Vivian Plasencia
a2e8f5a15c chore: v4.8.2 2024-12-18 13:06:36 +01:00
Vivian Plasencia
f77df8d98f fix: include solhint config file in contracts templates (#929) 2024-12-18 13:01:35 +01:00
Vivian Plasencia
2b9fde2676 chore: v4.8.1 2024-12-18 11:41:01 +01:00
Vivian Plasencia
ac4ddfc6eb chore(cli-template-contracts-foundry): add prepublish script (#927)
chore(cli-template-contracts-foundry): add prepublish script to publish foundry template
2024-12-18 11:32:36 +01:00
Vivian Plasencia
afae06e8e1 chore: v4.8.0 2024-12-17 15:06:02 +01:00
Jimmy Chu
4cc6980b55 Add CLI Foundry Template (cont.) (#905)
* Semaphore identity example code bug fix

* Receive suggestion for consistency

* chore: forge init

* forge install: forge-std

v1.9.2

* Foundry CLI First Draft

* modules

* forge install: semaphore

v4.0.3

* forge install: zk-kit.solidity

* forge install: poseidon-solidity

v0.0.5

* forge install: openzeppelin-contracts

v5.0.2

* modules

* forge install: semaphore

v4.0.3

* forge install: zk-kit.solidity

* forge install: poseidon-solidity

v0.0.5

* forge install: openzeppelin-contracts

v5.0.2

* modules

* forge install: semaphore

v4.0.3

* forge install: zk-kit.solidity

* forge install: poseidon-solidity

v0.0.5

* forge install: openzeppelin-contracts

v5.0.2

* modules

* forge install: semaphore

v4.0.3

* forge install: zk-kit.solidity

* forge install: poseidon-solidity

v0.0.5

* forge install: openzeppelin-contracts

v5.0.2

* modules

* forge install: semaphore

v4.0.3

* forge install: zk-kit.solidity

* forge install: poseidon-solidity

v0.0.5

* forge install: openzeppelin-contracts

v5.0.2

* modules

* forge install: semaphore

v4.0.3

* forge install: zk-kit.solidity

* forge install: poseidon-solidity

v0.0.5

* forge install: openzeppelin-contracts

v5.0.2

* forge install: forge-std

v1.9.2

* modules

* forge install: semaphore

v4.0.3

* forge install: zk-kit.solidity

* forge install: poseidon-solidity

v0.0.5

* forge install: openzeppelin-contracts

v5.0.2

* modules

* forge install: semaphore

v4.0.3

* forge install: zk-kit.solidity

* forge install: poseidon-solidity

v0.0.5

* forge install: openzeppelin-contracts

v5.0.2

* forge install: forge-std

v1.9.2

* modules

* forge install: semaphore

v4.0.3

* forge install: zk-kit.solidity

* forge install: poseidon-solidity

v0.0.5

* forge install: openzeppelin-contracts

v5.0.2

* forge install: forge-std

v1.9.2

* modules

* forge install: semaphore

v4.0.3

* forge install: zk-kit.solidity

* forge install: poseidon-solidity

v0.0.5

* forge install: openzeppelin-contracts

v5.0.2

* modules

* forge install: semaphore

v4.0.3

* forge install: zk-kit.solidity

* forge install: poseidon-solidity

v0.0.5

* forge install: openzeppelin-contracts

v5.0.2

* forge install: forge-std

v1.9.2

* modules

* forge install: semaphore

v4.0.3

* forge install: zk-kit.solidity

* forge install: poseidon-solidity

v0.0.5

* forge install: openzeppelin-contracts

v5.0.2

* forge install: forge-std

v1.9.2

* change test name

* modify declaration of semaphore and verifier

* Modify Test Function Name

* Add Test Chain Target

* forge std install

* refactor(cli-template-contracts-foundry): change default Anvil address and private key

* chore(cli-template-contracts-foundry): add comments

* refactor(cli-template-contracts-foundry): add Semaphore & SemaphoreVerifier addresses for test chain

* chore(cli-template-contracts-foundry): add forge coverage for Makefile

* chore(cli-template-contracts-foundry): add env.example

* docs(cli-template-contracts-foundry): add command instructions

* updated

* forge build works

* Fixed for linting

* chore(cli-template-contracts-foundry): make the lint, prettier, and lint-staged pass

* chore(cli-template-contracts-foundry): replace Makefile(removed) with package.json

* chore(cli-template-contracts-foundry): passing the ci test

* updated test

* feat(cli-template-contracts-foundry): complete cli-template-contracts-foundry

re #854, #185

* Update dependencies

* Add explanation on `yarn dev`

* fix(cli-template-contracts-foundry): fix `yarn dev` command and add docs on integrate w/ boilerplate

* Added yarnrc

* updated version

* Added Foundry in template option

---------

Co-authored-by: weipooppys93030 <55434365+weipooppys93030@users.noreply.github.com>
Co-authored-by: timou0911 <x0928048316@gmail.com>
Co-authored-by: csiejimmyliu <91661606+csiejimmyliu@users.noreply.github.com>
2024-12-17 14:48:36 +01:00
cedoor
6b04ec0eca chore: v4.7.3 2024-12-12 08:55:13 +00:00
Jake C-T
13a9480165 fix(core): bump ethers to v6.13.4 (#921)
Update ethers version to resolve ws security issue (CVE-2024-37890).
Move contract address check outside of branch statement so Typescript can see.
Add build instructions to setup to resolve 'Cannot find module '@semaphore-protocol/...' when
running tests for the first time.

re #920
2024-12-12 08:53:17 +00:00
cedoor
53967a9a3c chore: v4.7.2 2024-12-09 10:44:07 +01:00
Lautaro Di Sanza
5b92c0a2bc fix(group): after a sequence of updates a proof is invalid (#910)
* fix(group): after a sequence of updates a proof is invalid

* fix(group): after a sequence of updates a proof is invalid
2024-12-09 10:43:08 +01:00
Dmytrol
31c776ea68 Fix Typo in Quick Setup Documentation (#916)
typos quick-setup.md
2024-12-06 10:05:56 +05:30
Vivian Plasencia
8d83d59220 chore: v4.7.1 2024-12-05 18:49:30 +01:00
Vivian Plasencia
9e4fb5376c chore: update subgraph versions (#913)
re #912
2024-12-05 18:45:49 +01:00
Vivian Plasencia
745edb8e92 chore(website): add ethindia event to the website (#911) 2024-12-04 19:15:22 +01:00
Cypher Pepe
e732992952 docs: Typo Fixes and Documentation Updates (#907)
* typo howitworks.md

* typos libsemaphore.md

* typos what-is-semaphore.md

* typo subgraph.md

* typo identities.mdx

* typo proofs.mdx

* typos page.tsx

* typo page.tsx
2024-12-02 14:35:45 +07:00
Dmitry
3fcce15375 Fix typo in section.identities.box2.description Update code.json (#909)
Correct "identtity" to "identity"
2024-12-02 14:34:08 +07:00
Cedoor
ebb6731d89 docs(subgraph): update README.md (#906)
* docs(subgraph): update README.md

* docs(subgraph): update README.md
2024-11-28 18:02:55 +07:00
wangjingcun
0c23acf9cf chore: fix 404 status URL (#904)
Signed-off-by: wangjingcun <wangjingcun@aliyun.com>
2024-11-28 14:57:10 +07:00
cedoor
3e7db08eeb chore: v4.7.0 2024-11-27 17:24:57 +07:00
Cedoor
8adfc30da8 chore(contracts): add scroll sepolia to supported networks (#902)
* chore(contracts): add scroll sepolia to supported networks

* chore(contracts): deploy contracts on scroll sepolia

re #899

* chore(contracts): deploy semaphore on correct scroll sepolia network

re #899
2024-11-27 17:24:08 +07:00
sripwoud
42639662c3 docs: add soldeer install instructions (#903)
* docs: add  `soldeer` install instructions

* update README
2024-11-27 12:36:36 +07:00
Shikhar Singh
64025516c0 feat: clean node_modules before building subgraph (#884)
* feat(cli): remove @semaphore-protocol/cli prepublish script

The idea is to remove the prepublish script from the scripts object of the package.json file of
every cli template when the template is downloaded using the CLI.

BREAKING CHANGE: n

* refactor(cli): add comment

* refactor(cli): create seperate file for removePrePublishScript function

* refactor(cli): using updatedPackageJsonContent var instead of calling readFileSync again

* fix(subgraph): clean node_modules before building subgraph

* refactor(subgraph): fix: test typo

* refactor(subgraph): refactor: remove nohoist

* refactor(subgraph): refactor: workspaces structure
2024-11-26 09:42:42 +01:00
sripwoud
91f8a4be2a fix(ci): publish pkg if no releases yet (#900)
* fix(ci): publish pkg if no releases yet

* chore(ci): add workflow release trigger

* fix: workflow dispatch instead of workflow release
2024-11-26 15:21:07 +07:00
Bryer
ebd9a27c1b typo fix Update CONTRIBUTING.md (#901)
Corrected phrasing in "Commit rules" section
2024-11-26 15:20:14 +07:00
cedoor
bada8b8792 chore: v4.6.0 2024-11-25 13:09:50 +07:00
Cedoor
e93b19c566 chore(contracts): deploy contracts (#892)
* chore(contracts): deploy contracts

* chore(subgraph): deploy new subgraphs
2024-11-25 13:08:31 +07:00
leopardracer
862f715d05 fix: typos in documentation files (#898)
* Update usage.md

* Update glossary.md
2024-11-25 12:42:49 +07:00
Dmitry
3ed6c38587 Fixed closing tag issue in Update README.md (#894)
In the table section, there is a minor mistake in the closing tag. Instead of using </tbody>, it should be </tbody>. This is a formatting mistake.
2024-11-20 15:53:14 +07:00
Cedoor
7e183f3d2c refactor(contracts): support version range (#891)
re #888
2024-10-31 13:19:05 +00:00
Jimmy Chu
901d0954c0 refactor(contracts): specify gas cost in SemaphoreVerifier precompile calls (#883)
* chore(contracts): remove sub() from gas() in staticcall at SemaphoreVerifier

re #871

* refactor(contracts): using fixed gas cost on precompile calls

re #871

* refactor(contracts): increease fixed gas cost with safety buffer
2024-10-31 12:35:19 +00:00
Erick Vasquez
caebc1a4ab feat: add veilescrow to projects section (#890) 2024-10-30 18:46:38 +01:00
Vivian Plasencia
9b419f0c78 docs: add benchmarks page (#889)
* docs(docs): add benchmarks page to the docs

re #815

* chore(docs): update the docusaurus version
2024-10-30 10:54:13 +01:00
91 changed files with 3874 additions and 917 deletions

View File

@@ -4,6 +4,7 @@ permissions:
contents: write
on:
workflow_dispatch:
push:
tags:
- "v*"

View File

@@ -42,7 +42,7 @@ When you submit your PR (or later change that code), a CI build will automatical
We always use ESLint and Prettier. To check that your code follows the rules, simply run the npm script `yarn lint`.
### Commits rules
### Commit rules
For commits it is recommended to use [Conventional Commits](https://www.conventionalcommits.org).

View File

@@ -264,7 +264,7 @@ The core of the Semaphore protocol is in the [circuit logic](/packages/circuits/
</a>
</td>
</tr>
<tbody>
</tbody>
</table>
## 🛠 Install
@@ -275,12 +275,18 @@ Clone this repository:
git clone https://github.com/semaphore-protocol/semaphore.git
```
And install the dependencies:
Install the dependencies:
```bash
cd semaphore && yarn
```
And build the repositiory:
```bash
yarn build
```
## 📜 Usage
Copy the `.env.example` file as `.env`:

Binary file not shown.

After

Width:  |  Height:  |  Size: 315 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 223 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 182 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 201 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 126 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 133 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 130 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 134 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 125 KiB

View File

@@ -42,7 +42,7 @@
"message": "Valores públicos"
},
"section.identities.box2.description": {
"message": "Semaphore utiliza la función hash Poseidon para crear el identtity commitment a partir de los valores privados. Los identity commitments se pueden compartir públicamente, de forma similar a las direcciones Ethereum."
"message": "Semaphore utiliza la función hash Poseidon para crear el identity commitment a partir de los valores privados. Los identity commitments se pueden compartir públicamente, de forma similar a las direcciones Ethereum."
},
"section.identities.box3.title": {
"message": "Generar identidades"

View File

@@ -12,6 +12,6 @@ as well as relevant circuits in
which the Semaphore zk-SNARK uses.
The summary of the audit results can be found
[here](https://github.com/appliedzkp/semaphore/tree/master/audit). After three
[here](https://github.com/semaphore-protocol/semaphore/blob/main/apps/docs/versioned_docs/version-V1/audit.md). After three
rounds of fixes, all security and performance issues were fixed, and the few
remaining issues are minor and do not affect security.

View File

@@ -58,7 +58,7 @@ Hardhat includes the Hardhat Network, a local Ethereum network for development.
## Install Semaphore packages
Semaphore provides contracts, JavaScript libraries and an Hardhat plugin for developers building zero-knowledge applications.
Semaphore provides contracts, JavaScript libraries and a Hardhat plugin for developers building zero-knowledge applications.
- `@semaphore-protocol/contracts` provides contracts to manage groups and verify Semaphore proofs on-chain.
- JavaScript libraries help developers build zero-knowledge applications.

View File

@@ -16,10 +16,10 @@
"format:write": "remark ./**/*.mdx --output"
},
"dependencies": {
"@docusaurus/core": "3.1.1",
"@docusaurus/preset-classic": "3.1.1",
"@docusaurus/core": "3.5.2",
"@docusaurus/preset-classic": "3.5.2",
"@mdx-js/react": "^3.0.0",
"@semaphore-protocol/utils": "4.5.0",
"@semaphore-protocol/utils": "4.8.2",
"@svgr/webpack": "^5.5.0",
"clsx": "^1.2.1",
"docusaurus-plugin-sass": "^0.2.5",
@@ -31,8 +31,8 @@
"url-loader": "^4.1.1"
},
"devDependencies": {
"@docusaurus/module-type-aliases": "3.1.1",
"@docusaurus/tsconfig": "3.1.1",
"@docusaurus/module-type-aliases": "3.5.2",
"@docusaurus/tsconfig": "3.5.2",
"@types/react": "^18.2.29",
"remark-cli": "^12.0.0",
"remark-frontmatter": "^5.0.0",

View File

@@ -12,6 +12,6 @@ as well as relevant circuits in
which the Semaphore zk-SNARK uses.
The summary of the audit results can be found
[here](https://github.com/appliedzkp/semaphore/tree/master/audit). After three
[here](https://github.com/semaphore-protocol/semaphore/blob/main/apps/docs/versioned_docs/version-V1/audit.md). After three
rounds of fixes, all security and performance issues were fixed, and the few
remaining issues are minor and do not affect security.

View File

@@ -121,7 +121,7 @@ authenticity of the signal and prevents front-running attacks.
## Cryptographic primitives
Semaphore uses MiMC for the Merkle tree, Pedersen commmitments for the identity
Semaphore uses MiMC for the Merkle tree, Pedersen commitments for the identity
commitments, Blake2 for the nullifiers hash, and EdDSA for the signature.
MiMC is a relatively new hash function. We use the recommended MiMC

View File

@@ -145,7 +145,7 @@ Returns `false` otherwise.
**`signMsg(privKey: EddsaPrivateKey, msg: SnarkBigInt): EdDSAMiMcSpongeSignature)`**
Encapsualtes `circomlib.eddsa.signMiMCSponge` to sign a message `msg` using private key `privKey`.
Encapsulates `circomlib.eddsa.signMiMCSponge` to sign a message `msg` using private key `privKey`.
**`verifySignature(msg: SnarkBigInt, signature: EdDSAMiMcSpongeSignature, pubKey: EddsaPublicKey)`: boolean**
@@ -190,7 +190,7 @@ const genWitness = async (
- `circuit` is the output of `genCircuit()`.
- `identity` is the `Identity` whose identity commitment you want to prove is
in the set of registered identities.
- `idCommitments` is an array of registered identity commmitments; i.e. the
- `idCommitments` is an array of registered identity commitments; i.e. the
leaves of the tree.
- `treeDepth` is the number of levels which the Merkle tree used has
- `externalNullifier` is the current external nullifier
@@ -212,7 +212,7 @@ Only `witness` is essential to generate the proof; the other data is only
useful for debugging and additional off-chain checks, such as verifying the
signature and the Merkle tree root.
**`formatForVerifierContract = (proof: SnarkProof, publicSignals: SnarkPublicSignals`**
**`formatForVerifierContract = (proof: SnarkProof, publicSignals: SnarkPublicSignals)`**
Converts the data in `proof` and `publicSignals` to strings and rearranges
elements of `proof.pi_b` so that `snarkjs`'s `verifier.sol` will accept it.

View File

@@ -26,7 +26,7 @@ With the Client contract as the owner of the Semaphore contract, the Client
contract may call owner-only Semaphore functions such as
`addExternalNullifier()`.
## Add, deactivate, or reactivate external nullifiiers
## Add, deactivate, or reactivate external nullifiers
These functions add, deactivate, and reactivate an external nullifier respectively.
As each identity can only signal once to an external nullifier, and as a signal

View File

@@ -55,7 +55,7 @@ In sum, Semaphore provides the ability to:
### External nullifiers
Think of an external nullifier as a voting booth where each user may only cast
one vote. If they try to cast a second vote a the same booth, that vote is
one vote. If they try to cast a second vote at the same booth, that vote is
invalid.
An external nullifier is any 29-byte value. Semaphore always starts with one
@@ -89,7 +89,7 @@ An anonymous voting app would be configured differently:
| ----------------------------------- | ------------------------ |
| The hash of the respondent's answer | The hash of the question |
This allows any user to vote with an arbitary response (e.g. yes, no, or maybe)
This allows any user to vote with an arbitrary response (e.g. yes, no, or maybe)
to any question. The user, however, can only vote once per question.
## About the code

View File

@@ -9,7 +9,7 @@ Site owners publish _subgraphs_ that expose site data for anyone to query.
Semaphore's subgraph allows you to retrieve data from the [`Semaphore.sol`](https://github.com/semaphore-protocol/semaphore/tree/v2.6.1/packages/contracts/Semaphore.sol) smart contract.
:::tip
The Graph protocol uses the [GraphQL](https://graphql.org/) query lanaguage. For examples, see the [GraphQL API documentation](https://thegraph.com/docs/developer/graphql-api). Visit the [subgraph repository](https://github.com/semaphore-protocol/subgraph) to see the list of Semaphore subgraphs.
The Graph protocol uses the [GraphQL](https://graphql.org/) query language. For examples, see the [GraphQL API documentation](https://thegraph.com/docs/developer/graphql-api). Visit the [subgraph repository](https://github.com/semaphore-protocol/subgraph) to see the list of Semaphore subgraphs.
:::
## Schema

View File

@@ -37,7 +37,7 @@ For more information, see [Merkle tree in Wikipedia](https://en.wikipedia.org/wi
## Nullifier
A value used to prevent double entry or double signalling.
A value used to prevent double entry or double signaling.
See [Circuit nullifier hash](/V3/technical-reference/circuits/#nullifier-hash).

View File

@@ -0,0 +1,131 @@
---
sidebar_position: 8
---
# Benchmarks
Semaphore v4 introduces new features and performance improvements. Detailed changes are available in the [release changelog](https://github.com/semaphore-protocol/semaphore/releases/tag/v4.0.0).
The primary changes in benchmark values are driven by the two major protocol updates:
- New [Identity schema](https://github.com/semaphore-protocol/semaphore/tree/main/packages/identity).
- [LeanIMT](https://github.com/privacy-scaling-explorations/zk-kit/tree/main/packages/lean-imt): New optimized IMT.
## New Identity schema
Semaphore v4 includes a new schema for the identities allowing the creation and verification of signatures.
Although the new Identity package is slightly slower than the one in Semaphore v3 (by just a few milliseconds), the trade-off is minimal considering the included functionality.
The new identity schema adds additional constraints to the Semaphore v4 circuit; however, this does not negatively impact overall performance of the protocol.
## LeanIMT
Semaphore v4 uses the LeanIMT data structure for group operations, an improvement over the IMT used in v3.
For further details, see the [LeanIMT paper](https://github.com/privacy-scaling-explorations/zk-kit/tree/main/papers/leanimt).
The LeanIMT offers dynamic depth, resulting in faster and more cost-effective group operations, across Node.js, browser and smart contracts.
Semaphore v4 support tree depths from 1 to 32, while v3 supports depths from 16 to 32, both for proof generation and verification.
## System Specifications and Software environment
All the benchmarks were run in an environment with these properties:
**System Specifications**
Computer: MacBook Pro
Chip: Apple M2 Pro
Memory (RAM): 16 GB
Operating System: macOS Sequoia version 15.0.1
**Software environment**
Node.js version: 20.18.0
Browser: Google Chrome Version 130.0.6723.92 (Official Build) (arm64)
## Running the benchmarks
### Javascript and Circom
GitHub repository to the run Node.js, browser and Circom benchmarks: https://github.com/vplasencia/semaphore-benchmarks
### Solidity
GitHub repository to run the Solidity benchmarks: https://github.com/semaphore-protocol/semaphore
## Node.js benchmarks
### Identities
![Identities](../../assets/img-benchmarks/node/identity-node-benchmarks.png)
### Create Group
Create group, either empty or with initial members.
![Create Group](../../assets/img-benchmarks/node/create-group-node-benchmarks.png)
### Add Member
Add a member to groups with different sizes.
![Add Member](../../assets/img-benchmarks/node/add-member-node-benchmarks.png)
### Generate Proof
Generate a proof using groups with different numbers of members.
![Generate Proof](../../assets/img-benchmarks/node/generate-proof-node-benchmarks.png)
### Verify Proof
Verify a proof using groups with different numbers of members.
![Verify Proof](../../assets/img-benchmarks/node/verify-proof-node-benchmarks.png)
## Browser benchmarks
Main functions used in the browser.
![Browser benchmarks](../../assets/img-benchmarks/browser/browser-benchmarks.png)
## Circuit benchmarks
### Semaphore V3
<img
src={require('../../assets/img-benchmarks/circuits/semaphore-v3-circuits-benchmarks.png').default}
alt="Circuit benchmarks Semaphore v3"
style={{ width: '300px', height: 'auto' }}
/>
### Semaphore V4
<img
src={require('../../assets/img-benchmarks/circuits/semaphore-v4-circuits-benchmarks.png').default}
alt="Circuit benchmarks Semaphore v4"
style={{ width: '300px', height: 'auto' }}
/>
## Contracts
<img
src={require('../../assets/img-benchmarks/contracts/contract-benchmarks.png').default}
alt="Contract Benchmarks"
style={{ width: '590px', height: 'auto' }}
/>
### Semaphore V3 gas report
![Contracts benchmarks Semaphore v3](../../assets/img-benchmarks/contracts/semaphore-v3-contracts-benchmarks.png)
### Semaphore V4 gas report
![Contracts benchmarks Semaphore v4](../../assets/img-benchmarks/contracts/semaphore-v4-contracts-benchmarks.png)

View File

@@ -1,5 +1,5 @@
---
sidebar_position: 12
sidebar_position: 13
---
# Credits

View File

@@ -1,5 +1,5 @@
---
sidebar_position: 11
sidebar_position: 12
---
# FAQ

View File

@@ -1,5 +1,5 @@
---
sidebar_position: 8
sidebar_position: 9
---
# Glossary

View File

@@ -20,7 +20,7 @@ To prevent fraud, the owner should keep their private key secret.
## Install package
In your code, use the [`@semaphore-protocol/identity`](https://github.com/semaphore-protocol/semaphore/tree/main/packages/identity) package to manage Semaphore identites.
In your code, use the [`@semaphore-protocol/identity`](https://github.com/semaphore-protocol/semaphore/tree/main/packages/identity) package to manage Semaphore identities.
<Tabs
defaultValue="npm"

View File

@@ -79,7 +79,7 @@ const group = new Group(members)
Each proof requires a [scope](/glossary#scope), on which each user may only generate one valid proof. The scope, together with the user's private key, is used to generate the nullifier, which is the value you can actually use to check whether a proof with that scope has already been generated by that user. In a voting application where double-voting must be prevented, the scope could be the ballot id, or the Merkle root of the group.
### 4. Generate the anomymous message
### 4. Generate the anonymous message
Finally, you can generate the proof with the anonymous message using the `generateProof` function. For example:

View File

@@ -1,5 +1,5 @@
---
sidebar_position: 9
sidebar_position: 10
---
import Articles from '@site/src/components/Articles';

View File

@@ -1,5 +1,5 @@
---
sidebar_position: 10
sidebar_position: 11
---
import Tabs from "@theme/Tabs"

View File

@@ -42,21 +42,22 @@
## Networks
You can access any subgraph supported by Semaphore with the following URL: https://api.studio.thegraph.com/query/14377/semaphore-<network-name>/v4.0.0-beta.17.
You can access any subgraph supported by Semaphore with the following URL: `https://api.studio.thegraph.com/query/14377/semaphore-<network-name>/v4.2.0`.
Supported networks:
- `sepolia`
- `optimism`
- `optimism-sepolia`
- `arbitrum-one`
- `arbitrum`
- `arbitrum-sepolia`
- `matic`
- `polygon-amoy`
- `matic-amoy`
- `base-sepolia`
- `base`
- `linea-sepolia`
- `linea`
- `scroll-sepolia`
## 🛠 Install

View File

@@ -26,7 +26,7 @@ export default function Build() {
url: "https://github.com/semaphore-protocol/boilerplate",
details: [
"Begin your projects with a ready-to-use example template",
"Create identity, join group, send anonmous feedback",
"Create identity, join group, send anonymous feedback",
"Easily modify to align with specific project goals"
]
},
@@ -133,7 +133,7 @@ export default function Build() {
</VStack>
</Flex>
<Box position="relative" w={{ base: "full", xl: "727px" }} h="630" overflow="hidden">
<Box position="relative" w={{ base: "full", xl: "727px" }} h="630px" overflow="hidden">
<Image
src="https://semaphore.cedoor.dev/flower-shadow.jpg"
alt=""

View File

@@ -287,7 +287,7 @@ export default function Home() {
Upcoming Events
</Heading>
<VStack align="left" spacing="10" maxH="600" overflowY="auto">
<VStack align="left" spacing="10" maxH="600px" overflowY="auto">
{events.map((event) => (
<Link href={event.link} key={event.name} isExternal>
<VStack align="left">

View File

@@ -10,5 +10,11 @@
"date": "Nov 12-15, 2024",
"description": "Semaphore team will deliver an in-person talk and run workshops.",
"link": "https://devcon.org/en/"
},
{
"name": "ETHIndia",
"date": "Dec 6-8, 2024",
"description": "Semaphore team will deliver an in-person talk on Semaphore and Bandada.",
"link": "https://ethindia.co"
}
]

View File

@@ -555,5 +555,15 @@
"github": "https://github.com/GeneralMagicio/pairwise-RPGF4",
"website": "https://pairwise.vote"
}
},
{
"name": "VeilEscrow",
"categories": ["Privacy", "Coordination"],
"tagline": "Secure, private, and decentralized escrows for anonymous transactions",
"pse": false,
"icon": "",
"links": {
"github": "https://github.com/evgongora/VeilEscrow"
}
}
]

View File

@@ -9,7 +9,8 @@
"scripts": {
"build": "yarn build:libraries && yarn build:subgraph && yarn build:website && yarn build:docs",
"build:libraries": "yarn workspaces foreach -Apt --no-private run build",
"build:subgraph": "yarn workspace semaphore-subgraph build:sepolia",
"clean:subgraph": "rimraf apps/subgraph/node_modules",
"build:subgraph": "yarn clean:subgraph && yarn workspace semaphore-subgraph build:sepolia",
"build:website": "yarn workspace semaphore-website build",
"build:docs": "yarn workspace semaphore-docs build",
"compile:contracts": "yarn workspace semaphore-contracts compile",

View File

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

View File

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

View File

@@ -0,0 +1,3 @@
SEPOLIA_RPC_URL=
PRIVATE_KEY=
ETHERSCAN_API_KEY=

View File

@@ -0,0 +1,43 @@
node_modules
.env
# solidity-coverage files
/coverage
/coverage.json
# Output of 'npm pack'
*.tgz
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*
# Optional npm cache directory
.npm
.DS_Store
# yarn v3
.pnp.*
.pnp.js
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
# Foundry artifact
cache/
out/
# artifact for deploying on local Anvil node
**/31337

View File

@@ -0,0 +1,30 @@
# dependencies
node_modules
package-lock.json
yarn.lock
.yarn
# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# testing
coverage
coverage.json
# misc
.DS_Store
*.pem
# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Foundry artifact
cache/
out/
# artifact for deploying on local Anvil node
**/31337

View File

@@ -0,0 +1,6 @@
{
"semi": false,
"arrowParens": "always",
"trailingComma": "none",
"plugins": ["prettier-plugin-solidity"]
}

View File

@@ -0,0 +1,6 @@
{
"extends": "solhint:recommended",
"rules": {
"func-visibility": ["error", { "ignoreConstructors": true }]
}
}

File diff suppressed because one or more lines are too long

View File

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

View File

@@ -0,0 +1,113 @@
# Semaphore Foundry Template
This project demonstrates a basic Semaphore use case. It comes with a sample contract, a test for that contract and a sample script that deploys that contract.
## Prerequisites
This project requires [**Foundry**](https://getfoundry.sh/), and thus a [**Rust environment**](https://www.rust-lang.org/), installed in the machine.
## Install
### Install dependencies
```bash
yarn
```
## Usage
### Compile contracts
```bash
yarn compile
```
### Test contracts
```bash
yarn test
```
You can also generate a test coverage report:
```bash
yarn test:coverage
```
Or a test gas report:
```bash
yarn test:gas-report
```
You can also start a local [Anvil node](https://book.getfoundry.sh/anvil/) with Semaphore and Feedback contracts deployed on it with:
```bash
yarn dev
```
### Code quality and formatting
Run [solhint](https://github.com/protofire/solhint) to analyze the code and catch bugs:
```bash
yarn lint
```
Run [Prettier](https://prettier.io/) to check formatting rules:
```bash
yarn prettier
```
Or to automatically format the code:
```bash
yarn prettier:write
```
### Integrating with Semaphore Boilerplate
You can also integrate this project with [Semaphore Boilerplate](https://github.com/semaphore-protocol/boilerplate), using this project as the contract end and connecting with Boilerplate front end.
1. In `cli-template-contracts-foundry` package directory, run:
```sh
yarn install
yarn dev
```
After running `yarn dev`, notice the output of
```sh
# ...
# ...
== Return ==
feedbackAddr: address 0x6f1AFCA8BCA87bF02091AF6187a5002802f9FB31
semaphoreAddr: address 0xb730ce6CAE3FB706e83E4E00dFA31623966570eB
semaphoreVerifierAddr: address 0xE2c114f548bEf410eaCe04D0390b61cc963df295
# ...
# ...
```
2. Now, with another terminal, clone Semaphore Boilerplate down:
```sh
# Clone Semaphore boilerplate and build dependencies
git clone https://github.com/semaphore-protocol/boilerplate.git
cd boilerplate
yarn install
# Use the sample .env.example
cp .env.example .env
```
3. Open the file `apps/web-app/.env.development`. Modify the values of `NEXT_PUBLIC_FEEDBACK_CONTRACT_ADDRESS` and `NEXT_PUBLIC_SEMAPHORE_CONTRACT_ADDRESS` with **feedbackAddr** and **semaphoreAddr** values shown in step 1.
4. Run the Boilerplate front end:
```sh
yarn dev:web-app
```

View File

@@ -0,0 +1,15 @@
[profile.default]
src = "src"
out = "out"
script = "script"
libs = ["node_modules"]
allow_paths = ["*", "../.."]
[rpc_endpoints]
anvil = "http://127.0.0.1:8545"
# sepolia = "${SEPOLIA_RPC_URL}"
[etherscan]
# sepolia = { key = "${ETHERSCAN_API_KEY}" }
# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options

View File

@@ -0,0 +1,45 @@
{
"name": "@semaphore-protocol/cli-template-contracts-foundry",
"version": "4.8.2",
"description": "Semaphore Foundry template.",
"license": "Unlicense",
"devDependencies": {
"@semaphore-protocol/contracts": "4.8.2",
"@zk-kit/lean-imt.sol": "2.0.0",
"forge-std": "github:foundry-rs/forge-std#v1.9.4",
"poseidon-solidity": "0.0.5",
"prettier": "^3.2.5",
"prettier-plugin-solidity": "^1.3.1",
"solhint": "^4.1.1",
"wait-on": "^8.0.1"
},
"scripts": {
"dev": "anvil & (wait-on tcp:8545 && forge script script/DeployFeedback.s.sol --rpc-url anvil --broadcast --sender 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266)",
"compile": "forge build",
"clean": "forge clean",
"test": "forge test -vvv",
"test:report-gas": "forge test --gas-report",
"test:coverage": "forge coverage",
"lint": "yarn solhint \"{script,src,test}/**/*.sol\"",
"prettier": "prettier -c \"**/*.{json,md,svg,yml,sol}\"",
"prettier:write": "prettier -w \"**/*.{json,md,svg,yml,sol}\"",
"check": "yarn test & yarn lint & yarn prettier",
"prepublish": "tar -czf files.tgz .gitignore .yarn .yarnrc.yml"
},
"files": [
"src",
"test",
"script",
"package.json",
"foundry.toml",
"remappings.txt",
"README.md",
"files.tgz",
".editorconfig",
".env.example",
".prettierignore",
".prettierrc.json",
".solhint.json"
],
"packageManager": "yarn@4.1.0"
}

View File

@@ -0,0 +1,4 @@
@semaphore/contracts/=./node_modules/@semaphore-protocol/contracts/
@zk-kit/lean-imt.sol/=./node_modules/@zk-kit/lean-imt.sol/
forge-std/=./node_modules/forge-std/src/
poseidon-solidity/=./node_modules/poseidon-solidity/

View File

@@ -0,0 +1,37 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.23;
import {Feedback} from "../src/Feedback.sol";
import {Semaphore} from "@semaphore/contracts/Semaphore.sol";
import {SemaphoreVerifier} from "@semaphore/contracts/base/SemaphoreVerifier.sol";
import {ISemaphoreVerifier} from "@semaphore/contracts/interfaces/ISemaphoreVerifier.sol";
import {Script} from "forge-std/Script.sol";
// Passing SALT parameter to use CREATE2 for deterministic contract address
bytes32 constant SALT = bytes32(0);
contract DeployFeedback is Script {
function run() external returns (address feedbackAddr, address semaphoreAddr, address semaphoreVerifierAddr) {
// Default to use the first test user private key of anvil node
uint256 deployerPrivateKey = vm.envOr(
"PRIVATE_KEY",
uint256(0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80)
);
vm.startBroadcast(deployerPrivateKey);
// Deploy SemaphoreVerifier
SemaphoreVerifier semaphoreVerifierContract = new SemaphoreVerifier{salt: SALT}();
semaphoreVerifierAddr = address(semaphoreVerifierContract);
// Deploy Semaphore
Semaphore semaphoreContract = new Semaphore{salt: SALT}(ISemaphoreVerifier(semaphoreVerifierAddr));
semaphoreAddr = address(semaphoreContract);
// Deploy Feedback
Feedback feedbackContract = new Feedback{salt: SALT}(semaphoreAddr);
feedbackAddr = address(feedbackContract);
vm.stopBroadcast();
}
}

View File

@@ -0,0 +1,39 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.23;
import {ISemaphore} from "@semaphore/contracts/interfaces/ISemaphore.sol";
contract Feedback {
ISemaphore public semaphore;
uint256 public groupId;
constructor(address semaphoreAddress) {
semaphore = ISemaphore(semaphoreAddress);
groupId = semaphore.createGroup();
}
function joinGroup(uint256 identityCommitment) external {
semaphore.addMember(groupId, identityCommitment);
}
function sendFeedback(
uint256 merkleTreeDepth,
uint256 merkleTreeRoot,
uint256 nullifier,
uint256 feedback,
uint256[8] calldata points
) external {
ISemaphore.SemaphoreProof memory proof = ISemaphore.SemaphoreProof(
merkleTreeDepth,
merkleTreeRoot,
nullifier,
feedback,
groupId,
points
);
semaphore.validateProof(groupId, proof);
}
}

View File

@@ -0,0 +1,74 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.23;
import {Test} from "forge-std/Test.sol";
import {ISemaphore} from "@semaphore/contracts/interfaces/ISemaphore.sol";
import {ISemaphoreGroups} from "@semaphore/contracts/interfaces/ISemaphoreGroups.sol";
import {Feedback} from "../src/Feedback.sol";
import {DeployFeedback} from "../script/DeployFeedback.s.sol";
contract FeedbackTest is Test {
event MemberAdded(uint256 indexed groupId, uint256 index, uint256 identityCommitment, uint256 merkleTreeRoot);
Feedback internal feedbackContract;
ISemaphore internal semaphoreContract;
ISemaphoreGroups internal semaphoreGroups;
uint256 internal groupId;
function setUp() external {
DeployFeedback deployFeedback = new DeployFeedback();
(address feedbackAddress, address semaphoreAddress, ) = deployFeedback.run();
feedbackContract = Feedback(feedbackAddress);
semaphoreContract = ISemaphore(semaphoreAddress);
semaphoreGroups = ISemaphoreGroups(semaphoreAddress);
groupId = feedbackContract.groupId();
}
function testGroupCreatedInConstructor() public view {
uint256 groupCount = semaphoreContract.groupCounter();
assertEq(groupCount, 1);
}
function testJoinGroup() public {
// The commitment below is generated with private key of the first account in Anvil
uint256 identityCommitment = 15072455385723004728391568434269917452175057560864330595979104241296826134229;
// Test: expect an event emitted. Check for all event topics and data
vm.expectEmit(true, true, true, true);
emit MemberAdded(groupId, 0, identityCommitment, identityCommitment);
feedbackContract.joinGroup(identityCommitment);
}
function testSendFeedback() public {
uint256[] memory commitments = new uint256[](2);
commitments[0] = uint256(11005642493773047649202648265396872197147567800455247120861783398111750817516);
commitments[1] = uint256(14473821761500463903284857947161896352613497175238126022206384102438097355186);
for (uint256 i = 0; i < commitments.length; ++i) {
feedbackContract.joinGroup(commitments[i]);
}
uint256 merkleTreeDepth = 1;
uint256 merkleTreeRoot = semaphoreGroups.getMerkleTreeRoot(groupId);
uint256 feedback = uint256(bytes32("Hello World"));
// These values are computed by running through @semaphore-protocol/circuits
uint256 nullifier = 14622092170088252518938850323258916742048811914834592843410744760450844885096;
uint256[8] memory points = [
2004484873491928515306456072357737929124240734208600886081152392890959117520,
21291026142870585364296731900941597996672838511394659364623185352043543529323,
4657264777014371046112557309523098953851041383509685591373847255581509612788,
6904165961903336246592681066375875983213983935764940579845010085396463328555,
1952750241178995674697344628236393389729638396609772141225880353616301956443,
106937615136633409337870509099767689510837462832227699340906789167349502398,
13080722838047436988558418790480431472161933638137155324683844808531903905810,
2547578906197450986657523555784319153413167960139250957065929818900731634820
];
vm.expectEmit(true, true, true, true);
emit ISemaphore.ProofValidated(groupId, merkleTreeDepth, merkleTreeRoot, nullifier, feedback, groupId, points);
feedbackContract.sendFeedback(merkleTreeDepth, merkleTreeRoot, nullifier, feedback, points);
}
}

View File

@@ -1,6 +1,6 @@
{
"name": "@semaphore-protocol/cli-template-contracts-hardhat",
"version": "4.5.0",
"version": "4.8.2",
"description": "Semaphore Hardhat template.",
"license": "Unlicense",
"files": [
@@ -16,7 +16,8 @@
".prettierrc.json",
"hardhat.config.ts",
"tsconfig.json",
"README.md"
"README.md",
".solhint.json"
],
"publishConfig": {
"access": "public"
@@ -41,9 +42,9 @@
"@nomicfoundation/hardhat-network-helpers": "^1.0.0",
"@nomicfoundation/hardhat-toolbox": "^4.0.0",
"@nomicfoundation/hardhat-verify": "^2.0.0",
"@semaphore-protocol/core": "4.5.0",
"@semaphore-protocol/hardhat": "4.5.0",
"@semaphore-protocol/utils": "4.5.0",
"@semaphore-protocol/core": "4.8.2",
"@semaphore-protocol/hardhat": "4.8.2",
"@semaphore-protocol/utils": "4.8.2",
"@typechain/ethers-v6": "^0.5.0",
"@typechain/hardhat": "^9.0.0",
"@types/chai": "^4.2.0",
@@ -59,7 +60,7 @@
"eslint-config-airbnb-typescript": "^17.1.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.29.1",
"ethers": "^6.4.0",
"ethers": "^6.13.4",
"hardhat": "^2.20.1",
"hardhat-gas-reporter": "^1.0.8",
"prettier": "^3.2.5",
@@ -71,7 +72,7 @@
"typescript": "^5.3.3"
},
"dependencies": {
"@semaphore-protocol/contracts": "4.5.0"
"@semaphore-protocol/contracts": "4.8.2"
},
"packageManager": "yarn@4.1.0"
}

View File

@@ -20,9 +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.5.0",
"@semaphore-protocol/hardhat": "4.5.0",
"@semaphore-protocol/utils": "4.5.0",
"@semaphore-protocol/core": "4.8.2",
"@semaphore-protocol/hardhat": "4.8.2",
"@semaphore-protocol/utils": "4.8.2",
"@typechain/ethers-v6": "^0.5.0",
"@typechain/hardhat": "^9.0.0",
"@types/chai": "^4.2.0",
@@ -38,7 +38,7 @@
"eslint-config-airbnb-typescript": "^17.1.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.29.1",
"ethers": "^6.4.0",
"ethers": "^6.13.4",
"hardhat": "^2.20.1",
"hardhat-gas-reporter": "^1.0.8",
"prettier": "^3.2.5",
@@ -50,7 +50,7 @@
"typescript": "^5.3.3"
},
"dependencies": {
"@semaphore-protocol/contracts": "4.5.0"
"@semaphore-protocol/contracts": "4.8.2"
},
"packageManager": "yarn@4.1.0"
}

View File

@@ -9,10 +9,10 @@
"lint": "next lint"
},
"dependencies": {
"@semaphore-protocol/core": "4.5.0",
"@semaphore-protocol/data": "4.5.0",
"@semaphore-protocol/utils": "4.5.0",
"ethers": "^6.11.1",
"@semaphore-protocol/core": "4.8.2",
"@semaphore-protocol/data": "4.8.2",
"@semaphore-protocol/utils": "4.8.2",
"ethers": "^6.13.4",
"next": "14.1.0",
"next-pwa": "^5.6.0",
"react": "^18",

View File

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

View File

@@ -20,9 +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.5.0",
"@semaphore-protocol/hardhat": "4.5.0",
"@semaphore-protocol/utils": "4.5.0",
"@semaphore-protocol/core": "4.8.2",
"@semaphore-protocol/hardhat": "4.8.2",
"@semaphore-protocol/utils": "4.8.2",
"@typechain/ethers-v6": "^0.5.0",
"@typechain/hardhat": "^9.0.0",
"@types/chai": "^4.2.0",
@@ -38,7 +38,7 @@
"eslint-config-airbnb-typescript": "^17.1.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.29.1",
"ethers": "^6.4.0",
"ethers": "^6.13.4",
"hardhat": "^2.20.1",
"hardhat-gas-reporter": "^1.0.8",
"prettier": "^3.2.5",
@@ -50,7 +50,7 @@
"typescript": "^5.3.3"
},
"dependencies": {
"@semaphore-protocol/contracts": "4.5.0"
"@semaphore-protocol/contracts": "4.8.2"
},
"packageManager": "yarn@4.1.0"
}

View File

@@ -9,10 +9,10 @@
"lint": "next lint"
},
"dependencies": {
"@semaphore-protocol/core": "4.5.0",
"@semaphore-protocol/data": "4.5.0",
"@semaphore-protocol/utils": "4.5.0",
"ethers": "^6.11.1",
"@semaphore-protocol/core": "4.8.2",
"@semaphore-protocol/data": "4.8.2",
"@semaphore-protocol/utils": "4.8.2",
"ethers": "^6.13.4",
"next": "14.1.0",
"next-pwa": "^5.6.0",
"react": "^18",

View File

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

View File

@@ -1,7 +1,7 @@
{
"name": "@semaphore-protocol/cli",
"type": "module",
"version": "4.5.0",
"version": "4.8.2",
"description": "A command line tool to set up your Semaphore project and get group data.",
"license": "MIT",
"bin": {
@@ -41,8 +41,8 @@
"rollup-plugin-cleanup": "^3.2.1"
},
"dependencies": {
"@semaphore-protocol/data": "4.5.0",
"@semaphore-protocol/utils": "4.5.0",
"@semaphore-protocol/data": "4.8.2",
"@semaphore-protocol/utils": "4.8.2",
"axios": "^1.6.7",
"boxen": "^7.1.1",
"chalk": "^5.3.0",

View File

@@ -32,6 +32,10 @@ const supportedTemplates = [
{
value: "contracts-hardhat",
name: "Hardhat"
},
{
value: "contracts-foundry",
name: "Foundry"
}
]

View File

@@ -46,18 +46,16 @@ To learn more about contracts visit [semaphore.pse.dev](https://docs.semaphore.p
## 🛠 Install
### npm or yarn
You can install the semaphore protocol contracts with any node package manager (`bun`, `npm`, `pnpm`,`yarn`) or the solidity package manager [`soldeer`](https://soldeer.xyz).
Install the `@semaphore-protocol/contracts` package with npm:
```bash
```commandline
bun add @semaphore-protocol/contracts
npm i @semaphore-protocol/contracts
```
or yarn:
```bash
pnpm add @semaphore-protocol/contracts
yarn add @semaphore-protocol/contracts
# for soldeer, an explicit version is required, e.g:
soldeer install semaphore-protocol-contracts~4.6.0
```
## 📜 Usage

View File

@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.23;
pragma solidity >=0.8.23 <=0.8.28;
import {ISemaphore} from "./interfaces/ISemaphore.sol";
import {ISemaphoreVerifier} from "./interfaces/ISemaphoreVerifier.sol";

View File

@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.23;
pragma solidity >=0.8.23 <=0.8.28;
/// @dev Minimum supported tree depth.
uint8 constant MIN_DEPTH = 1;

View File

@@ -1,5 +1,5 @@
//SPDX-License-Identifier: MIT
pragma solidity 0.8.23;
pragma solidity >=0.8.23 <=0.8.28;
import {ISemaphoreGroups} from "../interfaces/ISemaphoreGroups.sol";
import {InternalLeanIMT, LeanIMTData} from "@zk-kit/lean-imt.sol/InternalLeanIMT.sol";

View File

@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
// Part of this file was generated with [snarkJS](https://github.com/iden3/snarkjs).
pragma solidity 0.8.23;
pragma solidity >=0.8.23 <=0.8.28;
import {MAX_DEPTH} from "./Constants.sol";
import {SemaphoreVerifierKeyPts} from "./SemaphoreVerifierKeyPts.sol";
@@ -59,7 +59,10 @@ contract SemaphoreVerifier {
mstore(add(mIn, 32), y)
mstore(add(mIn, 64), s)
success := staticcall(sub(gas(), 2000), 7, mIn, 96, mIn, 64)
// ecMul gas cost is fixed at 6000. Add 33.3% gas for safety buffer.
// Last checked in 2024 Oct, evm codename Cancun
// ref: https://www.evm.codes/precompiled?fork=cancun#0x07
success := staticcall(8000, 7, mIn, 96, mIn, 64)
if iszero(success) {
mstore(0, 0)
@@ -69,7 +72,10 @@ contract SemaphoreVerifier {
mstore(add(mIn, 64), mload(pR))
mstore(add(mIn, 96), mload(add(pR, 32)))
success := staticcall(sub(gas(), 2000), 6, mIn, 128, pR, 64)
// ecAdd gas cost is fixed at 150. Add 33.3% gas for safety buffer.
// Last checked in 2024 Oct, evm codename Cancun
// ref: https://www.evm.codes/precompiled?fork=cancun#0x06
success := staticcall(200, 6, mIn, 128, pR, 64)
if iszero(success) {
mstore(0, 0)
@@ -149,7 +155,10 @@ contract SemaphoreVerifier {
mstore(add(_pPairing, 704), mload(add(vkPoints, 64)))
mstore(add(_pPairing, 736), mload(add(vkPoints, 96)))
let success := staticcall(sub(gas(), 2000), 8, _pPairing, 768, _pPairing, 0x20)
// ecPairing gas cost at 181000 given 768 bytes input. Add 33.3% gas for safety buffer.
// Last checked in 2024 Oct, evm codename Cancun
// ref: https://www.evm.codes/precompiled?fork=cancun#0x08
let success := staticcall(241333, 8, _pPairing, 768, _pPairing, 0x20)
isOk := and(success, mload(_pPairing))
}

View File

@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT
// Part of this file was generated with [snarkJS](https://github.com/iden3/snarkjs).
pragma solidity 0.8.23;
pragma solidity >=0.8.23 <=0.8.28;
library SemaphoreVerifierKeyPts {
error Semaphore__VKPtBytesMaxDepthInvariantViolated(uint256 actual, uint256 expected);

View File

@@ -1,5 +1,5 @@
//SPDX-License-Identifier: MIT
pragma solidity 0.8.23;
pragma solidity >=0.8.23 <=0.8.28;
/// @title Semaphore contract interface.
interface ISemaphore {

View File

@@ -1,5 +1,5 @@
//SPDX-License-Identifier: MIT
pragma solidity 0.8.23;
pragma solidity >=0.8.23 <=0.8.28;
/// @title SemaphoreGroups contract interface.
interface ISemaphoreGroups {

View File

@@ -1,5 +1,5 @@
//SPDX-License-Identifier: MIT
pragma solidity 0.8.23;
pragma solidity >=0.8.23 <=0.8.28;
/// @title SemaphoreVerifier contract interface.
interface ISemaphoreVerifier {

View File

@@ -1,6 +1,6 @@
{
"name": "@semaphore-protocol/contracts",
"version": "4.5.0",
"version": "4.8.2",
"description": "Semaphore contracts to manage groups and broadcast anonymous signals.",
"license": "MIT",
"files": [

View File

@@ -64,6 +64,14 @@ const hardhatConfig: HardhatUserConfig = {
apiURL: "https://api.lineascan.build/api",
browserURL: "https://lineascan.build"
}
},
{
network: "scroll-sepolia",
chainId: 534351,
urls: {
apiURL: "https://api-sepolia.scrollscan.com/api",
browserURL: "https://sepolia.scrollscan.com"
}
}
]
},

View File

@@ -29,7 +29,7 @@
"@types/ncp": "^2",
"@types/node": "^20.10.7",
"chai": "^4.2.0",
"ethers": "^6.4.0",
"ethers": "^6.13.4",
"hardhat": "^2.19.4",
"hardhat-gas-reporter": "^1.0.8",
"ncp": "^2.0.0",

View File

@@ -463,9 +463,62 @@ describe("Semaphore", () => {
const proof = await generateProof(identity, group, message, group.root, merkleTreeDepth)
return { semaphoreContract, groupId, proof }
return { semaphoreContract, groupId, proof, accountAddresses }
}
it("Should insert members,remove member,update member and verifyProof", async () => {
const { semaphoreContract, accountAddresses } = await loadFixture(deployValidateProofFixture)
const identity = new Identity("0")
const members = Array.from({ length: 3 }, (_, i) => new Identity(i.toString())).map(
({ commitment }) => commitment
)
const group = new Group(members)
// Create a group and add 3 members.
await semaphoreContract["createGroup(address)"](accountAddresses[0])
const groupId = 2
// Adding members to group
await semaphoreContract.addMembers(groupId, members)
// Remove the third member.
{
group.removeMember(2)
const { siblings } = group.generateMerkleProof(2)
await semaphoreContract.removeMember(groupId, members[2], siblings)
}
// Update the second member.
{
group.updateMember(1, members[2])
const { siblings } = group.generateMerkleProof(1)
await semaphoreContract.updateMember(groupId, members[1], members[2], siblings)
}
// Validate a proof.
const proof = await generateProof(identity, group, 42, group.root)
const transaction = await semaphoreContract.validateProof(groupId, proof)
await expect(transaction)
.to.emit(semaphoreContract, "ProofValidated")
.withArgs(
groupId,
proof.merkleTreeDepth,
proof.merkleTreeRoot,
proof.nullifier,
proof.message,
proof.merkleTreeRoot,
proof.points
)
})
it("Should throw an exception if the proof is not valid", async () => {
const { semaphoreContract, groupId, proof } = await loadFixture(deployValidateProofFixture)

View File

@@ -1,6 +1,6 @@
{
"name": "@semaphore-protocol/core",
"version": "4.5.0",
"version": "4.8.2",
"description": "Core library for the essential Semaphore features.",
"type": "module",
"license": "MIT",
@@ -42,8 +42,8 @@
"access": "public"
},
"dependencies": {
"@semaphore-protocol/group": "4.5.0",
"@semaphore-protocol/identity": "4.5.0",
"@semaphore-protocol/proof": "4.5.0"
"@semaphore-protocol/group": "4.8.2",
"@semaphore-protocol/identity": "4.8.2",
"@semaphore-protocol/proof": "4.8.2"
}
}

View File

@@ -1,6 +1,6 @@
{
"name": "@semaphore-protocol/data",
"version": "4.5.0",
"version": "4.8.2",
"description": "A library for querying Semaphore smart contract.",
"type": "module",
"license": "MIT",
@@ -37,8 +37,8 @@
"rollup-plugin-cleanup": "^3.2.1"
},
"dependencies": {
"@semaphore-protocol/utils": "4.5.0",
"@semaphore-protocol/utils": "4.8.2",
"axios": "1.6.6",
"ethers": "6.11.0"
"ethers": "6.13.4"
}
}

View File

@@ -40,7 +40,7 @@ export default class SemaphoreEthers {
* @param options Configuration options for the ethers provider and the Semaphore contract.
*/
constructor(networkOrEthereumURL: EthersNetwork | string = defaultNetwork, options: EthersOptions = {}) {
checkParameter(networkOrEthereumURL, "networkOrSubgraphURL", "string")
checkParameter(networkOrEthereumURL, "networkOrEthereumURL", "string")
if (options.provider) {
checkParameter(options.provider, "provider", "string")
@@ -58,13 +58,13 @@ export default class SemaphoreEthers {
options.address ??= address
options.startBlock ??= startBlock
} else {
if (options.address === undefined) {
throw new Error(`Network '${networkOrEthereumURL}' needs a Semaphore contract address`)
}
options.startBlock ??= 0
}
if (options.address === undefined) {
throw new Error(`Network '${networkOrEthereumURL}' needs a Semaphore contract address`)
}
let provider: Provider
switch (options.provider) {

View File

@@ -12,5 +12,5 @@ export default function getURL(supportedNetwork: SupportedNetwork): string {
throw new TypeError(`Network '${supportedNetwork}' is not supported`)
}
return `https://api.studio.thegraph.com/query/14377/semaphore-${supportedNetwork}/v4.0.0`
return `https://api.studio.thegraph.com/query/14377/semaphore-${supportedNetwork}/v4.2.0`
}

View File

@@ -1,6 +1,6 @@
{
"name": "@semaphore-protocol/group",
"version": "4.5.0",
"version": "4.8.2",
"description": "A library to create and manage Semaphore groups.",
"type": "module",
"license": "MIT",
@@ -36,7 +36,7 @@
"rollup-plugin-cleanup": "^3.2.1"
},
"dependencies": {
"@zk-kit/lean-imt": "2.2.1",
"@zk-kit/lean-imt": "2.2.2",
"@zk-kit/utils": "1.2.1",
"poseidon-lite": "0.3.0"
}

View File

@@ -1,6 +1,6 @@
{
"name": "@semaphore-protocol/hardhat",
"version": "4.5.0",
"version": "4.8.2",
"description": "A Hardhat plugin to deploy Semaphore contracts.",
"type": "module",
"license": "MIT",
@@ -41,8 +41,8 @@
},
"dependencies": {
"@nomicfoundation/hardhat-ethers": "^3.0.0",
"@semaphore-protocol/contracts": "4.5.0",
"ethers": "^6.4.0",
"@semaphore-protocol/contracts": "4.8.2",
"ethers": "^6.13.4",
"hardhat-dependency-compiler": "^1.1.3"
}
}

View File

@@ -1,6 +1,6 @@
{
"name": "@semaphore-protocol/identity",
"version": "4.5.0",
"version": "4.8.2",
"description": "A library to create Semaphore identities.",
"type": "module",
"license": "MIT",

View File

@@ -1,6 +1,6 @@
{
"name": "@semaphore-protocol/proof",
"version": "4.5.0",
"version": "4.8.2",
"description": "A library to generate and verify Semaphore proofs.",
"type": "module",
"license": "MIT",
@@ -47,14 +47,14 @@
"rollup-plugin-cleanup": "^3.2.1"
},
"peerDependencies": {
"@semaphore-protocol/group": "4.5.0",
"@semaphore-protocol/identity": "4.5.0"
"@semaphore-protocol/group": "4.8.2",
"@semaphore-protocol/identity": "4.8.2"
},
"dependencies": {
"@semaphore-protocol/utils": "4.5.0",
"@semaphore-protocol/utils": "4.8.2",
"@zk-kit/artifacts": "1.8.0",
"@zk-kit/utils": "1.2.1",
"ethers": "6.10.0",
"ethers": "6.13.4",
"snarkjs": "0.7.4"
}
}

View File

@@ -1,6 +1,6 @@
{
"name": "@semaphore-protocol/utils",
"version": "4.5.0",
"version": "4.8.2",
"description": "A library to provide utility functions to the other Semaphore packages.",
"type": "module",
"license": "MIT",
@@ -54,6 +54,6 @@
"rollup-plugin-cleanup": "^3.2.1"
},
"dependencies": {
"ethers": "^6.11.1"
"ethers": "^6.13.4"
}
}

View File

@@ -4,18 +4,18 @@
"contracts": [
{
"name": "SemaphoreVerifier",
"address": "0xe538f9DeeE04A397decb1E7dc5D16fD6f123c043",
"startBlock": 6333999
"address": "0x6C42599435B82121794D835263C846384869502d",
"startBlock": 6983614
},
{
"name": "PoseidonT3",
"address": "0xB43122Ecb241DD50062641f089876679fd06599a",
"startBlock": 6333999
"startBlock": 6983614
},
{
"name": "Semaphore",
"address": "0x1e0d7FF1610e480fC93BdEC510811ea2Ba6d7c2f",
"startBlock": 6333999
"address": "0x06d1530c829366A7fff0069e77c5af6A6FA7db2E",
"startBlock": 6983614
}
]
},
@@ -24,18 +24,18 @@
"contracts": [
{
"name": "SemaphoreVerifier",
"address": "0xe538f9DeeE04A397decb1E7dc5D16fD6f123c043",
"startBlock": 64798522
"address": "0x6C42599435B82121794D835263C846384869502d",
"startBlock": 93258221
},
{
"name": "PoseidonT3",
"address": "0xB43122Ecb241DD50062641f089876679fd06599a",
"startBlock": 64798522
"startBlock": 93258221
},
{
"name": "Semaphore",
"address": "0x1e0d7FF1610e480fC93BdEC510811ea2Ba6d7c2f",
"startBlock": 64798522
"address": "0x06d1530c829366A7fff0069e77c5af6A6FA7db2E",
"startBlock": 93258221
}
]
},
@@ -44,18 +44,18 @@
"contracts": [
{
"name": "SemaphoreVerifier",
"address": "0xe538f9DeeE04A397decb1E7dc5D16fD6f123c043",
"startBlock": 14757931
"address": "0x6C42599435B82121794D835263C846384869502d",
"startBlock": 19289434
},
{
"name": "PoseidonT3",
"address": "0xB43122Ecb241DD50062641f089876679fd06599a",
"startBlock": 14757931
"startBlock": 19289434
},
{
"name": "Semaphore",
"address": "0x1e0d7FF1610e480fC93BdEC510811ea2Ba6d7c2f",
"startBlock": 14757931
"address": "0x06d1530c829366A7fff0069e77c5af6A6FA7db2E",
"startBlock": 19289434
}
]
},
@@ -64,18 +64,18 @@
"contracts": [
{
"name": "SemaphoreVerifier",
"address": "0xe538f9DeeE04A397decb1E7dc5D16fD6f123c043",
"startBlock": 9636193
"address": "0x6C42599435B82121794D835263C846384869502d",
"startBlock": 13850778
},
{
"name": "PoseidonT3",
"address": "0xB43122Ecb241DD50062641f089876679fd06599a",
"startBlock": 9636193
"startBlock": 13850778
},
{
"name": "Semaphore",
"address": "0x1e0d7FF1610e480fC93BdEC510811ea2Ba6d7c2f",
"startBlock": 9636193
"address": "0x06d1530c829366A7fff0069e77c5af6A6FA7db2E",
"startBlock": 13850778
}
]
},
@@ -84,18 +84,18 @@
"contracts": [
{
"name": "SemaphoreVerifier",
"address": "0xe538f9DeeE04A397decb1E7dc5D16fD6f123c043",
"startBlock": 258951463
"address": "0x6C42599435B82121794D835263C846384869502d",
"startBlock": 269586534
},
{
"name": "PoseidonT3",
"address": "0xB43122Ecb241DD50062641f089876679fd06599a",
"startBlock": 258951463
"startBlock": 269586534
},
{
"name": "Semaphore",
"address": "0x1e0d7FF1610e480fC93BdEC510811ea2Ba6d7c2f",
"startBlock": 258951463
"address": "0x06d1530c829366A7fff0069e77c5af6A6FA7db2E",
"startBlock": 269586534
}
]
},
@@ -104,18 +104,18 @@
"contracts": [
{
"name": "SemaphoreVerifier",
"address": "0xe538f9DeeE04A397decb1E7dc5D16fD6f123c043",
"startBlock": 62466952
"address": "0x6C42599435B82121794D835263C846384869502d",
"startBlock": 63715311
},
{
"name": "PoseidonT3",
"address": "0xB43122Ecb241DD50062641f089876679fd06599a",
"startBlock": 62466952
"startBlock": 63715311
},
{
"name": "Semaphore",
"address": "0x1e0d7FF1610e480fC93BdEC510811ea2Ba6d7c2f",
"startBlock": 62466952
"address": "0x06d1530c829366A7fff0069e77c5af6A6FA7db2E",
"startBlock": 63715311
}
]
},
@@ -124,18 +124,18 @@
"contracts": [
{
"name": "SemaphoreVerifier",
"address": "0xe538f9DeeE04A397decb1E7dc5D16fD6f123c043",
"startBlock": 126057798
"address": "0x6C42599435B82121794D835263C846384869502d",
"startBlock": 127391657
},
{
"name": "PoseidonT3",
"address": "0xB43122Ecb241DD50062641f089876679fd06599a",
"startBlock": 126057798
"startBlock": 127391657
},
{
"name": "Semaphore",
"address": "0x1e0d7FF1610e480fC93BdEC510811ea2Ba6d7c2f",
"startBlock": 126057798
"address": "0x06d1530c829366A7fff0069e77c5af6A6FA7db2E",
"startBlock": 127391657
}
]
},
@@ -144,18 +144,18 @@
"contracts": [
{
"name": "SemaphoreVerifier",
"address": "0xe538f9DeeE04A397decb1E7dc5D16fD6f123c043",
"startBlock": 16008294
"address": "0x6C42599435B82121794D835263C846384869502d",
"startBlock": 17307202
},
{
"name": "PoseidonT3",
"address": "0xB43122Ecb241DD50062641f089876679fd06599a",
"startBlock": 16008294
"startBlock": 17307202
},
{
"name": "Semaphore",
"address": "0x1e0d7FF1610e480fC93BdEC510811ea2Ba6d7c2f",
"startBlock": 16008294
"address": "0x06d1530c829366A7fff0069e77c5af6A6FA7db2E",
"startBlock": 17307202
}
]
},
@@ -164,18 +164,18 @@
"contracts": [
{
"name": "SemaphoreVerifier",
"address": "0xe538f9DeeE04A397decb1E7dc5D16fD6f123c043",
"startBlock": 3928632
"address": "0x6C42599435B82121794D835263C846384869502d",
"startBlock": 5225214
},
{
"name": "PoseidonT3",
"address": "0xB43122Ecb241DD50062641f089876679fd06599a",
"startBlock": 3928632
"startBlock": 5225214
},
{
"name": "Semaphore",
"address": "0x1e0d7FF1610e480fC93BdEC510811ea2Ba6d7c2f",
"startBlock": 3928632
"address": "0x06d1530c829366A7fff0069e77c5af6A6FA7db2E",
"startBlock": 5225214
}
]
},
@@ -184,18 +184,18 @@
"contracts": [
{
"name": "SemaphoreVerifier",
"address": "0xe538f9DeeE04A397decb1E7dc5D16fD6f123c043",
"startBlock": 20553357
"address": "0x6C42599435B82121794D835263C846384869502d",
"startBlock": 21796660
},
{
"name": "PoseidonT3",
"address": "0xB43122Ecb241DD50062641f089876679fd06599a",
"startBlock": 20553357
"startBlock": 21796660
},
{
"name": "Semaphore",
"address": "0x1e0d7FF1610e480fC93BdEC510811ea2Ba6d7c2f",
"startBlock": 20553357
"address": "0x06d1530c829366A7fff0069e77c5af6A6FA7db2E",
"startBlock": 21796660
}
]
},
@@ -204,18 +204,38 @@
"contracts": [
{
"name": "SemaphoreVerifier",
"address": "0xe538f9DeeE04A397decb1E7dc5D16fD6f123c043",
"startBlock": 10235849
"address": "0x6C42599435B82121794D835263C846384869502d",
"startBlock": 11459722
},
{
"name": "PoseidonT3",
"address": "0xB43122Ecb241DD50062641f089876679fd06599a",
"startBlock": 10235849
"startBlock": 11459722
},
{
"name": "Semaphore",
"address": "0x1e0d7FF1610e480fC93BdEC510811ea2Ba6d7c2f",
"startBlock": 10235849
"address": "0x06d1530c829366A7fff0069e77c5af6A6FA7db2E",
"startBlock": 11459722
}
]
},
{
"network": "scroll-sepolia",
"contracts": [
{
"name": "SemaphoreVerifier",
"address": "0x6C42599435B82121794D835263C846384869502d",
"startBlock": 7397758
},
{
"name": "PoseidonT3",
"address": "0xB43122Ecb241DD50062641f089876679fd06599a",
"startBlock": 7397758
},
{
"name": "Semaphore",
"address": "0x06d1530c829366A7fff0069e77c5af6A6FA7db2E",
"startBlock": 7397758
}
]
}

View File

@@ -64,5 +64,11 @@ export default {
url: "https://rpc.linea.build",
chainId: 59144,
explorer: "https://lineascan.build"
},
"scroll-sepolia": {
name: "Scroll Sepolia",
url: "https://sepolia-rpc.scroll.io",
chainId: 534351,
explorer: "https://sepolia.scrollscan.com"
}
}

View File

@@ -10,10 +10,12 @@ async function maybePushToSoldeer() {
const response = await fetch(
"https://api.soldeer.xyz/api/v1/revision?project_name=semaphore-protocol-contracts&limit=1"
)
const { data, status } = await response.json()
const { data } = await response.json()
// fail status if no version published at all yet
if (status === "fail" || compare(contractsLocalVersion, data[0].version) === 1)
if (
data.length === 0 || // data = [] if no version has ever been published yet
compare(contractsLocalVersion, data[0].version) === 1
)
execSync(`soldeer push semaphore-protocol-contracts~${contractsLocalVersion} packages/contracts/contracts`, {
stdio: "inherit"
})

View File

@@ -8,6 +8,7 @@ const EXCLUDE_PKGS = [
"cli-template-contracts-hardhat",
"cli-template-monorepo-ethers",
"cli-template-monorepo-subgraph",
"cli-template-contracts-foundry",
"contracts",
"core",
"hardhat"

2859
yarn.lock

File diff suppressed because it is too large Load Diff