mirror of
https://github.com/privacy-scaling-explorations/zk-kit.git
synced 2026-04-22 03:00:15 -04:00
readme files
This commit is contained in:
74
packages/identity/README.md
Normal file
74
packages/identity/README.md
Normal file
@@ -0,0 +1,74 @@
|
||||
<p align="center">
|
||||
<h1 align="center">
|
||||
Semaphore identities
|
||||
</h1>
|
||||
<p align="center">Library for managing identites for Semaphore and Rln protocols.</p>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<a href="https://github.com/appliedzkp/libsemaphore/blob/main/LICENSE">
|
||||
<img alt="Github license" src="https://img.shields.io/github/license/appliedzkp/libsemaphore.svg?style=flat-square">
|
||||
</a>
|
||||
<a href="https://www.npmjs.com/package/@libsem/identity">
|
||||
<img alt="NPM version" src="https://img.shields.io/npm/v/@libsem/identity?style=flat-square" />
|
||||
</a>
|
||||
<a href="https://npmjs.org/package/@libsem/identity">
|
||||
<img alt="Downloads" src="https://img.shields.io/npm/dm/@libsem/identity.svg?style=flat-square" />
|
||||
</a>
|
||||
<a href="https://bundlephobia.com/package/@libsem/identity">
|
||||
<img alt="npm bundle size (scoped)" src="https://img.shields.io/bundlephobia/minzip/@libsem/identity" />
|
||||
</a>
|
||||
<a href="https://eslint.org/">
|
||||
<img alt="Linter eslint" src="https://img.shields.io/badge/linter-eslint-8080f2?style=flat-square&logo=eslint" />
|
||||
</a>
|
||||
<a href="https://prettier.io/">
|
||||
<img alt="Code style prettier" src="https://img.shields.io/badge/code%20style-prettier-f8bc45?style=flat-square&logo=prettier" />
|
||||
</a>
|
||||
</p>
|
||||
|
||||
---
|
||||
|
||||
## 🛠 Install
|
||||
|
||||
### npm or yarn
|
||||
|
||||
Install the `@libsem/identity` package with npm:
|
||||
|
||||
```bash
|
||||
npm i @libsem/identity
|
||||
```
|
||||
|
||||
or yarn:
|
||||
|
||||
```bash
|
||||
yarn add @libsem/identity
|
||||
```
|
||||
|
||||
## 📜 Usage
|
||||
|
||||
**Import**
|
||||
|
||||
```typescript
|
||||
import { ZkIdentity, Identity } from "@libsem/identity";
|
||||
|
||||
```
|
||||
```javascript
|
||||
|
||||
const { ZkIdentity } = require("@libsem/identity");
|
||||
|
||||
```
|
||||
|
||||
**Mainpulation**
|
||||
|
||||
```typescript
|
||||
const identity: Identity = ZkIdentity.genIdentity();
|
||||
const identityCommitment: bigint = ZkIdentity.genIdentityCommitment(identity);
|
||||
```
|
||||
**Serialization**
|
||||
|
||||
```typescript
|
||||
const identity: Identity = ZkIdentity.genIdentity();
|
||||
const serialized: string = ZkIdentity.serializeIdentity(identity);
|
||||
const unserialized: Identity = ZkIdentity.unSerializeIdentity(serialized);
|
||||
|
||||
```
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@libsem/identity",
|
||||
"version": "1.0.8",
|
||||
"version": "1.0.9",
|
||||
"description": "Library for managing identites for Semaphore and Rln protocols",
|
||||
"main": "dist/index.node.js",
|
||||
"types": "dist/types/index.d.ts",
|
||||
|
||||
93
packages/protocols/README.md
Normal file
93
packages/protocols/README.md
Normal file
@@ -0,0 +1,93 @@
|
||||
<p align="center">
|
||||
<h1 align="center">
|
||||
Semaphore identities
|
||||
</h1>
|
||||
<p align="center">Library for managing identites for Semaphore and Rln protocols.</p>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<a href="https://github.com/appliedzkp/libsemaphore/blob/main/LICENSE">
|
||||
<img alt="Github license" src="https://img.shields.io/github/license/appliedzkp/libsemaphore.svg?style=flat-square">
|
||||
</a>
|
||||
<a href="https://www.npmjs.com/package/@libsem/protocols">
|
||||
<img alt="NPM version" src="https://img.shields.io/npm/v/@libsem/protocols?style=flat-square" />
|
||||
</a>
|
||||
<a href="https://npmjs.org/package/@libsem/protocols">
|
||||
<img alt="Downloads" src="https://img.shields.io/npm/dm/@libsem/protocols.svg?style=flat-square" />
|
||||
</a>
|
||||
<a href="https://bundlephobia.com/package/@libsem/protocols">
|
||||
<img alt="npm bundle size (scoped)" src="https://img.shields.io/bundlephobia/minzip/@libsem/protocols" />
|
||||
</a>
|
||||
<a href="https://eslint.org/">
|
||||
<img alt="Linter eslint" src="https://img.shields.io/badge/linter-eslint-8080f2?style=flat-square&logo=eslint" />
|
||||
</a>
|
||||
<a href="https://prettier.io/">
|
||||
<img alt="Code style prettier" src="https://img.shields.io/badge/code%20style-prettier-f8bc45?style=flat-square&logo=prettier" />
|
||||
</a>
|
||||
</p>
|
||||
|
||||
---
|
||||
|
||||
## 🛠 Install
|
||||
|
||||
### npm or yarn
|
||||
|
||||
Install the `@libsem/protocols` package with npm:
|
||||
|
||||
```bash
|
||||
npm i @libsem/protocols
|
||||
```
|
||||
|
||||
or yarn:
|
||||
|
||||
```bash
|
||||
yarn add @libsem/protocols
|
||||
```
|
||||
|
||||
## 📜 Usage
|
||||
|
||||
**Import**
|
||||
|
||||
```typescript
|
||||
import { ZkIdentity, Identity } from '@libsem/identity';
|
||||
import { Semaphore, MerkleProof, IProof, generateMerkleProof, genExternalNullifier, genSignalHash } from '@libsem/protocols';
|
||||
|
||||
|
||||
```
|
||||
```javascript
|
||||
|
||||
const { ZkIdentity } = require('@libsem/identity');
|
||||
const { Semaphore, Rln, NRln, generateMerkleProof, genExternalNullifier, genSignalHash } = require('@libsem/protocols');
|
||||
```
|
||||
|
||||
**Merkle Proofs**
|
||||
Generate merkle proof for your identity given the array of registered identity commitments
|
||||
|
||||
```typescript
|
||||
const identityCommitments: Array<bigint> = [...];
|
||||
const identityCommitment: bigint = ZkIdentity.genIdentityCommitment(identity);
|
||||
|
||||
const merkleProof: MerkleProof = generateMerkleProof(TREE_DEPTH, ZERO_VALUE, NUMBER_OF_LEAVES_PER_NODE, identityCommitments, identityCommitment);
|
||||
```
|
||||
|
||||
**Semaphore**
|
||||
|
||||
In order to create semaphore proof, make sure to
|
||||
|
||||
```typescript
|
||||
const witness = Semaphore.genWitness(identity, merkleProof, externalNullifier, signal);
|
||||
const fullProof = await Semaphore.genProof(witness, wasmFilePath, finalZkeyPath);
|
||||
```
|
||||
**Serialization**
|
||||
|
||||
```typescript
|
||||
const identity: Identity = ZkIdentity.genIdentity();
|
||||
const serialized: string = ZkIdentity.serializeIdentity(identity);
|
||||
const unserialized: Identity = ZkIdentity.unSerializeIdentity(serialized);
|
||||
|
||||
```
|
||||
## 📜 Final Note
|
||||
|
||||
For full examples of how to integrate with contracts check https://github.com/appliedzkp/semaphore repository
|
||||
|
||||
For additional info check tests directory
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@libsem/protocols",
|
||||
"version": "1.0.9",
|
||||
"version": "1.0.10",
|
||||
"description": "Client library for generating and verifying Semaphore & Rln ZK proofs",
|
||||
"main": "dist/index.node.js",
|
||||
"types": "dist/types/index.d.ts",
|
||||
|
||||
Reference in New Issue
Block a user