# poseidon-lite

> Lightweight poseidon hash

Latest version **0.3.0** (published 2024-08-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install poseidon-lite
pnpm add poseidon-lite
yarn add poseidon-lite
bun add poseidon-lite
```

## 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.3.0 |
| Published | 2024-08-23 |
| First published | 2022-11-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 615 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | jchancehud |
| Keywords | poseidon, hash, zk |

## Links

- npm: https://www.npmjs.com/package/poseidon-lite
- Homepage: https://github.com/vimwitch/poseidon-lite#readme
- npm.io page: https://npm.io/package/poseidon-lite

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 0.3.0 (latest) — 2024-08-23
- 0.2.1 — 2024-08-12
- 0.2.0 — 2023-04-19
- 0.1.1 — 2023-04-18
- 0.1.0 — 2023-03-09
- 0.0.2 — 2022-11-10
- 0.0.1 — 2022-11-10
- 0.0.0 — 2022-11-10

## README

# poseidon-lite [![CircleCI](https://dl.circleci.com/status-badge/img/gh/chancehudson/poseidon-lite/tree/main.svg?style=shield)](https://dl.circleci.com/status-badge/redirect/gh/chancehudson/poseidon-lite/tree/main)

A 0 dependence poseidon implementation over alt_bn128 (aka BN254).

## Warning

This implementation uses the native javascript `BigInt` which is vulnerable to timing attacks.

This implementation has **not** been audited.

## Use

`npm i poseidon-lite`

```js
import { poseidon2 } from 'poseidon-lite'
// pass an array to the function
// array length must be equal to the function name
// returns a BigInt
const hash = poseidon2(['0x01', '0x02'])
```

### Individual import

```js
import { poseidon2 } from 'poseidon-lite/poseidon2'
const hash = poseidon2(['0x01', '0x02'])
```

### Get state elements

More state elements can be retrieved by passing an optional second argument. Useful for e.g. sponge based encryption. The maximum number of elements that can be retrieved is `input.length + 1`.

```js
import { poseidon2 } from 'poseidon-lite'

// retrieve 3 state elements instead of the default 1
const elements = poseidon2(['0x01', '0x02'], 3)
// elements is now a BigInt[3]
```

## Build

```sh
npm i
npm run build
npm test
```

## License

Versions `>=0.2.0` are MIT

Versions `<0.2.0` are GPL-3.0

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