0.4.2 • Published 7 months ago

poseidon2 v0.4.2

Weekly downloads
-
License
MIT
Repository
-
Last release
7 months ago

Contributors Forks Stargazers Issues

Install

npm install poseidon2

Note For TypeScript Users:

If you see the error "Cannot find module 'poseidon2/goldilocks-12' or its corresponding type declarations.ts(2307)", update your tsconfig.json to set "moduleResolution": "NodeNext".

Usage For Goldilocks Field, T = 12

Permute

import { permute } from "poseidon2/goldilocks-12";
const result = permute([
  1337n,
  123456n,
  100n,
  15n,
  1n,
  2n,
  3n,
  4n,
  22n,
  23n,
  24n,
  25n,
]);

Two to One (Hash two 4-element-wide values)

import { twoToOne } from "poseidon2/goldilocks-12";
const result = twoToOne([1337n, 123456n, 100n, 15n], [1n, 2n, 3n, 4n]);

Sponge Hash with Pad (Hash n elements with padding)

import { hashPad } from "poseidon2/goldilocks-12";
const result = hashPad([1n, 2n, 3n, 1337n, 9999n, 123n]);

How to use with other prime fields/t values

See Working with other prime fields and t values.

Credits

Original implementation of poseidon2 by https://github.com/HorizenLabs

License

MIT License

Copyright (c) 2023 Zero Knowledge Labs Limited

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

0.4.1

7 months ago

0.4.0

7 months ago

0.4.2

7 months ago

0.3.0

8 months ago

0.2.0

8 months ago

0.1.1

8 months ago

0.1.0

12 months ago