Skip to content

NethermindEth/bflat-libziskos

Repository files navigation

libziskos for RISC-V 64-bit

Build and Release GitHub release GitHub downloads

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.

About

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.

Artifacts

Each release includes:

  • libziskos.a - static library with ziskos functionality (precompiles) and direct system call wrappers (zisk_syscalls.S assembled for rv64ima).
  • libziskos.bflat.manifest - bflat manifest describing the library, its target triple, and the resolved zisk commit hash. It also instructs bflat to wrap memcpy, memset, memmove, and memcmp.
  • Nethermind.ZiskOS.Runtime NuGet package - .NET runtime package that bundles libziskos.a and the manifest for consumption from managed projects.

Usage

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.

Building Locally

Prerequisites

  • Docker
  • Git
  • Bash

Build Instructions

  1. Clone this repository:
git clone https://github.com/nethermindeth/bflat-libziskos.git
cd bflat-libziskos
  1. Set the zisk version tag you want to build:
export ZISK_REF=v0.17.0
  1. Run the build script:
./build/build.sh
  1. Find the built artifacts in the output/ directory:
ls -lh output/

Build Details

The build process:

  1. Clones the zisk repository at the specified tag.
  2. Builds a Docker image based on rustlang/rust:nightly with the RISC-V cross-compilation toolchain (gcc-riscv64-linux-gnu, binutils-riscv64-linux-gnu) and the rust-src component for -Z build-std.
  3. Applies entrypoint.patch to the cloned ziskos/entrypoint crate. The patch wraps _start, _zisk_main, memcpy, memmove, and memcmp for bflat-side wrap linkage, builds the unmangled _start/_zisk_main entrypoints, replaces sys_alloc_aligned, and exposes inline_bump_alloc_aligned. It also patches lib-c/build.rs to skip the C++ library compilation for the zkvm target.
  4. Adds the no_entrypoint feature to the entrypoint crate so the static library can be linked into a host-provided entrypoint.
  5. 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.
  6. Assembles system call wrappers from src/zisk_syscalls/zisk_syscalls.S with riscv64-linux-gnu-as --march=rv64ima --mabi=lp64.
  7. Merges syscalls into libziskos.a using riscv64-linux-gnu-ar and riscv64-linux-gnu-ranlib.
  8. Emits the bflat manifest (libziskos.bflat.manifest), injecting the resolved zisk commit hash as zisk_ref_hash when jq is available.

The final libziskos.a contains:

  • ziskos core functionality (precompiles, runtime)
  • Direct system call wrappers for zkVM syscalls

Contributing

Contributions are welcome! Please feel free to submit issues or pull requests.

About

libziskos for riscv64 bflat

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors