Skip to main content

Module hasher

Module hasher 

Source
Expand description

Hasher chiplet trace constants and types.

This module defines the structure of the hasher chiplet’s execution trace, including:

  • Trace selectors that determine which hash operation is being performed
  • State layout for the Poseidon2 permutation (12 field elements: 8 rate + 4 capacity)
  • Column ranges and indices for accessing trace data

The hasher chiplet supports several operations:

  • Linear hashing (absorbing arbitrary-length inputs)
  • 2-to-1 hashing (Merkle tree node computation)
  • Merkle path verification
  • Merkle root updates (for authenticated data structure modifications)

Structs§

Hasher
Implementation of the Poseidon2 hash function with 256-bit output.
Word
A unit of data consisting of 4 field elements.

Constants§

CAPACITY_COL_RANGE
The capacity portion of the hasher state in the execution trace, located in columns 11..15. With LE sponge state layout [RATE0, RATE1, CAP], capacity comes last.
CAPACITY_DOMAIN_IDX
The index in the hasher state where the domain is set when initializing the hasher.
CAPACITY_LEN
Number of field elements in the capacity portion of the hasher’s state.
DIGEST_LEN
DIGEST_RANGE
The output portion of the hash state, located in the first rate word (RATE0).
HASH_CYCLE_LEN
The number of rows in the execution trace required to compute a permutation of Poseidon2. This is equal to 32.
HASH_CYCLE_LEN_FELT
LAST_CYCLE_ROW
Index of the last row in a permutation cycle (0-based).
LAST_CYCLE_ROW_FELT
LINEAR_HASH
Specifies a start of a new linear hash computation or absorption of new elements into an executing linear hash computation. These selectors can also be used for a simple 2-to-1 hash computation.
LINEAR_HASH_LABEL
Unique label computed as 1 plus the full chiplet selector with the bits reversed. selector = [0 | 1, 0, 0], flag = rev(selector) + 1 = [0, 0, 1 | 0] + 1 = 3
MP_VERIFY
Specifies a start of Merkle path verification computation or absorption of a new path node into the hasher state.
MP_VERIFY_LABEL
Unique label computed as 1 plus the full chiplet selector with the bits reversed. selector = [0 | 1, 0, 1], flag = rev(selector) + 1 = [1, 0, 1 | 0] + 1 = 11
MR_UPDATE_NEW
Specifies a start of Merkle path verification or absorption of a new path node into the hasher state for the “new” node value during Merkle root update computation.
MR_UPDATE_NEW_LABEL
Unique label computed as 1 plus the full chiplet selector with the bits reversed. selector = [0 | 1, 1, 1], flag = rev(selector) + 1 = [1, 1, 1 | 0] + 1 = 15
MR_UPDATE_OLD
Specifies a start of Merkle path verification or absorption of a new path node into the hasher state for the “old” node value during Merkle root update computation.
MR_UPDATE_OLD_LABEL
Unique label computed as 1 plus the full chiplet selector with the bits reversed. selector = [0 | 1, 1, 0], flag = rev(selector) + 1 = [0, 1, 1 | 0] + 1 = 7
NUM_ROUNDS
Number of round steps used to complete a single permutation.
NUM_SELECTORS
Number of selector columns in the trace.
P1_COL_IDX
Index of the auxiliary trace column tracking the state of the sibling table.
RATE_COL_RANGE
The rate portion of the hasher state in the execution trace, located in columns 3..11. With LE sponge state layout [RATE0, RATE1, CAP], rate comes first.
RATE_LEN
Number of field elements in the rate portion of the hasher’s state.
RETURN_HASH
Specifies a completion of a computation such that only the hash result (values in h0, h1, h2 h3) is returned.
RETURN_HASH_LABEL
Unique label computed as 1 plus the full chiplet selector with the bits reversed. selector = [0 | 0, 0, 0], flag = rev(selector) + 1 = [0, 0, 0 | 0] + 1 = 1
RETURN_STATE
Specifies a completion of a computation such that the entire hasher state (values in h0 through h11) is returned.
RETURN_STATE_LABEL
Unique label computed as 1 plus the full chiplet selector with the bits reversed. selector = [0 | 0, 0, 1], flag = rev(selector) + 1 = [1, 0, 0 | 0] + 1 = 9
STATE_COL_RANGE
The hasher state portion of the execution trace, located in columns 3..15.
STATE_WIDTH
Number of field element needed to represent the sponge state for the hash function.
TRACE_WIDTH
Number of columns in Hasher execution trace. There is one additional column for the node index.

Type Aliases§

HasherState
Type for the Hasher’s state.
Selectors
Type for Hasher trace selector. These selectors are used to define which transition function is to be applied at a specific row of the hasher execution trace.