Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

poseidon-h

inverse-technology21Apache-2.00.0.4TypeScript support: included

Poseidon hash with alt_bn128 implementation in Typescript

poseidon, hash, alt_bn128, groth16, snarkjs, circom

readme

Poseidon Hash over bn254 with Typescript

MIT License Language npm version CI Check

A poseidon hash implementation over BN254. Circom circuit and Groth16 tests.

Use at your own risk.

Install

$ npm i poseidon-h

Usage

import { poseidon, randomFieldElement } from "poseidon-h";
const wasm = require("circom_tester").wasm;

const hash = poseidon([1n, 2n]);
const hash2 = poseidon([randomFieldElement(), randomFieldElement()]);
const circuit = await wasm(path.join("circuit", "poseidon.circom"));
const witness = await circuit.calculateWitness({ inputs });
const hash = poseidon(inputs);

await circuit.assertOut(witness, { out: hash });

Test

$ yarn test

Groth16

$ yarn groth16