Expand description

Module for generating parameters for the Poseidon SNARK-friendly hash function.

This crate will, given a choice of:

  • M, the desired security level (in bits),
  • t, the width of the desired hash function, e.g. $t=3$ corresponds to 2-to-1 hash.
  • p, the prime modulus,
  • allow_inverse, whether or not to allow an inverse alpha for the Sbox layer.

generate the best choice of parameters, for both the unoptimized version of Poseidon specified in the Poseidon paper, as well as the optimizations described in Appendix B.


For generating parameters at build time.


Represents an matrix of round constants.
Input parameters that are used to generate Poseidon parameters.
Represents a matrix over PrimeField elements.
Represents an MDS (maximum distance separable) matrix.
Represents an optimized matrix of round constants.
Represents an optimized MDS (maximum distance separable) matrix.
A set of Poseidon parameters for a given set of input parameters.
RoundNumbers required for security based on known attacks.
Represents a square matrix over PrimeField elements


The exponent in Sbox(x) = x^\alpha.


Basic matrix operations all matrices should implement.
Matrix operations that are defined on square matrices.


Compute vector dot product
Computes the binary log of a BigInteger
Multiply two matrices