poseidon

Version, currently main branch1 version
  • main branchlatestDec 11, 2020

github.com/guipublic/poseidon

Crystal library implementing Poseidon hash

0 stars
0 dependents
License: MIT

Installation

# Add this to your shard.yml
dependencies:
  poseidon:
    github: guipublic/poseidon
    branch: main

main is a branch, not a release, so this tracks it rather than pinning a version.

Then run:

shards install

shard.yml

Crystal
0.35.1
License
MIT
Author
Guillaume Drevon

Dependencies

Runtime Dependencies

  • ecdsa*github: sikoba/ecdsa.cr

README

Poseidon hash

Poseidon is a zero-knowledge friendly hash, defined in the following research paper.

We propose here a crystal implementation based on the reference implementation. We also includes the sponge construction so that arbitrary input length hash can be computed.

Usage

Instantiate the class Poseidon with a prime number and the number of desired bits of security. Optionally one can specify the sponge capacity and the width of the permutation (in number of field elements). The hashing function requires a PoseidonParameters object, which can be retrieved by calling the auto_parameters function. Parameters can be fully customized by initialising a PoseidonParams object and calling the set_params function. In that case, one must also set the round constants that can either be provided with the set_round_constants function or auto-generated. If the round constants are generated, you must call init_generator() before computing the hash.

Please note that the mds matrix is not generated, it is hardcoded for only a few values of field size and permutation width. In case of, one can set it with the set_mds_matrix function.

You can also refer to the examples in spec.