$ show 0xPolygonHermez/zisk
ZisK is a high-performance zero-knowledge virtual machine (zkVM) developed by Polygon that generates and verifies proofs for RISC-V program execution. The codebase implements a full proving stack: a custom Rust emulator and a faster C++/assembly executor, a transpiler that converts RISC-V ELF binaries into Zisk ROM format, a guest operating system (`ziskos`) exposing cryptographic syscalls, a set of precompiled state machines (Keccak, SHA-256, Blake2/3, secp256k1, BN254, BLS12-381, BabyJubJub, arithmetic equality, DMA, EVM JUMPDEST), and a STARK proving backend built on PIL2/proofman, with optional PLONK wrapping and Solidity verifier contracts. The system is delivered as a Rust/C++ workspace with a `cargo-zisk` CLI, an SDK offering embedded and remote proving clients, and a distributed coordinator/worker gRPC layer for scaling proof generation across machines and GPUs. The primary data flow starts with guest programs compiled for the `riscv64ima-zisk-zkvm-elf` target. The CLI or SDK builds the ELF, the transpiler converts it to a Zisk ROM, and the emulator or assembly executor executes it to produce execution traces, memory operations, and public outputs. These traces feed dedicated state-machine collectors and planners that generate witness data for the proofman STARK pipeline. Recursion and aggregation are supported through the `recurser` crate and circom templates, and finalized proofs can be verified natively in Rust or on-chain via generated Solidity verifiers. Inputs and hints flow through a stream abstraction supporting files, Unix sockets, memory, channels, and QUIC, which underpins both local and distributed proving. Architecturally, the repository is a large monorepo of roughly 50 crates organized around a clean separation between emulation/execution, witness generation, state machines, precompiles, SDK/CLI, and distributed services. It demonstrates mature engineering practices such as trait-based stream IO, declarative precompile registration, planner/collector patterns for state machine instantiation, generated-code integration, and extensive integration testing. However, it is pre-release (`1.3.2-alpha`), contains significant vendored C/C++ code, has platform-gated assembly paths that are stubs outside Linux x86_64, and exhibits duplication across guest and host cryptographic implementations. Despite these weaknesses, the core abstractions are generally well-designed and the repository is actively maintained, with CI, release workflows, and a substantial test artifact corpus.
The LLM identified 3 files worth highlighting for reuse:
Defines the core StreamRead/StreamWrite traits and a transport-agnostic streaming layer with implementations for files, Unix sockets, in-memory buffers, mpsc channels, and QUIC. This is a clean, isolated abstraction that can be extracted and reused in any Rust application needing pluggable byte-stream I/O, especially where local and network transports must be interchangeable without changing higher-level protocol logic.
Provides a lightweight cooperative cancellation token used by SDK job handles to abort long-running prove/setup/execute operations. It is self-contained, has no internal dependencies beyond std, and demonstrates a reusable pattern for async job lifecycle management. Any Rust service managing cancellable background work can adopt this token design with minimal modification.
Implements programmatic generation of Keccak-f round transformation equations (theta, rho, pi, chi, iota) as reusable expression builders. Instead of hand-writing the repetitive round logic and PIL constraints, this code constructs the algebraic expressions once and emits both Rust and PIL representations. It is a strong example of a code-generation pattern for permutation-based cryptographic circuits and could be adapted to generate constraints or reference implementations for other permutation algorithms.