Compare commits

..

1 Commits

Author SHA1 Message Date
cedoor
281f00ebd5 chore: v3.10.0
Former-commit-id: 63e7e7a7937b84be9122d060b7ec3bf73b182703
2023-05-15 16:13:43 +01:00
70 changed files with 1307 additions and 375 deletions

View File

@@ -40,5 +40,7 @@ jobs:
uses: crazy-max/ghaction-github-pages@v2.5.0
with:
build_dir: docs
jekyll: false
fqdn: js.semaphore.appliedzkp.org
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

4
.gitignore vendored
View File

@@ -63,7 +63,9 @@ node_modules/
# Production
build
dist
docs
docs/*
!docs/CNAME
!docs/index.html
# Hardhat
artifacts

View File

@@ -3,7 +3,7 @@
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://github.com/semaphore-protocol/website/blob/main/static/img/semaphore-icon-dark.svg">
<source media="(prefers-color-scheme: light)" srcset="https://github.com/semaphore-protocol/website/blob/main/static/img/semaphore-icon.svg">
<img width="40" alt="Semaphore icon" src="https://github.com/semaphore-protocol/website/blob/main/static/img/semaphore-icon.svg">
<img width="40" alt="Semaphore icon." src="https://github.com/semaphore-protocol/website/blob/main/static/img/semaphore-icon.svg">
</picture>
Semaphore
</h1>
@@ -52,7 +52,7 @@
🔎 Issues
</a>
<span>&nbsp;&nbsp;|&nbsp;&nbsp;</span>
<a href="https://semaphore.pse.dev/discord">
<a href="https://semaphore.appliedzkp.org/discord">
🗣️ Chat &amp; Support
</a>
</h4>
@@ -61,7 +61,7 @@
| Semaphore is a protocol, designed to be a simple and generic privacy layer for Ethereum DApps. Using zero knowledge, Ethereum users can prove their membership of a group and send signals such as votes or endorsements without revealing their original identity. |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
The core of the Semaphore protocol is in the [circuit logic](/packages/circuits/scheme.png). However Semaphore also provides [Solidity contracts](/packages/contracts) and JavaScript libraries to make the steps for offchain proof creation and onchain 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 verification easier. To learn more about Semaphore visit [semaphore.appliedzkp.org](https://semaphore.appliedzkp.org).
## 📦 Packages
@@ -94,7 +94,7 @@ The core of the Semaphore protocol is in the [circuit logic](/packages/circuits/
<a href="/packages/identity">
@semaphore-protocol/identity
</a>
<a href="https://js.semaphore.pse.dev/modules/_semaphore_protocol_identity">
<a href="https://js.semaphore.appliedzkp.org/identity">
(docs)
</a>
</td>
@@ -116,7 +116,7 @@ The core of the Semaphore protocol is in the [circuit logic](/packages/circuits/
<a href="/packages/group">
@semaphore-protocol/group
</a>
<a href="https://js.semaphore.pse.dev/modules/_semaphore_protocol_group">
<a href="https://js.semaphore.appliedzkp.org/group">
(docs)
</a>
</td>
@@ -138,7 +138,7 @@ The core of the Semaphore protocol is in the [circuit logic](/packages/circuits/
<a href="/packages/proof">
@semaphore-protocol/proof
</a>
<a href="https://js.semaphore.pse.dev/modules/_semaphore_protocol_proof">
<a href="https://js.semaphore.appliedzkp.org/proof">
(docs)
</a>
</td>
@@ -160,7 +160,7 @@ The core of the Semaphore protocol is in the [circuit logic](/packages/circuits/
<a href="/packages/data">
@semaphore-protocol/data
</a>
<a href="https://js.semaphore.pse.dev/modules/_semaphore_protocol_data">
<a href="https://js.semaphore.appliedzkp.org/data">
(docs)
</a>
</td>
@@ -220,7 +220,7 @@ The core of the Semaphore protocol is in the [circuit logic](/packages/circuits/
<a href="/packages/heyauthn">
@semaphore-protocol/heyauthn
</a>
<a href="https://js.semaphore.pse.dev/modules/_semaphore_protocol_heyauthn">
<a href="https://js.semaphore.appliedzkp.org/heyauthn">
(docs)
</a>
</td>
@@ -251,25 +251,7 @@ The following are some of the internal and external projects that use Semaphore.
<tbody>
<tr>
<td>
<a href="https://bandada.pse.dev">
Bandada
</a>
</td>
<td>
An open-source system for managing privacy-preserving groups of anonymous individuals. Create and manage onchain and offchain Semaphore groups using UI or API.
</td>
<td>
<a href="https://github.com/privacy-scaling-explorations/bandada">
Github
</a>|
<a href="https://discord.com/invite/sF5CT5rzrR">
Discord
</a>
</td>
</tr>
<tr>
<td>
<a href="https://explorer.semaphore.pse.dev">
<a href="https://explorer.semaphore.appliedzkp.org">
Semaphore Explorer
</a>
</td>
@@ -280,7 +262,7 @@ The following are some of the internal and external projects that use Semaphore.
<a href="https://github.com/semaphore-protocol/explorer">
Github
</a>|
<a href="https://semaphore.pse.dev/discord">
<a href="https://semaphore.appliedzkp.org/discord">
Discord
</a>
</td>
@@ -298,7 +280,7 @@ The following are some of the internal and external projects that use Semaphore.
<a href="https://github.com/semaphore-protocol/discord-bot">
Github
</a>|
<a href="https://semaphore.pse.dev/discord">
<a href="https://semaphore.appliedzkp.org/discord">
Discord
</a>
</td>
@@ -379,21 +361,6 @@ The following are some of the internal and external projects that use Semaphore.
</a>
</td>
</tr>
<tr>
<td>
<a href="https://stealthcomms.surge.sh/">
StealthComms
</a>
</td>
<td>
A project that allows users to prove their membership in a group and send messages/signals without revealing their original identity.
</td>
<td>
<a href="https://github.com/atomniketh/zk-app">
Github
</a>
</td>
</tr>
<tbody>
</table>

123
docs/index.html Normal file
View File

@@ -0,0 +1,123 @@
<!DOCTYPE html>
<html style="height: 100%">
<head>
<meta charset="utf-8" />
<meta http-equiv="x-ua-compatible" content="IE=edge" />
<title>Semaphore packages</title>
<meta
name="description"
content="A monorepo of Semaphore packages."
/>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"
/>
</head>
<body
style="
margin: 0;
background-color: #EAF0F4;
color: #000;
height: 100%;
font-family: 'Courier New', monospace;
display: flex;
flex-direction: column;
justify-content: space-between;
"
>
<div
style="
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
flex: 1;
padding: 0 20px;
text-align: center;
"
>
<div style="display: flex">
<span style="margin-right: 5px">
<img width="40" src="https://raw.githubusercontent.com/semaphore-protocol/website/main/static/img/semaphore-icon.svg">
</span>
<h1 style="margin: 0; font-size: 40px">Semaphore packages</h1>
</div>
<p style="max-width: 500px">
A monorepo of Semaphore packages.
</p>
<ul style="list-style-type: none; padding: 0; margin: 0; margin-top: 10px"></ul>
</div>
<footer
style="
display: flex;
justify-content: center;
padding: 15px 20px;
background-color: #EAF0F4;
"
>
<div
style="
display: flex;
justify-content: space-between;
align-items: center;
width: 900px;
"
>
<p style="margin: 0; font-size: 16px">
Copyright © 2022 Ethereum Foundation
</p>
<div>
<a
style="margin-right: 15px; text-decoration: none"
target="_blank"
href="https://github.com/semaphore-protocol/semaphore"
>
<i
class="fa fa-github"
style="font-size: 24px; color: #000"
></i>
</a>
</div>
</div>
</footer>
</body>
<script>
const url =
"https://api.github.com/repos/semaphore-protocol/semaphore/contents?ref=gh-pages"
function insertLinks(packages) {
const [element] = window.document.getElementsByTagName("ul")
let html = ""
for (const package of packages) {
html += `<li style="display: flex; align-items: center; margin-bottom: 8px">
<a style="margin-right: 15px" target="_blank" href="https://github.com/semaphore-protocol/semaphore/tree/main/packages/${package}">
<i class="fa fa-github" style="font-size: 24px; color: #000"></i>
</a>
<a style="color: #000; text-decoration: none; font-size: 16px"
onmouseover="this.style.color='#404A4E';"
onmouseout="this.style.color='#000';"
target="_blank" href="https://semaphore-protocol.github.io/semaphore/${package}">
@semaphore-protocol/${package} >
</a></li>`
}
element.innerHTML = html
}
fetch(url)
.then((response) => response.json())
.then((data) => {
const ignore = [".nojekyll", "index.html", "CNAME"]
const packages = data
.map((c) => c.name)
.filter((name) => !ignore.includes(name))
localStorage.setItem("packages", JSON.stringify(packages))
insertLinks(packages)
})
</script>
</html>

View File

@@ -17,7 +17,7 @@
"lint": "eslint . --ext .js,.ts && yarn workspace contracts lint",
"prettier": "prettier -c .",
"prettier:write": "prettier -w .",
"docs": "typedoc --cname js.semaphore.pse.dev --githubPages true",
"docs": "yarn workspaces foreach --no-private run docs",
"version:bump": "yarn workspaces foreach --no-private version -d ${0} && yarn version apply --all && git commit -am \"chore: v${0}\" && git tag v${0}",
"version:publish": "yarn build:libraries && yarn remove:template-files && yarn workspaces foreach --no-private npm publish --tolerate-republish --access public",
"version:release": "changelogithub",
@@ -50,13 +50,11 @@
"@commitlint/cli": "^16.0.2",
"@commitlint/config-conventional": "^16.0.0",
"@rollup/plugin-typescript": "^8.3.0",
"@types/circomlibjs": "^0.1.4",
"@types/download": "^8.0.1",
"@types/glob": "^7.2.0",
"@types/jest": "^27.4.0",
"@types/node": "^17.0.9",
"@types/rimraf": "^3.0.2",
"@types/snarkjs": "^0.7.5",
"@typescript-eslint/eslint-plugin": "^5.9.1",
"@typescript-eslint/parser": "^5.9.1",
"babel-jest": "^27.4.6",
@@ -79,7 +77,6 @@
"rollup": "^2.64.0",
"ts-node": "^10.4.0",
"tslib": "^2.3.1",
"typedoc": "^0.25.1",
"typescript": "^4.7.0"
},
"config": {

View File

@@ -28,10 +28,10 @@
🔎 Issues
</a>
<span>&nbsp;&nbsp;|&nbsp;&nbsp;</span>
<a href="https://semaphore.pse.dev/discord">
<a href="https://semaphore.appliedzkp.org/discord">
🗣️ Chat &amp; Support
</a>
</h4>
</div>
To learn more about circuits visit [semaphore.pse.dev](https://semaphore.pse.dev/docs/technical-reference/circuits).
To learn more about circuits visit [semaphore.appliedzkp.org](https://semaphore.appliedzkp.org/docs/technical-reference/circuits).

View File

@@ -48,7 +48,7 @@ yarn deploy --semaphore <semaphore-address> --group <group-id> --network goerli
```
> **Note**
> Check the Semaphore contract addresses [here](https://semaphore.pse.dev/docs/deployed-contracts#semaphore).
> Check the Semaphore contract addresses [here](https://semaphore.appliedzkp.org/docs/deployed-contracts#semaphore).
> **Warning**
> The group id is a number!

View File

@@ -1,6 +1,6 @@
{
"name": "@semaphore-protocol/cli-template-contracts-hardhat",
"version": "3.12.3",
"version": "3.10.0",
"description": "Semaphore Hardhat template.",
"license": "Unlicense",
"files": [
@@ -36,10 +36,10 @@
"@nomicfoundation/hardhat-toolbox": "^2.0.0",
"@nomiclabs/hardhat-ethers": "^2.0.0",
"@nomiclabs/hardhat-etherscan": "^3.0.0",
"@semaphore-protocol/group": "3.12.3",
"@semaphore-protocol/hardhat": "3.12.3",
"@semaphore-protocol/identity": "3.12.3",
"@semaphore-protocol/proof": "3.12.3",
"@semaphore-protocol/group": "3.10.0",
"@semaphore-protocol/hardhat": "3.10.0",
"@semaphore-protocol/identity": "3.10.0",
"@semaphore-protocol/proof": "3.10.0",
"@typechain/ethers-v5": "^10.1.0",
"@typechain/hardhat": "^6.1.2",
"@types/chai": "^4.2.0",
@@ -58,7 +58,7 @@
"typescript": ">=4.5.0"
},
"dependencies": {
"@semaphore-protocol/contracts": "3.12.3"
"@semaphore-protocol/contracts": "3.10.0"
},
"config": {
"solidity": {

View File

@@ -33,7 +33,7 @@ yarn deploy --semaphore <semaphore-address> --group <group-id> --network arbitru
3. Copy your contract artifacts from `apps/contracts/build/contracts/contracts` folder to `apps/web-app/contract-artifacts` folders manually. Or run `yarn copy:contract-artifacts` in the project root to do it automatically.
> **Note**
> Check the Semaphore contract addresses [here](https://semaphore.pse.dev/docs/deployed-contracts).
> Check the Semaphore contract addresses [here](https://semaphore.appliedzkp.org/docs/deployed-contracts).
> **Warning**
> The group id is a number!

View File

@@ -18,10 +18,10 @@
"@nomicfoundation/hardhat-chai-matchers": "^1.0.5",
"@nomiclabs/hardhat-ethers": "^2.0.0",
"@nomiclabs/hardhat-etherscan": "^3.1.7",
"@semaphore-protocol/group": "3.12.3",
"@semaphore-protocol/hardhat": "3.12.3",
"@semaphore-protocol/identity": "3.12.3",
"@semaphore-protocol/proof": "3.12.3",
"@semaphore-protocol/group": "3.10.0",
"@semaphore-protocol/hardhat": "3.10.0",
"@semaphore-protocol/identity": "3.10.0",
"@semaphore-protocol/proof": "3.10.0",
"@typechain/ethers-v5": "^10.0.0",
"@typechain/hardhat": "^6.0.0",
"@types/chai": "^4.3.1",
@@ -40,7 +40,7 @@
"typechain": "^8.0.0"
},
"dependencies": {
"@semaphore-protocol/contracts": "3.12.3"
"@semaphore-protocol/contracts": "3.10.0"
},
"config": {
"solidity": {

View File

@@ -10,10 +10,10 @@
},
"dependencies": {
"@next/font": "13.0.3",
"@semaphore-protocol/data": "3.12.3",
"@semaphore-protocol/group": "3.12.3",
"@semaphore-protocol/identity": "3.12.3",
"@semaphore-protocol/proof": "3.12.3",
"@semaphore-protocol/data": "3.10.0",
"@semaphore-protocol/group": "3.10.0",
"@semaphore-protocol/identity": "3.10.0",
"@semaphore-protocol/proof": "3.10.0",
"@types/react": "18.0.25",
"@types/react-dom": "18.0.8",
"dotenv": "^16.0.3",

View File

@@ -84,7 +84,7 @@ export default function GroupsPage() {
<p>
Semaphore{" "}
<a
href="https://semaphore.pse.dev/docs/guides/groups"
href="https://semaphore.appliedzkp.org/docs/guides/groups"
target="_blank"
rel="noreferrer noopener nofollow"
>

View File

@@ -40,7 +40,7 @@ export default function IdentitiesPage() {
<p>
Users interact with the protocol using a Semaphore{" "}
<a
href="https://semaphore.pse.dev/docs/guides/identities"
href="https://semaphore.appliedzkp.org/docs/guides/identities"
target="_blank"
rel="noreferrer noopener nofollow"
>

View File

@@ -112,7 +112,7 @@ export default function ProofsPage() {
<p>
Semaphore members can anonymously{" "}
<a
href="https://semaphore.pse.dev/docs/guides/proofs"
href="https://semaphore.appliedzkp.org/docs/guides/proofs"
target="_blank"
rel="noreferrer noopener nofollow"
>

View File

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

View File

@@ -33,7 +33,7 @@ yarn deploy --semaphore <semaphore-address> --group <group-id> --network arbitru
3. Copy your contract artifacts from `apps/contracts/build/contracts/contracts` folder to `apps/web-app/contract-artifacts` folders manually. Or run `yarn copy:contract-artifacts` in the project root to do it automatically.
> **Note**
> Check the Semaphore contract addresses [here](https://semaphore.pse.dev/docs/deployed-contracts).
> Check the Semaphore contract addresses [here](https://semaphore.appliedzkp.org/docs/deployed-contracts).
> **Warning**
> The group id is a number!

View File

@@ -18,10 +18,10 @@
"@nomicfoundation/hardhat-chai-matchers": "^1.0.5",
"@nomiclabs/hardhat-ethers": "^2.0.0",
"@nomiclabs/hardhat-etherscan": "^3.1.7",
"@semaphore-protocol/group": "3.12.3",
"@semaphore-protocol/hardhat": "3.12.3",
"@semaphore-protocol/identity": "3.12.3",
"@semaphore-protocol/proof": "3.12.3",
"@semaphore-protocol/group": "3.10.0",
"@semaphore-protocol/hardhat": "3.10.0",
"@semaphore-protocol/identity": "3.10.0",
"@semaphore-protocol/proof": "3.10.0",
"@typechain/ethers-v5": "^10.0.0",
"@typechain/hardhat": "^6.0.0",
"@types/chai": "^4.3.1",
@@ -40,7 +40,7 @@
"typechain": "^8.0.0"
},
"dependencies": {
"@semaphore-protocol/contracts": "3.12.3"
"@semaphore-protocol/contracts": "3.10.0"
},
"config": {
"solidity": {

View File

@@ -10,10 +10,10 @@
},
"dependencies": {
"@next/font": "13.0.3",
"@semaphore-protocol/data": "3.12.3",
"@semaphore-protocol/group": "3.12.3",
"@semaphore-protocol/identity": "3.12.3",
"@semaphore-protocol/proof": "3.12.3",
"@semaphore-protocol/data": "3.10.0",
"@semaphore-protocol/group": "3.10.0",
"@semaphore-protocol/identity": "3.10.0",
"@semaphore-protocol/proof": "3.10.0",
"@types/react": "18.0.25",
"@types/react-dom": "18.0.8",
"dotenv": "^16.0.3",

View File

@@ -84,7 +84,7 @@ export default function GroupsPage() {
<p>
Semaphore{" "}
<a
href="https://semaphore.pse.dev/docs/guides/groups"
href="https://semaphore.appliedzkp.org/docs/guides/groups"
target="_blank"
rel="noreferrer noopener nofollow"
>

View File

@@ -40,7 +40,7 @@ export default function IdentitiesPage() {
<p>
Users interact with the protocol using a Semaphore{" "}
<a
href="https://semaphore.pse.dev/docs/guides/identities"
href="https://semaphore.appliedzkp.org/docs/guides/identities"
target="_blank"
rel="noreferrer noopener nofollow"
>

View File

@@ -112,7 +112,7 @@ export default function ProofsPage() {
<p>
Semaphore members can anonymously{" "}
<a
href="https://semaphore.pse.dev/docs/guides/proofs"
href="https://semaphore.appliedzkp.org/docs/guides/proofs"
target="_blank"
rel="noreferrer noopener nofollow"
>

View File

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

View File

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

View File

@@ -1,7 +1,7 @@
{
"name": "@semaphore-protocol/cli",
"type": "module",
"version": "3.12.3",
"version": "3.10.0",
"description": "A command line tool to set up your Semaphore project and get group data.",
"license": "MIT",
"bin": {
@@ -39,10 +39,11 @@
"@types/semver": "^7.3.13",
"rollup-plugin-cleanup": "^3.2.1",
"rollup-plugin-typescript2": "^0.31.2",
"ts-node": "^10.9.1"
"ts-node": "^10.9.1",
"typedoc": "^0.22.11"
},
"dependencies": {
"@semaphore-protocol/data": "3.12.3",
"@semaphore-protocol/data": "3.10.0",
"axios": "^1.3.2",
"boxen": "^7.0.1",
"chalk": "^5.1.2",

View File

@@ -132,10 +132,7 @@ program
const groupIds = await getGroupIds(network)
if (groupIds === null) {
console.info(`\n ${logSymbols.info}`, `info: there are no groups on the '${network}' network\n`)
return
}
if (groupIds === null) return
const content = `${chalk.bold("Groups")} (${groupIds.length}): \n${groupIds
.map((id: any) => ` - ${id}`)
@@ -163,10 +160,7 @@ program
if (!groupId) {
const groupIds = await getGroupIds(network)
if (groupIds === null) {
console.info(`\n ${logSymbols.info}`, `info: there are no groups on the '${network}' network\n`)
return
}
if (groupIds === null) return
groupId = await getGroupId(groupIds)
}
@@ -199,11 +193,6 @@ program
}
}
if (!group) {
console.info(`\n ${logSymbols.error}`, "error: the group does not exist\n")
return
}
let content = ` ${chalk.bold("Id")}: ${group.id}\n`
content += ` ${chalk.bold("Admin")}: ${group.admin}\n`
content += ` ${chalk.bold("Merkle tree")}:\n`
@@ -234,10 +223,7 @@ program
if (!groupId) {
const groupIds = await getGroupIds(network)
if (groupIds === null) {
console.info(`\n ${logSymbols.info}`, `info: there are no groups on the '${network}' network\n`)
return
}
if (groupIds === null) return
groupId = await getGroupId(groupIds)
}
@@ -300,10 +286,7 @@ program
if (!groupId) {
const groupIds = await getGroupIds(network)
if (groupIds === null) {
console.info(`\n ${logSymbols.info}`, `info: there are no groups on the '${network}' network\n`)
return
}
if (groupIds === null) return
groupId = await getGroupId(groupIds)
}

View File

@@ -34,13 +34,13 @@
🔎 Issues
</a>
<span>&nbsp;&nbsp;|&nbsp;&nbsp;</span>
<a href="https://semaphore.pse.dev/discord">
<a href="https://semaphore.appliedzkp.org/discord">
🗣️ Chat &amp; Support
</a>
</h4>
</div>
To learn more about contracts visit [semaphore.pse.dev](https://semaphore.pse.dev/docs/technical-reference/contracts).
To learn more about contracts visit [semaphore.appliedzkp.org](https://semaphore.appliedzkp.org/docs/technical-reference/contracts).
---

View File

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

View File

@@ -30,7 +30,7 @@
"@types/rimraf": "^3.0.2",
"chai": "^4.3.5",
"circomlib": "^2.0.2",
"circomlibjs": "^0.1.7",
"circomlibjs": "^0.0.8",
"download": "^8.0.0",
"ethers": "^5.6.8",
"hardhat": "^2.9.7",
@@ -38,6 +38,7 @@
"js-logger": "^1.6.1",
"prettier-plugin-solidity": "^1.0.0-beta.19",
"rimraf": "^3.0.2",
"snarkjs": "^0.4.13",
"solhint": "^3.3.6",
"solhint-plugin-prettier": "^0.0.5",
"solidity-coverage": "^0.7.21",

View File

@@ -1,4 +1,4 @@
import { poseidonContract } from "circomlibjs"
import { poseidon_gencontract as poseidonContract } from "circomlibjs"
import { task, types } from "hardhat/config"
task("deploy:semaphore-voting", "Deploy a SemaphoreVoting contract")

View File

@@ -1,4 +1,4 @@
import { poseidonContract } from "circomlibjs"
import { poseidon_gencontract as poseidonContract } from "circomlibjs"
import { task, types } from "hardhat/config"
task("deploy:semaphore-whistleblowing", "Deploy a SemaphoreWhistleblowing contract")

View File

@@ -1,4 +1,4 @@
import { poseidonContract } from "circomlibjs"
import { poseidon_gencontract as poseidonContract } from "circomlibjs"
import { task, types } from "hardhat/config"
import { saveDeployedContracts } from "../scripts/utils"

View File

@@ -18,7 +18,7 @@
<a href="https://npmjs.org/package/@semaphore-protocol/data">
<img alt="Downloads" src="https://img.shields.io/npm/dm/@semaphore-protocol/data.svg?style=flat-square" />
</a>
<a href="https://js.semaphore.pse.dev/data">
<a href="https://js.semaphore.appliedzkp.org/data">
<img alt="Documentation typedoc" src="https://img.shields.io/badge/docs-typedoc-744C7C?style=flat-square">
</a>
<a href="https://eslint.org/">
@@ -43,7 +43,7 @@
🔎 Issues
</a>
<span>&nbsp;&nbsp;|&nbsp;&nbsp;</span>
<a href="https://semaphore.pse.dev/discord">
<a href="https://semaphore.appliedzkp.org/discord">
🗣️ Chat &amp; Support
</a>
</h4>

View File

@@ -1,6 +1,6 @@
{
"name": "@semaphore-protocol/data",
"version": "3.12.3",
"version": "3.10.0",
"description": "A library to query Semaphore contracts.",
"license": "MIT",
"main": "dist/index.node.js",
@@ -23,7 +23,8 @@
"scripts": {
"build:watch": "rollup -c rollup.config.ts -w --configPlugin typescript",
"build": "rimraf dist && rollup -c rollup.config.ts --configPlugin typescript",
"prepublishOnly": "yarn build"
"prepublishOnly": "yarn build",
"docs": "typedoc src/index.ts --out ../../docs/data"
},
"publishConfig": {
"access": "public"
@@ -31,7 +32,8 @@
"devDependencies": {
"@rollup/plugin-json": "^6.0.0",
"rollup-plugin-cleanup": "^3.2.1",
"rollup-plugin-typescript2": "^0.31.2"
"rollup-plugin-typescript2": "^0.31.2",
"typedoc": "^0.22.11"
},
"dependencies": {
"@ethersproject/contracts": "^5.7.0",

View File

@@ -31,11 +31,7 @@ describe("SemaphoreEthers", () => {
const semaphore2 = new SemaphoreEthers("matic")
const semaphore3 = new SemaphoreEthers("optimism-goerli")
const semaphore4 = new SemaphoreEthers("arbitrum-goerli")
const semaphore5 = new SemaphoreEthers("arbitrum-goerli", {
address: "0x0000000000000000000000000000000000000000",
startBlock: 0
})
const semaphore6 = new SemaphoreEthers("homestead", {
const semaphore5 = new SemaphoreEthers("homestead", {
address: "0x0000000000000000000000000000000000000000",
startBlock: 0
})
@@ -46,10 +42,9 @@ describe("SemaphoreEthers", () => {
expect(semaphore2.network).toBe("maticmum")
expect(semaphore3.network).toBe("optimism-goerli")
expect(semaphore4.network).toBe("arbitrum-goerli")
expect(semaphore5.network).toBe("homestead")
expect(semaphore5.options.startBlock).toBe(0)
expect(semaphore5.options.address).toContain("0x000000")
expect(semaphore6.network).toBe("homestead")
expect(semaphore6.options.startBlock).toBe(0)
expect(semaphore6.options.address).toContain("0x000000")
})
it("Should instantiate a SemaphoreEthers object with different providers", () => {

View File

@@ -43,35 +43,37 @@ export default class SemaphoreEthers {
switch (networkOrEthereumURL) {
case "arbitrum":
options.address ??= "0xc60E0Ee1a2770d5F619858C641f14FC4a6401520"
options.startBlock ??= 77278430
options.address = "0xc60E0Ee1a2770d5F619858C641f14FC4a6401520"
options.startBlock = 77278430
break
case "arbitrum-goerli":
options.address ??= "0x3889927F0B5Eb1a02C6E2C20b39a1Bd4EAd76131"
options.startBlock ??= 15174410
options.address = "0x3889927F0B5Eb1a02C6E2C20b39a1Bd4EAd76131"
options.startBlock = 15174410
break
case "maticmum":
options.address ??= "0x3889927F0B5Eb1a02C6E2C20b39a1Bd4EAd76131"
options.startBlock ??= 33995010
options.address = "0x3889927F0B5Eb1a02C6E2C20b39a1Bd4EAd76131"
options.startBlock = 33995010
break
case "goerli":
options.address ??= "0x3889927F0B5Eb1a02C6E2C20b39a1Bd4EAd76131"
options.startBlock ??= 8777695
options.address = "0x3889927F0B5Eb1a02C6E2C20b39a1Bd4EAd76131"
options.startBlock = 8777695
break
case "sepolia":
options.address ??= "0x3889927F0B5Eb1a02C6E2C20b39a1Bd4EAd76131"
options.startBlock ??= 3231111
options.address = "0x3889927F0B5Eb1a02C6E2C20b39a1Bd4EAd76131"
options.startBlock = 3231111
break
case "optimism-goerli":
options.address ??= "0x3889927F0B5Eb1a02C6E2C20b39a1Bd4EAd76131"
options.startBlock ??= 7632846
options.address = "0x3889927F0B5Eb1a02C6E2C20b39a1Bd4EAd76131"
options.startBlock = 7632846
break
default:
if (options.address === undefined) {
throw new Error(`You should provide a Semaphore contract address for this network`)
}
options.startBlock ??= 0
if (options.startBlock === undefined) {
options.startBlock = 0
}
}
let provider: Provider

View File

@@ -202,8 +202,7 @@ describe("SemaphoreSubgraph", () => {
const expectedValue = await semaphore.getGroups({
filters: {
admin: "0x7bcd6f009471e9974a77086a69289d16eadba286",
identityCommitment: "123"
admin: "0x7bcd6f009471e9974a77086a69289d16eadba286"
}
})

View File

@@ -68,17 +68,13 @@ export default class SemaphoreSubgraph {
let filtersQuery = ""
if (options.filters) {
const { admin, identityCommitment, timestamp, timestampGte, timestampLte } = options.filters
const { admin, timestamp, timestampGte, timestampLte } = options.filters
const filterFragments = []
if (admin) {
filterFragments.push(`admin: "${admin}"`)
}
if (identityCommitment) {
filterFragments.push(`members_: { identityCommitment: "${identityCommitment}" }`)
}
/* istanbul ignore next */
if (timestamp) {
filterFragments.push(`timestamp: "${jsDateToGraphqlDate(timestamp)}"`)

View File

@@ -24,7 +24,6 @@ export type GroupOptions = {
verifiedProofs?: boolean
filters?: {
admin?: string
identityCommitment?: string
timestamp?: Date
timestampGte?: Date
timestampLte?: Date

View File

@@ -1,3 +0,0 @@
{
"entryPoints": ["src/index.ts"]
}

View File

@@ -18,7 +18,7 @@
<a href="https://npmjs.org/package/@semaphore-protocol/group">
<img alt="Downloads" src="https://img.shields.io/npm/dm/@semaphore-protocol/group.svg?style=flat-square" />
</a>
<a href="https://js.semaphore.pse.dev/group">
<a href="https://js.semaphore.appliedzkp.org/group">
<img alt="Documentation typedoc" src="https://img.shields.io/badge/docs-typedoc-744C7C?style=flat-square">
</a>
<a href="https://eslint.org/">
@@ -43,7 +43,7 @@
🔎 Issues
</a>
<span>&nbsp;&nbsp;|&nbsp;&nbsp;</span>
<a href="https://semaphore.pse.dev/discord">
<a href="https://semaphore.appliedzkp.org/discord">
🗣️ Chat &amp; Support
</a>
</h4>

View File

@@ -1,6 +1,6 @@
{
"name": "@semaphore-protocol/group",
"version": "3.12.3",
"version": "3.10.0",
"description": "A library to create and manage Semaphore groups.",
"license": "MIT",
"main": "dist/index.node.js",
@@ -23,7 +23,8 @@
"scripts": {
"build:watch": "rollup -c rollup.config.ts -w --configPlugin typescript",
"build": "rimraf dist && rollup -c rollup.config.ts --configPlugin typescript",
"prepublishOnly": "yarn build"
"prepublishOnly": "yarn build",
"docs": "typedoc src/index.ts --out ../../docs/group"
},
"publishConfig": {
"access": "public"
@@ -33,7 +34,8 @@
"@rollup/plugin-node-resolve": "^15.0.1",
"poseidon-lite": "^0.2.0",
"rollup-plugin-cleanup": "^3.2.1",
"rollup-plugin-typescript2": "^0.31.2"
"rollup-plugin-typescript2": "^0.31.2",
"typedoc": "^0.22.11"
},
"dependencies": {
"@ethersproject/bignumber": "^5.7.0",

View File

@@ -20,7 +20,7 @@ export default class Group {
}
this._id = id
this.merkleTree = new IncrementalMerkleTree(poseidon2, treeDepth, hash(id), 2, members.map(BigInt))
this.merkleTree = new IncrementalMerkleTree(poseidon2, treeDepth, hash(id), 2, members)
}
/**

View File

@@ -1,3 +0,0 @@
{
"entryPoints": ["src/index.ts"]
}

View File

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

View File

@@ -1,6 +1,6 @@
{
"name": "@semaphore-protocol/hardhat",
"version": "3.12.3",
"version": "3.10.0",
"description": "A Semaphore Hardhat plugin to deploy verifiers and Semaphore contract.",
"license": "MIT",
"main": "dist/index.node.js",
@@ -38,8 +38,8 @@
},
"dependencies": {
"@nomiclabs/hardhat-ethers": "^2.1.1",
"@semaphore-protocol/contracts": "3.12.3",
"circomlibjs": "^0.1.7",
"@semaphore-protocol/contracts": "3.10.0",
"circomlibjs": "^0.0.8",
"ethers": "^5.7.1",
"hardhat-dependency-compiler": "^1.1.3"
}

View File

@@ -1,4 +1,4 @@
import { poseidonContract } from "circomlibjs"
import { poseidon_gencontract as poseidonContract } from "circomlibjs"
import { task, types } from "hardhat/config"
task("deploy:semaphore", "Deploy a Semaphore contract")

View File

@@ -18,7 +18,7 @@
<a href="https://npmjs.org/package/@semaphore-protocol/heyauthn">
<img alt="Downloads" src="https://img.shields.io/npm/dm/@semaphore-protocol/heyauthn.svg?style=flat-square" />
</a>
<a href="https://js.semaphore.pse.dev/heyauthn">
<a href="https://js.semaphore.appliedzkp.org/heyauthn">
<img alt="Documentation typedoc" src="https://img.shields.io/badge/docs-typedoc-744C7C?style=flat-square">
</a>
<a href="https://eslint.org/">
@@ -43,7 +43,7 @@
🔎 Issues
</a>
<span>&nbsp;&nbsp;|&nbsp;&nbsp;</span>
<a href="https://semaphore.pse.dev/discord">
<a href="https://semaphore.appliedzkp.org/discord">
🗣️ Chat &amp; Support
</a>
</h4>

View File

@@ -1,6 +1,6 @@
{
"name": "@semaphore-protocol/heyauthn",
"version": "3.12.3",
"version": "3.10.0",
"description": "A library to allow developers to create and manage Semaphore identities using WebAuthn",
"license": "MIT",
"main": "dist/index.node.js",
@@ -23,17 +23,19 @@
"scripts": {
"build:watch": "rollup -c rollup.config.ts -w --configPlugin typescript",
"build": "rimraf dist && rollup -c rollup.config.ts --configPlugin typescript",
"prepublishOnly": "yarn build"
"prepublishOnly": "yarn build",
"docs": "typedoc src/index.ts --out ../../docs/heyauthn"
},
"publishConfig": {
"access": "public"
},
"devDependencies": {
"rollup-plugin-cleanup": "^3.2.1",
"rollup-plugin-typescript2": "^0.31.2"
"rollup-plugin-typescript2": "^0.31.2",
"typedoc": "^0.22.11"
},
"dependencies": {
"@semaphore-protocol/identity": "3.12.3",
"@semaphore-protocol/identity": "3.10.0",
"@simplewebauthn/browser": "7.2.0",
"@simplewebauthn/server": "7.2.0"
}

View File

@@ -1,3 +0,0 @@
{
"entryPoints": ["src/index.ts"]
}

View File

@@ -18,7 +18,7 @@
<a href="https://npmjs.org/package/@semaphore-protocol/identity">
<img alt="Downloads" src="https://img.shields.io/npm/dm/@semaphore-protocol/identity.svg?style=flat-square" />
</a>
<a href="https://js.semaphore.pse.dev/identity">
<a href="https://js.semaphore.appliedzkp.org/identity">
<img alt="Documentation typedoc" src="https://img.shields.io/badge/docs-typedoc-744C7C?style=flat-square">
</a>
<a href="https://eslint.org/">
@@ -43,7 +43,7 @@
🔎 Issues
</a>
<span>&nbsp;&nbsp;|&nbsp;&nbsp;</span>
<a href="https://semaphore.pse.dev/discord">
<a href="https://semaphore.appliedzkp.org/discord">
🗣️ Chat &amp; Support
</a>
</h4>

View File

@@ -1,6 +1,6 @@
{
"name": "@semaphore-protocol/identity",
"version": "3.12.3",
"version": "3.10.0",
"description": "A library to create Semaphore identities.",
"license": "MIT",
"main": "dist/index.node.js",
@@ -23,7 +23,8 @@
"scripts": {
"build:watch": "rollup -c rollup.config.ts -w --configPlugin typescript",
"build": "rimraf dist && rollup -c rollup.config.ts --configPlugin typescript",
"prepublishOnly": "yarn build"
"prepublishOnly": "yarn build",
"docs": "typedoc src/index.ts --out ../../docs/identity"
},
"publishConfig": {
"access": "public"
@@ -33,7 +34,8 @@
"@rollup/plugin-node-resolve": "^15.0.1",
"poseidon-lite": "^0.2.0",
"rollup-plugin-cleanup": "^3.2.1",
"rollup-plugin-typescript2": "^0.31.2"
"rollup-plugin-typescript2": "^0.31.2",
"typedoc": "^0.22.11"
},
"dependencies": {
"@ethersproject/bignumber": "^5.5.0",

View File

@@ -1,3 +0,0 @@
{
"entryPoints": ["src/index.ts"]
}

View File

@@ -18,7 +18,7 @@
<a href="https://npmjs.org/package/@semaphore-protocol/proof">
<img alt="Downloads" src="https://img.shields.io/npm/dm/@semaphore-protocol/proof.svg?style=flat-square" />
</a>
<a href="https://js.semaphore.pse.dev/proof">
<a href="https://js.semaphore.appliedzkp.org/proof">
<img alt="Documentation typedoc" src="https://img.shields.io/badge/docs-typedoc-744C7C?style=flat-square">
</a>
<a href="https://eslint.org/">
@@ -43,7 +43,7 @@
🔎 Issues
</a>
<span>&nbsp;&nbsp;|&nbsp;&nbsp;</span>
<a href="https://semaphore.pse.dev/discord">
<a href="https://semaphore.appliedzkp.org/discord">
🗣️ Chat &amp; Support
</a>
</h4>

View File

@@ -1,16 +1,12 @@
{
"name": "@semaphore-protocol/proof",
"version": "3.12.3",
"version": "3.10.0",
"description": "A library to generate and verify Semaphore proofs.",
"license": "MIT",
"main": "dist/index.node.js",
"exports": {
"node": {
"import": "./dist/index.node.mjs",
"require": "./dist/index.node.js"
},
"browser": "./dist/index.browser.mjs",
"default": "./dist/index.browser.mjs"
"import": "./dist/index.mjs",
"require": "./dist/index.node.js"
},
"types": "dist/types/index.d.ts",
"files": [
@@ -26,10 +22,9 @@
},
"scripts": {
"build:watch": "rollup -c rollup.config.ts -w --configPlugin typescript",
"build": "rimraf dist && yarn build:browser && yarn build:node",
"build:browser": "rollup -c rollup.browser.config.ts --configPlugin typescript",
"build:node": "rollup -c rollup.node.config.ts --configPlugin typescript",
"prepublishOnly": "yarn build"
"build": "rimraf dist && rollup -c rollup.config.ts --configPlugin typescript",
"prepublishOnly": "yarn build",
"docs": "typedoc src/index.ts --out ../../docs/proof"
},
"publishConfig": {
"access": "public"
@@ -38,25 +33,22 @@
"@rollup/plugin-commonjs": "^24.1.0",
"@rollup/plugin-json": "^5.0.1",
"@rollup/plugin-node-resolve": "^15.0.2",
"@rollup/plugin-replace": "^5.0.3",
"@rollup/plugin-virtual": "^3.0.2",
"ffjavascript": "^0.2.54",
"poseidon-lite": "^0.2.0",
"rimraf": "^5.0.5",
"rollup": "^4.0.2",
"rollup-plugin-cleanup": "^3.2.1",
"rollup-plugin-typescript2": "^0.31.2",
"snarkjs": "0.7.1"
"typedoc": "^0.22.11"
},
"peerDependencies": {
"@semaphore-protocol/group": "3.12.3",
"@semaphore-protocol/identity": "3.12.3"
"@semaphore-protocol/group": "3.10.0",
"@semaphore-protocol/identity": "3.10.0"
},
"dependencies": {
"@ethersproject/bignumber": "^5.5.0",
"@ethersproject/bytes": "^5.7.0",
"@ethersproject/keccak256": "^5.7.0",
"@ethersproject/strings": "^5.5.0",
"@zk-kit/incremental-merkle-tree": "0.4.3"
"@zk-kit/incremental-merkle-tree": "0.4.3",
"snarkjs": "0.4.13"
}
}

View File

@@ -1,72 +0,0 @@
import commonjs from "@rollup/plugin-commonjs"
import json from "@rollup/plugin-json"
import { nodeResolve } from "@rollup/plugin-node-resolve"
import replace from "@rollup/plugin-replace"
import virtual from "@rollup/plugin-virtual"
import * as fs from "fs"
import cleanup from "rollup-plugin-cleanup"
import typescript from "rollup-plugin-typescript2"
// Needed by fastfile.
import { O_CREAT, O_EXCL, O_RDONLY, O_RDWR, O_TRUNC } from "constants"
const constants = `
export const O_TRUNC = ${O_TRUNC};
export const O_CREAT = ${O_CREAT};
export const O_RDWR = ${O_RDWR};
export const O_EXCL = ${O_EXCL};
export const O_RDONLY = ${O_RDONLY}
`
const empty = "export default {}"
const pkg = JSON.parse(fs.readFileSync("./package.json", "utf-8"))
const banner = `/**
* @module ${pkg.name}
* @version ${pkg.version}
* @file ${pkg.description}
* @copyright Ethereum Foundation 2022
* @license ${pkg.license}
* @see [Github]{@link ${pkg.homepage}}
*/`
export default {
input: "src/index.ts",
output: [
{
file: pkg.exports.browser,
format: "es",
banner
}
],
external: Object.keys(pkg.dependencies),
plugins: [
typescript({
tsconfig: "./build.tsconfig.json",
useTsconfigDeclarationDir: true
}),
virtual({
fs: empty,
os: empty,
crypto: empty,
readline: empty,
ejs: empty,
events: empty,
stream: empty,
util: empty,
constants
}),
nodeResolve({
browser: true,
preferBuiltins: false,
exportConditions: ["browser", "default", "module", "require"]
}),
commonjs(),
replace({
preventAssignment: false,
"process.browser": true
}),
cleanup({ comments: "jsdoc" }),
json()
]
}

View File

@@ -1,9 +1,9 @@
import typescript from "rollup-plugin-typescript2"
import commonjs from "@rollup/plugin-commonjs"
import json from "@rollup/plugin-json"
import { nodeResolve } from "@rollup/plugin-node-resolve"
import * as fs from "fs"
import cleanup from "rollup-plugin-cleanup"
import typescript from "rollup-plugin-typescript2"
import json from "@rollup/plugin-json"
import { nodeResolve } from "@rollup/plugin-node-resolve"
const pkg = JSON.parse(fs.readFileSync("./package.json", "utf-8"))
const banner = `/**
@@ -18,17 +18,8 @@ const banner = `/**
export default {
input: "src/index.ts",
output: [
{
file: pkg.exports.node.require,
format: "cjs",
banner,
exports: "auto"
},
{
file: pkg.exports.node.import,
format: "es",
banner
}
{ file: pkg.exports.require, format: "cjs", banner, exports: "auto" },
{ file: pkg.exports.import, format: "es", banner }
],
external: Object.keys(pkg.dependencies),
plugins: [
@@ -36,8 +27,8 @@ export default {
tsconfig: "./build.tsconfig.json",
useTsconfigDeclarationDir: true
}),
nodeResolve(),
commonjs(),
nodeResolve(),
cleanup({ comments: "jsdoc" }),
json()
]

View File

@@ -3,10 +3,10 @@ import { BytesLike, Hexable } from "@ethersproject/bytes"
import { Group } from "@semaphore-protocol/group"
import type { Identity } from "@semaphore-protocol/identity"
import { MerkleProof } from "@zk-kit/incremental-merkle-tree"
import { groth16, NumericString } from "snarkjs"
import { groth16 } from "snarkjs"
import hash from "./hash"
import packProof from "./packProof"
import { SemaphoreProof, SnarkArtifacts } from "./types"
import { FullProof, SnarkArtifacts } from "./types"
/**
* Generates a Semaphore proof.
@@ -23,7 +23,7 @@ export default async function generateProof(
externalNullifier: BytesLike | Hexable | number | bigint,
signal: BytesLike | Hexable | number | bigint,
snarkArtifacts?: SnarkArtifacts
): Promise<SemaphoreProof> {
): Promise<FullProof> {
let merkleProof: MerkleProof
if ("depth" in groupOrMerkleProof) {
@@ -61,8 +61,8 @@ export default async function generateProof(
return {
merkleTreeRoot: publicSignals[0],
nullifierHash: publicSignals[1],
signal: BigNumber.from(signal).toString() as NumericString,
externalNullifier: BigNumber.from(externalNullifier).toString() as NumericString,
signal: BigNumber.from(signal).toString(),
externalNullifier: BigNumber.from(externalNullifier).toString(),
proof: packProof(proof)
}
}

View File

@@ -1,16 +1,15 @@
import { BigNumber } from "@ethersproject/bignumber"
import { BytesLike, Hexable, zeroPad } from "@ethersproject/bytes"
import { keccak256 } from "@ethersproject/keccak256"
import { NumericString } from "snarkjs"
/**
* Creates a keccak256 hash of a message compatible with the SNARK scalar modulus.
* @param message The message to be hashed.
* @returns The message digest.
*/
export default function hash(message: BytesLike | Hexable | number | bigint): NumericString {
export default function hash(message: BytesLike | Hexable | number | bigint): bigint {
message = BigNumber.from(message).toTwos(256).toHexString()
message = zeroPad(message, 32)
return (BigInt(keccak256(message)) >> BigInt(8)).toString() as NumericString
return BigInt(keccak256(message)) >> BigInt(8)
}

View File

@@ -6,7 +6,7 @@ import calculateNullifierHash from "./calculateNullifierHash"
import generateProof from "./generateProof"
import hash from "./hash"
import packProof from "./packProof"
import { SemaphoreProof } from "./types"
import { FullProof } from "./types"
import unpackProof from "./unpackProof"
import verifyProof from "./verifyProof"
@@ -21,7 +21,7 @@ describe("Proof", () => {
const identity = new Identity()
let fullProof: SemaphoreProof
let fullProof: FullProof
let curve: any
beforeAll(async () => {
@@ -34,7 +34,9 @@ describe("Proof", () => {
describe("# generateProof", () => {
it("Should not generate Semaphore proofs if the identity is not part of the group", async () => {
const group = new Group(treeDepth, 20, [BigInt(1), BigInt(2)])
const group = new Group(treeDepth)
group.addMembers([BigInt(1), BigInt(2)])
const fun = () =>
generateProof(identity, group, externalNullifier, signal, {
@@ -46,7 +48,9 @@ describe("Proof", () => {
})
it("Should not generate a Semaphore proof with default snark artifacts with Node.js", async () => {
const group = new Group(treeDepth, 20, [BigInt(1), BigInt(2), identity.commitment])
const group = new Group(treeDepth)
group.addMembers([BigInt(1), BigInt(2), identity.commitment])
const fun = () => generateProof(identity, group, externalNullifier, signal)
@@ -54,7 +58,9 @@ describe("Proof", () => {
})
it("Should generate a Semaphore proof passing a group as parameter", async () => {
const group = new Group(treeDepth, 20, [BigInt(1), BigInt(2), identity.commitment])
const group = new Group(treeDepth)
group.addMembers([BigInt(1), BigInt(2), identity.commitment])
fullProof = await generateProof(identity, group, externalNullifier, signal, {
wasmFilePath,
@@ -66,7 +72,9 @@ describe("Proof", () => {
}, 20000)
it("Should generate a Semaphore proof passing a Merkle proof as parameter", async () => {
const group = new Group(treeDepth, 20, [BigInt(1), BigInt(2), identity.commitment])
const group = new Group(treeDepth)
group.addMembers([BigInt(1), BigInt(2), identity.commitment])
fullProof = await generateProof(identity, group.generateMerkleProof(2), externalNullifier, signal, {
wasmFilePath,
@@ -96,35 +104,47 @@ describe("Proof", () => {
it("Should hash the signal value correctly", async () => {
const signalHash = hash(signal)
expect(signalHash).toBe("8665846418922331996225934941481656421248110469944536651334918563951783029")
expect(signalHash.toString()).toBe(
"8665846418922331996225934941481656421248110469944536651334918563951783029"
)
})
it("Should hash the external nullifier value correctly", async () => {
const externalNullifierHash = hash(externalNullifier)
expect(externalNullifierHash).toBe(
expect(externalNullifierHash.toString()).toBe(
"244178201824278269437519042830883072613014992408751798420801126401127326826"
)
})
it("Should hash a number", async () => {
expect(hash(2)).toBe("113682330006535319932160121224458771213356533826860247409332700812532759386")
expect(hash(2).toString()).toBe(
"113682330006535319932160121224458771213356533826860247409332700812532759386"
)
})
it("Should hash a big number", async () => {
expect(hash(BigInt(2))).toBe("113682330006535319932160121224458771213356533826860247409332700812532759386")
expect(hash(BigInt(2)).toString()).toBe(
"113682330006535319932160121224458771213356533826860247409332700812532759386"
)
})
it("Should hash an hex number", async () => {
expect(hash("0x2")).toBe("113682330006535319932160121224458771213356533826860247409332700812532759386")
expect(hash("0x2").toString()).toBe(
"113682330006535319932160121224458771213356533826860247409332700812532759386"
)
})
it("Should hash an string number", async () => {
expect(hash("2")).toBe("113682330006535319932160121224458771213356533826860247409332700812532759386")
expect(hash("2").toString()).toBe(
"113682330006535319932160121224458771213356533826860247409332700812532759386"
)
})
it("Should hash an array", async () => {
expect(hash([2])).toBe("113682330006535319932160121224458771213356533826860247409332700812532759386")
expect(hash([2]).toString()).toBe(
"113682330006535319932160121224458771213356533826860247409332700812532759386"
)
})
})

View File

@@ -1,7 +1,6 @@
import calculateNullifierHash from "./calculateNullifierHash"
import generateProof from "./generateProof"
import verifyProof from "./verifyProof"
import calculateNullifierHash from "./calculateNullifierHash"
export { MerkleProof } from "@zk-kit/incremental-merkle-tree"
export * from "./types"
export { generateProof, verifyProof, calculateNullifierHash }
export * from "./types"

View File

@@ -1,20 +1,19 @@
import { Groth16Proof } from "snarkjs"
import { PackedProof } from "./types"
import { SnarkJSProof, Proof } from "./types"
/**
* Packs a proof into a format compatible with Semaphore.
* @param proof The Groth16 proof generated with SnarkJS.
* @param originalProof The proof generated with SnarkJS.
* @returns The proof compatible with Semaphore.
*/
export default function packProof(proof: Groth16Proof): PackedProof {
export default function packProof(originalProof: SnarkJSProof): Proof {
return [
proof.pi_a[0],
proof.pi_a[1],
proof.pi_b[0][1],
proof.pi_b[0][0],
proof.pi_b[1][1],
proof.pi_b[1][0],
proof.pi_c[0],
proof.pi_c[1]
originalProof.pi_a[0],
originalProof.pi_a[1],
originalProof.pi_b[0][1],
originalProof.pi_b[0][0],
originalProof.pi_b[1][1],
originalProof.pi_b[1][0],
originalProof.pi_c[0],
originalProof.pi_c[1]
]
}

View File

@@ -1,25 +1,33 @@
import type { NumericString } from "snarkjs"
export type BigNumberish = string | bigint
export type SnarkArtifacts = {
wasmFilePath: string
zkeyFilePath: string
}
export type SemaphoreProof = {
merkleTreeRoot: NumericString
signal: NumericString
nullifierHash: NumericString
externalNullifier: NumericString
proof: PackedProof
export type SnarkJSProof = {
pi_a: BigNumberish[]
pi_b: BigNumberish[][]
pi_c: BigNumberish[]
protocol: string
curve: string
}
export type PackedProof = [
NumericString,
NumericString,
NumericString,
NumericString,
NumericString,
NumericString,
NumericString,
NumericString
export type FullProof = {
merkleTreeRoot: BigNumberish
signal: BigNumberish
nullifierHash: BigNumberish
externalNullifier: BigNumberish
proof: Proof
}
export type Proof = [
BigNumberish,
BigNumberish,
BigNumberish,
BigNumberish,
BigNumberish,
BigNumberish,
BigNumberish,
BigNumberish
]

View File

@@ -1,12 +1,11 @@
import { Groth16Proof } from "snarkjs"
import { PackedProof } from "./types"
import { SnarkJSProof, Proof } from "./types"
/**
* Unpacks a proof into its original form.
* @param proof The proof compatible with Semaphore.
* @returns The proof compatible with SnarkJS.
*/
export default function unpackProof(proof: PackedProof): Groth16Proof {
export default function unpackProof(proof: Proof): SnarkJSProof {
return {
pi_a: [proof[0], proof[1]],
pi_b: [

View File

@@ -1,6 +1,6 @@
import { groth16 } from "snarkjs"
import hash from "./hash"
import { SemaphoreProof } from "./types"
import { FullProof } from "./types"
import unpackProof from "./unpackProof"
import verificationKeys from "./verificationKeys.json"
@@ -11,7 +11,7 @@ import verificationKeys from "./verificationKeys.json"
* @returns True if the proof is valid, false otherwise.
*/
export default function verifyProof(
{ merkleTreeRoot, nullifierHash, externalNullifier, signal, proof }: SemaphoreProof,
{ merkleTreeRoot, nullifierHash, externalNullifier, signal, proof }: FullProof,
treeDepth: number
): Promise<boolean> {
if (treeDepth < 16 || treeDepth > 32) {

View File

@@ -1,3 +0,0 @@
{
"entryPoints": ["src/index.ts"]
}

View File

@@ -4,9 +4,9 @@
"tagline": "Semaphore explorer for on-chain groups.",
"icon": "",
"links": {
"website": "https://community.semaphore.pse.dev/semaphore-explorer",
"website": "https://community.semaphore.appliedzkp.org/semaphore-explorer",
"github": "https://github.com/semaphore-protocol/explorer",
"discord": "https://semaphore.pse.dev/discord"
"discord": "https://semaphore.appliedzkp.org/discord"
}
},
{
@@ -16,7 +16,7 @@
"links": {
"website": "https://discord.com/api/oauth2/authorize?client_id=1082429985496772628&permissions=1024&scope=bot",
"github": "https://github.com/semaphore-protocol/discord-bot",
"discord": "https://semaphore.pse.dev/discord"
"discord": "https://semaphore.appliedzkp.org/discord"
}
},
{
@@ -31,7 +31,7 @@
},
{
"name": "Plurality",
"tagline": "An Identity Lego Building Block for dapp creators that lets them identify their users without using any third-party KYC provider or other middlemen, whilst preserving the privacy of users.",
"tagline": " An Identity Lego Building Block for dapp creators that lets them identify their users without using any third-party KYC provider or other middlemen, whilst preserving the privacy of users.",
"icon": "",
"links": {
"github": "https://github.com/Web3-Plurality"
@@ -39,7 +39,7 @@
},
{
"name": "ZK Proof of Humanity",
"tagline": "A project that allows humans, registered in Proof of Humanity, to prove their humanity without doxing.",
"tagline": "A project to allows humans, registered in Proof of Humanity, to prove their humanity without doxing.",
"icon": "",
"links": {
"website": "https://zk-proof-of-humanity.vercel.app",
@@ -63,14 +63,5 @@
"website": "https://bq2.netlify.app/",
"github": "https://github.com/0xdeenz/bq2"
}
},
{
"name": "StealthComms",
"tagline": "A project that allows users to prove their membership in a group and send messages/signals without revealing their original identity.",
"icon": "",
"links": {
"website": "https://stealthcomms.surge.sh/",
"github": "https://github.com/atomniketh/zk-app"
}
}
]

View File

@@ -1,6 +0,0 @@
{
"entryPoints": ["packages/*"],
"name": "Semaphore SDK",
"entryPointStrategy": "packages",
"exclude": ["**/cli-template*", "**/circuits", "**/contracts", "**/hardhat", "**/cli"]
}

895
types/circomlibjs/index.d.ts vendored Normal file
View File

@@ -0,0 +1,895 @@
/** Declaration file generated by dts-gen */
declare module "circomlibjs" {
export class evmasm {
constructor(...args: any[])
add(...args: any[]): void
addmod(...args: any[]): void
address(...args: any[]): void
and(...args: any[]): void
balance(...args: any[]): void
blockhash(...args: any[]): void
byte(...args: any[]): void
call(...args: any[]): void
callcode(...args: any[]): void
calldatacopy(...args: any[]): void
calldataload(...args: any[]): void
calldatasize(...args: any[]): void
caller(...args: any[]): void
callvalue(...args: any[]): void
codecopy(...args: any[]): void
codesize(...args: any[]): void
coinbase(...args: any[]): void
create(...args: any[]): void
createTxData(...args: any[]): void
delegatecall(...args: any[]): void
difficulty(...args: any[]): void
div(...args: any[]): void
dup(...args: any[]): void
eq(...args: any[]): void
exp(...args: any[]): void
extcodecopy(...args: any[]): void
extcodesize(...args: any[]): void
gas(...args: any[]): void
gaslimit(...args: any[]): void
gasprice(...args: any[]): void
gt(...args: any[]): void
invalid(...args: any[]): void
iszero(...args: any[]): void
jmp(...args: any[]): void
jmpi(...args: any[]): void
keccak(...args: any[]): void
label(...args: any[]): void
log0(...args: any[]): void
log1(...args: any[]): void
log2(...args: any[]): void
log3(...args: any[]): void
log4(...args: any[]): void
lt(...args: any[]): void
mload(...args: any[]): void
mod(...args: any[]): void
msize(...args: any[]): void
mstore(...args: any[]): void
mstore8(...args: any[]): void
mul(...args: any[]): void
mulmod(...args: any[]): void
not(...args: any[]): void
number(...args: any[]): void
or(...args: any[]): void
origin(...args: any[]): void
pc(...args: any[]): void
pop(...args: any[]): void
push(...args: any[]): void
return(...args: any[]): void
returndatacopy(...args: any[]): void
returndatasize(...args: any[]): void
revert(...args: any[]): void
sdiv(...args: any[]): void
selfdestruct(...args: any[]): void
sgt(...args: any[]): void
sha3(...args: any[]): void
shor(...args: any[]): void
signextend(...args: any[]): void
sload(...args: any[]): void
slt(...args: any[]): void
smod(...args: any[]): void
sstore(...args: any[]): void
staticcall(...args: any[]): void
stop(...args: any[]): void
sub(...args: any[]): void
swap(...args: any[]): void
timestamp(...args: any[]): void
}
export class smt_memdb {
constructor(...args: any[])
get(...args: any[]): void
getRoot(...args: any[]): void
multiDel(...args: any[]): void
multiGet(...args: any[]): void
multiIns(...args: any[]): void
setRoot(...args: any[]): void
}
export function poseidon(inputs: any): any
export function poseidon_slow(inputs: any): any
export namespace babyjub {
const A: any
const Base8: any[]
const D: any
const Generator: any[]
const order: any
const p: any
const subOrder: any
function addPoint(a: any, b: any): any
function inCurve(P: any): any
function inSubgroup(P: any): any
function mulPointEscalar(base: any, e: any): any
function packPoint(P: any): any
function unpackPoint(_buff: any): any
namespace F {
const R: any
const Ri: any
const bitLength: number
const half: any
const m: number
const mask: any
const n32: number
const n64: number
const n8: number
const negone: any
const nqr: any
const nqr_to_t: any
const one: any
const p: any
const s: number
const sqrt_q: any
const sqrt_s: number
const sqrt_t: any
const sqrt_tm1d2: any
const sqrt_z: any
const t: any
const two: any
const type: string
const zero: any
function add(...args: any[]): void
function band(...args: any[]): void
function bnot(...args: any[]): void
function bor(...args: any[]): void
function bxor(...args: any[]): void
function div(...args: any[]): void
function e(...args: any[]): void
function eq(...args: any[]): void
function exp(...args: any[]): void
function fromRng(...args: any[]): void
function fromRprBE(...args: any[]): void
function fromRprBEM(...args: any[]): void
function fromRprLE(...args: any[]): void
function fromRprLEM(...args: any[]): void
function geq(...args: any[]): void
function gt(...args: any[]): void
function idiv(...args: any[]): void
function inv(...args: any[]): void
function isZero(...args: any[]): void
function land(...args: any[]): void
function leq(...args: any[]): void
function lnot(...args: any[]): void
function lor(...args: any[]): void
function lt(...args: any[]): void
function mod(...args: any[]): void
function mul(...args: any[]): void
function mulScalar(...args: any[]): void
function neg(...args: any[]): void
function neq(...args: any[]): void
function normalize(...args: any[]): void
function pow(...args: any[]): void
function random(...args: any[]): void
function shl(...args: any[]): void
function shr(...args: any[]): void
function sqrt(a: any): any
function sqrt_old(...args: any[]): void
function square(...args: any[]): void
function sub(...args: any[]): void
function toRprBE(...args: any[]): void
function toRprBEM(...args: any[]): void
function toRprLE(...args: any[]): void
function toRprLEM(...args: any[]): void
function toString(...args: any[]): void
}
}
export namespace eddsa {
function packSignature(sig: any): any
function pruneBuffer(_buff: any): any
function prv2pub(prv: any): any
function sign(prv: any, msg: any): any
function signMiMC(prv: any, msg: any): any
function signMiMCSponge(prv: any, msg: any): any
function signPoseidon(prv: any, msg: any): any
function unpackSignature(sigBuff: any): any
function verify(msg: any, sig: any, A: any): any
function verifyMiMC(msg: any, sig: any, A: any): any
function verifyMiMCSponge(msg: any, sig: any, A: any): any
function verifyPoseidon(msg: any, sig: any, A: any): any
}
export namespace mimc7 {
function getConstants(seed: any, nRounds: any): any
function getIV(seed: any): any
function hash(_x_in: any, _k: any): any
function multiHash(arr: any, key: any): any
namespace F {
const R: any
const Ri: any
const bitLength: number
const half: any
const m: number
const mask: any
const n32: number
const n64: number
const n8: number
const negone: any
const nqr: any
const nqr_to_t: any
const one: any
const p: any
const s: number
const sqrt_q: any
const sqrt_s: number
const sqrt_t: any
const sqrt_tm1d2: any
const sqrt_z: any
const t: any
const two: any
const type: string
const zero: any
function add(...args: any[]): void
function band(...args: any[]): void
function bnot(...args: any[]): void
function bor(...args: any[]): void
function bxor(...args: any[]): void
function div(...args: any[]): void
function e(...args: any[]): void
function eq(...args: any[]): void
function exp(...args: any[]): void
function fromRng(...args: any[]): void
function fromRprBE(...args: any[]): void
function fromRprBEM(...args: any[]): void
function fromRprLE(...args: any[]): void
function fromRprLEM(...args: any[]): void
function geq(...args: any[]): void
function gt(...args: any[]): void
function idiv(...args: any[]): void
function inv(...args: any[]): void
function isZero(...args: any[]): void
function land(...args: any[]): void
function leq(...args: any[]): void
function lnot(...args: any[]): void
function lor(...args: any[]): void
function lt(...args: any[]): void
function mod(...args: any[]): void
function mul(...args: any[]): void
function mulScalar(...args: any[]): void
function neg(...args: any[]): void
function neq(...args: any[]): void
function normalize(...args: any[]): void
function pow(...args: any[]): void
function random(...args: any[]): void
function shl(...args: any[]): void
function shr(...args: any[]): void
function sqrt(a: any): any
function sqrt_old(...args: any[]): void
function square(...args: any[]): void
function sub(...args: any[]): void
function toRprBE(...args: any[]): void
function toRprBEM(...args: any[]): void
function toRprLE(...args: any[]): void
function toRprLEM(...args: any[]): void
function toString(...args: any[]): void
}
}
export namespace mimc_gencontract {
const abi: {
constant: boolean
inputs: {
name: string
type: string
}[]
name: string
outputs: {
name: string
type: string
}[]
payable: boolean
stateMutability: string
type: string
}[]
function createCode(seed: any, n: any): any
}
export namespace mimcsponge {
function getConstants(seed: any, nRounds: any): any
function getIV(seed: any): any
function hash(_xL_in: any, _xR_in: any, _k: any): any
function multiHash(arr: any, key: any, numOutputs: any): any
}
export namespace mimcsponge_gencontract {
const abi: {
constant: boolean
inputs: {
name: string
type: string
}[]
name: string
outputs: {
name: string
type: string
}[]
payable: boolean
stateMutability: string
type: string
}[]
function createCode(seed: any, n: any): any
}
export namespace pedersenHash {
function getBasePoint(baseHashType: any, pointIdx: any): any
function hash(msg: any, options: any): any
}
export namespace poseidon_gencontract {
function createCode(nInputs: any): any
function generateABI(nInputs: any): any
}
export namespace smt {
class SMT {
constructor(...args: any[])
delete(...args: any[]): void
find(...args: any[]): void
insert(...args: any[]): void
update(...args: any[]): void
}
class SMTMemDB {
constructor(...args: any[])
get(...args: any[]): void
getRoot(...args: any[]): void
multiDel(...args: any[]): void
multiGet(...args: any[]): void
multiIns(...args: any[]): void
setRoot(...args: any[]): void
}
function loadFromFile(fileName: any): void
function newMemEmptyTrie(): any
}
export namespace smt_hashes_mimc {
function hash0(left: any, right: any): any
function hash1(key: any, value: any): any
namespace F {
const R: any
const Ri: any
const bitLength: number
const half: any
const m: number
const mask: any
const n32: number
const n64: number
const n8: number
const negone: any
const nqr: any
const nqr_to_t: any
const one: any
const p: any
const s: number
const sqrt_q: any
const sqrt_s: number
const sqrt_t: any
const sqrt_tm1d2: any
const sqrt_z: any
const t: any
const two: any
const type: string
const zero: any
function add(...args: any[]): void
function band(...args: any[]): void
function bnot(...args: any[]): void
function bor(...args: any[]): void
function bxor(...args: any[]): void
function div(...args: any[]): void
function e(...args: any[]): void
function eq(...args: any[]): void
function exp(...args: any[]): void
function fromRng(...args: any[]): void
function fromRprBE(...args: any[]): void
function fromRprBEM(...args: any[]): void
function fromRprLE(...args: any[]): void
function fromRprLEM(...args: any[]): void
function geq(...args: any[]): void
function gt(...args: any[]): void
function idiv(...args: any[]): void
function inv(...args: any[]): void
function isZero(...args: any[]): void
function land(...args: any[]): void
function leq(...args: any[]): void
function lnot(...args: any[]): void
function lor(...args: any[]): void
function lt(...args: any[]): void
function mod(...args: any[]): void
function mul(...args: any[]): void
function mulScalar(...args: any[]): void
function neg(...args: any[]): void
function neq(...args: any[]): void
function normalize(...args: any[]): void
function pow(...args: any[]): void
function random(...args: any[]): void
function shl(...args: any[]): void
function shr(...args: any[]): void
function sqrt(a: any): any
function sqrt_old(...args: any[]): void
function square(...args: any[]): void
function sub(...args: any[]): void
function toRprBE(...args: any[]): void
function toRprBEM(...args: any[]): void
function toRprLE(...args: any[]): void
function toRprLEM(...args: any[]): void
function toString(...args: any[]): void
}
}
export namespace smt_hashes_poseidon {
function hash0(left: any, right: any): any
function hash1(key: any, value: any): any
namespace F {
const R: any
const Ri: any
const bitLength: number
const half: any
const m: number
const mask: any
const n32: number
const n64: number
const n8: number
const negone: any
const nqr: any
const nqr_to_t: any
const one: any
const p: any
const s: number
const sqrt_q: any
const sqrt_s: number
const sqrt_t: any
const sqrt_tm1d2: any
const sqrt_z: any
const t: any
const two: any
const type: string
const zero: any
function add(...args: any[]): void
function band(...args: any[]): void
function bnot(...args: any[]): void
function bor(...args: any[]): void
function bxor(...args: any[]): void
function div(...args: any[]): void
function e(...args: any[]): void
function eq(...args: any[]): void
function exp(...args: any[]): void
function fromRng(...args: any[]): void
function fromRprBE(...args: any[]): void
function fromRprBEM(...args: any[]): void
function fromRprLE(...args: any[]): void
function fromRprLEM(...args: any[]): void
function geq(...args: any[]): void
function gt(...args: any[]): void
function idiv(...args: any[]): void
function inv(...args: any[]): void
function isZero(...args: any[]): void
function land(...args: any[]): void
function leq(...args: any[]): void
function lnot(...args: any[]): void
function lor(...args: any[]): void
function lt(...args: any[]): void
function mod(...args: any[]): void
function mul(...args: any[]): void
function mulScalar(...args: any[]): void
function neg(...args: any[]): void
function neq(...args: any[]): void
function normalize(...args: any[]): void
function pow(...args: any[]): void
function random(...args: any[]): void
function shl(...args: any[]): void
function shr(...args: any[]): void
function sqrt(a: any): any
function sqrt_old(...args: any[]): void
function square(...args: any[]): void
function sub(...args: any[]): void
function toRprBE(...args: any[]): void
function toRprBEM(...args: any[]): void
function toRprLE(...args: any[]): void
function toRprLEM(...args: any[]): void
function toString(...args: any[]): void
}
}
}

57
types/snarkjs/index.d.ts vendored Normal file
View File

@@ -0,0 +1,57 @@
/** Declaration file generated by dts-gen */
declare module "snarkjs" {
export = snarkjs
declare const snarkjs: {
groth16: {
exportSolidityCallData: any
fullProve: any
prove: any
verify: any
}
plonk: {
exportSolidityCallData: any
fullProve: any
prove: any
setup: any
verify: any
}
powersOfTau: {
beacon: any
challengeContribute: any
contribute: any
convert: any
exportChallenge: any
exportJson: any
importResponse: any
newAccumulator: any
preparePhase2: any
truncate: any
verify: any
}
r1cs: {
exportJson: any
info: any
print: any
}
wtns: {
calculate: any
debug: any
exportJson: any
}
zKey: {
beacon: any
bellmanContribute: any
contribute: any
exportBellman: any
exportJson: any
exportSolidityVerifier: any
exportVerificationKey: any
importBellman: any
newZKey: any
verifyFromInit: any
verifyFromR1cs: any
}
}
}

View File

@@ -1 +1 @@
865dad819e1817c3838abeeeee464ca69ce9eacb
456429e12fe3405758ed27df01c0a93393ac3e89