Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@semaphore-extensions/identity-proof

Package Overview
Dependencies
Maintainers
2
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@semaphore-extensions/identity-proof

A library to prove the ownership of a Semaphore identity without revealing the private key.

  • 1.0.0-beta.2
  • latest
  • npm
  • Socket score

Version published
Maintainers
2
Created
Source

Semaphore Identity Proof

A library to prove the ownership of a Semaphore identity without revealing the private key.

NPM license NPM version Downloads npm bundle size (scoped) Linter eslint Code style prettier

🗣️ Chat & Support   |   📘 Docs
This zero-knowledge library allows you to prove and verify that you have the private key of a Semaphore identity. It will be mainly used on-chain because you can get the same result off-chain using EdDSA signatures with the @semaphore-protocol/identity package. It facilitates the demonstration of having an EdDSA hash pre-image while keeping the pre-image value confidential. Additionally, it offers a mechanism to prevent the same proof from being reused. The circuit that forms the foundation of this library is accessible via this link.

[!WARNING]
The Snark artifacts currently used to generate zero-knowledge proofs are the result of an insecure trusted setup, and the library has not yet been audited. Therefore, it is advised not to use it in production.

🛠 Install

Install the @semaphore-extensions/identity-proof package:

npm i @semaphore-extensions/identity-proof

or yarn:

yarn add @semaphore-extensions/identity-proof

📜 Usage

import { generate, verify } from "@semaphore-extensions/identity-proof"

// Your private key (secret) associated with your commitment.
const privateKey = "secret"
// A public value used to contextualize the cryptographic proof and calculate the nullifier.
const scope = "scope"

// Generate the proof.
const fullProof = await generate(privateKey, scope)

/*
    nb. commitment and scope are always the same - proof is variable.
{
    commitment: '21756852044673293804725356853298692762259855200429755225624171532449447776732',
    scope: '52191664570483756643537362991541193331102618014473399276861326740461293928448',
    proof: [
        '14987543977537638797613616391807211498102534775759297152458980015937921301475',
        '3399335485250714998192957632691923175498432819155620830553382340417897595836',
        '458847933923791518779258584891719351511628278818450523853640641455008133942',
        '9130558865745328382423837376229933835283742789420937388990076948167771186665',
        '2527867303822223913583586720705858457538165210401589969189198821632271648294',
        '870032122185130505849909299495220614500026484724112145131565329210361970548',
        '7499124546917660821334566902083675362480525785493429715971012094306224236446',
        '4681140599918274218600441523225984097742730174371377925026448119492671129895'
    ]
}

*/
console.log(fullProof)

// If not specified, the Snark artifacts are downloaded automatically.
// You can specify them as follows.

// const fullProof = await generate(privateKey, scope, {
//     wasm: "<your-path>/identity-proof.wasm",
//     zkey: "<your-path>/identity-proof.zkey"
// })

// Verify the proof.
const response = await verify(fullProof)

// true.
console.log(response)

📈 Benchmarks

Benchmarks were run on an Intel Core i7-1165G7, 16 GB RAM machine.

Generate proofVerify proofConstraints
258ms15ms1017
import { generate, verify } from "@semaphore-extensions/identity-proof"

console.time("generate")

const proof = await generate("secret", "scope")

console.timeEnd("generate")

console.time("verify")

console.log(await verify(proof))

console.timeEnd("verify")

FAQs

Package last updated on 20 May 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc