# @zkpassport/poseidon2

> A blazing fast Poseidon2 implementation in TypeScript for the BN254 curve

Latest version **0.6.2** (published 2025-07-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install @zkpassport/poseidon2
pnpm add @zkpassport/poseidon2
yarn add @zkpassport/poseidon2
bun add @zkpassport/poseidon2
```

## Health

**Score 40/100 (D)** — status: maintenance-mode.

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

Warnings: low downloads; pre 1.0.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.6.2 |
| Published | 2025-07-03 |
| First published | 2025-01-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 247.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | michaelelliot, madztheo |

## Links

- npm: https://www.npmjs.com/package/@zkpassport/poseidon2
- npm.io page: https://npm.io/package/@zkpassport/poseidon2

## Recent versions

- 0.6.2 (latest) — 2025-07-03
- 0.6.1 — 2025-02-21
- 0.6.0 — 2025-02-07
- 0.5.5 — 2025-02-06
- 0.5.4 — 2025-02-06
- 0.5.3 — 2025-01-20
- 0.5.2 — 2025-01-14
- 0.5.1 — 2025-01-05
- 0.5.0 — 2025-01-05

## README

# @zkpassport/poseidon2

A fast Poseidon2 implementation in pure TypeScript for the BN254 curve.

## Installation

```bash
# Using bun
bun add @zkpassport/poseidon2

# Using npm
npm i @zkpassport/poseidon2

# Using yarn
yarn add @zkpassport/poseidon2
```

## Usage

This package provides both synchronous and asynchronous Poseidon2 hash functions. The asynchronous version is recommended for hashing many inputs, as it yields to the event loop during computation, whereas the synchronous version blocks execution.

### Synchronous Usage

```typescript
import { poseidon2Hash } from "@zkpassport/poseidon2"

// Hash an array of bigints
const input = [1n, 2n, 3n]
const hash = poseidon2Hash(input)
console.log(hash) // Returns a single bigint hash value
```

### Asynchronous Usage

```typescript
import { poseidon2HashAsync } from "@zkpassport/poseidon2"

// Hash an array of bigints asynchronously
const input = [1n, 2n, 3n]
const hash = await poseidon2HashAsync(input)
console.log(hash) // Returns a single bigint hash value
```

## Features

- Optimized implementation for BN254 curve
- Both synchronous and asynchronous hash functions
- TypeScript support with full type definitions
- Zero dependencies
- Efficient memory usage
- Suitable for both Node.js and browser environments

## Performance

Hashrate comparison between TypeScript and WASM implementations:

| Implementation       | Iterations | Time (sec) | Hashes/sec |
| -------------------- | ---------- | ---------- | ---------- |
| Poseidon2 TypeScript | 1,000,000  | ~140       | ~7,000     |
| Poseidon2 WASM       | 1,000,000  | ~30        | ~32,000    |

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