Expand description
Poseidon hash function optimized for zero-knowledge proofs
This crate provides a field-native implementation of the Poseidon hash function,
specifically optimized for use in STARK proof systems with Complex<Mersenne31>.
§Design
Poseidon is an algebraic hash function designed for efficient implementation in zero-knowledge proof systems. Unlike traditional hashes like SHA-3, Poseidon operates directly on field elements, making it orders of magnitude more efficient in circuit constraints.
§Security
- Uses conservative round counts based on peer-reviewed research
- MDS matrices generated using secure methods
- Parameters chosen for 128-bit and 256-bit security levels
§Example
ⓘ
use lib_q_poseidon::{Poseidon, Poseidon128};
use lib_q_stark_field::extension::Complex;
use lib_q_stark_mersenne31::Mersenne31;
type Val = Complex<Mersenne31>;
let hasher = Poseidon128::permutation();
let input = vec![Val::from(1u32), Val::from(2u32)];
let hash = hasher.hash(&input);Structs§
- Poseidon128
- Poseidon-128 parameters for 128-bit security over
Complex<Mersenne31> - Poseidon256
- Poseidon-256 parameters for 256-bit security over
Complex<Mersenne31> - Poseidon
Params - Poseidon parameter configuration
- Poseidon
Permutation - Poseidon permutation function
- Poseidon
Sponge - Poseidon sponge in the absorb phase (before padding).
- Poseidon
Sponge Squeeze - Poseidon sponge after padding: squeeze output only.
Enums§
- Poseidon
Error - Error types for Poseidon operations
Traits§
- Poseidon
- High-level Poseidon hash interface
Functions§
- mds_
matrix_ 5x5 - MDS matrix for state width 5 (Poseidon-128 over
Complex<Mersenne31>). Cauchy construction so every square submatrix has nonzero determinant. - mds_
matrix_ 7x7 - MDS matrix for state width 7 (Poseidon-256 over
Complex<Mersenne31>). - round_
constants_ 128 - Round constants for Poseidon-128 (64 rounds total: 8 full + 56 partial)
State width 5 for 128-bit security over
Complex<Mersenne31>(capacity 3 × ~62 bits ≥ 128). - round_
constants_ 256 - Round constants for Poseidon-256 (68 rounds total: 8 full + 60 partial)
State width 7 for 256-bit security over
Complex<Mersenne31>(capacity 5 × ~62 bits ≥ 256). - sbox
- S-box function: x^5
Type Aliases§
- Poseidon
Field - Field type used for Poseidon
- Poseidon
State - Poseidon permutation state (variable length: state_width elements)