Skip to main content

Module hasher

Module hasher 

Source
Expand description

Low-level Poseidon2 hasher functions and constants.

This module provides core hashing primitives for the Poseidon2 hash function, including:

  • Constants defining the hasher state layout (STATE_WIDTH, RATE_LEN, NUM_ROUNDS)
  • Pass-through functions for common hash operations (merge, hash_elements)
  • Step-by-step permutation functions for fine-grained control (apply_round, apply_permutation)

This module serves as a thin wrapper around miden_crypto::hash::Poseidon2, providing a consistent interface for the Miden VM’s hashing needs. For higher-level hasher chiplet functionality, see the trace and processor modules.

Structs§

Hasher
Implementation of the Poseidon2 hash function with 256-bit output.

Constants§

NUM_ROUNDS
Number of “round steps” used by the hasher chiplet per permutation.
RATE_LEN
Number of field elements in the rate portion of the hasher’s state.
STATE_WIDTH
Number of field element needed to represent the sponge state for the hash function.

Functions§

apply_permutation
Applies the Poseidon2 permutation to the provided state.
apply_round
Applies a single Poseidon2 “step” to the provided state.
hash_elements
Returns a hash of the provided list of field elements.
merge
Returns a hash of two digests. This method is intended for use in construction of Merkle trees.
merge_in_domain
Returns a hash of two digests with a specified domain.