Skip to main content

Hash functions

Hash functions provided by zisklib: SHA-256, Keccak-256, stateful BLAKE2b compression, and RIPEMD-160, each dispatching to a dedicated state machine inside the zkVM.

Overview

This module documents the cryptographic hash primitives that zisklib exposes as safe Rust wrappers over zkVM hash syscalls. It serves guest programs that need standard digests for Merkle trees, commitment schemes, signature pre-images, address derivation, and other protocol glue where a hash is part of the statement being proven.


SHA-256 hash over an arbitrary byte slice. Handles padding and multi-block inputs automatically via the SHA-256 state machine.

pub fn sha256(input: &[u8]) -> [u8; 32]

Parameters

NameTypeDescription
input&[u8]Byte slice to hash. Any length; padding and blocking handled internally.

Returns

TypeDescription
[u8; 32]SHA-256 digest of input.

Example

let digest: [u8; 32] = zisklib::sha256(b"hello world");