A library to create Semaphore identities.
This library provides a class that can be used to create identities compatible with the Semaphore circuits. Each identity contains two private values (trapdoor and nullifier), and the Poseidon hash of these values (commitment) is used as the public identifier of the Semaphore identity. |
---|
Install the @semaphore-protocol/identity
package with npm:
npm i @semaphore-protocol/identity
or yarn:
yarn add @semaphore-protocol/identity
# new Identity(identityOrMessage?: string): Identity
import { Identity } from "@semaphore-protocol/identity"
// Trapdoor and nullifier are generated randomly.
const identity1 = new Identity()
// Trapdoor and nullifier are generated deterministically from a secret message.
const identity2 = new Identity("secret-message")
// Trapdoor and nullifier are generated from an existing identity.
const identity3 = new Identity(identity1.toString())
# getTrapdoor(): bigint
const trapdoor = identity.getTrapdoor()
# getNullifier(): bigint
const nullifier = identity.getNullifier()
# generateCommitment(): bigint
const commitment = identity.generateCommitment()
Generated using TypeDoc