@semaphore-protocol/identity
TypeScript icon, indicating that this package has built-in type declarations

4.8.2 • Public • Published

Semaphore identity

A library to create Semaphore identities.

NPM license NPM version Downloads Documentation typedoc Linter eslint Code style prettier

This library provides a class that can be used to create identities compatible with the Semaphore circuits. Each identity contains an EdDSA private key, its public key, and the identity commitment, which is the Poseidon hash of the public key.

🛠 Install

npm or yarn

Install the @semaphore-protocol/identity package with npm:

npm i @semaphore-protocol/identity

or yarn:

yarn add @semaphore-protocol/identity

📜 Usage

For more information on the functions provided by @semaphore-protocol/identity, please refer to the TypeDoc documentation.

# new Identity(privateKey?: BigNumberish): Identity

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

// The identity will be generated randomly.
const { privateKey, publicKey, commitment } = new Identity()

// Alternatively, you can pass your private key.
const identity = new Identity("your-private-key")

# identity.export(): string

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

const identity = new Identity()

const privateKey = identity.export()

# identity.import(privateKey: string): Identity

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

const identity = new Identity()

const privateKey = identity.export()

const identity2 = Identity.import(privateKey)

# identity.signMessage(message: BigNumberish): Signature<string>

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

const message = "message"
const identity = new Identity()

const signature = identity.signMessage(message)

# Identity.verifySignature(message: BigNumberish, signature: Signature, publicKey: Point): boolean

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

const message = "message"
const identity = new Identity()

const signature = identity.signMessage(message)

Identity.verifySignature(message, signature, identity.publicKey)

# Identity.generateCommitment(publicKey: Point): bigint

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

Identity.generateCommitment(identity.publicKey)

Readme

Keywords

none

Package Sidebar

Install

npm i @semaphore-protocol/identity

Weekly Downloads

1,207

Version

4.8.2

License

MIT

Unpacked Size

30.7 kB

Total Files

7

Last publish

Collaborators

  • cedoor
  • vplasencia