mirror of
https://github.com/semaphore-protocol/semaphore.git
synced 2026-01-15 01:28:02 -05:00
Compare commits
50 Commits
v4.0.0-bet
...
v4.0.0-bet
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a522fff448 | ||
|
|
d9d97de09c | ||
|
|
88df87e339 | ||
|
|
9c2968eecd | ||
|
|
c795ddce35 | ||
|
|
764ff52516 | ||
|
|
2b7dbf3519 | ||
|
|
ea2145471d | ||
|
|
197a7ae204 | ||
|
|
663bea73d0 | ||
|
|
072d94fdee | ||
|
|
a20d3db122 | ||
|
|
d00c0a3309 | ||
|
|
c071d5b6e5 | ||
|
|
c1ab686a6c | ||
|
|
1942afe766 | ||
|
|
f57f4979ce | ||
|
|
65a6983c54 | ||
|
|
30844cee5f | ||
|
|
5fecb53438 | ||
|
|
3f7eb28051 | ||
|
|
1fb6e99cd0 | ||
|
|
a3f86d9ad3 | ||
|
|
832b0d6887 | ||
|
|
a159c23b91 | ||
|
|
825a52cc4d | ||
|
|
e0057a56af | ||
|
|
7afcd53649 | ||
|
|
f569b2fc70 | ||
|
|
aa0c9ceba2 | ||
|
|
4a68eb5e03 | ||
|
|
32944c412b | ||
|
|
8d8fb82407 | ||
|
|
73a306241b | ||
|
|
9b023041e8 | ||
|
|
b6ffad5b8c | ||
|
|
8abfb93b4c | ||
|
|
138e5339bd | ||
|
|
784cddb483 | ||
|
|
5898a175b0 | ||
|
|
6e8f84025f | ||
|
|
6b659a80d0 | ||
|
|
5caa3c7fd8 | ||
|
|
619459e64b | ||
|
|
11eff59b3b | ||
|
|
0e2e6dfd0e | ||
|
|
ecfcda70cc | ||
|
|
601a339d9b | ||
|
|
6d0d7444b6 | ||
|
|
b441be91a4 |
@@ -2,11 +2,12 @@ const fs = require("node:fs")
|
||||
const path = require("node:path")
|
||||
|
||||
const packages = fs.readdirSync(path.resolve(__dirname, "packages"))
|
||||
const apps = fs.readdirSync(path.resolve(__dirname, "apps"))
|
||||
|
||||
module.exports = {
|
||||
extends: ["@commitlint/config-conventional"],
|
||||
prompt: {
|
||||
scopes: [...packages],
|
||||
scopes: [...packages, ...apps],
|
||||
markBreakingChangeMode: true,
|
||||
allowCustomIssuePrefix: false,
|
||||
allowEmptyIssuePrefix: false,
|
||||
|
||||
@@ -2,9 +2,5 @@ DEFAULT_NETWORK=hardhat
|
||||
TREE_DEPTH=10
|
||||
REPORT_GAS=false
|
||||
BACKEND_PRIVATE_KEY=
|
||||
INFURA_API_KEY=
|
||||
COINMARKETCAP_API_KEY=
|
||||
ETHERSCAN_API_KEY=
|
||||
DEFENDER_KEY=
|
||||
DEFENDER_SECRET=
|
||||
CREATE2_SALT=1234
|
||||
|
||||
9
.github/workflows/production.yml
vendored
9
.github/workflows/production.yml
vendored
@@ -24,12 +24,12 @@ jobs:
|
||||
- name: Install dependencies
|
||||
run: yarn
|
||||
|
||||
- name: Compile contracts
|
||||
run: yarn compile:contracts
|
||||
|
||||
- name: Build libraries
|
||||
run: yarn build:libraries
|
||||
|
||||
- name: Compile contracts
|
||||
run: yarn compile:contracts
|
||||
|
||||
- name: Build subgraph
|
||||
run: yarn build:subgraph
|
||||
|
||||
@@ -54,6 +54,9 @@ jobs:
|
||||
- name: Install dependencies
|
||||
run: yarn
|
||||
|
||||
- name: Build libraries
|
||||
run: yarn build:libraries
|
||||
|
||||
- name: Build subgraph
|
||||
run: yarn build:subgraph
|
||||
|
||||
|
||||
6
.github/workflows/pull-requests.yml
vendored
6
.github/workflows/pull-requests.yml
vendored
@@ -22,12 +22,12 @@ jobs:
|
||||
- name: Install dependencies
|
||||
run: yarn
|
||||
|
||||
- name: Compile contracts
|
||||
run: yarn compile:contracts
|
||||
|
||||
- name: Build libraries
|
||||
run: yarn build:libraries
|
||||
|
||||
- name: Compile contracts
|
||||
run: yarn compile:contracts
|
||||
|
||||
- name: Build subgraph
|
||||
run: yarn build:subgraph
|
||||
|
||||
|
||||
893
.yarn/releases/yarn-4.1.0.cjs
vendored
Executable file
893
.yarn/releases/yarn-4.1.0.cjs
vendored
Executable file
File diff suppressed because one or more lines are too long
1
.yarn/releases/yarn-4.1.0.cjs.REMOVED.git-id
vendored
1
.yarn/releases/yarn-4.1.0.cjs.REMOVED.git-id
vendored
@@ -1 +0,0 @@
|
||||
738adce5914a0e193f2e1255e4dcf7042256a1c1
|
||||
@@ -59,10 +59,10 @@
|
||||
</h4>
|
||||
</div>
|
||||
|
||||
| Semaphore is a protocol, designed to be a simple and generic privacy layer for Ethereum DApps. Using zero knowledge, Ethereum users can prove their membership of a group and send signals such as votes or endorsements without revealing their original identity. |
|
||||
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| Semaphore is a generic privacy layer. Leveraging zero-knowledge technology, users can prove their membership in groups and send messages (extending from votes to endorsements) off-chain or across EVM-compatible blockchains, all without revealing their personal identity. |
|
||||
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||
|
||||
The core of the Semaphore protocol is in the [circuit logic](/packages/circuits/scheme.png). However Semaphore also provides [Solidity contracts](/packages/contracts) and JavaScript libraries to make the steps for offchain proof creation and onchain verification easier. To learn more about Semaphore visit [semaphore.pse.dev](https://semaphore.pse.dev).
|
||||
The core of the Semaphore protocol is in the [circuit logic](/packages/circuits/scheme.png). However, Semaphore also provides [Solidity contracts](/packages/contracts) and JavaScript libraries to make the steps for offchain proof creation and onchain/offchain verification easier. To learn more about Semaphore visit [semaphore.pse.dev](https://semaphore.pse.dev).
|
||||
|
||||
## 📦 Packages
|
||||
|
||||
|
||||
@@ -71,6 +71,8 @@ const config: Config = {
|
||||
backgroundColor: "#dde6fc",
|
||||
textColor: "#000000"
|
||||
},
|
||||
// Social media card
|
||||
image: "img/social-media.png",
|
||||
navbar: {
|
||||
logo: {
|
||||
alt: "Semaphore Logo",
|
||||
@@ -84,7 +86,7 @@ const config: Config = {
|
||||
},
|
||||
{
|
||||
label: "Whitepaper",
|
||||
to: "https://docs.semaphore.pse.dev/whitepaper-v1.pdf",
|
||||
to: "https://semaphore.pse.dev/whitepaper-v1.pdf",
|
||||
position: "left",
|
||||
className: "whitepaper-v1"
|
||||
},
|
||||
|
||||
@@ -40,7 +40,7 @@ For more information, see [Merkle tree in Wikipedia](https://en.wikipedia.org/wi
|
||||
|
||||
A value used to prevent double entry or double signalling.
|
||||
|
||||
See [Circuit nullifier hash](/technical-reference/circuits/#hash-anulador-nullifier-hash).
|
||||
See [Circuit nullifier hash](/V2/technical-reference/circuits/#nullifier-hash).
|
||||
|
||||
## Relay
|
||||
|
||||
@@ -48,7 +48,7 @@ A third-party who receives a fee for including relayed transactions in the block
|
||||
To preserve the anonymity of the user broadcasting a signal with Semaphore, an application may use a relayer to post the signal transaction to Ethereum on behalf of the user.
|
||||
|
||||
Applications may provide rewards for relayers and implement front-running prevention mechanisms, such as requiring the signals to include the relayer’s address, binding the
|
||||
signal to that specific address (https://docs.semaphore.pse.dev/whitepaper-v1.pdf, p.6).
|
||||
signal to that specific address (https://semaphore.pse.dev/whitepaper-v1.pdf, p.6).
|
||||
|
||||
## Trusted setup files
|
||||
|
||||
|
||||
@@ -20,14 +20,14 @@ title: Groups
|
||||
|
||||
Use Semaphore in your application or smart contract to create off-chain and on-chain groups.
|
||||
|
||||
A [Semaphore group](/glossary/#grupo-semaphore) contains [identity commitments](/glossary/#compromiso-de-identidad-identity-commitment) of group members.
|
||||
A [Semaphore group](/V2/glossary/#semaphore-group) contains [identity commitments](/V2/glossary/#identity-commitment) of group members.
|
||||
Example uses of groups include the following:
|
||||
|
||||
- Poll question that attendees join to rate an event.
|
||||
- Ballot that members join to vote on a proposal.
|
||||
- Whistleblowers who are verified employees of an organization.
|
||||
|
||||
A Semaphore group is an [incremental Merkle tree](/glossary/#árbol-de-merkle-merkle-tree), and group members (i.e., identity commitments) are tree leaves.
|
||||
A Semaphore group is an [incremental Merkle tree](/V2/glossary/#merkle-tree), and group members (i.e., identity commitments) are tree leaves.
|
||||
Semaphore groups set the following two parameters:
|
||||
|
||||
- **Tree depth**: the maximum number of members a group can contain (`max size = 2 ^ tree depth`).
|
||||
|
||||
@@ -5,7 +5,7 @@ title: Identities
|
||||
|
||||
# Semaphore identities
|
||||
|
||||
In order to join a [Semaphore group](/glossary#semaphore-group), a user must first create a [Semaphore identity](/glossary#semaphore-identity).
|
||||
In order to join a [Semaphore group](/V2/glossary#semaphore-group), a user must first create a [Semaphore identity](/V2/glossary#semaphore-identity).
|
||||
A Semaphore identity contains two values generated with the identity:
|
||||
|
||||
- Identity trapdoor
|
||||
|
||||
@@ -7,7 +7,7 @@ title: Proofs
|
||||
|
||||
Learn how to use Semaphore to generate and verify zero-knowledge proofs.
|
||||
|
||||
Once a user joins their [Semaphore identity](/glossary#semaphore-identity) to a [Semaphore group](/glossary#semaphore-group), the user can signal anonymously with a zero-knowledge proof that proves the following:
|
||||
Once a user joins their [Semaphore identity](/V2/glossary#semaphore-identity) to a [Semaphore group](/V2/glossary#semaphore-group), the user can signal anonymously with a zero-knowledge proof that proves the following:
|
||||
|
||||
- The user is a member of the group.
|
||||
- The same user created the signal and the proof.
|
||||
@@ -27,11 +27,11 @@ To generate a proof, pass the following properties to the `generateProof` functi
|
||||
- `group`: The group to which the user belongs.
|
||||
- `externalNullifier`: The value that prevents double-signaling.
|
||||
- `signal`: The signal the user wants to send anonymously.
|
||||
- `snarkArtifacts`: The `zkey` and `wasm` [trusted setup files](/glossary/#trusted-setup-files).
|
||||
- `snarkArtifacts`: The `zkey` and `wasm` [trusted setup files](/V2/glossary/#trusted-setup-files).
|
||||
|
||||
In the voting system use case, once all the voters have joined their [identities](/guides/identities#create-an-identity) to the ballot [group](/guides/groups),
|
||||
In the voting system use case, once all the voters have joined their [identities](/V2/guides/identities#create-identities) to the ballot [group](/V2/guides/groups),
|
||||
a voter can generate a proof to vote for a proposal.
|
||||
In the call to `generateProof`, the voting system passes the unique ballot ID (the [Merkle tree](/glossary/#merkle-tree/) root of the group) as the
|
||||
In the call to `generateProof`, the voting system passes the unique ballot ID (the [Merkle tree](/V2/glossary#merkle-tree) root of the group) as the
|
||||
`externalNullifier` to prevent the voter signaling more than once for the ballot.
|
||||
The following code sample shows how to use `generateProof` to generate the voting proof:
|
||||
|
||||
@@ -53,7 +53,7 @@ Use the [`@semaphore-protocol/proof`](https://github.com/semaphore-protocol/sema
|
||||
To verify a proof, pass the following to the `verifyProof` function:
|
||||
|
||||
- _`proof`_: the Semaphore proof.
|
||||
- _`verificationKey`_: the JavaScript object in the `semaphore.json` [trusted setup file](/glossary/#trusted-setup-files).
|
||||
- _`verificationKey`_: the JavaScript object in the `semaphore.json` [trusted setup file](/V2/glossary/#trusted-setup-files).
|
||||
|
||||
The following code sample shows how to parse the verification key object from `semaphore.json`
|
||||
and verify the previously generated proof:
|
||||
|
||||
@@ -213,7 +213,7 @@ and [Chai assertions](https://www.chaijs.com/).
|
||||
wget http://www.trusted-setup-pse.org/semaphore/20/semaphore.wasm
|
||||
```
|
||||
|
||||
Learn more about [trusted setup files](/glossary/#trusted-setup-files).
|
||||
Learn more about [trusted setup files](/V2/glossary/#trusted-setup-files).
|
||||
|
||||
3. Rename the `Lock.js` test file to `Greeter.js` and replace the content with the following:
|
||||
|
||||
|
||||
@@ -6,9 +6,9 @@ sidebar_position: 2
|
||||
|
||||
The [Semaphore circuit](https://github.com/semaphore-protocol/semaphore/tree/v2.6.1/packages/circuits) is the heart of the protocol and consists of three parts:
|
||||
|
||||
- [**Proof of membership**](/technical-reference/circuits#proof-of-membership)
|
||||
- [**Nullifier hash**](/technical-reference/circuits#nullifier-hash)
|
||||
- [**Signal**](/technical-reference/circuits#signal)
|
||||
- [**Proof of membership**](/V2/technical-reference/circuits#proof-of-membership)
|
||||
- [**Nullifier hash**](/V2/technical-reference/circuits#nullifier-hash)
|
||||
- [**Signal**](/V2/technical-reference/circuits#signal)
|
||||
|
||||

|
||||
|
||||
|
||||
@@ -6,9 +6,9 @@ sidebar_position: 3
|
||||
|
||||
Semaphore includes three types of contracts:
|
||||
|
||||
- [**Base contracts**](/technical-reference/contracts#base-contracts)
|
||||
- [**Extension contracts**](/technical-reference/contracts#extension-contracts)
|
||||
- [**Verifiers**](/technical-reference/contracts#verifiers)
|
||||
- [**Base contracts**](/V2/technical-reference/contracts#base-contracts)
|
||||
- [**Extension contracts**](/V2/technical-reference/contracts#extension-contracts)
|
||||
- [**Verifiers**](/V2/technical-reference/contracts#verifiers)
|
||||
|
||||
:::info
|
||||
To use Semaphore contracts and interfaces in your project,
|
||||
@@ -24,7 +24,7 @@ Semaphore provides the following base contracts:
|
||||
|
||||
These contracts are closely related to the protocol.
|
||||
You can inherit them in your contract or you can use [`Semaphore.sol`](https://github.com/semaphore-protocol/semaphore/tree/v2.6.1/packages/contracts/Semaphore.sol), which inherits them for you.
|
||||
See our [deployed contracts](/deployed-contracts#semaphore) to find the addresses for your network.
|
||||
See our [deployed contracts](/V2/deployed-contracts#semaphore) to find the addresses for your network.
|
||||
|
||||
:::info
|
||||
While some dApps may use on-chain groups, others may prefer to use off-chain groups, saving only their tree roots in the contract.
|
||||
@@ -41,7 +41,7 @@ More extensions will be added in the future.
|
||||
## Verifiers
|
||||
|
||||
To verify Semaphore proofs, the [`SemaphoreCore.sol`](https://github.com/semaphore-protocol/semaphore/tree/v2.6.1/packages/contracts/base/SemaphoreCore.sol) contract requires the address of a deployed verifier contract.
|
||||
You can choose to manually deploy the [verifier](https://github.com/semaphore-protocol/semaphore/tree/v2.6.1/packages/contracts/verifiers) you prefer or you can use one of our [deployed verifiers](/deployed-contracts#verifiers).
|
||||
You can choose to manually deploy the [verifier](https://github.com/semaphore-protocol/semaphore/tree/v2.6.1/packages/contracts/verifiers) you prefer or you can use one of our [deployed verifiers](/V2/deployed-contracts#verifiers).
|
||||
|
||||
Each verifier name indicates the tree depth that it can verify.
|
||||
For example, given a Semaphore proof generated with a tree depth `20`:
|
||||
|
||||
@@ -36,7 +36,7 @@ Community members connect their wallets to the dApp to take the following action
|
||||
|
||||
### Relay
|
||||
|
||||
To preserve anonymity and avoid disclosing the member's wallet address, the dApp may use a [relay](/glossary/#relay) to broadcast the vote.
|
||||
To preserve anonymity and avoid disclosing the member's wallet address, the dApp may use a [relay](/V2/glossary/#relay) to broadcast the vote.
|
||||
The relay calls the **contract** function that then posts the member's vote transaction to Ethereum.
|
||||
|
||||
## Private voting
|
||||
@@ -52,7 +52,7 @@ The voting scenario has the following steps:
|
||||
|
||||
### Create a poll
|
||||
|
||||
A community coordinator or dApp administrator uses the deployed smart contract to create an on-chain (Ethereum) poll, a [Semaphore group](/guides/groups/) that members can join and cast votes to.
|
||||
A community coordinator or dApp administrator uses the deployed smart contract to create an on-chain (Ethereum) poll, a [Semaphore group](/V2/guides/groups/) that members can join and cast votes to.
|
||||
|
||||
In the following sample code, the voting contract declares a `createPoll` function that uses the Semaphore base `_createGroup` function:
|
||||
|
||||
@@ -78,11 +78,11 @@ function createPoll(
|
||||
}
|
||||
```
|
||||
|
||||
A poll is a Semaphore [group](/guides/groups/) that stores the following:
|
||||
A poll is a Semaphore [group](/V2/guides/groups/) that stores the following:
|
||||
|
||||
- A topic to vote on.
|
||||
- The public ID of the poll creator.
|
||||
- [Semaphore IDs](/guides/identities/) of members who joined the poll.
|
||||
- [Semaphore IDs](/V2/guides/identities/) of members who joined the poll.
|
||||
|
||||
To create the poll, the administrator calls the smart contract function--for example:
|
||||
|
||||
@@ -128,7 +128,7 @@ With a member registered for a poll, learn how the dApp [records votes](#record-
|
||||
Once members have joined a poll, the coordinator starts the poll to allow voting.
|
||||
When a member votes (for example, by selecting a radio button), then the dApp takes the following actions:
|
||||
|
||||
1. Uses the `@semaphore-protocol/proof` library to create a proof of the vote, the poll identifier, the Semaphore ID, and a [nullifier](/glossary/#nullifier) that prevents double-voting.
|
||||
1. Uses the `@semaphore-protocol/proof` library to create a proof of the vote, the poll identifier, the Semaphore ID, and a [nullifier](/V2/glossary/#nullifier) that prevents double-voting.
|
||||
2. Sends the vote proof to the [relay](#relay).
|
||||
|
||||
### Related
|
||||
|
||||
@@ -15,9 +15,9 @@ Use cases include private voting, whistleblowing, anonymous DAOs and mixers.
|
||||
|
||||
With Semaphore, you can allow your users to do the following:
|
||||
|
||||
1. [Create a Semaphore identity](/guides/identities/).
|
||||
2. [Add their Semaphore identity to a group (i.e. _Merkle tree_)](/guides/groups/).
|
||||
3. [Send a verifiable, anonymous signal (e.g a vote or endorsement)](/guides/proofs/).
|
||||
1. [Create a Semaphore identity](/V2/guides/identities/).
|
||||
2. [Add their Semaphore identity to a group (i.e. _Merkle tree_)](/V2/guides/groups/).
|
||||
3. [Send a verifiable, anonymous signal (e.g a vote or endorsement)](/V2/guides/proofs/).
|
||||
|
||||
When a user broadcasts a signal (for example: a vote), Semaphore zero-knowledge
|
||||
proofs can ensure that the user has joined the group and hasn't already cast a signal with their nullifier.
|
||||
|
||||
@@ -9,18 +9,18 @@ sidebar_position: 7
|
||||
La identidad de un usuario en el protocolo Semaphore.
|
||||
Una identidad contiene los tres valores que se mencionan a continuación:
|
||||
|
||||
- [Compromiso de identidad](#identity-commitment) (identity commitment): el valor público.
|
||||
- [Compromiso de identidad](#compromiso-de-identidad-identity-commitment) (identity commitment): el valor público.
|
||||
- Identidad trampilla (identity trapdoor) y anulador de identidad (identity nullifier): valores secretos que únicamente son del conocimiento del usuario.
|
||||
|
||||
## Compromiso de identidad (Identity commitment)
|
||||
|
||||
El valor público de la [identidad Semaphore](#semaphore-identity) utilizado en los [grupos Semaphore](#semaphore-group).
|
||||
El valor público de la [identidad Semaphore](#identidad-semaphore) utilizado en los [grupos Semaphore](#grupo-semaphore).
|
||||
|
||||
Semaphore utiliza la función hash [Poseidon](https://www.poseidon-hash.info/) para crear un compromiso de identidad a partir de los valores secretos de la identidad Semaphore.
|
||||
|
||||
## Grupo Semaphore
|
||||
|
||||
Un grupo es un [árbol de Merkle](#merkle-tree) binario e incremental en el que cada hoja contiene un [compromiso de identidad](#identity-commitment) para un usuario.
|
||||
Un grupo es un [árbol de Merkle](#árbol-de-merkle-merkle-tree) binario e incremental en el que cada hoja contiene un [compromiso de identidad](#compromiso-de-identidad-identity-commitment) para un usuario.
|
||||
El compromiso de identidad comprueba que un usuario es un miembro del grupo sin revelar la identidad Semaphore del usuario.
|
||||
|
||||
Semaphore utiliza la función hash **Poseidon** para crear árboles de Merkle.
|
||||
@@ -39,14 +39,14 @@ Para más información, vea [árbol de Merkle en Wikipedia](https://es.wikipedia
|
||||
|
||||
Un valor utilizado para prevenir registros dobles o dos señales emitidas por el mismo usuario.
|
||||
|
||||
Ver [hash de circuito nullifier](/technical-reference/circuits/#nullifier-hash).
|
||||
Ver [hash de circuito nullifier](/V3/technical-reference/circuits#hash-anulador-nullifier-hash).
|
||||
|
||||
## Retransmisor (Relayer)
|
||||
|
||||
Un tercero que recibe una comisión por incluir transacciones retransmitidas en la blockchain (McMenamin, Daza, and Fitz. https://eprint.iacr.org/2022/155.pdf, p.3).
|
||||
Para preservar la anonimidad del usuario emitiendo una señal con Semaphore, una aplicación puede utilizar un retransmisor para publicar la transacción de la señal en Ethereum en nombre del usuario.
|
||||
|
||||
Las aplicaciones pueden ofrecer recompensas a los retransmisores e implementar mecanismos para prevenir ventajas maliciosas, como requerir que las señales incluyan la dirección del retransmisor, vinculando así la señal a esa dirección en específico (https://docs.semaphore.pse.dev/whitepaper-v1.pdf, p.6).
|
||||
Las aplicaciones pueden ofrecer recompensas a los retransmisores e implementar mecanismos para prevenir ventajas maliciosas, como requerir que las señales incluyan la dirección del retransmisor, vinculando así la señal a esa dirección en específico (https://semaphore.pse.dev/whitepaper-v1.pdf, p.6).
|
||||
|
||||
## Archivos confiables de configuración (Trusted setup files)
|
||||
|
||||
|
||||
@@ -8,14 +8,14 @@ import TabItem from "@theme/TabItem"
|
||||
|
||||
# Gupos Semaphore
|
||||
|
||||
Un [grupo Semaphore](/glossary/#semaphore-group) contiene los [identity commitments](/glossary/#identity-commitment) (compromisos de identidad) de miembros del grupo.
|
||||
Un [grupo Semaphore](/V3/glossary/#grupo-semaphore) contiene los [identity commitments](/V3/glossary/#compromiso-de-identidad-identity-commitment) (compromisos de identidad) de miembros del grupo.
|
||||
Estos son algunos ejemplos de uso de los grupos:
|
||||
|
||||
- Encuesta con preguntas a la que se unen las personas que acudieron a un evento para calificarlo,
|
||||
- votación a la que se unen los miembros para votar por una propuesta,
|
||||
- Denunciantes que están verificados como empleados de una organización.
|
||||
|
||||
Un grupo Semaphore es un [árbol de Merkle incremental](/glossary/#incremental-merkle-tree), y los miembros del grupo (por ejemplo, [identity commitments](/glossary/#identity-commitments)) son las hojas del árbol.
|
||||
Un grupo Semaphore es un [árbol de Merkle incremental](/V3/glossary/#árbol-de-merkle-merkle-tree), y los miembros del grupo (por ejemplo, [identity commitments](/V3/glossary/#compromiso-de-identidad-identity-commitment)) son las hojas del árbol.
|
||||
Los grupos Semaphore determinan los siguientes tres parámetro:
|
||||
|
||||
- **Group id**: un identificador único para el grupo;
|
||||
@@ -24,14 +24,14 @@ Los grupos Semaphore determinan los siguientes tres parámetro:
|
||||
|
||||
Aprenda cómo trabajar con grupos.
|
||||
|
||||
- [**Grupos off-chain**](#off-chain-groups)
|
||||
- [**Grupos on-chain**](#on-chain-groups)
|
||||
- [**Grupos off-chain**](#grupos-off-chain-externos-a-la-cadena)
|
||||
- [**Grupos on-chain**](#grupos-on-chain)
|
||||
|
||||
## Grupos off-chain (externos a la cadena)
|
||||
|
||||
- [Crear un grupo](#create-a-group)
|
||||
- [Añadir miembros](#add-members)
|
||||
- [Remover o actualizar miembros](#remove-or-update-members)
|
||||
- [Crear un grupo](#crear-un-grupo)
|
||||
- [Añadir miembros](#añadir-miembros)
|
||||
- [Remover o actualizar miembros](#remover-o-actualizar-miembros)
|
||||
|
||||
### Crear un grupo
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import TabItem from "@theme/TabItem"
|
||||
|
||||
# Identidades Semaphore
|
||||
|
||||
Para unirse a un [grupo Semaphore](/glossary#semaphore-group), un usuario primero deberá crear una [identidad Semaphore](/glossary#semaphore-identity).
|
||||
Para unirse a un [grupo Semaphore](/V3/glossary#grupo-semaphore), un usuario primero deberá crear una [identidad Semaphore](/V3/glossary#identidad-semaphore).
|
||||
Una identidad Semaphore contiene dos valores generados junto con la identidad:
|
||||
|
||||
- Identity trapdoor (Identidad trampilla)
|
||||
@@ -21,8 +21,8 @@ Para prevenir fraudes, la persona dueña debe conservar de forma secreta ambos v
|
||||
|
||||
En su código, utilice la librería [`@semaphore-protocol/identity`](https://github.com/semaphore-protocol/semaphore/tree/main/packages/identity) para crear una identidad Semaphore _de forma determinística_ (del hash de un mensaje) o _de forma aleatoria_.
|
||||
|
||||
- [**Crear identidades aleatorias**](#create-random-identities)
|
||||
- [**Crear identidades determinísticas**](#create-deterministic-identities)
|
||||
- [**Crear identidades aleatorias**](#crear-identidades-aleatorias)
|
||||
- [**Crear identidades determinísticas**](#crear-identidades-determinísticas)
|
||||
|
||||
### Instalar librería:
|
||||
|
||||
|
||||
@@ -8,16 +8,16 @@ import TabItem from "@theme/TabItem"
|
||||
|
||||
# Pruebas Semaphore
|
||||
|
||||
Una vez que un usuario liga su [identidad Semaphore](/glossary#semaphore-identity) a un [grupo Semaphore](/glossary#semaphore-group), el usuario puede emitir una señal anónima con una prueba de conocimiento cero (ZKP) que demuestre lo siguiente:
|
||||
Una vez que un usuario liga su [identidad Semaphore](/V3/glossary#identidad-semaphore) a un [grupo Semaphore](/V3/glossary#grupo-semaphore), el usuario puede emitir una señal anónima con una prueba de conocimiento cero (ZKP) que demuestre lo siguiente:
|
||||
|
||||
- el usuario es un miembro del grupo,
|
||||
- el mismo usuario creo tanto la señal como la prueba.
|
||||
|
||||
Las y los desarrolladores pueden utilizar Semaphore para realizar las siguientes acciones:
|
||||
|
||||
- [**Generar una prueba externa a la cadena (off-chain)**](#generate-a-proof-off-chain)
|
||||
- [**Verificar una prueba externa a la cadena (off-chain)**](#verify-a-proof-off-chain)
|
||||
- [**Verificar una prueba interna a la cadena (on-chain)**](#verify-a-proof-on-chain)
|
||||
- [**Generar una prueba externa a la cadena (off-chain)**](#generar-una-prueba-off-chain)
|
||||
- [**Verificar una prueba externa a la cadena (off-chain)**](#verificar-una-prueba-off-chain)
|
||||
- [**Verificar una prueba interna a la cadena (on-chain)**](#verificar-una-prueba-on-chain)
|
||||
|
||||
## Generar una prueba off-chain
|
||||
|
||||
@@ -28,7 +28,7 @@ Para generar una prueba, transforme los siguientes parámetros con la función `
|
||||
- `group`: el grupo al cual pertenece el usuario;
|
||||
- `externalNullifier`: el valor que impide la emisión de dos señales por el mismo usuario;
|
||||
- `signal`: la señal que el usuario quiere enviar de forma anónima;
|
||||
- `snarkArtifacts`: la `zkey` y `wasm` de los [archivos confiables de configuración](/glossary/#trusted-setup-files).
|
||||
- `snarkArtifacts`: la `zkey` y `wasm` de los [archivos confiables de configuración](/V3/glossary/#archivos-confiables-de-configuración-trusted-setup-files).
|
||||
|
||||
#### Instalar librería:
|
||||
|
||||
@@ -62,9 +62,9 @@ pnpm add @semaphore-protocol/proof@^3
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
En el caso de uso de un sistema de votación, una vez que todos los votantes hayan ligado sus [identidades](/guides/identities#create-an-identity) al [grupo](/guides/groups) de la votación,
|
||||
En el caso de uso de un sistema de votación, una vez que todos los votantes hayan ligado sus [identidades](/V3/guides/identities#crear-identidades) al [grupo](/V3/guides/groups) de la votación,
|
||||
un votante puede generar una prueba para votar por una propuesta.
|
||||
En el llamado para `generateProof`(generar la prueba), el sistema de votación envía el ID único de la votación (la raíz del [árbol de Merkle](/glossary/#merkle-tree/) del grupo) como el
|
||||
En el llamado para `generateProof`(generar la prueba), el sistema de votación envía el ID único de la votación (la raíz del [árbol de Merkle](/V3/glossary/#árbol-de-merkle-merkle-tree) del grupo) como el
|
||||
`externalNullifier` para impedir que el votante emita más de una señal para esta votación.
|
||||
La siguiente muestra de código demuestra cómo utilizar `generateProof` para generar una prueba de votación:
|
||||
|
||||
@@ -108,10 +108,10 @@ await verifyProof(fullProof, 20) // verdadero o falso.
|
||||
|
||||
## Verificar una prueba on-chain
|
||||
|
||||
Utilice el contrato [`Semaphore.sol`](/technical-reference/contracts#semaphoresol) para verificar pruebas on-chain.
|
||||
Utilice el contrato [`Semaphore.sol`](/V3/technical-reference/contracts#semaphoresol) para verificar pruebas on-chain.
|
||||
|
||||
:::info
|
||||
Vea nuestros [contratos desplegados](/deployed-contracts) para encontrar las direcciones adecuadas para su red.
|
||||
Vea nuestros [contratos desplegados](/V3/deployed-contracts) para encontrar las direcciones adecuadas para su red.
|
||||
::::
|
||||
|
||||
Para verificar las pruebas Semaphore en su contrato, importe `ISemaphore.sol`, transfórmelo a la dirección `Semaphore.sol` y llame el método `verifyProof` con los siguientes parámetros:
|
||||
@@ -119,9 +119,9 @@ Para verificar las pruebas Semaphore en su contrato, importe `ISemaphore.sol`, t
|
||||
- `groupId`: el identificador del grupo;
|
||||
- `merkleTreeRoot`: la raíz del árbol de Merkle;
|
||||
- `signal`: la señal que el usuario quiere enviar de forma anónima ;
|
||||
- `nullifierHash`: un [nullifier hash](#retrieve-a-nullifier-hash) (hash anulador);
|
||||
- `nullifierHash`: un nullifier hash (hash anulador);
|
||||
- `externalNullifier`: el valor que impide la emisión de dos señales por el mismo usuario;
|
||||
- `proof`: una [prueba Semaphore que es compatible con Solidity](#generate-a-solidity-compatible-proof).
|
||||
- `proof`: una prueba Semaphore que es compatible con Solidity.
|
||||
|
||||
:::info
|
||||
Puede importar `ISemaphore.sol` y otros contratos Semaphore del módulo NPM [`@semaphore-protocol/contracts`](https://github.com/semaphore-protocol/semaphore/tree/main/packages/contracts).
|
||||
|
||||
@@ -293,7 +293,7 @@ En la carpeta raíz del proyecto:
|
||||
</Tabs>
|
||||
|
||||
:::note
|
||||
Revise las direcciones de los contratos de Semaphore [aquí](/deployed-contracts).
|
||||
Revise las direcciones de los contratos de Semaphore [aquí](/V3/deployed-contracts).
|
||||
:::
|
||||
|
||||
:::caution
|
||||
|
||||
@@ -6,7 +6,7 @@ sidebar_position: 9
|
||||
|
||||
## Artículos
|
||||
|
||||
[Propuesta de la comunidad: Semaphore: Señalización de conocimiento cero (ZK) en Ethereum (v1 Whitepaper)](https://docs.semaphore.pse.dev/whitepaper-v1.pdf) - Kobi Gurkan, Koh Wei Jie y Barry WhiteHat
|
||||
[Propuesta de la comunidad: Semaphore: Señalización de conocimiento cero (ZK) en Ethereum (v1 Whitepaper)](https://semaphore.pse.dev/whitepaper-v1.pdf) - Kobi Gurkan, Koh Wei Jie y Barry WhiteHat
|
||||
|
||||
[Para Mezcladores y más allá: presentando Semaphore, una herramienta de privacidad construida en Ethereum](https://medium.com/coinmonks/to-mixers-and-beyond-presenting-semaphore-a-privacy-gadget-built-on-ethereum-4c8b00857c9b) - Koh Wei Jie
|
||||
|
||||
|
||||
@@ -6,9 +6,9 @@ sidebar_position: 2
|
||||
|
||||
El [circuito Semaphore](https://github.com/semaphore-protocol/semaphore/tree/main/packages/circuits) es el corazón del protocolo y está compuesto por tres partes:
|
||||
|
||||
- [**Prueba de membresía**](/technical-reference/circuits#proof-of-membership)
|
||||
- [**Nullifier hash**](/technical-reference/circuits#nullifier-hash) (hash anulador)
|
||||
- [**Señal**](/technical-reference/circuits#signal)
|
||||
- [**Prueba de membresía**](#prueba-de-membresía)
|
||||
- [**Nullifier hash**](#hash-anulador-nullifier-hash) (hash anulador)
|
||||
- [**Señal**](#señal)
|
||||
|
||||

|
||||
|
||||
|
||||
@@ -6,10 +6,10 @@ sidebar_position: 3
|
||||
|
||||
Semaphore incluye dos tipos de contratos:
|
||||
|
||||
- [**Contratos base**](/technical-reference/contracts#base-contracts)
|
||||
- [**Contratos para la extensión**](/technical-reference/contracts#extension-contracts)
|
||||
- [**Contratos base**](#contratos-base)
|
||||
- [**Contratos para la extensión**](#contratos-para-la-extensión)
|
||||
|
||||
así como [**Semaphore.sol**](/technical-reference/contracts#semaphoresol), el principal contrato desplegado en las redes soportadas por Semaphore.
|
||||
así como [**Semaphore.sol**](#semaphoresol), el principal contrato desplegado en las redes soportadas por Semaphore.
|
||||
|
||||
:::info
|
||||
Para utilizar los contratos e interfaces Semaphore en su proyecto, instale el paquete NPM [`@semaphore-protocol/contracts`](https://github.com/semaphore-protocol/semaphore/tree/main/packages/contracts).
|
||||
@@ -23,7 +23,7 @@ Semaphore ofrece los siguientes contratos base:
|
||||
- [`SemaphoreGroups.sol`](https://github.com/semaphore-protocol/semaphore/blob/main/packages/contracts/base/SemaphoreGroups.sol): contiene las funciones para crear grupos y añadir/remover/actualizar miembros.
|
||||
|
||||
Los contratos base están relacionados de forma muy cercana al protocolo.
|
||||
Puede utilizarlos en su contrato o puede utilizar [**Semaphore.sol**](/technical-reference/contracts#semaphoresol) que ya los tiene integrados.
|
||||
Puede utilizarlos en su contrato o puede utilizar [**Semaphore.sol**](/V3/technical-reference/contracts#semaphoresol) que ya los tiene integrados.
|
||||
|
||||
:::info
|
||||
Si bien algunas dApps pueden utilizar grupos internos a la cadena, otros puede que prefieran utilizar grupos externos a la cadena, por lo que únicamente guardarán las raíces de sus árboles en el contrato.
|
||||
@@ -42,9 +42,9 @@ En un futuro se incluirán más extensiones.
|
||||
[`Semaphore.sol`](https://github.com/semaphore-protocol/semaphore/blob/main/packages/contracts/contracts/Semaphore.sol) utiliza los contratos base como punto de partida, los integra y de forma adicional brinda:
|
||||
|
||||
- un sistema que solamente permite que administradores (ej. cuentas de Ethereum o contratos inteligentes) controlen grupos;
|
||||
- un mecanismo que guarda los [hashes anuladores](/technical-reference/circuits#nullifier-hash) (nullifier hashes) de cada grupo y evita que el mismo miembro emita dos señales;
|
||||
- un mecanismo que guarda los [hashes anuladores](/V3/technical-reference/circuits#hash-anulador-nullifier-hash) (nullifier hashes) de cada grupo y evita que el mismo miembro emita dos señales;
|
||||
- un mecanismo que permite que pruebas Semaphore generadas con raíces de Merkle antiguas sean verificadas por un periodo de tiempo determinado por el administrador del grupo.
|
||||
|
||||
:::info
|
||||
Visitando [contratos desplegados](/deployed-contracts) puede encontrar las direcciones correspondientes a su red.
|
||||
Visitando [contratos desplegados](/V3/deployed-contracts) puede encontrar las direcciones correspondientes a su red.
|
||||
::::
|
||||
|
||||
@@ -15,9 +15,9 @@ Algunos de los potenciales casos de uso son: votaciones, denuncias, DAOs anónim
|
||||
|
||||
Con Semaphore puede permitir que sus usuarios realicen las siguientes acciones:
|
||||
|
||||
1. [Crear una identidad Semaphore](/guides/identities/).
|
||||
2. [Agregar su identidad Semaphore a un grupo (es decir: _Árbol de Merkle_)](/guides/groups/).
|
||||
3. [Enviar una señal anónima, verificable (ej. un voto o una aprobación)](/guides/proofs/).
|
||||
1. [Crear una identidad Semaphore](/V3/guides/identities/).
|
||||
2. [Agregar su identidad Semaphore a un grupo (es decir: _Árbol de Merkle_)](/V3/guides/groups/).
|
||||
3. [Enviar una señal anónima, verificable (ej. un voto o una aprobación)](/V3/guides/proofs/).
|
||||
|
||||
Cuando un usuario emite una señal (por ejemplo: un voto), las pruebas de conocimiento cero (ZKP) pueden asegurar que el usuario se ha incorporado al grupo y aún no ha emitido una señal con su nullifier (anulador).
|
||||
|
||||
@@ -39,7 +39,7 @@ y [librerías en JavaScript](https://github.com/semaphore-protocol/semaphore#-pa
|
||||
|
||||
### Ceremonia de configuración de confianza (Trusted Setup Ceremony)
|
||||
|
||||
Los [parámetros seguros](/glossary#trusted-setup-files) para generar pruebas válidas con los circuitos Semaphore fueron generados en una [ceremonia de configuración de confianza](https://storage.googleapis.com/trustedsetup-a86f4.appspot.com/semaphore/semaphore_top_index.html) que se completó con más de 300 participantes el [29 de Marzo de 2022](https://etherscan.io/tx/0xec6dbe68883c7593c2bea82f55af18b3aeb5cc146e026d0083a9b3faa9aa0b65#eventlog).
|
||||
Los [parámetros seguros](/V3/glossary#archivos-confiables-de-configuración-trusted-setup-files) para generar pruebas válidas con los circuitos Semaphore fueron generados en una [ceremonia de configuración de confianza](https://storage.googleapis.com/trustedsetup-a86f4.appspot.com/semaphore/semaphore_top_index.html) que se completó con más de 300 participantes el [29 de Marzo de 2022](https://etherscan.io/tx/0xec6dbe68883c7593c2bea82f55af18b3aeb5cc146e026d0083a9b3faa9aa0b65#eventlog).
|
||||
|
||||
### Auditorías
|
||||
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
"scripts": {
|
||||
"start": "docusaurus start",
|
||||
"start:es": "docusaurus start --locale es",
|
||||
"build": "docusaurus build",
|
||||
"pre-build": "yarn workspace @semaphore-protocol/utils build",
|
||||
"build": "yarn pre-build && docusaurus build",
|
||||
"swizzle": "docusaurus swizzle",
|
||||
"deploy": "docusaurus deploy",
|
||||
"clear": "docusaurus clear",
|
||||
@@ -16,6 +17,7 @@
|
||||
"@docusaurus/core": "3.1.1",
|
||||
"@docusaurus/preset-classic": "3.1.1",
|
||||
"@mdx-js/react": "^3.0.0",
|
||||
"@semaphore-protocol/utils": "4.0.0-beta.7",
|
||||
"@svgr/webpack": "^5.5.0",
|
||||
"clsx": "^1.2.1",
|
||||
"docusaurus-plugin-sass": "^0.2.5",
|
||||
|
||||
@@ -1,39 +1,11 @@
|
||||
import { deployedContracts, supportedNetworks } from "@semaphore-protocol/utils"
|
||||
import Heading from "@theme/Heading"
|
||||
import { useEffect, useState } from "react"
|
||||
|
||||
function capitalizeFirstLetter(s: string): string {
|
||||
return s.charAt(0).toUpperCase() + s.slice(1)
|
||||
}
|
||||
|
||||
function getEtherscanLink(network: string): string {
|
||||
switch (network) {
|
||||
case "sepolia":
|
||||
return "https://sepolia.etherscan.io/address/"
|
||||
case "mumbai":
|
||||
return "https://mumbai.polygonscan.com/address/"
|
||||
case "arbitrum":
|
||||
return "https://arbiscan.io/address/"
|
||||
case "arbitrum-sepolia":
|
||||
return "https://sepolia.arbiscan.io/address/"
|
||||
case "optimism-sepolia":
|
||||
return "https://sepolia-optimism.etherscan.io/address/"
|
||||
default:
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
export default function DeployedContracts() {
|
||||
const [deployedContracts, setDeployedContracts] = useState<any[]>([])
|
||||
|
||||
useEffect(() => {
|
||||
fetch(
|
||||
"https://raw.githubusercontent.com/semaphore-protocol/semaphore/main/packages/contracts/deployed-contracts.json"
|
||||
)
|
||||
.then((response) => response.json())
|
||||
.catch(() => [])
|
||||
.then(setDeployedContracts)
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<div>
|
||||
{deployedContracts.map(({ network, contracts }) => (
|
||||
@@ -43,7 +15,11 @@ export default function DeployedContracts() {
|
||||
{contracts.map(({ name, address }) => (
|
||||
<li key={address}>
|
||||
{name}:{" "}
|
||||
<a href={getEtherscanLink(network) + address} target="_blank" rel="noreferrer">
|
||||
<a
|
||||
href={`${supportedNetworks[network].explorer}/address/${address}`}
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
>
|
||||
{address}
|
||||
</a>
|
||||
</li>
|
||||
|
||||
BIN
apps/docs/static/img/social-media.png
vendored
Normal file
BIN
apps/docs/static/img/social-media.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 190 KiB |
3
apps/docs/vercel.json
Normal file
3
apps/docs/vercel.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"cleanUrls": true
|
||||
}
|
||||
@@ -95,7 +95,7 @@ to any question. The user, however, can only vote once per question.
|
||||
## About the code
|
||||
|
||||
This repository contains the code for Semaphore's contracts written in
|
||||
Soliidty, and zk-SNARK circuits written in
|
||||
Solidity, and zk-SNARK circuits written in
|
||||
[circom](https://github.com/iden3/circom). It also contains Typescript code to
|
||||
execute tests.
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ For more information, see [Merkle tree in Wikipedia](https://en.wikipedia.org/wi
|
||||
|
||||
A value used to prevent double entry or double signalling.
|
||||
|
||||
See [Circuit nullifier hash](/technical-reference/circuits/#nullifier-hash).
|
||||
See [Circuit nullifier hash](/V2/technical-reference/circuits/#nullifier-hash).
|
||||
|
||||
## Relay
|
||||
|
||||
@@ -48,7 +48,7 @@ A third-party who receives a fee for including relayed transactions in the block
|
||||
To preserve the anonymity of the user broadcasting a signal with Semaphore, an application may use a relayer to post the signal transaction to Ethereum on behalf of the user.
|
||||
|
||||
Applications may provide rewards for relayers and implement front-running prevention mechanisms, such as requiring the signals to include the relayer’s address, binding the
|
||||
signal to that specific address (https://docs.semaphore.pse.dev/whitepaper-v1.pdf, p.6).
|
||||
signal to that specific address (https://semaphore.pse.dev/whitepaper-v1.pdf, p.6).
|
||||
|
||||
## Trusted setup files
|
||||
|
||||
|
||||
@@ -20,14 +20,14 @@ title: Groups
|
||||
|
||||
Use Semaphore in your application or smart contract to create off-chain and on-chain groups.
|
||||
|
||||
A [Semaphore group](/glossary/#semaphore-group) contains [identity commitments](/glossary/#identity-commitment) of group members.
|
||||
A [Semaphore group](/V2/glossary/#semaphore-group) contains [identity commitments](/V2/glossary/#identity-commitment) of group members.
|
||||
Example uses of groups include the following:
|
||||
|
||||
- Poll question that attendees join to rate an event.
|
||||
- Ballot that members join to vote on a proposal.
|
||||
- Whistleblowers who are verified employees of an organization.
|
||||
|
||||
A Semaphore group is an [incremental Merkle tree](/glossary/#incremental-merkle-tree), and group members (i.e., [identity commitments](/glossary/#identity-commitments)) are tree leaves.
|
||||
A Semaphore group is an [incremental Merkle tree](/V2/glossary/#merkle-tree), and group members (i.e., [identity commitments](/V2/glossary/#identity-commitment)) are tree leaves.
|
||||
Semaphore groups set the following two parameters:
|
||||
|
||||
- **Tree depth**: the maximum number of members a group can contain (`max size = 2 ^ tree depth`).
|
||||
|
||||
@@ -5,7 +5,7 @@ title: Identities
|
||||
|
||||
# Semaphore identities
|
||||
|
||||
In order to join a [Semaphore group](/glossary#semaphore-group), a user must first create a [Semaphore identity](/glossary#semaphore-identity).
|
||||
In order to join a [Semaphore group](/V2/glossary#semaphore-group), a user must first create a [Semaphore identity](/V2/glossary#semaphore-identity).
|
||||
A Semaphore identity contains two values generated with the identity:
|
||||
|
||||
- Identity trapdoor
|
||||
|
||||
@@ -7,7 +7,7 @@ title: Proofs
|
||||
|
||||
Learn how to use Semaphore to generate and verify zero-knowledge proofs.
|
||||
|
||||
Once a user joins their [Semaphore identity](/glossary#semaphore-identity) to a [Semaphore group](/glossary#semaphore-group), the user can signal anonymously with a zero-knowledge proof that proves the following:
|
||||
Once a user joins their [Semaphore identity](/V2/glossary#semaphore-identity) to a [Semaphore group](/V2/glossary#semaphore-group), the user can signal anonymously with a zero-knowledge proof that proves the following:
|
||||
|
||||
- The user is a member of the group.
|
||||
- The same user created the signal and the proof.
|
||||
@@ -27,11 +27,11 @@ To generate a proof, pass the following properties to the `generateProof` functi
|
||||
- `group`: The group to which the user belongs.
|
||||
- `externalNullifier`: The value that prevents double-signaling.
|
||||
- `signal`: The signal the user wants to send anonymously.
|
||||
- `snarkArtifacts`: The `zkey` and `wasm` [trusted setup files](/glossary/#trusted-setup-files).
|
||||
- `snarkArtifacts`: The `zkey` and `wasm` [trusted setup files](/V2/glossary/#trusted-setup-files).
|
||||
|
||||
In the voting system use case, once all the voters have joined their [identities](/guides/identities#create-an-identity) to the ballot [group](/guides/groups),
|
||||
In the voting system use case, once all the voters have joined their [identities](/guides/identities#create-identities) to the ballot [group](/guides/groups),
|
||||
a voter can generate a proof to vote for a proposal.
|
||||
In the call to `generateProof`, the voting system passes the unique ballot ID (the [Merkle tree](/glossary/#merkle-tree/) root of the group) as the
|
||||
In the call to `generateProof`, the voting system passes the unique ballot ID (the [Merkle tree](/V2/glossary/#merkle-tree) root of the group) as the
|
||||
`externalNullifier` to prevent the voter signaling more than once for the ballot.
|
||||
The following code sample shows how to use `generateProof` to generate the voting proof:
|
||||
|
||||
@@ -53,7 +53,7 @@ Use the [`@semaphore-protocol/proof`](https://github.com/semaphore-protocol/sema
|
||||
To verify a proof, pass the following to the `verifyProof` function:
|
||||
|
||||
- _`proof`_: the Semaphore proof.
|
||||
- _`verificationKey`_: the JavaScript object in the `semaphore.json` [trusted setup file](/glossary/#trusted-setup-files).
|
||||
- _`verificationKey`_: the JavaScript object in the `semaphore.json` [trusted setup file](/V2/glossary/#trusted-setup-files).
|
||||
|
||||
The following code sample shows how to parse the verification key object from `semaphore.json`
|
||||
and verify the previously generated proof:
|
||||
|
||||
@@ -213,7 +213,7 @@ and [Chai assertions](https://www.chaijs.com/).
|
||||
wget http://www.trusted-setup-pse.org/semaphore/20/semaphore.wasm
|
||||
```
|
||||
|
||||
Learn more about [trusted setup files](/glossary/#trusted-setup-files).
|
||||
Learn more about [trusted setup files](/V2/glossary/#trusted-setup-files).
|
||||
|
||||
3. Rename the `Lock.js` test file to `Greeter.js` and replace the content with the following:
|
||||
|
||||
|
||||
@@ -6,9 +6,9 @@ sidebar_position: 2
|
||||
|
||||
The [Semaphore circuit](https://github.com/semaphore-protocol/semaphore/tree/v2.6.1/packages/circuits) is the heart of the protocol and consists of three parts:
|
||||
|
||||
- [**Proof of membership**](/technical-reference/circuits#proof-of-membership)
|
||||
- [**Nullifier hash**](/technical-reference/circuits#nullifier-hash)
|
||||
- [**Signal**](/technical-reference/circuits#signal)
|
||||
- [**Proof of membership**](/V2/technical-reference/circuits#proof-of-membership)
|
||||
- [**Nullifier hash**](/V2/technical-reference/circuits#nullifier-hash)
|
||||
- [**Signal**](/V2/technical-reference/circuits#signal)
|
||||
|
||||

|
||||
|
||||
|
||||
@@ -6,9 +6,9 @@ sidebar_position: 3
|
||||
|
||||
Semaphore includes three types of contracts:
|
||||
|
||||
- [**Base contracts**](/technical-reference/contracts#base-contracts)
|
||||
- [**Extension contracts**](/technical-reference/contracts#extension-contracts)
|
||||
- [**Verifiers**](/technical-reference/contracts#verifiers)
|
||||
- [**Base contracts**](/V2/technical-reference/contracts#base-contracts)
|
||||
- [**Extension contracts**](/V2/technical-reference/contracts#extension-contracts)
|
||||
- [**Verifiers**](/V2/technical-reference/contracts#verifiers)
|
||||
|
||||
:::info
|
||||
To use Semaphore contracts and interfaces in your project,
|
||||
@@ -24,7 +24,7 @@ Semaphore provides the following base contracts:
|
||||
|
||||
These contracts are closely related to the protocol.
|
||||
You can inherit them in your contract or you can use [`Semaphore.sol`](https://github.com/semaphore-protocol/semaphore/tree/v2.6.1/packages/contracts/contracts/Semaphore.sol), which inherits them for you.
|
||||
See our [deployed contracts](/deployed-contracts#semaphore) to find the addresses for your network.
|
||||
See our [deployed contracts](/V2/deployed-contracts#semaphore) to find the addresses for your network.
|
||||
|
||||
:::info
|
||||
While some dApps may use on-chain groups, others may prefer to use off-chain groups, saving only their tree roots in the contract.
|
||||
@@ -41,10 +41,10 @@ More extensions will be added in the future.
|
||||
## Verifiers
|
||||
|
||||
To verify Semaphore proofs, the [`SemaphoreCore.sol`](https://github.com/semaphore-protocol/semaphore/tree/v2.6.1/packages/contracts/contracts/base/SemaphoreCore.sol) contract requires the address of a deployed verifier contract.
|
||||
You can choose to manually deploy the [verifier](https://github.com/semaphore-protocol/semaphore/tree/v2.6.1/packages/contracts/contracts/verifiers) you prefer or you can use one of our [deployed verifiers](/deployed-contracts#verifiers).
|
||||
You can choose to manually deploy the [verifier](https://github.com/semaphore-protocol/semaphore/tree/v2.6.1/packages/contracts/contracts/verifiers) you prefer or you can use one of our [deployed verifiers](/V2/deployed-contracts#verifiers).
|
||||
|
||||
Each verifier name indicates the tree depth that it can verify.
|
||||
For example, given a Semaphore proof generated with a tree depth `20`:
|
||||
|
||||
- The `Verifier20.sol` contract can verify the proof.
|
||||
- The [group](/guides/groups) used for the proof can have a maximum `2^20=1048576` members.
|
||||
- The [group](/V2/guides/groups) used for the proof can have a maximum `2^20=1048576` members.
|
||||
|
||||
@@ -36,7 +36,7 @@ Community members connect their wallets to the dApp to take the following action
|
||||
|
||||
### Relay
|
||||
|
||||
To preserve anonymity and avoid disclosing the member's wallet address, the dApp may use a [relay](/glossary/#relay) to broadcast the vote.
|
||||
To preserve anonymity and avoid disclosing the member's wallet address, the dApp may use a [relay](/V2/glossary/#relay) to broadcast the vote.
|
||||
The relay calls the **contract** function that then posts the member's vote transaction to Ethereum.
|
||||
|
||||
## Private voting
|
||||
@@ -52,7 +52,7 @@ The voting scenario has the following steps:
|
||||
|
||||
### Create a poll
|
||||
|
||||
A community coordinator or dApp administrator uses the deployed smart contract to create an on-chain (Ethereum) poll, a [Semaphore group](/guides/groups/) that members can join and cast votes to.
|
||||
A community coordinator or dApp administrator uses the deployed smart contract to create an on-chain (Ethereum) poll, a [Semaphore group](/V2/guides/groups/) that members can join and cast votes to.
|
||||
|
||||
In the following sample code, the voting contract declares a `createPoll` function that uses the Semaphore base `_createGroup` function:
|
||||
|
||||
@@ -77,11 +77,11 @@ function createPoll(
|
||||
}
|
||||
```
|
||||
|
||||
A poll is a Semaphore [group](/guides/groups/) that stores the following:
|
||||
A poll is a Semaphore [group](/V2/guides/groups/) that stores the following:
|
||||
|
||||
- A topic to vote on.
|
||||
- The public ID of the poll creator.
|
||||
- [Semaphore IDs](/guides/identities/) of members who joined the poll.
|
||||
- [Semaphore IDs](/V2/guides/identities/) of members who joined the poll.
|
||||
|
||||
To create the poll, the administrator calls the smart contract function--for example:
|
||||
|
||||
@@ -127,7 +127,7 @@ With a member registered for a poll, learn how the dApp [records votes](#record-
|
||||
Once members have joined a poll, the coordinator starts the poll to allow voting.
|
||||
When a member votes (for example, by selecting a radio button), then the dApp takes the following actions:
|
||||
|
||||
1. Uses the `@semaphore-protocol/proof` library to create a proof of the vote, the poll identifier, the Semaphore ID, and a [nullifier](/glossary/#nullifier) that prevents double-voting.
|
||||
1. Uses the `@semaphore-protocol/proof` library to create a proof of the vote, the poll identifier, the Semaphore ID, and a [nullifier](/V2/glossary/#nullifier) that prevents double-voting.
|
||||
2. Sends the vote proof to the [relay](#relay).
|
||||
|
||||
### Related
|
||||
|
||||
@@ -15,9 +15,9 @@ Use cases include private voting, whistleblowing, anonymous DAOs and mixers.
|
||||
|
||||
With Semaphore, you can allow your users to do the following:
|
||||
|
||||
1. [Create a Semaphore identity](/guides/identities/).
|
||||
2. [Add their Semaphore identity to a group (i.e. _Merkle tree_)](/guides/groups/).
|
||||
3. [Send a verifiable, anonymous signal (e.g a vote or endorsement)](/guides/proofs/).
|
||||
1. [Create a Semaphore identity](/V2/guides/identities/).
|
||||
2. [Add their Semaphore identity to a group (i.e. _Merkle tree_)](/V2/guides/groups/).
|
||||
3. [Send a verifiable, anonymous signal (e.g a vote or endorsement)](/V2/guides/proofs/).
|
||||
|
||||
When a user broadcasts a signal (for example: a vote), Semaphore zero-knowledge
|
||||
proofs can ensure that the user has joined the group and hasn't already cast a signal with their nullifier.
|
||||
|
||||
@@ -47,7 +47,7 @@ A third-party who receives a fee for including relayed transactions in the block
|
||||
To preserve the anonymity of the user broadcasting a signal with Semaphore, an application may use a relayer to post the signal transaction to Ethereum on behalf of the user.
|
||||
|
||||
Applications may provide rewards for relayers and implement front-running prevention mechanisms, such as requiring the signals to include the relayer’s address, binding the
|
||||
signal to that specific address (https://docs.semaphore.pse.dev/whitepaper-v1.pdf, p.6).
|
||||
signal to that specific address (https://semaphore.pse.dev/whitepaper-v1.pdf, p.6).
|
||||
|
||||
## Trusted setup files
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ Example uses of groups include the following:
|
||||
- ballot that members join to vote on a proposal,
|
||||
- whistleblowers who are verified employees of an organization.
|
||||
|
||||
A Semaphore group is an [incremental Merkle tree](/V3/glossary/#incremental-merkle-tree), and group members (i.e., [identity commitments](/V3/glossary/#identity-commitments)) are tree leaves.
|
||||
A Semaphore group is an [incremental Merkle tree](/V3/glossary/#merkle-tree), and group members (i.e., [identity commitments](/V3/glossary/#identity-commitment)) are tree leaves.
|
||||
Semaphore groups set the following three parameters:
|
||||
|
||||
- **Group id**: a unique identifier for the group;
|
||||
|
||||
@@ -63,9 +63,9 @@ pnpm add @semaphore-protocol/proof@^3
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
In the voting system use case, once all the voters have joined their [identities](/V3/guides/identities#create-an-identity) to the ballot [group](/V3/guides/groups),
|
||||
In the voting system use case, once all the voters have joined their [identities](/V3/guides/identities#create-identities) to the ballot [group](/V3/guides/groups),
|
||||
a voter can generate a proof to vote for a proposal.
|
||||
In the call to `generateProof`, the voting system passes the unique ballot ID (the [Merkle tree](/V3/glossary/#merkle-tree/) root of the group) as the
|
||||
In the call to `generateProof`, the voting system passes the unique ballot ID (the [Merkle tree](/V3/glossary#merkle-tree) root of the group) as the
|
||||
`externalNullifier` to prevent the voter signaling more than once for the ballot.
|
||||
The following code sample shows how to use `generateProof` to generate the voting proof:
|
||||
|
||||
@@ -120,9 +120,9 @@ To verify Semaphore proofs in your contract, import `ISemaphore.sol`, pass it th
|
||||
- `groupId`: the identifier of the group;
|
||||
- `merkleTreeRoot`: the root of the Merkle tree;
|
||||
- `signal`: the signal the user wants to send anonymously;
|
||||
- `nullifierHash`: a [nullifier hash](#retrieve-a-nullifier-hash);
|
||||
- `nullifierHash`: a nullifier hash;
|
||||
- `externalNullifier`: the value that prevents double-signaling;
|
||||
- `proof`: a [Solidity-compatible Semaphore proof](#generate-a-solidity-compatible-proof).
|
||||
- `proof`: a Solidity-compatible Semaphore proof.
|
||||
|
||||
:::info
|
||||
You can import `ISemaphore.sol` and other Semaphore contracts from the [`@semaphore-protocol/contracts`](https://github.com/semaphore-protocol/semaphore/tree/v3.15.2/packages/contracts) NPM module.
|
||||
|
||||
@@ -6,7 +6,7 @@ sidebar_position: 9
|
||||
|
||||
## Articles
|
||||
|
||||
[Community Proposal: Semaphore: Zero-Knowledge Signaling on Ethereum (Whitepaper v1)](https://docs.semaphore.pse.dev/whitepaper-v1.pdf) - Kobi Gurkan, Koh Wei Jie and Barry WhiteHat
|
||||
[Community Proposal: Semaphore: Zero-Knowledge Signaling on Ethereum (Whitepaper v1)](https://semaphore.pse.dev/whitepaper-v1.pdf) - Kobi Gurkan, Koh Wei Jie and Barry WhiteHat
|
||||
|
||||
[To Mixers and Beyond: presenting Semaphore, a privacy gadget built on Ethereum](https://medium.com/coinmonks/to-mixers-and-beyond-presenting-semaphore-a-privacy-gadget-built-on-ethereum-4c8b00857c9b) - Koh Wei Jie
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import TabItem from "@theme/TabItem"
|
||||
|
||||
# Semaphore groups
|
||||
|
||||
A [Semaphore group](/glossary/#group) contains [identity commitments](/glossary/#commitment) of group members.
|
||||
A [Semaphore group](/glossary/#group) contains [identity commitments](/glossary/#identity-commitment) of group members.
|
||||
Example uses of groups include the following:
|
||||
|
||||
- poll question that attendees join to rate an event,
|
||||
@@ -76,9 +76,9 @@ You can also initialize a group with multiple members by passing the list of ide
|
||||
|
||||
```ts
|
||||
const members = [
|
||||
"11237622825477336339577122413451117718539783476837539122310492284566644730311",
|
||||
"9332663527862709610616009715800254142772436825222910251631161087138559093425",
|
||||
"13255821893820536903335282929376140649646180444238593676033702344407594536519"
|
||||
11237622825477336339577122413451117718539783476837539122310492284566644730311n,
|
||||
9332663527862709610616009715800254142772436825222910251631161087138559093425n,
|
||||
13255821893820536903335282929376140649646180444238593676033702344407594536519n
|
||||
]
|
||||
|
||||
const group2 = new Group(members)
|
||||
@@ -117,7 +117,7 @@ group.removeMember(0)
|
||||
To update members in a group, pass the member index and the new value to the `updateMember` method. For example:
|
||||
|
||||
```ts
|
||||
group.updateMember(0, 2)
|
||||
group.updateMember(0, 2n)
|
||||
```
|
||||
|
||||
:::caution
|
||||
|
||||
@@ -92,7 +92,7 @@ import { generateProof } from "@semaphore-protocol/proof"
|
||||
const scope = group.root
|
||||
const message = 1
|
||||
|
||||
const proof = await generateProof(identity, group, externalNullifier, message)
|
||||
const proof = await generateProof(identity, group, message, scope)
|
||||
```
|
||||
|
||||
## Verify a proof
|
||||
|
||||
@@ -42,13 +42,14 @@
|
||||
|
||||
## Networks
|
||||
|
||||
| Semaphore version | Sepolia | Mumbai | Optimism Sepolia | Arbitrum Sepolia | Arbitrum One |
|
||||
| ----------------- | ----------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- | ---------------- | ---------------- | --------------------------------------------------------------------------------------------------------------------- |
|
||||
| v2.0 | N/A | N/A | N/A | N/A | [semaphore-protocol/arbitrum](https://thegraph.com/hosted-service/subgraph/semaphore-protocol/arbitrum) |
|
||||
| v2.5 | N/A | N/A | N/A | N/A | N/A |
|
||||
| v2.6 | N/A | N/A | N/A | N/A | [semaphore-protocol/arbitrum-86337c](https://thegraph.com/hosted-service/subgraph/semaphore-protocol/arbitrum-86337c) |
|
||||
| v3.0 - v3.1 | N/A | N/A | N/A | N/A | [semaphore-protocol/arbitrum-72dca3](https://thegraph.com/hosted-service/subgraph/semaphore-protocol/arbitrum-72dca3) |
|
||||
| >= v3.2 | [semaphore-sepolia](https://api.studio.thegraph.com/query/14377/semaphore-sepolia/v3.6.1) | [semaphore-mumbai](https://api.studio.thegraph.com/query/14377/semaphore-mumbai/v3.6.1) | N/A | N/A | [semaphore-arbitrum](https://api.studio.thegraph.com/query/14377/semaphore-arbitrum/v3.6.1) |
|
||||
| Semaphore version | Sepolia | Mumbai | Optimism Sepolia | Arbitrum Sepolia | Arbitrum One |
|
||||
| ----------------- | ---------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------- |
|
||||
| v2.0 | N/A | N/A | N/A | N/A | [semaphore-protocol/arbitrum](https://thegraph.com/hosted-service/subgraph/semaphore-protocol/arbitrum) |
|
||||
| v2.5 | N/A | N/A | N/A | N/A | N/A |
|
||||
| v2.6 | N/A | N/A | N/A | N/A | [semaphore-protocol/arbitrum-86337c](https://thegraph.com/hosted-service/subgraph/semaphore-protocol/arbitrum-86337c) |
|
||||
| v3.0 - v3.1 | N/A | N/A | N/A | N/A | [semaphore-protocol/arbitrum-72dca3](https://thegraph.com/hosted-service/subgraph/semaphore-protocol/arbitrum-72dca3) |
|
||||
| >= v3.2 | [semaphore-sepolia](https://api.studio.thegraph.com/query/14377/semaphore-sepolia/v3.6.1) | [semaphore-mumbai](https://api.studio.thegraph.com/query/14377/semaphore-mumbai/v3.6.1) | N/A | N/A | [semaphore-arbitrum](https://api.studio.thegraph.com/query/14377/semaphore-arbitrum/v3.6.1) |
|
||||
| >= v4.0.0-beta | [semaphore-sepolia](https://api.studio.thegraph.com/query/14377/semaphore-sepolia/v4.0.0-beta) | [semaphore-matic-mumbai](https://api.studio.thegraph.com/query/14377/semaphore-matic-mumbai/v4.0.0-beta) | [semaphore-optimism-sepolia](https://api.studio.thegraph.com/query/14377/semaphore-optimism-sepolia/v4.0.0-beta) | [semaphore-arbitrum-sepolia](https://api.studio.thegraph.com/query/14377/semaphore-arbitrum-sepolia/v4.0.0-beta) | N/A |
|
||||
|
||||
## 🛠 Install
|
||||
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
{
|
||||
"sepolia": {
|
||||
"Semaphore": {
|
||||
"address": "0x5B8e7cC7bAC61A4b952d472b67056B2f260ba6dc",
|
||||
"startBlock": 5150903
|
||||
}
|
||||
},
|
||||
"mumbai": {
|
||||
"Semaphore": {
|
||||
"address": "",
|
||||
"startBlock": 0
|
||||
}
|
||||
},
|
||||
"optimism-sepolia": {
|
||||
"Semaphore": {
|
||||
"address": "",
|
||||
"startBlock": 0
|
||||
}
|
||||
},
|
||||
"arbitrum-sepolia": {
|
||||
"Semaphore": {
|
||||
"address": "",
|
||||
"startBlock": 0
|
||||
}
|
||||
},
|
||||
"arbitrum-one": {
|
||||
"Semaphore": {
|
||||
"address": "",
|
||||
"startBlock": 0
|
||||
}
|
||||
},
|
||||
"localhost": {
|
||||
"Semaphore": {
|
||||
"address": "0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0",
|
||||
"startBlock": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,8 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@graphprotocol/graph-cli": "0.67.0",
|
||||
"@graphprotocol/graph-ts": "0.32.0"
|
||||
"@graphprotocol/graph-ts": "0.32.0",
|
||||
"@semaphore-protocol/utils": "workspace:packages/utils"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/mustache": "^4.2.2",
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import Mustache from "mustache"
|
||||
import { getDeployedContract } from "@semaphore-protocol/utils"
|
||||
import { readFileSync, writeFileSync } from "fs"
|
||||
import Mustache from "mustache"
|
||||
|
||||
const network = process.argv.at(2)
|
||||
|
||||
const template = readFileSync("./subgraph.template.yaml", "utf-8")
|
||||
const networks = JSON.parse(readFileSync("./networks.json", "utf-8"))
|
||||
const subgraph = Mustache.render(template, { network, ...networks[network].Semaphore })
|
||||
|
||||
const subgraph = Mustache.render(template, { network, ...getDeployedContract(network) })
|
||||
|
||||
writeFileSync("./subgraph.yaml", subgraph)
|
||||
|
||||
@@ -13,8 +13,8 @@ const projects: any = fs
|
||||
displayName: name,
|
||||
setupFiles: ["dotenv/config"],
|
||||
moduleNameMapper: {
|
||||
"@semaphore-protocol/(.*)/(.*)": "<rootDir>/../$1/src/$2.ts",
|
||||
"@semaphore-protocol/(.*)": "<rootDir>/../$1/src/index.ts"
|
||||
"@semaphore-protocol/(.*)/(.*)": "<rootDir>/../$1/src/$2",
|
||||
"@semaphore-protocol/(.*)": "<rootDir>/../$1/src"
|
||||
}
|
||||
}))
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
"bugs": "https://github.com/semaphore-protocol/semaphore/issues",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"build": "yarn build:subgraph && yarn build:libraries",
|
||||
"build": "yarn build:libraries && yarn build:subgraph",
|
||||
"build:libraries": "yarn workspaces foreach -A -t --no-private run build",
|
||||
"build:subgraph": "yarn workspace semaphore-subgraph codegen sepolia && yarn workspace semaphore-subgraph build",
|
||||
"compile:contracts": "yarn workspace semaphore-contracts compile",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@semaphore-protocol/circuits",
|
||||
"version": "4.0.0-beta.4",
|
||||
"version": "4.0.0-beta.7",
|
||||
"description": "Semaphore Circom circuits to generate zero-knowledge proofs.",
|
||||
"license": "MIT",
|
||||
"files": [
|
||||
|
||||
@@ -62,6 +62,6 @@ template Semaphore(MAX_DEPTH) {
|
||||
// The message is not really used within the circuit.
|
||||
// The square applied to it is a way to force Circom's compiler to add a constraint and
|
||||
// prevent its value from being changed by an attacker.
|
||||
// More information here: https://geometryresearch.xyz/notebook/groth16-malleability.
|
||||
// More information here: https://geometry.xyz/notebook/groth16-malleability.
|
||||
signal dummySquare <== message * message;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
INFURA_API_KEY=
|
||||
ETHEREUM_PRIVATE_KEY=
|
||||
REPORT_GAS=false
|
||||
ETHERSCAN_API_KEY=
|
||||
|
||||
893
packages/cli-template-contracts-hardhat/.yarn/releases/yarn-4.1.0.cjs
vendored
Executable file
893
packages/cli-template-contracts-hardhat/.yarn/releases/yarn-4.1.0.cjs
vendored
Executable file
File diff suppressed because one or more lines are too long
@@ -1 +0,0 @@
|
||||
738adce5914a0e193f2e1255e4dcf7042256a1c1
|
||||
@@ -8,11 +8,10 @@ contract Feedback {
|
||||
|
||||
uint256 public groupId;
|
||||
|
||||
constructor(address semaphoreAddress, uint256 _groupId) {
|
||||
constructor(address semaphoreAddress) {
|
||||
semaphore = ISemaphore(semaphoreAddress);
|
||||
groupId = _groupId;
|
||||
|
||||
semaphore.createGroup(groupId, address(this));
|
||||
groupId = semaphore.createGroup();
|
||||
}
|
||||
|
||||
function joinGroup(uint256 identityCommitment) external {
|
||||
|
||||
@@ -1,54 +1,17 @@
|
||||
import { HardhatUserConfig } from "hardhat/config"
|
||||
import { NetworksUserConfig } from "hardhat/types"
|
||||
import "@nomicfoundation/hardhat-toolbox"
|
||||
import "dotenv/config"
|
||||
import "@semaphore-protocol/hardhat"
|
||||
import { getHardhatNetworks } from "@semaphore-protocol/utils"
|
||||
import "dotenv/config"
|
||||
import { HardhatUserConfig } from "hardhat/config"
|
||||
import "./tasks/deploy"
|
||||
|
||||
function getNetworks(): NetworksUserConfig {
|
||||
if (!process.env.INFURA_API_KEY || !process.env.ETHEREUM_PRIVATE_KEY) {
|
||||
return {}
|
||||
}
|
||||
|
||||
const accounts = [`0x${process.env.ETHEREUM_PRIVATE_KEY}`]
|
||||
const infuraApiKey = process.env.INFURA_API_KEY
|
||||
|
||||
return {
|
||||
sepolia: {
|
||||
url: `https://sepolia.infura.io/v3/${infuraApiKey}`,
|
||||
chainId: 11155111,
|
||||
accounts
|
||||
},
|
||||
mumbai: {
|
||||
url: `https://polygon-mumbai.infura.io/v3/${infuraApiKey}`,
|
||||
chainId: 80001,
|
||||
accounts
|
||||
},
|
||||
"optimism-sepolia": {
|
||||
url: `https://optimism-sepolia.infura.io/v3/${infuraApiKey}`,
|
||||
chainId: 11155420,
|
||||
accounts
|
||||
},
|
||||
"arbitrum-sepolia": {
|
||||
url: "https://sepolia-rollup.arbitrum.io/rpc",
|
||||
chainId: 421614,
|
||||
accounts
|
||||
},
|
||||
arbitrum: {
|
||||
url: "https://arb1.arbitrum.io/rpc",
|
||||
chainId: 42161,
|
||||
accounts
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const config: HardhatUserConfig = {
|
||||
solidity: "0.8.23",
|
||||
networks: {
|
||||
hardhat: {
|
||||
chainId: 1337
|
||||
},
|
||||
...getNetworks()
|
||||
...getHardhatNetworks(process.env.ETHEREUM_PRIVATE_KEY)
|
||||
},
|
||||
gasReporter: {
|
||||
currency: "USD",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@semaphore-protocol/cli-template-contracts-hardhat",
|
||||
"version": "4.0.0-beta.4",
|
||||
"version": "4.0.0-beta.7",
|
||||
"description": "Semaphore Hardhat template.",
|
||||
"license": "Unlicense",
|
||||
"files": [
|
||||
@@ -41,8 +41,9 @@
|
||||
"@nomicfoundation/hardhat-network-helpers": "^1.0.0",
|
||||
"@nomicfoundation/hardhat-toolbox": "^4.0.0",
|
||||
"@nomicfoundation/hardhat-verify": "^2.0.0",
|
||||
"@semaphore-protocol/core": "4.0.0-beta.4",
|
||||
"@semaphore-protocol/hardhat": "4.0.0-beta.4",
|
||||
"@semaphore-protocol/core": "4.0.0-beta.7",
|
||||
"@semaphore-protocol/hardhat": "4.0.0-beta.7",
|
||||
"@semaphore-protocol/utils": "4.0.0-beta.7",
|
||||
"@typechain/ethers-v6": "^0.5.0",
|
||||
"@typechain/hardhat": "^9.0.0",
|
||||
"@types/chai": "^4.2.0",
|
||||
@@ -70,7 +71,7 @@
|
||||
"typescript": "^5.3.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@semaphore-protocol/contracts": "4.0.0-beta.4"
|
||||
"@semaphore-protocol/contracts": "4.0.0-beta.7"
|
||||
},
|
||||
"packageManager": "yarn@4.1.0"
|
||||
}
|
||||
|
||||
@@ -2,9 +2,8 @@ import { task, types } from "hardhat/config"
|
||||
|
||||
task("deploy", "Deploy a Feedback contract")
|
||||
.addOptionalParam("semaphore", "Semaphore contract address", undefined, types.string)
|
||||
.addOptionalParam("group", "Group id", "42", types.string)
|
||||
.addOptionalParam("logs", "Print the logs", true, types.boolean)
|
||||
.setAction(async ({ logs, semaphore: semaphoreAddress, group: groupId }, { ethers, run }) => {
|
||||
.setAction(async ({ logs, semaphore: semaphoreAddress }, { ethers, run }) => {
|
||||
if (!semaphoreAddress) {
|
||||
const { semaphore } = await run("deploy:semaphore", {
|
||||
logs
|
||||
@@ -13,13 +12,9 @@ task("deploy", "Deploy a Feedback contract")
|
||||
semaphoreAddress = await semaphore.getAddress()
|
||||
}
|
||||
|
||||
if (!groupId) {
|
||||
groupId = process.env.GROUP_ID
|
||||
}
|
||||
|
||||
const FeedbackFactory = await ethers.getContractFactory("Feedback")
|
||||
|
||||
const feedbackContract = await FeedbackFactory.deploy(semaphoreAddress, groupId)
|
||||
const feedbackContract = await FeedbackFactory.deploy(semaphoreAddress)
|
||||
|
||||
if (logs) {
|
||||
console.info(`Feedback contract has been deployed to: ${await feedbackContract.getAddress()}`)
|
||||
|
||||
@@ -9,8 +9,6 @@ import { Feedback, ISemaphore } from "../typechain-types"
|
||||
|
||||
describe("Feedback", () => {
|
||||
async function deployFeedbackFixture() {
|
||||
const groupId = "42"
|
||||
|
||||
const { semaphore } = await run("deploy:semaphore", {
|
||||
logs: false
|
||||
})
|
||||
@@ -19,10 +17,11 @@ describe("Feedback", () => {
|
||||
|
||||
const feedbackContract: Feedback = await run("deploy", {
|
||||
logs: false,
|
||||
group: groupId,
|
||||
semaphore: await semaphoreContract.getAddress()
|
||||
})
|
||||
|
||||
const groupId = await feedbackContract.groupId()
|
||||
|
||||
return { semaphoreContract, feedbackContract, groupId }
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
DEFAULT_NETWORK=localhost
|
||||
INFURA_API_KEY=
|
||||
DEFAULT_NETWORK=hardhat
|
||||
ETHEREUM_PRIVATE_KEY=ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
|
||||
REPORT_GAS=false
|
||||
COINMARKETCAP_API_KEY=
|
||||
|
||||
893
packages/cli-template-monorepo-ethers/.yarn/releases/yarn-4.1.0.cjs
vendored
Executable file
893
packages/cli-template-monorepo-ethers/.yarn/releases/yarn-4.1.0.cjs
vendored
Executable file
File diff suppressed because one or more lines are too long
@@ -1 +0,0 @@
|
||||
738adce5914a0e193f2e1255e4dcf7042256a1c1
|
||||
@@ -8,11 +8,10 @@ contract Feedback {
|
||||
|
||||
uint256 public groupId;
|
||||
|
||||
constructor(address semaphoreAddress, uint256 _groupId) {
|
||||
constructor(address semaphoreAddress) {
|
||||
semaphore = ISemaphore(semaphoreAddress);
|
||||
groupId = _groupId;
|
||||
|
||||
semaphore.createGroup(groupId, address(this));
|
||||
groupId = semaphore.createGroup();
|
||||
}
|
||||
|
||||
function joinGroup(uint256 identityCommitment) external {
|
||||
|
||||
@@ -1,58 +1,21 @@
|
||||
import { HardhatUserConfig } from "hardhat/config"
|
||||
import { NetworksUserConfig } from "hardhat/types"
|
||||
import "@nomicfoundation/hardhat-toolbox"
|
||||
import { config as dotenvConfig } from "dotenv"
|
||||
import { resolve } from "path"
|
||||
import "@semaphore-protocol/hardhat"
|
||||
import { getHardhatNetworks } from "@semaphore-protocol/utils"
|
||||
import { config as dotenvConfig } from "dotenv"
|
||||
import { HardhatUserConfig } from "hardhat/config"
|
||||
import { resolve } from "path"
|
||||
import "./tasks/deploy"
|
||||
|
||||
dotenvConfig({ path: resolve(__dirname, "../../.env") })
|
||||
|
||||
function getNetworks(): NetworksUserConfig {
|
||||
if (!process.env.INFURA_API_KEY || !process.env.ETHEREUM_PRIVATE_KEY) {
|
||||
return {}
|
||||
}
|
||||
|
||||
const accounts = [`0x${process.env.ETHEREUM_PRIVATE_KEY}`]
|
||||
const infuraApiKey = process.env.INFURA_API_KEY
|
||||
|
||||
return {
|
||||
sepolia: {
|
||||
url: `https://sepolia.infura.io/v3/${infuraApiKey}`,
|
||||
chainId: 11155111,
|
||||
accounts
|
||||
},
|
||||
mumbai: {
|
||||
url: `https://polygon-mumbai.infura.io/v3/${infuraApiKey}`,
|
||||
chainId: 80001,
|
||||
accounts
|
||||
},
|
||||
"optimism-sepolia": {
|
||||
url: `https://optimism-sepolia.infura.io/v3/${infuraApiKey}`,
|
||||
chainId: 11155420,
|
||||
accounts
|
||||
},
|
||||
"arbitrum-sepolia": {
|
||||
url: "https://sepolia-rollup.arbitrum.io/rpc",
|
||||
chainId: 421614,
|
||||
accounts
|
||||
},
|
||||
arbitrum: {
|
||||
url: "https://arb1.arbitrum.io/rpc",
|
||||
chainId: 42161,
|
||||
accounts
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const config: HardhatUserConfig = {
|
||||
solidity: "0.8.23",
|
||||
defaultNetwork: process.env.DEFAULT_NETWORK || "localhost",
|
||||
defaultNetwork: process.env.DEFAULT_NETWORK || "hardhat",
|
||||
networks: {
|
||||
hardhat: {
|
||||
chainId: 1337
|
||||
},
|
||||
...getNetworks()
|
||||
...getHardhatNetworks(process.env.ETHEREUM_PRIVATE_KEY)
|
||||
},
|
||||
gasReporter: {
|
||||
currency: "USD",
|
||||
|
||||
@@ -20,8 +20,9 @@
|
||||
"@nomicfoundation/hardhat-network-helpers": "^1.0.0",
|
||||
"@nomicfoundation/hardhat-toolbox": "^4.0.0",
|
||||
"@nomicfoundation/hardhat-verify": "^2.0.0",
|
||||
"@semaphore-protocol/core": "4.0.0-beta.4",
|
||||
"@semaphore-protocol/hardhat": "4.0.0-beta.4",
|
||||
"@semaphore-protocol/core": "4.0.0-beta.7",
|
||||
"@semaphore-protocol/hardhat": "4.0.0-beta.7",
|
||||
"@semaphore-protocol/utils": "4.0.0-beta.7",
|
||||
"@typechain/ethers-v6": "^0.5.0",
|
||||
"@typechain/hardhat": "^9.0.0",
|
||||
"@types/chai": "^4.2.0",
|
||||
@@ -49,7 +50,7 @@
|
||||
"typescript": "^5.3.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@semaphore-protocol/contracts": "4.0.0-beta.4"
|
||||
"@semaphore-protocol/contracts": "4.0.0-beta.7"
|
||||
},
|
||||
"packageManager": "yarn@4.1.0"
|
||||
}
|
||||
|
||||
@@ -2,9 +2,8 @@ import { task, types } from "hardhat/config"
|
||||
|
||||
task("deploy", "Deploy a Feedback contract")
|
||||
.addOptionalParam("semaphore", "Semaphore contract address", undefined, types.string)
|
||||
.addOptionalParam("group", "Group id", "42", types.string)
|
||||
.addOptionalParam("logs", "Print the logs", true, types.boolean)
|
||||
.setAction(async ({ logs, semaphore: semaphoreAddress, group: groupId }, { ethers, run }) => {
|
||||
.setAction(async ({ logs, semaphore: semaphoreAddress }, { ethers, run }) => {
|
||||
if (!semaphoreAddress) {
|
||||
const { semaphore } = await run("deploy:semaphore", {
|
||||
logs
|
||||
@@ -13,13 +12,9 @@ task("deploy", "Deploy a Feedback contract")
|
||||
semaphoreAddress = await semaphore.getAddress()
|
||||
}
|
||||
|
||||
if (!groupId) {
|
||||
groupId = process.env.GROUP_ID
|
||||
}
|
||||
|
||||
const FeedbackFactory = await ethers.getContractFactory("Feedback")
|
||||
|
||||
const feedbackContract = await FeedbackFactory.deploy(semaphoreAddress, groupId)
|
||||
const feedbackContract = await FeedbackFactory.deploy(semaphoreAddress)
|
||||
|
||||
if (logs) {
|
||||
console.info(`Feedback contract has been deployed to: ${await feedbackContract.getAddress()}`)
|
||||
|
||||
@@ -9,8 +9,6 @@ import { Feedback, ISemaphore } from "../typechain-types"
|
||||
|
||||
describe("Feedback", () => {
|
||||
async function deployFeedbackFixture() {
|
||||
const groupId = "42"
|
||||
|
||||
const { semaphore } = await run("deploy:semaphore", {
|
||||
logs: false
|
||||
})
|
||||
@@ -19,10 +17,11 @@ describe("Feedback", () => {
|
||||
|
||||
const feedbackContract: Feedback = await run("deploy", {
|
||||
logs: false,
|
||||
group: groupId,
|
||||
semaphore: await semaphoreContract.getAddress()
|
||||
})
|
||||
|
||||
const groupId = await feedbackContract.groupId()
|
||||
|
||||
return { semaphoreContract, feedbackContract, groupId }
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
NEXT_PUBLIC_DEFAULT_NETWORK=localhost
|
||||
NEXT_PUBLIC_FEEDBACK_CONTRACT_ADDRESS=0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9
|
||||
NEXT_PUBLIC_SEMAPHORE_CONTRACT_ADDRESS=0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0
|
||||
NEXT_PUBLIC_GROUP_ID=42
|
||||
NEXT_PUBLIC_GROUP_ID=0
|
||||
|
||||
5
packages/cli-template-monorepo-ethers/apps/web-app/next-env.d.ts
vendored
Normal file
5
packages/cli-template-monorepo-ethers/apps/web-app/next-env.d.ts
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
/// <reference types="next" />
|
||||
/// <reference types="next/image-types/global" />
|
||||
|
||||
// NOTE: This file should not be edited
|
||||
// see https://nextjs.org/docs/basic-features/typescript for more information.
|
||||
@@ -9,8 +9,9 @@
|
||||
"lint": "next lint"
|
||||
},
|
||||
"dependencies": {
|
||||
"@semaphore-protocol/core": "4.0.0-beta.4",
|
||||
"@semaphore-protocol/data": "4.0.0-beta.4",
|
||||
"@semaphore-protocol/core": "4.0.0-beta.7",
|
||||
"@semaphore-protocol/data": "4.0.0-beta.7",
|
||||
"@semaphore-protocol/utils": "4.0.0-beta.7",
|
||||
"ethers": "^6.11.1",
|
||||
"next": "14.1.0",
|
||||
"next-pwa": "^5.6.0",
|
||||
|
||||
@@ -74,7 +74,7 @@ export default function GroupsPage() {
|
||||
setLoading(false)
|
||||
}, [_identity])
|
||||
|
||||
const userHasJoined = useCallback((identity: Identity) => _users.includes(identity.commitment), [_users])
|
||||
const userHasJoined = useCallback((identity: Identity) => _users.includes(identity.commitment.toString()), [_users])
|
||||
|
||||
return (
|
||||
<>
|
||||
|
||||
@@ -4,7 +4,7 @@ import LogsContext from "@/context/LogsContext"
|
||||
import SemaphoreContext from "@/context/SemaphoreContext"
|
||||
import useSemaphore from "@/hooks/useSemaphore"
|
||||
import shortenString from "@/utils/shortenString"
|
||||
import { SupportedNetwork } from "@semaphore-protocol/data"
|
||||
import { SupportedNetwork } from "@semaphore-protocol/utils"
|
||||
import { usePathname } from "next/navigation"
|
||||
import { useEffect, useState } from "react"
|
||||
import Link from "next/link"
|
||||
@@ -52,7 +52,7 @@ export default function PageContainer({
|
||||
<div>{shortenString(process.env.NEXT_PUBLIC_FEEDBACK_CONTRACT_ADDRESS as string, [6, 4])}</div>
|
||||
</a>
|
||||
<a
|
||||
href="https://github.com/semaphore-protocol/boilerplate"
|
||||
href="https://github.com/semaphore-protocol/semaphore"
|
||||
target="_blank"
|
||||
rel="noreferrer noopener nofollow"
|
||||
>
|
||||
|
||||
@@ -9,7 +9,7 @@ const ethereumNetwork =
|
||||
: process.env.NEXT_PUBLIC_DEFAULT_NETWORK
|
||||
|
||||
export default function useSemaphore(): SemaphoreContextType {
|
||||
const [_users, setUsers] = useState<any[]>([])
|
||||
const [_users, setUsers] = useState<string[]>([])
|
||||
const [_feedback, setFeedback] = useState<string[]>([])
|
||||
|
||||
const refreshUsers = useCallback(async (): Promise<void> => {
|
||||
@@ -19,7 +19,7 @@ export default function useSemaphore(): SemaphoreContextType {
|
||||
|
||||
const members = await semaphore.getGroupMembers(process.env.NEXT_PUBLIC_GROUP_ID as string)
|
||||
|
||||
setUsers(members.map((member) => member.toString()))
|
||||
setUsers(members)
|
||||
}, [])
|
||||
|
||||
const addUser = useCallback(
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@semaphore-protocol/cli-template-monorepo-ethers",
|
||||
"version": "4.0.0-beta.4",
|
||||
"version": "4.0.0-beta.7",
|
||||
"description": "Semaphore Hardhat + Next.js + SemaphoreEthers template.",
|
||||
"license": "Unlicense",
|
||||
"files": [
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
DEFAULT_NETWORK=localhost
|
||||
INFURA_API_KEY=
|
||||
DEFAULT_NETWORK=hardhat
|
||||
ETHEREUM_PRIVATE_KEY=ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
|
||||
REPORT_GAS=false
|
||||
COINMARKETCAP_API_KEY=
|
||||
|
||||
893
packages/cli-template-monorepo-subgraph/.yarn/releases/yarn-4.1.0.cjs
vendored
Executable file
893
packages/cli-template-monorepo-subgraph/.yarn/releases/yarn-4.1.0.cjs
vendored
Executable file
File diff suppressed because one or more lines are too long
@@ -1 +0,0 @@
|
||||
738adce5914a0e193f2e1255e4dcf7042256a1c1
|
||||
@@ -8,11 +8,10 @@ contract Feedback {
|
||||
|
||||
uint256 public groupId;
|
||||
|
||||
constructor(address semaphoreAddress, uint256 _groupId) {
|
||||
constructor(address semaphoreAddress) {
|
||||
semaphore = ISemaphore(semaphoreAddress);
|
||||
groupId = _groupId;
|
||||
|
||||
semaphore.createGroup(groupId, address(this));
|
||||
groupId = semaphore.createGroup();
|
||||
}
|
||||
|
||||
function joinGroup(uint256 identityCommitment) external {
|
||||
|
||||
@@ -1,58 +1,21 @@
|
||||
import { HardhatUserConfig } from "hardhat/config"
|
||||
import { NetworksUserConfig } from "hardhat/types"
|
||||
import "@nomicfoundation/hardhat-toolbox"
|
||||
import { config as dotenvConfig } from "dotenv"
|
||||
import { resolve } from "path"
|
||||
import "@semaphore-protocol/hardhat"
|
||||
import { getHardhatNetworks } from "@semaphore-protocol/utils"
|
||||
import { config as dotenvConfig } from "dotenv"
|
||||
import { HardhatUserConfig } from "hardhat/config"
|
||||
import { resolve } from "path"
|
||||
import "./tasks/deploy"
|
||||
|
||||
dotenvConfig({ path: resolve(__dirname, "../../.env") })
|
||||
|
||||
function getNetworks(): NetworksUserConfig {
|
||||
if (!process.env.INFURA_API_KEY || !process.env.ETHEREUM_PRIVATE_KEY) {
|
||||
return {}
|
||||
}
|
||||
|
||||
const accounts = [`0x${process.env.ETHEREUM_PRIVATE_KEY}`]
|
||||
const infuraApiKey = process.env.INFURA_API_KEY
|
||||
|
||||
return {
|
||||
sepolia: {
|
||||
url: `https://sepolia.infura.io/v3/${infuraApiKey}`,
|
||||
chainId: 11155111,
|
||||
accounts
|
||||
},
|
||||
mumbai: {
|
||||
url: `https://polygon-mumbai.infura.io/v3/${infuraApiKey}`,
|
||||
chainId: 80001,
|
||||
accounts
|
||||
},
|
||||
"optimism-sepolia": {
|
||||
url: `https://optimism-sepolia.infura.io/v3/${infuraApiKey}`,
|
||||
chainId: 11155420,
|
||||
accounts
|
||||
},
|
||||
"arbitrum-sepolia": {
|
||||
url: "https://sepolia-rollup.arbitrum.io/rpc",
|
||||
chainId: 421614,
|
||||
accounts
|
||||
},
|
||||
arbitrum: {
|
||||
url: "https://arb1.arbitrum.io/rpc",
|
||||
chainId: 42161,
|
||||
accounts
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const config: HardhatUserConfig = {
|
||||
solidity: "0.8.23",
|
||||
defaultNetwork: process.env.DEFAULT_NETWORK || "localhost",
|
||||
defaultNetwork: process.env.DEFAULT_NETWORK || "hardhat",
|
||||
networks: {
|
||||
hardhat: {
|
||||
chainId: 1337
|
||||
},
|
||||
...getNetworks()
|
||||
...getHardhatNetworks(process.env.ETHEREUM_PRIVATE_KEY)
|
||||
},
|
||||
gasReporter: {
|
||||
currency: "USD",
|
||||
|
||||
@@ -20,8 +20,9 @@
|
||||
"@nomicfoundation/hardhat-network-helpers": "^1.0.0",
|
||||
"@nomicfoundation/hardhat-toolbox": "^4.0.0",
|
||||
"@nomicfoundation/hardhat-verify": "^2.0.0",
|
||||
"@semaphore-protocol/core": "4.0.0-beta.4",
|
||||
"@semaphore-protocol/hardhat": "4.0.0-beta.4",
|
||||
"@semaphore-protocol/core": "4.0.0-beta.7",
|
||||
"@semaphore-protocol/hardhat": "4.0.0-beta.7",
|
||||
"@semaphore-protocol/utils": "4.0.0-beta.7",
|
||||
"@typechain/ethers-v6": "^0.5.0",
|
||||
"@typechain/hardhat": "^9.0.0",
|
||||
"@types/chai": "^4.2.0",
|
||||
@@ -49,7 +50,7 @@
|
||||
"typescript": "^5.3.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@semaphore-protocol/contracts": "4.0.0-beta.4"
|
||||
"@semaphore-protocol/contracts": "4.0.0-beta.7"
|
||||
},
|
||||
"packageManager": "yarn@4.1.0"
|
||||
}
|
||||
|
||||
@@ -2,9 +2,8 @@ import { task, types } from "hardhat/config"
|
||||
|
||||
task("deploy", "Deploy a Feedback contract")
|
||||
.addOptionalParam("semaphore", "Semaphore contract address", undefined, types.string)
|
||||
.addOptionalParam("group", "Group id", "42", types.string)
|
||||
.addOptionalParam("logs", "Print the logs", true, types.boolean)
|
||||
.setAction(async ({ logs, semaphore: semaphoreAddress, group: groupId }, { ethers, run }) => {
|
||||
.setAction(async ({ logs, semaphore: semaphoreAddress }, { ethers, run }) => {
|
||||
if (!semaphoreAddress) {
|
||||
const { semaphore } = await run("deploy:semaphore", {
|
||||
logs
|
||||
@@ -13,13 +12,9 @@ task("deploy", "Deploy a Feedback contract")
|
||||
semaphoreAddress = await semaphore.getAddress()
|
||||
}
|
||||
|
||||
if (!groupId) {
|
||||
groupId = process.env.GROUP_ID
|
||||
}
|
||||
|
||||
const FeedbackFactory = await ethers.getContractFactory("Feedback")
|
||||
|
||||
const feedbackContract = await FeedbackFactory.deploy(semaphoreAddress, groupId)
|
||||
const feedbackContract = await FeedbackFactory.deploy(semaphoreAddress)
|
||||
|
||||
if (logs) {
|
||||
console.info(`Feedback contract has been deployed to: ${await feedbackContract.getAddress()}`)
|
||||
|
||||
@@ -9,8 +9,6 @@ import { Feedback, ISemaphore } from "../typechain-types"
|
||||
|
||||
describe("Feedback", () => {
|
||||
async function deployFeedbackFixture() {
|
||||
const groupId = "42"
|
||||
|
||||
const { semaphore } = await run("deploy:semaphore", {
|
||||
logs: false
|
||||
})
|
||||
@@ -19,10 +17,11 @@ describe("Feedback", () => {
|
||||
|
||||
const feedbackContract: Feedback = await run("deploy", {
|
||||
logs: false,
|
||||
group: groupId,
|
||||
semaphore: await semaphoreContract.getAddress()
|
||||
})
|
||||
|
||||
const groupId = await feedbackContract.groupId()
|
||||
|
||||
return { semaphoreContract, feedbackContract, groupId }
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
NEXT_PUBLIC_DEFAULT_NETWORK=localhost
|
||||
NEXT_PUBLIC_FEEDBACK_CONTRACT_ADDRESS=0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9
|
||||
NEXT_PUBLIC_SEMAPHORE_CONTRACT_ADDRESS=0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0
|
||||
NEXT_PUBLIC_GROUP_ID=42
|
||||
NEXT_PUBLIC_GROUP_ID=0
|
||||
|
||||
@@ -9,8 +9,9 @@
|
||||
"lint": "next lint"
|
||||
},
|
||||
"dependencies": {
|
||||
"@semaphore-protocol/core": "4.0.0-beta.4",
|
||||
"@semaphore-protocol/data": "4.0.0-beta.4",
|
||||
"@semaphore-protocol/core": "4.0.0-beta.7",
|
||||
"@semaphore-protocol/data": "4.0.0-beta.7",
|
||||
"@semaphore-protocol/utils": "4.0.0-beta.7",
|
||||
"ethers": "^6.11.1",
|
||||
"next": "14.1.0",
|
||||
"next-pwa": "^5.6.0",
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
"use client"
|
||||
|
||||
import Stepper from "@/components/Stepper"
|
||||
import LogsContext from "@/context/LogsContext"
|
||||
import SemaphoreContext from "@/context/SemaphoreContext"
|
||||
import { Identity } from "@semaphore-protocol/core"
|
||||
import { useRouter } from "next/navigation"
|
||||
import { useCallback, useContext, useEffect, useState } from "react"
|
||||
import Feedback from "../../../contract-artifacts/Feedback.json"
|
||||
import Stepper from "@/components/Stepper"
|
||||
import LogsContext from "@/context/LogsContext"
|
||||
import SemaphoreContext from "@/context/SemaphoreContext"
|
||||
|
||||
export default function GroupsPage() {
|
||||
const router = useRouter()
|
||||
@@ -74,7 +74,7 @@ export default function GroupsPage() {
|
||||
setLoading(false)
|
||||
}, [_identity])
|
||||
|
||||
const userHasJoined = useCallback((identity: Identity) => _users.includes(identity.commitment), [_users])
|
||||
const userHasJoined = useCallback((identity: Identity) => _users.includes(identity.commitment.toString()), [_users])
|
||||
|
||||
return (
|
||||
<>
|
||||
|
||||
@@ -52,7 +52,7 @@ export default function PageContainer({
|
||||
<div>{shortenString(process.env.NEXT_PUBLIC_FEEDBACK_CONTRACT_ADDRESS as string, [6, 4])}</div>
|
||||
</a>
|
||||
<a
|
||||
href="https://github.com/semaphore-protocol/boilerplate"
|
||||
href="https://github.com/semaphore-protocol/semaphore"
|
||||
target="_blank"
|
||||
rel="noreferrer noopener nofollow"
|
||||
>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@semaphore-protocol/cli-template-monorepo-subgraph",
|
||||
"version": "4.0.0-beta.4",
|
||||
"version": "4.0.0-beta.7",
|
||||
"description": "Semaphore Hardhat + Next.js + SemaphoreSubgraph template.",
|
||||
"license": "Unlicense",
|
||||
"files": [
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@semaphore-protocol/cli",
|
||||
"type": "module",
|
||||
"version": "4.0.0-beta.4",
|
||||
"version": "4.0.0-beta.7",
|
||||
"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.0.0-beta.4",
|
||||
"@semaphore-protocol/utils": "4.0.0-beta.4",
|
||||
"@semaphore-protocol/data": "4.0.0-beta.7",
|
||||
"@semaphore-protocol/utils": "4.0.0-beta.7",
|
||||
"axios": "^1.6.7",
|
||||
"boxen": "^7.1.1",
|
||||
"chalk": "^5.3.0",
|
||||
|
||||
@@ -24,7 +24,7 @@ export default {
|
||||
"fs",
|
||||
"path",
|
||||
"child_process",
|
||||
"@semaphore-protocol/utils/supported-networks"
|
||||
"@semaphore-protocol/utils/networks"
|
||||
],
|
||||
plugins: [
|
||||
typescript({
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { GroupResponse, SemaphoreEthers, SemaphoreSubgraph } from "@semaphore-protocol/data"
|
||||
import supportedNetworks from "@semaphore-protocol/utils/supported-networks"
|
||||
import { isSupportedNetwork, supportedNetworks } from "@semaphore-protocol/utils/networks"
|
||||
import chalk from "chalk"
|
||||
import { program } from "commander"
|
||||
import decompress from "decompress"
|
||||
@@ -121,10 +121,10 @@ program
|
||||
.allowExcessArguments(false)
|
||||
.action(async ({ network }) => {
|
||||
if (!network) {
|
||||
network = await getSupportedNetwork(supportedNetworks)
|
||||
network = await getSupportedNetwork(Object.keys(supportedNetworks))
|
||||
}
|
||||
|
||||
if (!supportedNetworks.includes(network)) {
|
||||
if (!isSupportedNetwork(network)) {
|
||||
console.info(`\n ${logSymbols.error}`, `error: the network '${network}' is not supported\n`)
|
||||
return
|
||||
}
|
||||
@@ -151,10 +151,10 @@ program
|
||||
.allowExcessArguments(false)
|
||||
.action(async (groupId, { network }) => {
|
||||
if (!network) {
|
||||
network = await getSupportedNetwork(supportedNetworks)
|
||||
network = await getSupportedNetwork(Object.keys(supportedNetworks))
|
||||
}
|
||||
|
||||
if (!supportedNetworks.includes(network)) {
|
||||
if (!isSupportedNetwork(network)) {
|
||||
console.info(`\n ${logSymbols.error}`, `error: the network '${network}' is not supported\n`)
|
||||
return
|
||||
}
|
||||
@@ -219,10 +219,10 @@ program
|
||||
.allowExcessArguments(false)
|
||||
.action(async (groupId, { network }) => {
|
||||
if (!network) {
|
||||
network = await getSupportedNetwork(supportedNetworks)
|
||||
network = await getSupportedNetwork(Object.keys(supportedNetworks))
|
||||
}
|
||||
|
||||
if (!supportedNetworks.includes(network)) {
|
||||
if (!isSupportedNetwork(network)) {
|
||||
console.info(`\n ${logSymbols.error}`, `error: the network '${network}' is not supported\n`)
|
||||
return
|
||||
}
|
||||
@@ -285,10 +285,10 @@ program
|
||||
.allowExcessArguments(false)
|
||||
.action(async (groupId, { network }) => {
|
||||
if (!network) {
|
||||
network = await getSupportedNetwork(supportedNetworks)
|
||||
network = await getSupportedNetwork(Object.keys(supportedNetworks))
|
||||
}
|
||||
|
||||
if (!supportedNetworks.includes(network)) {
|
||||
if (!isSupportedNetwork(network)) {
|
||||
console.info(`\n ${logSymbols.error}`, `error: the network '${network}' is not supported\n`)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
contracts/README.md
|
||||
contracts/README.md
|
||||
@@ -56,6 +56,11 @@ contract Semaphore is ISemaphore, SemaphoreGroups {
|
||||
_updateGroupAdmin(groupId, newAdmin);
|
||||
}
|
||||
|
||||
/// @dev See {SemaphoreGroups- acceptGroupAdmin}.
|
||||
function acceptGroupAdmin(uint256 groupId) external override {
|
||||
_acceptGroupAdmin(groupId);
|
||||
}
|
||||
|
||||
/// @dev See {ISemaphore-updateGroupMerkleTreeDuration}.
|
||||
function updateGroupMerkleTreeDuration(
|
||||
uint256 groupId,
|
||||
|
||||
@@ -19,6 +19,10 @@ abstract contract SemaphoreGroups is ISemaphoreGroups {
|
||||
/// The admin can be an Ethereum account or a smart contract.
|
||||
mapping(uint256 => address) internal admins;
|
||||
|
||||
/// @dev Gets a group id and returns any pending admin.
|
||||
/// The pending admin can be an Ethereum account or a smart contract.
|
||||
mapping(uint256 => address) internal pendingAdmins;
|
||||
|
||||
/// @dev Checks if the group admin is the transaction sender.
|
||||
/// @param groupId: Id of the group.
|
||||
modifier onlyGroupAdmin(uint256 groupId) {
|
||||
@@ -48,13 +52,30 @@ abstract contract SemaphoreGroups is ISemaphoreGroups {
|
||||
emit GroupAdminUpdated(groupId, address(0), admin);
|
||||
}
|
||||
|
||||
/// @dev Updates the group admin.
|
||||
/// @dev Updates the group admin. In order for the new admin to actually be updated,
|
||||
/// they must explicitly accept by calling `_acceptGroupAdmin`.
|
||||
/// @param groupId: Id of the group.
|
||||
/// @param newAdmin: New admin of the group.
|
||||
function _updateGroupAdmin(uint256 groupId, address newAdmin) internal virtual onlyGroupAdmin(groupId) {
|
||||
admins[groupId] = newAdmin;
|
||||
pendingAdmins[groupId] = newAdmin;
|
||||
|
||||
emit GroupAdminUpdated(groupId, msg.sender, newAdmin);
|
||||
emit GroupAdminPending(groupId, msg.sender, newAdmin);
|
||||
}
|
||||
|
||||
/// @dev Allows the new admin to accept to update the group admin with their address.
|
||||
/// @param groupId: Id of the group.
|
||||
function _acceptGroupAdmin(uint256 groupId) internal virtual {
|
||||
if (pendingAdmins[groupId] != msg.sender) {
|
||||
revert Semaphore__CallerIsNotThePendingGroupAdmin();
|
||||
}
|
||||
|
||||
address oldAdmin = admins[groupId];
|
||||
|
||||
admins[groupId] = msg.sender;
|
||||
|
||||
delete pendingAdmins[groupId];
|
||||
|
||||
emit GroupAdminUpdated(groupId, oldAdmin, msg.sender);
|
||||
}
|
||||
|
||||
/// @dev Adds an identity commitment to an existing group.
|
||||
|
||||
@@ -70,6 +70,9 @@ interface ISemaphore {
|
||||
/// @dev See {SemaphoreGroups-_updateGroupAdmin}.
|
||||
function updateGroupAdmin(uint256 groupId, address newAdmin) external;
|
||||
|
||||
/// @dev See {SemaphoreGroups-_acceptGroupAdmin}.
|
||||
function acceptGroupAdmin(uint256 groupId) external;
|
||||
|
||||
/// @dev Updates the group Merkle tree duration.
|
||||
/// @param groupId: Id of the group.
|
||||
/// @param newMerkleTreeDuration: New Merkle tree duration.
|
||||
|
||||
@@ -5,17 +5,24 @@ pragma solidity 0.8.23;
|
||||
interface ISemaphoreGroups {
|
||||
error Semaphore__GroupDoesNotExist();
|
||||
error Semaphore__CallerIsNotTheGroupAdmin();
|
||||
error Semaphore__CallerIsNotThePendingGroupAdmin();
|
||||
|
||||
/// @dev Event emitted when a new group is created.
|
||||
/// @param groupId: Id of the group.
|
||||
event GroupCreated(uint256 indexed groupId);
|
||||
|
||||
/// @dev Event emitted when an admin is assigned to a group.
|
||||
/// @dev Event emitted when a new admin is assigned to a group.
|
||||
/// @param groupId: Id of the group.
|
||||
/// @param oldAdmin: Old admin of the group.
|
||||
/// @param newAdmin: New admin of the group.
|
||||
event GroupAdminUpdated(uint256 indexed groupId, address indexed oldAdmin, address indexed newAdmin);
|
||||
|
||||
/// @dev Event emitted when a group admin is being updated.
|
||||
/// @param groupId: Id of the group.
|
||||
/// @param oldAdmin: Old admin of the group.
|
||||
/// @param newAdmin: New admin of the group.
|
||||
event GroupAdminPending(uint256 indexed groupId, address indexed oldAdmin, address indexed newAdmin);
|
||||
|
||||
/// @dev Event emitted when a new identity commitment is added.
|
||||
/// @param groupId: Group id of the group.
|
||||
/// @param index: Merkle tree leaf index.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@semaphore-protocol/contracts",
|
||||
"version": "4.0.0-beta.4",
|
||||
"version": "4.0.0-beta.7",
|
||||
"description": "Semaphore contracts to manage groups and broadcast anonymous signals.",
|
||||
"license": "MIT",
|
||||
"files": [
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user