https://github.com/chancehudson/poseidon-lite
https://github.com/chancehudson/poseidon-lite
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/chancehudson/poseidon-lite
- Owner: chancehudson
- Created: 2022-11-09T05:03:28.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-08-23T03:53:09.000Z (almost 2 years ago)
- Last Synced: 2025-04-28T14:05:36.509Z (about 1 year ago)
- Language: JavaScript
- Homepage: https://npmjs.com/poseidon-lite
- Size: 2.81 MB
- Stars: 17
- Watchers: 1
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# poseidon-lite [](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