Skip to content

Commit

Permalink
refactor: merge main into 'jc/854' branch
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmychu0807 committed Nov 27, 2024
2 parents 072b11f + 4263966 commit adcec41
Show file tree
Hide file tree
Showing 124 changed files with 4,725 additions and 3,903 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ jobs:
sudo apt-get update && sudo apt-get install -y wget nlohmann-json3-dev libgmp-dev nasm g++ build-essential
- name: Setup Circom
run: wget https://github.com/iden3/circom/releases/latest/download/circom-linux-amd64 && sudo mv ./circom-linux-amd64 /usr/bin/circom && sudo chmod +x /usr/bin/circom
run: sudo wget https://github.com/iden3/circom/releases/download/v2.1.9/circom-linux-amd64 -O /usr/bin/circom && sudo chmod +x /usr/bin/circom

- name: Install dependencies
run: yarn
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pull-requests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ jobs:
run: |
sudo rm /etc/apt/sources.list.d/microsoft-prod.list
sudo apt-get update && sudo apt-get install -y wget nlohmann-json3-dev libgmp-dev nasm g++ build-essential
wget https://github.com/iden3/circom/releases/latest/download/circom-linux-amd64 && sudo mv ./circom-linux-amd64 /usr/bin/circom && sudo chmod +x /usr/bin/circom
sudo wget https://github.com/iden3/circom/releases/download/v2.1.9/circom-linux-amd64 -O /usr/bin/circom && sudo chmod +x /usr/bin/circom
yarn workspace @semaphore-protocol/group build
yarn workspace @semaphore-protocol/identity build
yarn workspace @semaphore-protocol/proof build
Expand Down
12 changes: 12 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ permissions:
contents: write

on:
workflow_dispatch:
push:
tags:
- "v*"
Expand All @@ -17,6 +18,16 @@ jobs:
with:
fetch-depth: 0

- name: Install soldeer
uses: taiki-e/install-action@v2
with:
tool: soldeer
- name: Store soldeer login credential
env:
SOLDEER_TOKEN: ${{ secrets.SOLDEER_TOKEN }}
run: |
echo "$SOLDEER_TOKEN" > "$GITHUB_WORKSPACE"/soldeer_login
- name: Install Node.js
uses: actions/setup-node@v4
with:
Expand All @@ -37,6 +48,7 @@ jobs:
run: yarn version:publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
SOLDEER_LOGIN_FILE: ${{ github.workspace }}/soldeer_login

- run: yarn version:release
env:
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ The core of the Semaphore protocol is in the [circuit logic](/packages/circuits/
</a>
</td>
</tr>
<tbody>
</tbody>
</table>

## 🛠 Install
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 5 additions & 5 deletions apps/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.0.3",
"@semaphore-protocol/utils": "4.6.0",
"@svgr/webpack": "^5.5.0",
"clsx": "^1.2.1",
"docusaurus-plugin-sass": "^0.2.5",
Expand All @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion apps/docs/versioned_docs/version-V1/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion apps/docs/versioned_docs/version-V3/glossary.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

Expand Down
131 changes: 131 additions & 0 deletions apps/docs/versioned_docs/version-V4/benchmarks.md
Original file line number Diff line number Diff line change
@@ -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)
2 changes: 1 addition & 1 deletion apps/docs/versioned_docs/version-V4/credits.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 12
sidebar_position: 13
---

# Credits
Expand Down
2 changes: 1 addition & 1 deletion apps/docs/versioned_docs/version-V4/faq.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 11
sidebar_position: 12
---

# FAQ
Expand Down
2 changes: 1 addition & 1 deletion apps/docs/versioned_docs/version-V4/glossary.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 8
sidebar_position: 9
---

# Glossary
Expand Down
30 changes: 30 additions & 0 deletions apps/docs/versioned_docs/version-V4/guides/identities.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,33 @@ After a message is signed, anyone can verify the signature using the message its
// Static method.
Identity.verifySignature(message, signature, identity1.publicKey)
```

## Export and import an identity

A Semaphore Identity can be exported and then imported later for reuse.

### Export an identity

Returns the private key encoded as a base64 string.

```ts
import { Identity } from "@semaphore-protocol/identity"

const identity = new Identity()

const privateKey = identity.export()
```

### Import an identity

Returns a Semaphore identity based on a private key encoded as a base64 string.

```ts
import { Identity } from "@semaphore-protocol/identity"

const identity = new Identity()

const privateKey = identity.export()

const identity2 = Identity.import(privateKey)
```
2 changes: 1 addition & 1 deletion apps/docs/versioned_docs/version-V4/resources.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 9
sidebar_position: 10
---

import Articles from '@site/src/components/Articles';
Expand Down
2 changes: 1 addition & 1 deletion apps/docs/versioned_docs/version-V4/troubleshooting.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 10
sidebar_position: 11
---

import Tabs from "@theme/Tabs"
Expand Down
24 changes: 15 additions & 9 deletions apps/subgraph/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,21 @@

## Networks

| Semaphore version | Sepolia | Polygon Mumbai | Optimism Sepolia | Arbitrum Sepolia | Arbitrum One | Polygon Amoy |
| ----------------- | ------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- |
| v2.0 | N/A | N/A | N/A | N/A | [semaphore-protocol/arbitrum](https://thegraph.com/hosted-service/subgraph/semaphore-protocol/arbitrum) | N/A |
| v2.5 | N/A | 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) | N/A |
| 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) | N/A |
| >= 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) | N/A |
| 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 | N/A |
| >= v4.0.0-beta.17 | [semaphore-sepolia](https://api.studio.thegraph.com/query/14377/semaphore-sepolia/v4.0.0-beta.17) | N/A | [semaphore-optimism-sepolia](https://api.studio.thegraph.com/query/14377/semaphore-optimism-sepolia/v4.0.0-beta.17) | [semaphore-arbitrum-sepolia](https://api.studio.thegraph.com/query/14377/semaphore-arbitrum-sepolia/v4.0.0-beta.17) | N/A | [semaphore-matic-amoy](https://api.studio.thegraph.com/query/14377/semaphore-matic-amoy/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.1.0.

Supported networks:

- `sepolia`
- `optimism`
- `optimism-sepolia`
- `arbitrum`
- `arbitrum-sepolia`
- `matic`
- `matic-amoy`
- `base-sepolia`
- `base`
- `linea-sepolia`
- `linea`

## 🛠 Install

Expand Down
2 changes: 1 addition & 1 deletion apps/subgraph/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"dependencies": {
"@graphprotocol/graph-cli": "0.78.0",
"@graphprotocol/graph-ts": "0.35.1",
"@semaphore-protocol/utils": "4.0.3"
"@semaphore-protocol/utils": "workspace:packages/utils"
},
"devDependencies": {
"@types/mustache": "^4.2.2",
Expand Down
14 changes: 13 additions & 1 deletion apps/subgraph/scripts/generate-subgraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,20 @@ const network = process.argv.at(2)

const template = readFileSync("./subgraph.template.yaml", "utf-8")

function mapNetwork(n) {
if (n === "matic-amoy") {
return "polygon-amoy"
}

if (n === "arbitrum") {
return "arbitrum-one"
}

return network
}

const subgraph = Mustache.render(template, {
network: network === "matic-amoy" ? "polygon-amoy" : network,
network: mapNetwork(network),
...getDeployedContract(network)
})

Expand Down
8 changes: 4 additions & 4 deletions apps/website/src/data/events.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[
{
"name": "ETHRome",
"date": "Oct 4-6, 2024",
"description": "Semaphore team will deliver an in-person talk and sponsor prizes for the hackathon.",
"link": "https://www.ethrome.org/"
"name": "DIF - Decentralized Identity Foundation",
"date": "Oct 1 - Nov 4, 2024",
"description": "Semaphore team will deliver a talk and sponsor prizes for the online hackathon.",
"link": "https://identity.foundation/"
},
{
"name": "Devcon",
Expand Down
Loading

0 comments on commit adcec41

Please sign in to comment.