zisklib
ZiskLib is the high-level safe layer over the VM syscalls. Each function dispatches to a dedicated state machine inside the zkVM, covering hash functions and elliptic curve arithmetic for secp256k1, secp256r1, BN254, BLS12-381, and Ed25519.
hints featureThe signatures on these pages are for the ziskos crate, which has no
hints feature (Cargo rejects features = ["hints"]). The same source
is also built as the ziskos-hints crate, where the hints feature is
on by default: there the crypto and big-integer functions each gain a
trailing hints: &mut Vec<u64> parameter used to record proving hints.
Every function is re-exported at the crate root, so the canonical path is
flat — e.g. ziskos::zisklib::sha256 — regardless of which submodule it
lives in.
Many functions also have a #[no_mangle] extern "C" form with a _c
suffix, such as scalar_mul_bn254_c or checked_add256_c, for C and
C++ guests. They take raw *const u64 / *mut u64 limb pointers instead
of arrays and slices, and return status codes instead of Result.
Only the two added in 1.4.0-alpha,
ecdsa_verify_secp256k1_c
and pairing_batch_safe_bn254_c,
have their own entries. For the rest, see the # Safety comments in
ziskos/entrypoint/src/zisklib/lib/.
zisklib also implements the zkVM standards' C interfaces, for C and
C++ guests and for toolchains that target them:
zisklib::zkvm_accelerators: the 19 functions of the standardzkvm_accelerators.hinterface (zkvm_keccak256,zkvm_sha256,zkvm_modexp,zkvm_bn254_pairing,zkvm_bls12_g1_msm,zkvm_kzg_point_eval,zkvm_secp256k1_ecrecover, and so on).zisklib::zkvm_accelerators_ext: 6 non-standard 256-bit modular arithmetic functions (zkvm_mulmod256,zkvm_add_mod256,zkvm_inv_mod256, ...), declared inzkvm_accelerators_ext.h.zisklib::zkvm_io::{read_input, write_output}: the standardzkvm_io.hinterface.read_inputreturns the first input record and does not advance theioread cursor, so use either it orio::read*for a given input, not both.write_outputappends to the same public-output stream asio::commit_slice.
These are not documented function by function here; see the # Safety
comments in ziskos/entrypoint/src/zisklib/lib/zkvm_accelerators*.rs
and zkvm_io.rs.
zisklib crate in ziskasmThis module is ziskos::zisklib. The ZisK repository also contains an
unpublished crate named zisklib in ziskasm/lang/rust, a set of
bindings for the hand-written ZisK assembly routines used by examples and
test guests. It is unrelated to the API on these pages.