# idc-nullifier

> This is a circuit that takes a semaphore identity and a nullifier in, and generates an identity commitment and the hash of the identity commitment and nullifier together.

Latest version **0.0.8** (published 2023-11-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install idc-nullifier
pnpm add idc-nullifier
yarn add idc-nullifier
bun add idc-nullifier
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.8 |
| Published | 2023-11-13 |
| First published | 2023-08-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 4 |
| Unpacked size | 3.1 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | atheartengineer |

## Links

- npm: https://www.npmjs.com/package/idc-nullifier
- npm.io page: https://npm.io/package/idc-nullifier

## Dependencies (4)

- [snarkjs](https://npm.io/package/snarkjs.md) ^0.7.0
- [circomlib](https://npm.io/package/circomlib.md) ^2.0.5
- [poseidon-lite](https://npm.io/package/poseidon-lite.md) ^0.2.0
- [@semaphore-protocol/identity](https://npm.io/package/@semaphore-protocol/identity.md) ^3.10.1

## Recent versions

- 0.0.8 (latest) — 2023-11-13
- 0.0.7 — 2023-10-25
- 0.0.6 — 2023-10-24
- 0.0.5 — 2023-10-24
- 0.0.4 — 2023-10-18
- 0.0.2 — 2023-08-01
- 0.0.1 — 2023-08-01

## README

# idcNullifier circuits

This is a circuit that takes a semaphore identity and a nullifier in, and generates an identity commitment and the hash of the identity commitment and nullifier together.

The purpose of this is to prove that you have the secrets to an identity commitment, with a nullifier to prevent replay attacks.

## Circuit

Constraints: 453

**Private Input**
_(semaphore identity secret)_

- identitySecret

**Public Inputs**

- externalNullifier - public external nullifier, it could be a timestamp, or a new identity commitment

**Outputs**

- nullifierHash - the identity commitment and nullifier hashed together
- identityCommitment - the identity commitment from the semaphore identity

## Proving Time

~380ms on a Macbook Air M2
~400ms on an AMD 5800x
~500ms on an Intel i7-1165G7

## Usage

### For use with a timestamp to prevent replay attacks

```ts
import { Prover, Verifier } from "idcNullifier";
import { Identity } from "@semaphore-protocol/identity";

const identity = new Identity("Seed");
const timestamp = new Date.now();

const prover = new Prover();

const proof = prover.generateProof({
  identity: identity,
  externalNullifier: timestamp,
});

const identityCommitment = proof.publicSignals.identityCommitment;
const externalNullifier = proof.publicSignals.externalNullifier;

const verifier = new Verifier();
const isValid = verifier.verifyProof(proof);
```

### To prove that you know the secrets for some identity commitment and that you want to replace your identity with a new identity commitment.
```ts
import { Prover, Verifier } from "idcNullifier";
import { Identity } from "@semaphore-protocol/identity";

const prover = new Prover();

const proof = prover.generateProof({
  identity: oldIdentity,
  externalNullifier: newIdentityCommitment,
});

const identityCommitment = proof.publicSignals.identityCommitment;
const newIdentityCommitment = proof.publicSignals.externalNullifier;

const verifier = new Verifier();
const isValid = verifier.verifyProof(proof);
```

---
_Source: https://npm.io/package/idc-nullifier · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
