Note that
ziggy-starkdust
is still experimental. Breaking changes will be made before the first stable release. The library is also NOT audited or reviewed for security at the moment. Use at your own risk.
Alternatively, if you have nix installed, you can get the full development environment nix develop
.
👇 ⚡ Zig
zig build
You can display the help message by running:
./zig-out/bin/ziggy-starkdust --help
./zig-out/bin/ziggy-starkdust execute --filename cairo-programs/fibonacci.json --proof-mode=false
Run all tests:
zig build test
Run all tests with test summary:
zig build test --summary all
Run a single test, for example, the "Felt252 zero" test:
$ zig test --test-filter "Felt252 zero" src/tests.zig
All 2 tests passed.
Notice that 2 tests passed despite running only 1 test, because
our tests are wrapped in another test call within src/tests.zig
.
For security guidelines, please refer to SECURITY.md.
We are using the OpenSSF Scorecard to track the security of this project.
Scorecard assesses open source projects for security risks through a series of automated checks.
You can see the current scorecard for this project here.
- The structure of the project and some initial code related to prime field functions is based on verkle-cryto repository by jsign.
- The design of the Cairo VM is inspired by Cairo VM in Rust and Cairo VM in Go by lambdaclass.
- Some cryptographic primitive code generation has been done using the amazing fiat-crypto by mit-plv.
- sig has been a great source of inspiration for the project structure and the way to use Zig.
- nektro for the zig-time library.
👇 ⚡
Choosing Zig for a third implementation of the Cairo VM brings several advantages, offering a unique blend of features not entirely covered by the existing Rust and Go implementations.
Zig aims for simplicity and clarity, enabling developers to read and understand the code quickly. It omits certain features like classes and exceptions to keep the language simple, which can be particularly useful for a VM where performance and maintainability are key.
Zig compiles to highly efficient native code, similar to Rust, making it an excellent choice for computationally-intensive tasks. The language's design gives the programmer direct control over memory and CPU, without unnecessary abstractions.
Zig provides an environment where you have explicit control over memory allocation, similar to C and C++. While this does mean you're responsible for managing memory yourself, Zig offers certain safety features to catch common errors, like undefined behavior, during compile time or by providing runtime checks. This approach allows for a blend of performance and safety, making it a suitable choice for a VM where you often need fine-grained control.
Zig offers first-class C interoperability without requiring any bindings or wrappers. This feature can be a game-changer for integrating with existing technologies.
Zig's comptime (compile-time) features offer powerful metaprogramming capabilities. This allows for expressive yet efficient code, as you can generate specialized routines at compile-time, reducing the need for runtime polymorphism.
Zig aims to reduce dependencies to a minimum, which could simplify the deployment and distribution of Cairo VM. This is particularly advantageous for systems that require high-reliability or have limited resources.
Although younger than Rust and Go, Zig's community is enthusiastic and rapidly growing. Adopting Zig at this stage means you can be a significant contributor to its ecosystem.
By choosing Zig for the third implementation of Cairo VM, we aim to leverage these features to build a high-performance, reliable, and maintainable virtual machine.
This project is licensed under the MIT license.
See LICENSE for more information.
Happy coding! 🎉
Thanks goes to these wonderful people (emoji key):
Abdel @ StarkWare 💻 |
bing 💻 |
Francesco Ceccon 💻 |
Thomas Coratger 💻 |
lambda-0x 💻 |
Nils 💻 |
johann bestowrous 💻 |
lanaivina 💻 |
This project follows the all-contributors specification. Contributions of any kind welcome!