Static library builds of ziskos for RISC-V 64-bit architecture with IMA extensions, suitable for Nethermind's bflat compiler. The repository also ships the Nethermind.ZiskOS.Runtime NuGet package, which embeds the static library for use from .NET projects targeting the Zisk zkVM.
This project provides pre-built static libraries for the zisk zkVM runtime, compiled for RISC-V 64-bit targets. The builds are specifically configured for:
- ISA: RV64IMAD (Integer, Multiplication, Atomic, Double-precision FP)
- ABI: LP64D
- Target OS: zkvm
- Vendor: zisk
The reason for choosing this target over rv64im is pretty simple. It is much more compatible with dotnet-riscv images already used in bflat. Still, these binaries are normally guaranteed to have no C, A, D instructions.
Each release includes:
libziskos.a- static library with ziskos functionality (precompiles) and direct system call wrappers (zisk_syscalls.Sassembled for rv64ima).libziskos.bflat.manifest- bflat manifest describing the library, its target triple, and the resolved zisk commit hash. It also instructs bflat to wrapmemcpy,memset,memmove, andmemcmp.zisk_entry.o,zisk.ld,zisk_sim.ld,zisk.bflat.manifest,zisk_sim.bflat.manifest- the ZisK and ZisK simulator platforms for bflat (see Platform).Nethermind.ZiskOS.RuntimeNuGet package - .NET runtime package that bundleslibziskos.a, the platform files and the manifests for consumption from managed projects.
This package also defines the ZisK target for bflat: --libc zisk selects
the platform that platform/ describes, so bflat itself knows nothing about
ZisK. platform/build.sh builds it into output/ (zisk_entry.o, zisk.ld, zisk_sim.ld, zisk.bflat.manifest and zisk_sim.bflat.manifest):
entry.Sis the guest's_startand the ZisK halt protocol, plus the initial argv/envp/auxv vector that musl's start-up reads.entry.Salso implements the platform interface that bflat's modules call (bflat itself has no code for any one zkVM):zkvm_platform_exit(thea7 = 93ecall),zkvm_platform_syscall(on to musl: ZisK emulates Linux syscalls) and the bridge of the ziskos Rust allocator onto bflat's heap.- the linker script is the ZisK memory map;
- the platform manifest gives the instruction set, the ABI, the RyuJIT
options, the defines and the post-link steps, and lists the bflat modules
that the guest needs (format:
docs/manifest.mdin bflat-riscv64).
The package also defines the zisk_sim platform: the same entry point with
the debugging memory map of the ZisK simulator. It links no libziskos.
--extlib with a .bflat.manifest path reads every *.bflat.manifest in that
directory, so the platform and the bindings come together. A guest that does
not use the accelerators can be built with the platform files alone.
tests/platform/run.sh runs the unit tests of the entry point under qemu-user.
Use bflat's ability to link to external libraries and provide the link to this repository, or reference the Nethermind.ZiskOS.Runtime NuGet package from a .NET project.
The release workflow signs the .nupkg before it publishes it. The build
job lists the package entries (scripts/sign_package.py list-nupkg). The
sign job, the reusable workflow sign.yml of bflat-riscv64, signs the lists
with the GitHub Actions secret BFLAT_SIGNING_KEY; it is the only job that
has the key, and it runs no build. The publish job adds the signatures
(scripts/sign_package.py embed) and checks them with the variable
BFLAT_SIGNING_PUBLIC_KEY. bflat refuses a package with a bad signature, and an
unsigned package unless --allow-unsigned is given. A local
.bflat.manifest is not checked. See docs/signing.md in bflat-riscv64.
scripts/sign_package.py is a copy of the script in bflat-riscv64; keep it
the same.
- Docker
- Git
- Bash
- Clone this repository:
git clone https://github.com/nethermindeth/bflat-libziskos.git
cd bflat-libziskos- Set the zisk version tag you want to build:
export ZISK_REF=v1.3.0-alpha- Run the build script:
./build/build.sh- Find the built artifacts in the
output/directory:
ls -lh output/The build process:
- Clones the zisk repository at the specified tag.
- Builds a Docker image based on
rustlang/rust:nightlywith the RISC-V cross-compilation toolchain (gcc-riscv64-linux-gnu,binutils-riscv64-linux-gnu) and therust-srccomponent for-Z build-std. - Applies
entrypoint.patchto the clonedziskos/entrypointcrate. The patch wraps_start,_zisk_main,memcpy,memmove, andmemcmpfor bflat-side wrap linkage, builds the unmangled_start/_zisk_mainentrypoints, replacessys_alloc_aligned, and exposesinline_bump_alloc_aligned. It also patcheslib-c/build.rsto skip the C++ library compilation for thezkvmtarget.build/secp256k1/secp256k1.patchthen routes zisklib'sk1·G + k2·P(used by ECDSA recovery) tostraus.rs: a windowed Straus-Shamir multiplication using signed radix-2^12 digits against positive-only tables of G and 2^128·G (g_tables.rs, generated bygen_tables.py). The accumulator handles equal points and infinity in place without replaying the walk. The patch also reads and writes the 32-byte big-endian values ofzkvm_secp256k1_ecrecoverwithld/sdandrev8instead of byte by byte.tests/secp256k1/run.shchecks it on the host against a plain Python recovery. - Adds the
no_entrypointfeature to the entrypoint crate so the static library can be linked into a host-provided entrypoint. - Builds the Rust library with Rust nightly using a custom RISC-V target specification (
riscv64imad-zisk-zkvm-elf) and-Z build-std=std,panic_abort. - Assembles system call wrappers from
src/zisk_syscalls/zisk_syscalls.Swithriscv64-linux-gnu-as --march=rv64ima --mabi=lp64. - Merges syscalls into
libziskos.ausingriscv64-linux-gnu-arandriscv64-linux-gnu-ranlib. - Emits the bflat manifest (
libziskos.bflat.manifest), injecting the resolved zisk commit hash asmetadata.zisk_ref_hashwhenjqis available.
The final libziskos.a contains:
- ziskos core functionality (precompiles, runtime)
- Direct system call wrappers for zkVM syscalls
Contributions are welcome! Please feel free to submit issues or pull requests.