Expand description
Keccak256 precompile for the Miden VM.
This module provides both execution-time and verification-time support for Keccak256 hashing.
§Architecture
§Event Handler (Execution-Time)
When the VM emits a Keccak event requesting non-deterministic hash results, the processor calls
KeccakPrecompile which reads input data from memory, computes the hash, provides the digest
via the advice stack, and logs the raw preimage bytes as a precompile request.
§Precompile Verifier (Verification-Time)
During verification, the [PrecompileVerifier] receives the stored preimage bytes, recomputes
the hash, and generates a commitment P2(P2(input) || P2(digest)), where P2 stands
for Poseidon2, that validates the computation was performed correctly.
§Commitment Tag Format
Each request is tagged as [event_id, len_bytes, 0, 0]. The len_bytes field prevents
collisions: since bytes are packed into 32-bit limbs, we must distinguish actual data bytes
from padding in the final limb.
§Digest Representation
A Keccak256 digest (256 bits) is represented as 8 field elements [h0, ..., h7],
each containing a u32 value where hi = u32::from_le_bytes([b_{4i}, ..., b_{4i+3}]).
Structs§
- Keccak
Felt Digest - Keccak256 digest representation in the Miden VM.
- Keccak
Precompile - Keccak
Preimage - Keccak256 preimage structure representing the raw input data to be hashed.
Constants§
- KECCAK_
HASH_ BYTES_ EVENT_ NAME - Event name for the keccak256 hash_bytes operation.