Getting Started with LLVM-Valida
Welcome to LLVM-Valida! This guide will walk you through the process of setting up and using LLVM-Valida, a compiler backend for the Valida Virtual Machine. LLVM-Valida allows you to compile programs written in languages like C, with planned support for C++ and Rust, for execution on the Valida VM, a STARK-based virtual machine designed for efficient zero-knowledge proofs.
Supported Operating Systems
LLVM-Valida is currently tested and known to work on the following operating systems:
Ubuntu 22.04.3 LTS
Arch Linux
Download
Grab the latest binary release from GitHub:
Extract the archive:
Usage
Once you have the binaries, you can compile, run, prove, and verify programs for the Valida VM using the following steps:
Compile your program: Replace
<your-program.c>
with the path to your C source file.Link your program and get the `.out` file:
Run your program on Valida and write the program log to a `.log` file:
Prove your program on Valida and write the proof to a `.proof` file:
Verify the proof of your program on Valida:
Example
The following is a simple Fibonacci test written in C that checks if the 6th Fibonacci number is 8 and returns nonzero if not:
Compile the source file with the LLVM-Valida clang compiler:
Link the object file:
Generate a proof:
Verify the proof:
Valida should output "Proof verified" on successful verification.
Building From Source
Prerequisites
Before you begin, ensure you have the following prerequisites installed on your system:
git
cmake
(version 3.22.1 or later)ninja
(version 1.10.1 or later)clang
(LLVM's C compiler)lld
(LLVM's linker)libstdc++-12-dev
Build
Follow these steps to build the Valida virtual machine:
Contributing
We welcome contributions to LLVM-Valida! To contribute, follow these steps:
Open a Pull Request (PR): Fork the repository, make your changes, and open a PR.
Get Approval: Get at least one approval from another maintainer.
Ensure Compliance:
Make sure your code compiles.
Ensure all tests pass.
Add tests when possible and include them in the test script (
run-valida-tests.sh
).
Formatting: Keep the code formatting consistent using
clang-format
. Activate the pre-commit hook or rungit clang-format
before committing.
Additional Resources
Last updated