poseidon-lite
TypeScript icon, indicating that this package has built-in type declarations

0.3.0 • Public • Published

poseidon-lite CircleCI

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

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

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.

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

npm i
npm run build
npm test

License

Versions >=0.2.0 are MIT

Versions <0.2.0 are GPL-3.0

/poseidon-lite/

    Package Sidebar

    Install

    npm i poseidon-lite

    Weekly Downloads

    20,342

    Version

    0.3.0

    License

    MIT

    Unpacked Size

    630 kB

    Total Files

    54

    Last publish

    Collaborators

    • jchancehud