Package Exports
- poseidon-lite
- poseidon-lite/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (poseidon-lite) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
poseidon-lite 
A stripped down poseidon implementation pulled from circomlibjs 0.0.8.
Use
// normal version
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'])
// optimized version (larger bundle size)
import { poseidon2 } from 'poseidon-lite/opt'
// 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'])
// Optimized version
import { poseidon2 } from 'poseidon-lite/opt/poseidon2'
const hash = poseidon2(['0x01', '0x02'])
Normal vs Opt
This package includes two implementations of poseidon. The normal function and an optimized version with more pre-computed values. The normal function is ~3x slower than the opt version, but is also ~40% smaller.
Comparison of two input poseidon (poseidon2()
):
Constants size
Normal: 12K
Opt: 20K
Speed
Normal: 243 hashes/second
Opt: 689 hashes/second
Build
npm i
npm run build
npm test