mirror of
https://github.com/semaphore-protocol/semaphore.git
synced 2026-01-09 14:48:12 -05:00
chore(docs): format mdx files (#754)
* chore(docs): format `mdx` files with `remark` `prettier` doesn't not have proper support for MDX v3. Docusaurus recommends using `remark` instead. https://docusaurus.io/docs/markdown-features/react re #503 * chore(docs): add remark lint plugins * chore: bump yarn.lock * chore: add `quiet` option to remark
This commit is contained in:
2
.github/pull_request_template.md
vendored
2
.github/pull_request_template.md
vendored
@@ -34,7 +34,7 @@
|
||||
- [ ] I have commented my code, particularly in hard-to-understand areas
|
||||
- [ ] I have made corresponding changes to the documentation
|
||||
- [ ] My changes generate no new warnings
|
||||
- [ ] I have run `yarn prettier` and `yarn lint` without getting any errors
|
||||
- [ ] I have run `yarn format` and `yarn lint` without getting any errors
|
||||
- [ ] I have added tests that prove my fix is effective or that my feature works
|
||||
- [ ] New and existing unit tests pass locally with my changes
|
||||
- [ ] Any dependent changes have been merged and published in downstream modules
|
||||
|
||||
4
.github/workflows/pull-requests.yml
vendored
4
.github/workflows/pull-requests.yml
vendored
@@ -31,8 +31,8 @@ jobs:
|
||||
- name: Build subgraph
|
||||
run: yarn build:subgraph
|
||||
|
||||
- name: Run Prettier
|
||||
run: yarn prettier
|
||||
- name: Format
|
||||
run: yarn format
|
||||
|
||||
- name: Run Eslint
|
||||
run: yarn lint
|
||||
|
||||
@@ -295,13 +295,13 @@ yarn lint
|
||||
Run [Prettier](https://prettier.io/) to check formatting rules:
|
||||
|
||||
```bash
|
||||
yarn prettier
|
||||
yarn format
|
||||
```
|
||||
|
||||
Or to automatically format the code:
|
||||
|
||||
```bash
|
||||
yarn prettier:write
|
||||
yarn format:write
|
||||
```
|
||||
|
||||
### Conventional commits
|
||||
|
||||
@@ -18,34 +18,31 @@ Hay dos formas para hacer esto, usando [`SemaphoreSubgraph`](https://github.com/
|
||||
## Instalar librería
|
||||
|
||||
<Tabs
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
{label: 'npm', value: 'npm'},
|
||||
{label: 'Yarn', value: 'yarn'},
|
||||
{label: 'pnpm', value: 'pnpm'}
|
||||
]}>
|
||||
<TabItem value="npm">
|
||||
]}
|
||||
>
|
||||
<TabItem value="npm">
|
||||
```bash
|
||||
npm install @semaphore-protocol/data@^3
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
```bash
|
||||
npm install @semaphore-protocol/data@^3
|
||||
```
|
||||
<TabItem value="yarn">
|
||||
```bash
|
||||
yarn add @semaphore-protocol/data@^3
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="yarn">
|
||||
|
||||
```bash
|
||||
yarn add @semaphore-protocol/data@^3
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
|
||||
```bash
|
||||
pnpm add @semaphore-protocol/data@^3
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
```bash
|
||||
pnpm add @semaphore-protocol/data@^3
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
## Obtener datos usando SemaphoreSubgraph
|
||||
@@ -113,6 +110,7 @@ const semaphoreSubgraph = new SemaphoreSubgraph("sepolia")
|
||||
const { members } = await semaphoreSubgraph.getGroup(groupId, { members: true })
|
||||
const group = new Group(groupId, 20, members)
|
||||
```
|
||||
|
||||
:::
|
||||
|
||||
## Obtener datos usando SemaphoreEthers
|
||||
@@ -178,4 +176,5 @@ const semaphoreEthers = new SemaphoreEthers("sepolia")
|
||||
const members = await semaphoreEthers.getGroupMembers(groupId)
|
||||
const group = new Group(groupId, 20, members)
|
||||
```
|
||||
|
||||
:::
|
||||
|
||||
@@ -11,70 +11,67 @@ import TabItem from "@theme/TabItem"
|
||||
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.
|
||||
- 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](/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;
|
||||
- **Tree depth**: el número máximo de miembros que puede contener un grupo (`max size = 2 ^ tree depth`);
|
||||
- **Members** la lista de miembros para inicializar el grupo.
|
||||
- **Group id**: un identificador único para el grupo;
|
||||
- **Tree depth**: el número máximo de miembros que puede contener un grupo (`max size = 2 ^ tree depth`);
|
||||
- **Members** la lista de miembros para inicializar el grupo.
|
||||
|
||||
Aprenda cómo trabajar con grupos.
|
||||
|
||||
- [**Grupos off-chain**](#grupos-off-chain-externos-a-la-cadena)
|
||||
- [**Grupos on-chain**](#grupos-on-chain)
|
||||
- [**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](#crear-un-grupo)
|
||||
- [Añadir miembros](#añadir-miembros)
|
||||
- [Remover o actualizar miembros](#remover-o-actualizar-miembros)
|
||||
- [Crear un grupo](#crear-un-grupo)
|
||||
- [Añadir miembros](#añadir-miembros)
|
||||
- [Remover o actualizar miembros](#remover-o-actualizar-miembros)
|
||||
|
||||
### Crear un grupo
|
||||
|
||||
Utilice la clase `Group` de la librería [`@semaphore-protocol/group`](https://github.com/semaphore-protocol/semaphore/blob/main/packages/group) para crear un grupo off-chain con los siguientes parámetros:
|
||||
|
||||
- `Group id`: un identificar único para el grupo;
|
||||
- `Tree depth`: (_default `20`_) el número máximo de usuarios que puede contener un grupo, el valor por defecto es 20 (`max size = 2 ^ tree depth`).
|
||||
- `Members`: (_default `[]`_) la lista de miembros para inicializar el grupo.
|
||||
- `Group id`: un identificar único para el grupo;
|
||||
- `Tree depth`: (*default `20`*) el número máximo de usuarios que puede contener un grupo, el valor por defecto es 20 (`max size = 2 ^ tree depth`).
|
||||
- `Members`: (*default `[]`*) la lista de miembros para inicializar el grupo.
|
||||
|
||||
#### Instalar librería:
|
||||
|
||||
<Tabs
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
{label: 'npm', value: 'npm'},
|
||||
{label: 'Yarn', value: 'yarn'},
|
||||
{label: 'pnpm', value: 'pnpm'}
|
||||
]}>
|
||||
<TabItem value="npm">
|
||||
]}
|
||||
>
|
||||
<TabItem value="npm">
|
||||
```bash
|
||||
npm install @semaphore-protocol/group@^3
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
```bash
|
||||
npm install @semaphore-protocol/group@^3
|
||||
```
|
||||
<TabItem value="yarn">
|
||||
```bash
|
||||
yarn add @semaphore-protocol/group@^3
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="yarn">
|
||||
|
||||
```bash
|
||||
yarn add @semaphore-protocol/group@^3
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
|
||||
```bash
|
||||
pnpm add @semaphore-protocol/group@^3
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
```bash
|
||||
pnpm add @semaphore-protocol/group@^3
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
Para crear un grupo con el número de usuarios que aparece por defecto (20) _`treeDepth`_, llame la función para construir un `Group` sin el segundo parámetro. Por ejemplo:
|
||||
Para crear un grupo con el número de usuarios que aparece por defecto (20) *`treeDepth`*, llame la función para construir un `Group` sin el segundo parámetro. Por ejemplo:
|
||||
|
||||
```ts
|
||||
import { Group } from "@semaphore-protocol/group"
|
||||
@@ -82,7 +79,7 @@ import { Group } from "@semaphore-protocol/group"
|
||||
const group = new Group(1)
|
||||
```
|
||||
|
||||
El siguiente código de ejemplo pasa por _`treeDepth`_ para crear un grupo para `2 ^ 30 = 1073741824` miembros:
|
||||
El siguiente código de ejemplo pasa por *`treeDepth`* para crear un grupo para `2 ^ 30 = 1073741824` miembros:
|
||||
|
||||
```ts
|
||||
import { Group } from "@semaphore-protocol/group"
|
||||
|
||||
@@ -11,48 +11,47 @@ import TabItem from "@theme/TabItem"
|
||||
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)
|
||||
- Identity nullifier (Anulador de identidad)
|
||||
- Identity trapdoor (Identidad trampilla)
|
||||
- Identity nullifier (Anulador de identidad)
|
||||
|
||||
Para utilizar y verificar su identidad, la persona dueña de la identidad (usuario) debe conocer los valores trapdoor y nullifier.
|
||||
Para prevenir fraudes, la persona dueña debe conservar de forma secreta ambos valores.
|
||||
|
||||
## Crear identidades
|
||||
|
||||
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_.
|
||||
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**](#crear-identidades-aleatorias)
|
||||
- [**Crear identidades determinísticas**](#crear-identidades-determinísticas)
|
||||
- [**Crear identidades aleatorias**](#crear-identidades-aleatorias)
|
||||
- [**Crear identidades determinísticas**](#crear-identidades-determinísticas)
|
||||
|
||||
### Instalar librería:
|
||||
|
||||
<Tabs
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
{label: 'npm', value: 'npm'},
|
||||
{label: 'Yarn', value: 'yarn'},
|
||||
{label: 'pnpm', value: 'pnpm'}
|
||||
]}>
|
||||
<TabItem value="npm">
|
||||
]}
|
||||
>
|
||||
<TabItem value="npm">
|
||||
```bash
|
||||
npm install @semaphore-protocol/identity@^3
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
```bash
|
||||
npm install @semaphore-protocol/identity@^3
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="yarn">
|
||||
```bash
|
||||
yarn add @semaphore-protocol/identity@^3
|
||||
```
|
||||
<TabItem value="yarn">
|
||||
```bash
|
||||
yarn add @semaphore-protocol/identity@^3
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
|
||||
```bash
|
||||
pnpm add @semaphore-protocol/identity@^3
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
```bash
|
||||
pnpm add @semaphore-protocol/identity@^3
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
### Crear identidades aleatorias
|
||||
@@ -67,8 +66,8 @@ const { trapdoor, nullifier, commitment } = new Identity()
|
||||
|
||||
La nueva identidad contiene dos valores aleatorios secretos: `trapdoor` y `nullifier`, y un valor público: `commitment`.
|
||||
|
||||
El hash Poseidon del identity nullifier y trapdoor se conoce como _identity secret_ (el secreto de identidad),
|
||||
y su hash es el _identity commitment_ (compromiso de identidad).
|
||||
El hash Poseidon del identity nullifier y trapdoor se conoce como *identity secret* (el secreto de identidad),
|
||||
y su hash es el *identity commitment* (compromiso de identidad).
|
||||
|
||||
Un identity commitment (compromiso de identidad), de forma similar a las direcciones Ethereum, es un valor público que se utiliza en los grupos Semaphore para representar la
|
||||
identidad de un miembro del grupo. Los valores secretos son similares a las llaves privadas
|
||||
@@ -77,7 +76,7 @@ Ethereum y se utilizan para generar pruebas de conocimiento cero (ZKP) Semaphore
|
||||
### Crear identidades determinísticas
|
||||
|
||||
Si transmite un mensaje como un parámetro, Semaphore genera `trapdoor` y `nullifier`
|
||||
del hash _SHA256_ del mensaje.
|
||||
del hash *SHA256* del mensaje.
|
||||
El mensaje puede ser una contraseña o un mensaje que el usuario firma de forma criptográfica con una llave privada.
|
||||
|
||||
Al utilizar identidades determinísticas siempre deberá mantener secreto el mensaje.
|
||||
|
||||
@@ -10,56 +10,54 @@ import TabItem from "@theme/TabItem"
|
||||
|
||||
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.
|
||||
- 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)**](#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 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
|
||||
|
||||
Utilice la librería [`@semaphore-protocol/proof`](https://github.com/semaphore-protocol/semaphore/tree/main/packages/proof) para generar una prueba off-chain.
|
||||
Para generar una prueba, transforme los siguientes parámetros con la función `generateProof`:
|
||||
|
||||
- `identity`: la identidad Semaphore del usuario emitiendo la señal y generando la prueba;
|
||||
- `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](/V3/glossary/#archivos-confiables-de-configuración-trusted-setup-files).
|
||||
- `identity`: la identidad Semaphore del usuario emitiendo la señal y generando la prueba;
|
||||
- `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](/V3/glossary/#archivos-confiables-de-configuración-trusted-setup-files).
|
||||
|
||||
#### Instalar librería:
|
||||
|
||||
<Tabs
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
{label: 'npm', value: 'npm'},
|
||||
{label: 'Yarn', value: 'yarn'},
|
||||
{label: 'pnpm', value: 'pnpm'}
|
||||
]}>
|
||||
<TabItem value="npm">
|
||||
]}
|
||||
>
|
||||
<TabItem value="npm">
|
||||
```bash
|
||||
npm install @semaphore-protocol/proof@^3
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
```bash
|
||||
npm install @semaphore-protocol/proof@^3
|
||||
```
|
||||
<TabItem value="yarn">
|
||||
```bash
|
||||
yarn add @semaphore-protocol/proof@^3
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="yarn">
|
||||
|
||||
```bash
|
||||
yarn add @semaphore-protocol/proof@^3
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
|
||||
```bash
|
||||
pnpm add @semaphore-protocol/proof@^3
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
```bash
|
||||
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](/V3/guides/identities#crear-identidades) al [grupo](/V3/guides/groups) de la votación,
|
||||
@@ -86,6 +84,7 @@ Si estás generando la prueba en el lado del cliente, puedes evitar agregar los
|
||||
```ts
|
||||
const fullProof = await generateProof(identity, group, externalNullifier, signal)
|
||||
```
|
||||
|
||||
:::
|
||||
|
||||
## Verificar una prueba off-chain
|
||||
@@ -93,8 +92,8 @@ const fullProof = await generateProof(identity, group, externalNullifier, signal
|
||||
Utilice la librería [`@semaphore-protocol/proof`](https://github.com/semaphore-protocol/semaphore/tree/main/packages/proof) para verificar una prueba Semaphore off-chain.
|
||||
Para verificar una prueba, transforme los siguientes parámetros con la función `verifyProof`:
|
||||
|
||||
- `fullProof`: la prueba Semaphore;
|
||||
- `treeDepth`: la profundidad del árbol de Merkle.
|
||||
- `fullProof`: la prueba Semaphore;
|
||||
- `treeDepth`: la profundidad del árbol de Merkle.
|
||||
|
||||
La siguiente muestra de código demuestra cómo verificar la prueba generada previamente:
|
||||
|
||||
@@ -116,12 +115,12 @@ Vea nuestros [contratos desplegados](/V3/deployed-contracts) para encontrar las
|
||||
|
||||
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:
|
||||
|
||||
- `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 (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.
|
||||
- `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 (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.
|
||||
|
||||
:::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).
|
||||
|
||||
@@ -31,37 +31,34 @@ El CLI [`semaphore`](https://github.com/semaphore-protocol/semaphore/tree/main/p
|
||||
Para comenzar a trabajar en su proyecto, instale las siguientes dependencias:
|
||||
|
||||
<Tabs
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
{label: 'npm', value: 'npm'},
|
||||
{label: 'Yarn', value: 'yarn'},
|
||||
{label: 'pnpm', value: 'pnpm'}
|
||||
]}>
|
||||
<TabItem value="npm">
|
||||
]}
|
||||
>
|
||||
<TabItem value="npm">
|
||||
```bash
|
||||
cd my-app
|
||||
npm i
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
```bash
|
||||
cd my-app
|
||||
npm i
|
||||
```
|
||||
<TabItem value="yarn">
|
||||
```bash
|
||||
cd my-app
|
||||
yarn
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="yarn">
|
||||
|
||||
```bash
|
||||
cd my-app
|
||||
yarn
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
<TabItem value="pnpm">
|
||||
|
||||
```bash
|
||||
cd my-app
|
||||
pnpm install
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
```bash
|
||||
cd my-app
|
||||
pnpm install
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
## Output
|
||||
@@ -116,34 +113,31 @@ cd apps/contracts
|
||||
Y compile sus contratos al correr:
|
||||
|
||||
<Tabs
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
{label: 'npm', value: 'npm'},
|
||||
{label: 'Yarn', value: 'yarn'},
|
||||
{label: 'pnpm', value: 'pnpm'}
|
||||
]}>
|
||||
<TabItem value="npm">
|
||||
]}
|
||||
>
|
||||
<TabItem value="npm">
|
||||
```bash
|
||||
npm run compile
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
```bash
|
||||
npm run compile
|
||||
```
|
||||
<TabItem value="yarn">
|
||||
```bash
|
||||
yarn compile
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="yarn">
|
||||
|
||||
```bash
|
||||
yarn compile
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
|
||||
```bash
|
||||
pnpm compile
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
```bash
|
||||
pnpm compile
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
### Pruebe los contratos
|
||||
@@ -151,100 +145,91 @@ pnpm compile
|
||||
Pruebe sus contratos al correr:
|
||||
|
||||
<Tabs
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
{label: 'npm', value: 'npm'},
|
||||
{label: 'Yarn', value: 'yarn'},
|
||||
{label: 'pnpm', value: 'pnpm'}
|
||||
]}>
|
||||
<TabItem value="npm">
|
||||
]}
|
||||
>
|
||||
<TabItem value="npm">
|
||||
```bash
|
||||
npm test
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
```bash
|
||||
npm test
|
||||
```
|
||||
<TabItem value="yarn">
|
||||
```bash
|
||||
yarn test
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="yarn">
|
||||
|
||||
```bash
|
||||
yarn test
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
|
||||
```bash
|
||||
pnpm test
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
```bash
|
||||
pnpm test
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
Genere un reporte de la prueba de cobertura:
|
||||
|
||||
<Tabs
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
{label: 'npm', value: 'npm'},
|
||||
{label: 'Yarn', value: 'yarn'},
|
||||
{label: 'pnpm', value: 'pnpm'}
|
||||
]}>
|
||||
<TabItem value="npm">
|
||||
]}
|
||||
>
|
||||
<TabItem value="npm">
|
||||
```bash
|
||||
npm run test:coverage
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
```bash
|
||||
npm run test:coverage
|
||||
```
|
||||
<TabItem value="yarn">
|
||||
```bash
|
||||
yarn test:coverage
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="yarn">
|
||||
|
||||
```bash
|
||||
yarn test:coverage
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
|
||||
```bash
|
||||
pnpm test:coverage
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
```bash
|
||||
pnpm test:coverage
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
O un reporte de la prueba de gas:
|
||||
|
||||
<Tabs
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
{label: 'npm', value: 'npm'},
|
||||
{label: 'Yarn', value: 'yarn'},
|
||||
{label: 'pnpm', value: 'pnpm'}
|
||||
]}>
|
||||
<TabItem value="npm">
|
||||
]}
|
||||
>
|
||||
<TabItem value="npm">
|
||||
```bash
|
||||
npm run test:report-gas
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
```bash
|
||||
npm run test:report-gas
|
||||
```
|
||||
<TabItem value="yarn">
|
||||
```bash
|
||||
yarn test:report-gas
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="yarn">
|
||||
|
||||
```bash
|
||||
yarn test:report-gas
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
|
||||
```bash
|
||||
pnpm test:report-gas
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
```bash
|
||||
pnpm test:report-gas
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
### Desplegar contratos
|
||||
@@ -255,82 +240,76 @@ En la carpeta raíz del proyecto:
|
||||
|
||||
1. Agregue sus variables de entorno en el archivo `.env`.
|
||||
|
||||
:::note
|
||||
Deberá por lo menos configurar un URL válido en Ethereum (ejemplo: Infura) y una llave privada con algunos ethers.
|
||||
:::
|
||||
:::note
|
||||
Deberá por lo menos configurar un URL válido en Ethereum (ejemplo: Infura) y una llave privada con algunos ethers.
|
||||
:::
|
||||
|
||||
2. Vaya a la carpeta `apps/contracts` y desplegue su contrato.
|
||||
|
||||
<Tabs
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
<Tabs
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
{label: 'npm', value: 'npm'},
|
||||
{label: 'Yarn', value: 'yarn'},
|
||||
{label: 'pnpm', value: 'pnpm'}
|
||||
]}>
|
||||
<TabItem value="npm">
|
||||
]}
|
||||
>
|
||||
<TabItem value="npm">
|
||||
```bash
|
||||
npm run deploy -- --semaphore <semaphore-address> --group <group-id> --network goerli
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
```bash
|
||||
npm run deploy -- --semaphore <semaphore-address> --group <group-id> --network goerli
|
||||
```
|
||||
<TabItem value="yarn">
|
||||
```bash
|
||||
yarn deploy --semaphore <semaphore-address> --group <group-id> --network goerli
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="yarn">
|
||||
<TabItem value="pnpm">
|
||||
```bash
|
||||
pnpm deploy --semaphore <semaphore-address> --group <group-id> --network goerli
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
```bash
|
||||
yarn deploy --semaphore <semaphore-address> --group <group-id> --network goerli
|
||||
```
|
||||
:::note
|
||||
Revise las direcciones de los contratos de Semaphore [aquí](/V3/deployed-contracts).
|
||||
:::
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
|
||||
```bash
|
||||
pnpm deploy --semaphore <semaphore-address> --group <group-id> --network goerli
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
:::note
|
||||
Revise las direcciones de los contratos de Semaphore [aquí](/V3/deployed-contracts).
|
||||
:::
|
||||
|
||||
:::caution
|
||||
El group id (id del grupo) es un número.
|
||||
:::
|
||||
:::caution
|
||||
El group id (id del grupo) es un número.
|
||||
:::
|
||||
|
||||
### Inicie la app
|
||||
|
||||
Inicie la aplicación:
|
||||
|
||||
<Tabs
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
{label: 'npm', value: 'npm'},
|
||||
{label: 'Yarn', value: 'yarn'},
|
||||
{label: 'pnpm', value: 'pnpm'}
|
||||
]}>
|
||||
<TabItem value="npm">
|
||||
]}
|
||||
>
|
||||
<TabItem value="npm">
|
||||
```bash
|
||||
npm run dev
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
```bash
|
||||
npm run dev
|
||||
```
|
||||
<TabItem value="yarn">
|
||||
```bash
|
||||
yarn dev
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="yarn">
|
||||
|
||||
```bash
|
||||
yarn dev
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
|
||||
```bash
|
||||
pnpm dev
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
```bash
|
||||
pnpm dev
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
@@ -70,65 +70,59 @@ Para resolver eso:
|
||||
1- Instale `@esbuild-plugins/node-globals-polyfill` y `@esbuild-plugins/node-modules-polyfill`
|
||||
|
||||
<Tabs
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
{label: 'npm', value: 'npm'},
|
||||
{label: 'Yarn', value: 'yarn'},
|
||||
{label: 'pnpm', value: 'pnpm'}
|
||||
]}>
|
||||
<TabItem value="npm">
|
||||
]}
|
||||
>
|
||||
<TabItem value="npm">
|
||||
```bash
|
||||
npm install @esbuild-plugins/node-globals-polyfill
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
```bash
|
||||
npm install @esbuild-plugins/node-globals-polyfill
|
||||
```
|
||||
<TabItem value="yarn">
|
||||
```bash
|
||||
yarn add @esbuild-plugins/node-globals-polyfill
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="yarn">
|
||||
|
||||
```bash
|
||||
yarn add @esbuild-plugins/node-globals-polyfill
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
|
||||
```bash
|
||||
pnpm add @esbuild-plugins/node-globals-polyfill
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
```bash
|
||||
pnpm add @esbuild-plugins/node-globals-polyfill
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
<Tabs
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
{label: 'npm', value: 'npm'},
|
||||
{label: 'Yarn', value: 'yarn'},
|
||||
{label: 'pnpm', value: 'pnpm'}
|
||||
]}>
|
||||
<TabItem value="npm">
|
||||
]}
|
||||
>
|
||||
<TabItem value="npm">
|
||||
```bash
|
||||
npm install @esbuild-plugins/node-modules-polyfill
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
```bash
|
||||
npm install @esbuild-plugins/node-modules-polyfill
|
||||
```
|
||||
<TabItem value="yarn">
|
||||
```bash
|
||||
yarn add @esbuild-plugins/node-modules-polyfill
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="yarn">
|
||||
|
||||
```bash
|
||||
yarn add @esbuild-plugins/node-modules-polyfill
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
|
||||
```bash
|
||||
pnpm add @esbuild-plugins/node-modules-polyfill
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
```bash
|
||||
pnpm add @esbuild-plugins/node-modules-polyfill
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
2- Modifique `vite.config.ts` para añadirlos:
|
||||
@@ -236,4 +230,4 @@ Para comprobarlo, puede utilizar la [Semaphore CLI](https://github.com/semaphore
|
||||
|
||||
### Transacción revertida al usar el mismo external nullifier
|
||||
|
||||
Cuando genera una prueba usando el mismo external nullifier que usó para verificar una prueba antes, la transacción se revertirá porque ese external nullifier ya se usó. Si desea enviar y verificar varias pruebas de la misma identidad, debe usar un external nullifier diferente cada vez que genere una prueba.
|
||||
Cuando genera una prueba usando el mismo external nullifier que usó para verificar una prueba antes, la transacción se revertirá porque ese external nullifier ya se usó. Si desea enviar y verificar varias pruebas de la misma identidad, debe usar un external nullifier diferente cada vez que genere una prueba.
|
||||
|
||||
@@ -11,7 +11,9 @@
|
||||
"clear": "docusaurus clear",
|
||||
"serve": "docusaurus serve",
|
||||
"write-translations": "docusaurus write-translations",
|
||||
"write-heading-ids": "docusaurus write-heading-ids"
|
||||
"write-heading-ids": "docusaurus write-heading-ids",
|
||||
"format": "remark ./**/*.mdx --frail --quiet",
|
||||
"format:write": "remark ./**/*.mdx --output"
|
||||
},
|
||||
"dependencies": {
|
||||
"@docusaurus/core": "3.1.1",
|
||||
@@ -32,6 +34,11 @@
|
||||
"@docusaurus/module-type-aliases": "3.1.1",
|
||||
"@docusaurus/tsconfig": "3.1.1",
|
||||
"@types/react": "^18.2.29",
|
||||
"remark-cli": "^12.0.0",
|
||||
"remark-frontmatter": "^5.0.0",
|
||||
"remark-mdx": "^3.0.1",
|
||||
"remark-preset-lint-consistent": "^6.0.0",
|
||||
"remark-preset-lint-recommended": "^7.0.0",
|
||||
"typescript": "~5.2.2"
|
||||
},
|
||||
"browserslist": {
|
||||
@@ -48,5 +55,22 @@
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18.0"
|
||||
},
|
||||
"remarkConfig": {
|
||||
"settings": {
|
||||
"bullet": "-"
|
||||
},
|
||||
"plugins": [
|
||||
"remark-mdx",
|
||||
"remark-preset-lint-consistent",
|
||||
"remark-preset-lint-recommended",
|
||||
[
|
||||
"remark-frontmatter",
|
||||
{
|
||||
"type": "yaml",
|
||||
"marker": "-"
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,34 +18,31 @@ There are two ways to do this, using [`SemaphoreSubgraph`](https://github.com/se
|
||||
## Install library
|
||||
|
||||
<Tabs
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
{label: 'npm', value: 'npm'},
|
||||
{label: 'Yarn', value: 'yarn'},
|
||||
{label: 'pnpm', value: 'pnpm'}
|
||||
]}>
|
||||
<TabItem value="npm">
|
||||
]}
|
||||
>
|
||||
<TabItem value="npm">
|
||||
```bash
|
||||
npm install @semaphore-protocol/data@^3
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
```bash
|
||||
npm install @semaphore-protocol/data@^3
|
||||
```
|
||||
<TabItem value="yarn">
|
||||
```bash
|
||||
yarn add @semaphore-protocol/data@^3
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="yarn">
|
||||
|
||||
```bash
|
||||
yarn add @semaphore-protocol/data@^3
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
|
||||
```bash
|
||||
pnpm add @semaphore-protocol/data@^3
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
```bash
|
||||
pnpm add @semaphore-protocol/data@^3
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
## Fetch data using SemaphoreSubgraph
|
||||
@@ -113,6 +110,7 @@ const semaphoreSubgraph = new SemaphoreSubgraph("sepolia")
|
||||
const { members } = await semaphoreSubgraph.getGroup(groupId, { members: true })
|
||||
const group = new Group(groupId, 20, members)
|
||||
```
|
||||
|
||||
:::
|
||||
|
||||
## Fetch data using SemaphoreEthers
|
||||
@@ -178,4 +176,5 @@ const semaphoreEthers = new SemaphoreEthers("sepolia")
|
||||
const members = await semaphoreEthers.getGroupMembers(groupId)
|
||||
const group = new Group(groupId, 20, members)
|
||||
```
|
||||
|
||||
:::
|
||||
|
||||
@@ -11,70 +11,67 @@ import TabItem from "@theme/TabItem"
|
||||
A [Semaphore group](/V3/glossary/#semaphore-group) contains [identity commitments](/V3/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.
|
||||
- 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](/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;
|
||||
- **Tree depth**: the maximum number of members a group can contain (`max size = 2 ^ tree depth`);
|
||||
- **Members**: the list of members to initialize the group.
|
||||
- **Group id**: a unique identifier for the group;
|
||||
- **Tree depth**: the maximum number of members a group can contain (`max size = 2 ^ tree depth`);
|
||||
- **Members**: the list of members to initialize the group.
|
||||
|
||||
Learn how to work with groups.
|
||||
|
||||
- [**Off-chain groups**](#off-chain-groups)
|
||||
- [**On-chain groups**](#on-chain-groups)
|
||||
- [**Off-chain groups**](#off-chain-groups)
|
||||
- [**On-chain groups**](#on-chain-groups)
|
||||
|
||||
## Off-chain groups
|
||||
|
||||
- [Create a group](#create-a-group)
|
||||
- [Add members](#add-members)
|
||||
- [Remove or update members](#remove-or-update-members)
|
||||
- [Create a group](#create-a-group)
|
||||
- [Add members](#add-members)
|
||||
- [Remove or update members](#remove-or-update-members)
|
||||
|
||||
### Create a group
|
||||
|
||||
Use the [`@semaphore-protocol/group`](https://github.com/semaphore-protocol/semaphore/blob/v3.15.2/packages/group) library `Group` class to create an off-chain group with the following parameters:
|
||||
|
||||
- `Group id`: a unique identifier for the group;
|
||||
- `Tree depth`: (_default `20`_) the maximum number of members a group can contain (`max size = 2 ^ tree depth`).
|
||||
- `Members`: (_default `[]`_) the list of members to initialize the group.
|
||||
- `Group id`: a unique identifier for the group;
|
||||
- `Tree depth`: (*default `20`*) the maximum number of members a group can contain (`max size = 2 ^ tree depth`).
|
||||
- `Members`: (*default `[]`*) the list of members to initialize the group.
|
||||
|
||||
#### Install library:
|
||||
|
||||
<Tabs
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
{label: 'npm', value: 'npm'},
|
||||
{label: 'Yarn', value: 'yarn'},
|
||||
{label: 'pnpm', value: 'pnpm'}
|
||||
]}>
|
||||
<TabItem value="npm">
|
||||
]}
|
||||
>
|
||||
<TabItem value="npm">
|
||||
```bash
|
||||
npm install @semaphore-protocol/group@^3
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
```bash
|
||||
npm install @semaphore-protocol/group@^3
|
||||
```
|
||||
<TabItem value="yarn">
|
||||
```bash
|
||||
yarn add @semaphore-protocol/group@^3
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="yarn">
|
||||
|
||||
```bash
|
||||
yarn add @semaphore-protocol/group@^3
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
|
||||
```bash
|
||||
pnpm add @semaphore-protocol/group@^3
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
```bash
|
||||
pnpm add @semaphore-protocol/group@^3
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
To create a group with default _`treeDepth`_, call the `Group` constructor without the second parameter. For example:
|
||||
To create a group with default *`treeDepth`*, call the `Group` constructor without the second parameter. For example:
|
||||
|
||||
```ts
|
||||
import { Group } from "@semaphore-protocol/group"
|
||||
@@ -82,7 +79,7 @@ import { Group } from "@semaphore-protocol/group"
|
||||
const group = new Group(1)
|
||||
```
|
||||
|
||||
The following example code passes _`treeDepth`_ to create a group for `2 ^ 30 = 1073741824` members:
|
||||
The following example code passes *`treeDepth`* to create a group for `2 ^ 30 = 1073741824` members:
|
||||
|
||||
```ts
|
||||
import { Group } from "@semaphore-protocol/group"
|
||||
|
||||
@@ -11,50 +11,47 @@ import TabItem from "@theme/TabItem"
|
||||
In order to join a [Semaphore group](/V3/glossary#semaphore-group), a user must first create a [Semaphore identity](/V3/glossary#semaphore-identity).
|
||||
A Semaphore identity contains two values generated with the identity:
|
||||
|
||||
- Identity trapdoor
|
||||
- identity nullifier
|
||||
- Identity trapdoor
|
||||
- identity nullifier
|
||||
|
||||
To use and verify the identity, the identity owner (user) must know the trapdoor and nullifier values.
|
||||
To prevent fraud, the owner should keep both values secret.
|
||||
|
||||
## Create identities
|
||||
|
||||
In your code, use the [`@semaphore-protocol/identity`](https://github.com/semaphore-protocol/semaphore/tree/v3.15.2/packages/identity) library to create a Semaphore identity _deterministically_ (from the hash of a message) or _randomly_.
|
||||
In your code, use the [`@semaphore-protocol/identity`](https://github.com/semaphore-protocol/semaphore/tree/v3.15.2/packages/identity) library to create a Semaphore identity *deterministically* (from the hash of a message) or *randomly*.
|
||||
|
||||
- [**Create random identities**](#create-random-identities)
|
||||
- [**Create deterministic identities**](#create-deterministic-identities)
|
||||
- [**Create random identities**](#create-random-identities)
|
||||
- [**Create deterministic identities**](#create-deterministic-identities)
|
||||
|
||||
### Install library:
|
||||
|
||||
<Tabs
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
{label: 'npm', value: 'npm'},
|
||||
{label: 'Yarn', value: 'yarn'},
|
||||
{label: 'pnpm', value: 'pnpm'}
|
||||
]}>
|
||||
<TabItem value="npm">
|
||||
]}
|
||||
>
|
||||
<TabItem value="npm">
|
||||
```bash
|
||||
npm install @semaphore-protocol/identity@^3
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
```bash
|
||||
npm install @semaphore-protocol/identity@^3
|
||||
```
|
||||
<TabItem value="yarn">
|
||||
```bash
|
||||
yarn add @semaphore-protocol/identity@^3
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="yarn">
|
||||
|
||||
```bash
|
||||
yarn add @semaphore-protocol/identity@^3
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
|
||||
```bash
|
||||
pnpm add @semaphore-protocol/identity@^3
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
```bash
|
||||
pnpm add @semaphore-protocol/identity@^3
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
### Create random identities
|
||||
@@ -69,8 +66,8 @@ const { trapdoor, nullifier, commitment } = new Identity()
|
||||
|
||||
The new identity contains two random secret values: `trapdoor` and `nullifier`, and one public value: `commitment`.
|
||||
|
||||
The Poseidon hash of the identity nullifier and trapdoor is called the _identity secret_,
|
||||
and its hash is the _identity commitment_.
|
||||
The Poseidon hash of the identity nullifier and trapdoor is called the *identity secret*,
|
||||
and its hash is the *identity commitment*.
|
||||
|
||||
An identity commitment, similarly to Ethereum addresses, is a public value used
|
||||
in Semaphore groups to represent the identity of a group member. The secret values are similar to
|
||||
@@ -79,7 +76,7 @@ Ethereum private keys and are used to generate Semaphore zero-knowledge proofs a
|
||||
### Create deterministic identities
|
||||
|
||||
If you pass a message as a parameter, Semaphore generates `trapdoor` and `nullifier`
|
||||
from the _SHA256_ hash of the message.
|
||||
from the *SHA256* hash of the message.
|
||||
The message might be a password or a message that the user cryptographically signs with a private key.
|
||||
|
||||
When using deterministic identities, you should always keep the message secret.
|
||||
|
||||
@@ -10,57 +10,54 @@ import TabItem from "@theme/TabItem"
|
||||
|
||||
Once a user joins their [Semaphore identity](/V3/glossary#semaphore-identity) to a [Semaphore group](/V3/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.
|
||||
- the user is a member of the group,
|
||||
- the same user created the signal and the proof.
|
||||
|
||||
Developers can use Semaphore for the following:
|
||||
|
||||
- [**Generate a proof off-chain**](#generate-a-proof-off-chain)
|
||||
- [**Verify a proof off-chain**](#verify-a-proof-off-chain)
|
||||
- [**Verify a proof on-chain**](#verify-a-proof-on-chain)
|
||||
- [**Generate a proof off-chain**](#generate-a-proof-off-chain)
|
||||
- [**Verify a proof off-chain**](#verify-a-proof-off-chain)
|
||||
- [**Verify a proof on-chain**](#verify-a-proof-on-chain)
|
||||
|
||||
## Generate a proof off-chain
|
||||
|
||||
Use the [`@semaphore-protocol/proof`](https://github.com/semaphore-protocol/semaphore/tree/v3.15.2/packages/proof) library to generate an off-chain proof.
|
||||
To generate a proof, pass the following parameters to the `generateProof` function:
|
||||
|
||||
- `identity`: the Semaphore identity of the user broadcasting the signal and generating the proof;
|
||||
- `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](/V3/glossary/#trusted-setup-files).
|
||||
- `identity`: the Semaphore identity of the user broadcasting the signal and generating the proof;
|
||||
- `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](/V3/glossary/#trusted-setup-files).
|
||||
|
||||
#### Install library:
|
||||
|
||||
<Tabs
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
{label: 'npm', value: 'npm'},
|
||||
{label: 'Yarn', value: 'yarn'},
|
||||
{label: 'pnpm', value: 'pnpm'}
|
||||
]}>
|
||||
<TabItem value="npm">
|
||||
]}
|
||||
>
|
||||
<TabItem value="npm">
|
||||
```bash
|
||||
npm install @semaphore-protocol/proof@^3
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
```bash
|
||||
npm install @semaphore-protocol/proof@^3
|
||||
```
|
||||
<TabItem value="yarn">
|
||||
```bash
|
||||
yarn add @semaphore-protocol/proof@^3
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="yarn">
|
||||
|
||||
```bash
|
||||
yarn add @semaphore-protocol/proof@^3
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
|
||||
```bash
|
||||
pnpm add @semaphore-protocol/proof@^3
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
```bash
|
||||
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-identities) to the ballot [group](/V3/guides/groups),
|
||||
@@ -87,6 +84,7 @@ If you are generating the proof on the client side, you can avoid adding the sna
|
||||
```ts
|
||||
const fullProof = await generateProof(identity, group, externalNullifier, signal)
|
||||
```
|
||||
|
||||
:::
|
||||
|
||||
## Verify a proof off-chain
|
||||
@@ -94,8 +92,8 @@ const fullProof = await generateProof(identity, group, externalNullifier, signal
|
||||
Use the [`@semaphore-protocol/proof`](https://github.com/semaphore-protocol/semaphore/tree/v3.15.2/packages/proof) library to verify a Semaphore proof off-chain.
|
||||
To verify a proof, pass the following to the `verifyProof` function:
|
||||
|
||||
- `fullProof`: the Semaphore proof;
|
||||
- `treeDepth`: the Merkle tree depth.
|
||||
- `fullProof`: the Semaphore proof;
|
||||
- `treeDepth`: the Merkle tree depth.
|
||||
|
||||
The following code sample shows how to verify the previously generated proof:
|
||||
|
||||
@@ -117,12 +115,12 @@ See our [deployed contracts](/V3/deployed-contracts) to find the addresses for y
|
||||
|
||||
To verify Semaphore proofs in your contract, import `ISemaphore.sol`, pass it the `Semaphore.sol` address and call the `verifyProof` method with following parameters:
|
||||
|
||||
- `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;
|
||||
- `externalNullifier`: the value that prevents double-signaling;
|
||||
- `proof`: a Solidity-compatible Semaphore proof.
|
||||
- `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;
|
||||
- `externalNullifier`: the value that prevents double-signaling;
|
||||
- `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.
|
||||
|
||||
@@ -31,37 +31,34 @@ The [`semaphore CLI`](https://github.com/semaphore-protocol/semaphore/tree/v3.15
|
||||
To start working on your project, install the dependencies:
|
||||
|
||||
<Tabs
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
{label: 'npm', value: 'npm'},
|
||||
{label: 'Yarn', value: 'yarn'},
|
||||
{label: 'pnpm', value: 'pnpm'}
|
||||
]}>
|
||||
<TabItem value="npm">
|
||||
]}
|
||||
>
|
||||
<TabItem value="npm">
|
||||
```bash
|
||||
cd my-app
|
||||
npm i
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
```bash
|
||||
cd my-app
|
||||
npm i
|
||||
```
|
||||
<TabItem value="yarn">
|
||||
```bash
|
||||
cd my-app
|
||||
yarn
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="yarn">
|
||||
|
||||
```bash
|
||||
cd my-app
|
||||
yarn
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
|
||||
```bash
|
||||
cd my-app
|
||||
pnpm install
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
```bash
|
||||
cd my-app
|
||||
pnpm install
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
## Output
|
||||
@@ -116,34 +113,31 @@ cd apps/contracts
|
||||
And compile your contracts:
|
||||
|
||||
<Tabs
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
{label: 'npm', value: 'npm'},
|
||||
{label: 'Yarn', value: 'yarn'},
|
||||
{label: 'pnpm', value: 'pnpm'}
|
||||
]}>
|
||||
<TabItem value="npm">
|
||||
]}
|
||||
>
|
||||
<TabItem value="npm">
|
||||
```bash
|
||||
npm run compile
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
```bash
|
||||
npm run compile
|
||||
```
|
||||
<TabItem value="yarn">
|
||||
```bash
|
||||
yarn compile
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="yarn">
|
||||
|
||||
```bash
|
||||
yarn compile
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
|
||||
```bash
|
||||
pnpm compile
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
```bash
|
||||
pnpm compile
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
### Test contracts
|
||||
@@ -151,100 +145,91 @@ pnpm compile
|
||||
Test your contracts:
|
||||
|
||||
<Tabs
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
{label: 'npm', value: 'npm'},
|
||||
{label: 'Yarn', value: 'yarn'},
|
||||
{label: 'pnpm', value: 'pnpm'}
|
||||
]}>
|
||||
<TabItem value="npm">
|
||||
]}
|
||||
>
|
||||
<TabItem value="npm">
|
||||
```bash
|
||||
npm test
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
```bash
|
||||
npm test
|
||||
```
|
||||
<TabItem value="yarn">
|
||||
```bash
|
||||
yarn test
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="yarn">
|
||||
|
||||
```bash
|
||||
yarn test
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
|
||||
```bash
|
||||
pnpm test
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
```bash
|
||||
pnpm test
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
Generate a test coverage report:
|
||||
|
||||
<Tabs
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
{label: 'npm', value: 'npm'},
|
||||
{label: 'Yarn', value: 'yarn'},
|
||||
{label: 'pnpm', value: 'pnpm'}
|
||||
]}>
|
||||
<TabItem value="npm">
|
||||
]}
|
||||
>
|
||||
<TabItem value="npm">
|
||||
```bash
|
||||
npm run test:coverage
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
```bash
|
||||
npm run test:coverage
|
||||
```
|
||||
<TabItem value="yarn">
|
||||
```bash
|
||||
yarn test:coverage
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="yarn">
|
||||
|
||||
```bash
|
||||
yarn test:coverage
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
|
||||
```bash
|
||||
pnpm test:coverage
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
```bash
|
||||
pnpm test:coverage
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
Or a test gas report:
|
||||
|
||||
<Tabs
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
{label: 'npm', value: 'npm'},
|
||||
{label: 'Yarn', value: 'yarn'},
|
||||
{label: 'pnpm', value: 'pnpm'}
|
||||
]}>
|
||||
<TabItem value="npm">
|
||||
]}
|
||||
>
|
||||
<TabItem value="npm">
|
||||
```bash
|
||||
npm run test:report-gas
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
```bash
|
||||
npm run test:report-gas
|
||||
```
|
||||
<TabItem value="yarn">
|
||||
```bash
|
||||
yarn test:report-gas
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="yarn">
|
||||
|
||||
```bash
|
||||
yarn test:report-gas
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
|
||||
```bash
|
||||
pnpm test:report-gas
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
```bash
|
||||
pnpm test:report-gas
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
### Deploy contracts
|
||||
@@ -255,82 +240,76 @@ In the project root folder:
|
||||
|
||||
1. Add your environment variables in the `.env` file.
|
||||
|
||||
:::note
|
||||
You should at least set a valid Infura API Key (you could use Alchemy as well) and a private key with some ethers.
|
||||
:::
|
||||
:::note
|
||||
You should at least set a valid Infura API Key (you could use Alchemy as well) and a private key with some ethers.
|
||||
:::
|
||||
|
||||
2. Go to the `apps/contracts` folder and deploy your contract.
|
||||
|
||||
<Tabs
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
<Tabs
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
{label: 'npm', value: 'npm'},
|
||||
{label: 'Yarn', value: 'yarn'},
|
||||
{label: 'pnpm', value: 'pnpm'}
|
||||
]}>
|
||||
<TabItem value="npm">
|
||||
]}
|
||||
>
|
||||
<TabItem value="npm">
|
||||
```bash
|
||||
npm run deploy -- --semaphore <semaphore-address> --group <group-id> --network arbitrum-goerli
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
```bash
|
||||
npm run deploy -- --semaphore <semaphore-address> --group <group-id> --network arbitrum-goerli
|
||||
```
|
||||
<TabItem value="yarn">
|
||||
```bash
|
||||
yarn deploy --semaphore <semaphore-address> --group <group-id> --network arbitrum-goerli
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="yarn">
|
||||
<TabItem value="pnpm">
|
||||
```bash
|
||||
pnpm deploy --semaphore <semaphore-address> --group <group-id> --network arbitrum-goerli
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
```bash
|
||||
yarn deploy --semaphore <semaphore-address> --group <group-id> --network arbitrum-goerli
|
||||
```
|
||||
:::note
|
||||
Check the Semaphore contract addresses [here](/V3/deployed-contracts).
|
||||
:::
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
|
||||
```bash
|
||||
pnpm deploy --semaphore <semaphore-address> --group <group-id> --network arbitrum-goerli
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
:::note
|
||||
Check the Semaphore contract addresses [here](/V3/deployed-contracts).
|
||||
:::
|
||||
|
||||
:::caution
|
||||
The group id is a number.
|
||||
:::
|
||||
:::caution
|
||||
The group id is a number.
|
||||
:::
|
||||
|
||||
### Start app
|
||||
|
||||
Start the application:
|
||||
|
||||
<Tabs
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
{label: 'npm', value: 'npm'},
|
||||
{label: 'Yarn', value: 'yarn'},
|
||||
{label: 'pnpm', value: 'pnpm'}
|
||||
]}>
|
||||
<TabItem value="npm">
|
||||
]}
|
||||
>
|
||||
<TabItem value="npm">
|
||||
```bash
|
||||
npm run dev
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
```bash
|
||||
npm run dev
|
||||
```
|
||||
<TabItem value="yarn">
|
||||
```bash
|
||||
yarn dev
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="yarn">
|
||||
|
||||
```bash
|
||||
yarn dev
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
|
||||
```bash
|
||||
pnpm dev
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
```bash
|
||||
pnpm dev
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
@@ -70,65 +70,59 @@ To solve that:
|
||||
1- Install `@esbuild-plugins/node-globals-polyfill` and `@esbuild-plugins/node-modules-polyfill`
|
||||
|
||||
<Tabs
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
{label: 'npm', value: 'npm'},
|
||||
{label: 'Yarn', value: 'yarn'},
|
||||
{label: 'pnpm', value: 'pnpm'}
|
||||
]}>
|
||||
<TabItem value="npm">
|
||||
]}
|
||||
>
|
||||
<TabItem value="npm">
|
||||
```bash
|
||||
npm install @esbuild-plugins/node-globals-polyfill
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
```bash
|
||||
npm install @esbuild-plugins/node-globals-polyfill
|
||||
```
|
||||
<TabItem value="yarn">
|
||||
```bash
|
||||
yarn add @esbuild-plugins/node-globals-polyfill
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="yarn">
|
||||
|
||||
```bash
|
||||
yarn add @esbuild-plugins/node-globals-polyfill
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
|
||||
```bash
|
||||
pnpm add @esbuild-plugins/node-globals-polyfill
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
```bash
|
||||
pnpm add @esbuild-plugins/node-globals-polyfill
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
<Tabs
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
{label: 'npm', value: 'npm'},
|
||||
{label: 'Yarn', value: 'yarn'},
|
||||
{label: 'pnpm', value: 'pnpm'}
|
||||
]}>
|
||||
<TabItem value="npm">
|
||||
]}
|
||||
>
|
||||
<TabItem value="npm">
|
||||
```bash
|
||||
npm install @esbuild-plugins/node-modules-polyfill
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
```bash
|
||||
npm install @esbuild-plugins/node-modules-polyfill
|
||||
```
|
||||
<TabItem value="yarn">
|
||||
```bash
|
||||
yarn add @esbuild-plugins/node-modules-polyfill
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="yarn">
|
||||
|
||||
```bash
|
||||
yarn add @esbuild-plugins/node-modules-polyfill
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
|
||||
```bash
|
||||
pnpm add @esbuild-plugins/node-modules-polyfill
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
```bash
|
||||
pnpm add @esbuild-plugins/node-modules-polyfill
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
2- Modify the `vite.config.ts` to add them:
|
||||
|
||||
@@ -111,23 +111,23 @@ In the project root folder:
|
||||
|
||||
1. Add your environment variables in the `.env` file.
|
||||
|
||||
:::note
|
||||
You should at least set a valid Infura API Key (you could use Alchemy as well) and a private key with some ethers.
|
||||
:::
|
||||
:::note
|
||||
You should at least set a valid Infura API Key (you could use Alchemy as well) and a private key with some ethers.
|
||||
:::
|
||||
|
||||
2. Go to the `apps/contracts` folder and deploy your contract.
|
||||
|
||||
```bash
|
||||
yarn deploy --semaphore <semaphore-address> --group <group-id> --network sepolia
|
||||
```
|
||||
```bash
|
||||
yarn deploy --semaphore <semaphore-address> --group <group-id> --network sepolia
|
||||
```
|
||||
|
||||
:::note
|
||||
Check the Semaphore contract addresses [here](/deployed-contracts).
|
||||
:::
|
||||
:::note
|
||||
Check the Semaphore contract addresses [here](/deployed-contracts).
|
||||
:::
|
||||
|
||||
:::caution
|
||||
The group id is a number.
|
||||
:::
|
||||
:::caution
|
||||
The group id is a number.
|
||||
:::
|
||||
|
||||
### Start app
|
||||
|
||||
|
||||
@@ -11,9 +11,9 @@ import TabItem from "@theme/TabItem"
|
||||
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,
|
||||
- ballot that members join to vote on a proposal,
|
||||
- whistleblowers who are verified employees of an organization.
|
||||
- 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.
|
||||
|
||||
:::info
|
||||
Semaphore V4 uses the [ZK-Kit](https://github.com/privacy-scaling-explorations/zk-kit) LeanIMT (i.e., Lean Incremental
|
||||
@@ -28,34 +28,31 @@ Use the [`@semaphore-protocol/group`](https://github.com/semaphore-protocol/sema
|
||||
### Install package
|
||||
|
||||
<Tabs
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
{label: 'npm', value: 'npm'},
|
||||
{label: 'Yarn', value: 'yarn'},
|
||||
{label: 'pnpm', value: 'pnpm'}
|
||||
]}>
|
||||
<TabItem value="npm">
|
||||
]}
|
||||
>
|
||||
<TabItem value="npm">
|
||||
```bash
|
||||
npm install @semaphore-protocol/group
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
```bash
|
||||
npm install @semaphore-protocol/group
|
||||
```
|
||||
<TabItem value="yarn">
|
||||
```bash
|
||||
yarn add @semaphore-protocol/group
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="yarn">
|
||||
|
||||
```bash
|
||||
yarn add @semaphore-protocol/group
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
|
||||
```bash
|
||||
pnpm add @semaphore-protocol/group
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
```bash
|
||||
pnpm add @semaphore-protocol/group
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
:::info
|
||||
@@ -142,34 +139,31 @@ Use the [`@semaphore-protocol/contracts`](https://github.com/semaphore-protocol/
|
||||
### Install package
|
||||
|
||||
<Tabs
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
{label: 'npm', value: 'npm'},
|
||||
{label: 'Yarn', value: 'yarn'},
|
||||
{label: 'pnpm', value: 'pnpm'}
|
||||
]}>
|
||||
<TabItem value="npm">
|
||||
]}
|
||||
>
|
||||
<TabItem value="npm">
|
||||
```bash
|
||||
npm install @semaphore-protocol/contracts
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
```bash
|
||||
npm install @semaphore-protocol/contracts
|
||||
```
|
||||
<TabItem value="yarn">
|
||||
```bash
|
||||
yarn add @semaphore-protocol/contracts
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="yarn">
|
||||
|
||||
```bash
|
||||
yarn add @semaphore-protocol/contracts
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
|
||||
```bash
|
||||
pnpm add @semaphore-protocol/contracts
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
```bash
|
||||
pnpm add @semaphore-protocol/contracts
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
### Create a group
|
||||
@@ -240,4 +234,3 @@ function removeMember(uint256 identityCommitment, uint256[] calldata merkleProof
|
||||
:::info
|
||||
If you want to see an example of a working contract, have a look at the [`contracts-hardhat`](https://github.com/semaphore-protocol/semaphore/tree/main/packages/cli-template-contracts-hardhat) CLI template. You can also create a project with that template by running `semaphore create my-app --template contracts-hardhat`.
|
||||
:::
|
||||
|
||||
|
||||
@@ -11,9 +11,9 @@ import TabItem from "@theme/TabItem"
|
||||
In order to join a [Semaphore group](/glossary#group), a user must first create a [Semaphore identity](/glossary#identity).
|
||||
A Semaphore identity contains three values generated with the identity:
|
||||
|
||||
- Private key
|
||||
- Public key
|
||||
- Commitment
|
||||
- Private key
|
||||
- Public key
|
||||
- Commitment
|
||||
|
||||
To use and verify the identity, the identity owner (user) must know its private key.
|
||||
To prevent fraud, the owner should keep their private key secret.
|
||||
@@ -23,34 +23,31 @@ To prevent fraud, the owner should keep their private key secret.
|
||||
In your code, use the [`@semaphore-protocol/identity`](https://github.com/semaphore-protocol/semaphore/tree/main/packages/identity) package to manage Semaphore identites.
|
||||
|
||||
<Tabs
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
{label: 'npm', value: 'npm'},
|
||||
{label: 'Yarn', value: 'yarn'},
|
||||
{label: 'pnpm', value: 'pnpm'}
|
||||
]}>
|
||||
<TabItem value="npm">
|
||||
]}
|
||||
>
|
||||
<TabItem value="npm">
|
||||
```bash
|
||||
npm install @semaphore-protocol/identity
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
```bash
|
||||
npm install @semaphore-protocol/identity
|
||||
```
|
||||
<TabItem value="yarn">
|
||||
```bash
|
||||
yarn add @semaphore-protocol/identity
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="yarn">
|
||||
|
||||
```bash
|
||||
yarn add @semaphore-protocol/identity
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
|
||||
```bash
|
||||
pnpm add @semaphore-protocol/identity
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
```bash
|
||||
pnpm add @semaphore-protocol/identity
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
:::info
|
||||
@@ -88,7 +85,7 @@ You may choose to delegate such functionality to existing wallets such as Metama
|
||||
1. In Metamask, a user signs a message with the private key of their Ethereum account.
|
||||
2. In your application, the user creates a deterministic identity with the signed message that acts as your Semaphore private key.
|
||||
3. The user can now recreate their Semaphore identity whenever they want by signing the same message with their Ethereum account in Metamask.
|
||||
:::
|
||||
:::
|
||||
|
||||
## Sign and verify messages
|
||||
|
||||
|
||||
@@ -10,8 +10,8 @@ import TabItem from "@theme/TabItem"
|
||||
|
||||
Once a user joins a [Semaphore group](/glossary#group) with their [Semaphore identity](/glossary#identity), the user can send their anonymous [message](/glossary#message) with a zero-knowledge proof that proves the following:
|
||||
|
||||
- the user is a member of the group,
|
||||
- the same user created the message and the proof.
|
||||
- the user is a member of the group,
|
||||
- the same user created the message and the proof.
|
||||
|
||||
A unique [nullifier](/glossary#nullifier) is also generated for each proof that can be used to check whether that proof has already been validated.
|
||||
|
||||
@@ -20,34 +20,31 @@ A unique [nullifier](/glossary#nullifier) is also generated for each proof that
|
||||
In your code, use the [`@semaphore-protocol/proof`](https://github.com/semaphore-protocol/semaphore/tree/main/packages/proof) package to generate and verify a proof.
|
||||
|
||||
<Tabs
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
defaultValue="npm"
|
||||
groupId="package-managers"
|
||||
values={[
|
||||
{label: 'npm', value: 'npm'},
|
||||
{label: 'Yarn', value: 'yarn'},
|
||||
{label: 'pnpm', value: 'pnpm'}
|
||||
]}>
|
||||
<TabItem value="npm">
|
||||
]}
|
||||
>
|
||||
<TabItem value="npm">
|
||||
```bash
|
||||
npm install @semaphore-protocol/proof
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
```bash
|
||||
npm install @semaphore-protocol/proof
|
||||
```
|
||||
<TabItem value="yarn">
|
||||
```bash
|
||||
yarn add @semaphore-protocol/proof
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="yarn">
|
||||
|
||||
```bash
|
||||
yarn add @semaphore-protocol/proof
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
|
||||
```bash
|
||||
pnpm add @semaphore-protocol/proof
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="pnpm">
|
||||
```bash
|
||||
pnpm add @semaphore-protocol/proof
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
:::info
|
||||
|
||||
@@ -7,7 +7,7 @@ import RemoteCode from '@site/src/components/RemoteCode';
|
||||
# Subgraph
|
||||
|
||||
[The Graph](https://thegraph.com/) is a protocol for indexing networks like Ethereum and IPFS.
|
||||
Site owners publish _subgraphs_ that expose site data for anyone to query.
|
||||
Site owners publish *subgraphs* that expose site data for anyone to query.
|
||||
Semaphore's subgraph allows you to retrieve data from the [`Semaphore.sol`](https://github.com/semaphore-protocol/semaphore/blob/main/packages/contracts/contracts/Semaphore.sol) smart contract.
|
||||
|
||||
:::tip
|
||||
@@ -16,5 +16,4 @@ The Graph protocol uses the [GraphQL](https://graphql.org/) query language. For
|
||||
|
||||
## Schema
|
||||
|
||||
<RemoteCode url="https://raw.githubusercontent.com/semaphore-protocol/semaphore/main/apps/subgraph/schema.graphql"
|
||||
title="apps/subgraph/schema.graphql" language="graphql" />
|
||||
<RemoteCode url="https://raw.githubusercontent.com/semaphore-protocol/semaphore/main/apps/subgraph/schema.graphql" title="apps/subgraph/schema.graphql" language="graphql" />
|
||||
|
||||
@@ -18,15 +18,15 @@
|
||||
"test:contracts": "yarn workspace semaphore-contracts test:coverage",
|
||||
"test:circuits": "yarn workspace @semaphore-protocol/circuits test",
|
||||
"lint": "eslint . --ext .js,.ts,.tsx && yarn workspace semaphore-contracts lint",
|
||||
"prettier": "prettier -c .",
|
||||
"prettier:write": "prettier -w .",
|
||||
"format": "prettier -c . && yarn workspace semaphore-docs format",
|
||||
"format:write": "prettier -w . && yarn workspace semaphore-docs format:write",
|
||||
"docs": "typedoc --cname js.semaphore.pse.dev --githubPages true",
|
||||
"version:bump": "yarn workspaces foreach -A --no-private version -d ${0} && yarn version apply --all && yarn remove:stable-version-field && NO_HOOK=1 git commit -am \"chore: v${0}\" && git tag v${0}",
|
||||
"version:publish": "yarn build:libraries && yarn clean:cli-templates && yarn workspaces foreach -A --no-private npm publish --tolerate-republish --access public",
|
||||
"version:release": "changelogithub",
|
||||
"clean": "ts-node scripts/clean-apps.ts && ts-node scripts/clean-packages.ts && yarn clean:cli-templates && rimraf node_modules",
|
||||
"clean:cli-templates": "ts-node scripts/clean-cli-templates.ts",
|
||||
"remove:stable-version-field": "ts-node scripts/remove-stable-version-field.ts && yarn prettier:write",
|
||||
"remove:stable-version-field": "ts-node scripts/remove-stable-version-field.ts && yarn format:write",
|
||||
"precommit": "lint-staged",
|
||||
"postinstall": "husky install"
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user