
Product
Socket Zero Introduces Automated Remediation PRs
Put vulnerability remediation on autopilot with automated security patches and intelligent dependency upgrades across your GitHub repositories.
github.com/0xPolygonMiden/miden-vm
Advanced tools
A STARK-based virtual machine.
WARNING: This project is in an alpha stage. It has not been audited and may contain bugs and security flaws. This implementation is NOT ready for production use.
WARNING: For no_std, only the wasm32-unknown-unknown and wasm32-wasip1 targets are officially supported.
Miden VM is a zero-knowledge virtual machine written in Rust. For any program executed on Miden VM, a STARK-based proof of execution can be automatically generated. This proof can then be used by anyone to verify that the program was executed correctly without the need for re-executing the program or even knowing the contents of the program.
The Miden VM uses Plonky3 as the proving system, although with some modifications. See the p3-miden repository for more information.
In the latest stable release, most of the core features of the VM have been stabilized, and most of the STARK proof generation has been implemented. We are still making changes to the VM internals and external interfaces, so you should expect some breaking changes with each new release.
The next version of the VM is being developed in the next branch; see the changelog for changes made in the currently unreleased version, and every past release.
Miden VM is a fully-featured virtual machine. Despite being optimized for zero-knowledge proof generation, it provides all the features one would expect from a regular VM. To highlight a few:
miden-core-lib which adds support for such things as 64-bit unsigned integers. Developers can build other similar libraries to extend the VM's functionality in ways which fit their use cases.In the coming months we plan to finalize the design of the VM and implement support for the following features:
Miden VM is written in pure Rust and can be compiled to WebAssembly. Rust's std standard library is linked by default for most crates. To compile to one of the two wasm32 supported targets, use cargo's --no-default-features flag to ensure Rust's standard library isn't linked (*i.e. compiling in no_std).
This workspace's .cargo/config.toml sets -C target-feature=+simd128 for the wasm32-unknown-unknown target, enabling Plonky3's SIMD128 backend for faster hashing (Blake3, Poseidon2) in WASM. Cargo only applies .cargo/config.toml to builds run from this workspace (or a directory nested under it); downstream consumers building Miden as a dependency (e.g. via web-sdk) must set this flag themselves, for example with RUSTFLAGS="-C target-feature=+simd128" or their own .cargo/config.toml, to get the same speedup.
When compiled with the concurrent feature enabled, the prover will generate STARK proofs using multiple threads. For the benefits of concurrent proof generation, check out benchmarks below.
Internally, we use rayon for parallel computations. Hence, to control the number of threads used to generate a STARK proof, you can use RAYON_NUM_THREADS environment variable.
The project is organized into several crates like so:
| Crate | Description |
|---|---|
| core | Contains components defining the Miden VM instruction set, program structure, and a set of utility functions used by other crates. |
| assembly | Contains the Miden assembler. The assembler is used to compile Miden assembly source code into Miden VM programs. |
| processor | Contains the Miden VM processor. The processor is used to execute Miden programs and to generate program execution traces. These traces are then used by the Miden prover to generate proofs of correct program execution. |
| air | Contains algebraic intermediate representation (AIR) of Miden VM processor logic. This AIR is used by the VM during proof generation and verification. |
| prover | Contains the Miden VM prover. The prover is used to generate STARK proofs attesting to correct execution of Miden VM programs. Internally, the prover uses Miden processor to execute programs and generate the execution traces. |
| verifier | Contains a light-weight verifier which can be used to verify proofs of program execution generated by the Miden VM. |
| miden-vm | Aggregates functionality exposed by Miden VM processor, prover, and verifier in a single place, and also provides a CLI interface for the Miden VM. |
| core-lib | Contains the Miden core assembly library. The goal of Miden core library is to provide highly-optimized and battle-tested implementations of commonly-used primitives. |
| test-utils | Contains utilities for testing execution of Miden VM programs. |
The documentation in the docs/ folder is built using Docusaurus and is automatically absorbed into the main miden-docs repository for the main documentation website. Changes to the next branch trigger an automated deployment workflow. The docs folder requires npm packages to be installed before building.
The benchmarks below should be viewed only as a rough guide for expected future performance. The reasons that many optimizations have not been applied yet, and we expect that there will be some speedup once we dedicate some time to performance optimizations.
A few general notes on performance:
To refresh the Blake3 results below, run the same Criterion benchmark used by CI:
RAYON_NUM_THREADS=16 cargo run --profile optimized -p miden-vm-blake3-bench --bin blake3-nonregression -- run \
--repo-root . \
--output-dir target/blake3-nonregression \
--rayon-num-threads 16 \
--sample-size 10 \
--light-sample-size 100 \
--measurement-time-secs 1 \
--warm-up-time-secs 1 \
--bench-axes all \
--git-ref "$(git rev-parse HEAD)"
The result is written to target/blake3-nonregression/result.json; the harness does not parse the miden-vm run or miden-vm prove text output. The benchmark records execute_trace_inputs_sync, build_trace, prove_trace_sync, and e2e_prove. The e2e_prove metric runs execution and trace generation on each sample, but only measures the prover span. The harness also proves and verifies the program once before timing proof-heavy axes.
When executed on a single CPU core, the current version of Miden VM operates at around 20 - 25 KHz. In the benchmarks below, the VM executes a Blake3 example program on Apple M4 Max CPU in a single thread. The generated proofs have a target security level of 96 bits.
| VM cycles | Execution time | Proving time | RAM consumed | Proof size |
|---|---|---|---|---|
| 214 | 0.3 ms | 885 ms | 200 MB | 80 KB |
| 216 | 0.7 ms | 3.6 sec | 750 MB | 100 KB |
| 218 | 1.2 ms | 14.7 sec | 2.9 GB | 116 KB |
| 220 | 6 ms | 59 sec | 11 GB | 136 KB |
As can be seen from the above, proving time roughly doubles with every doubling in the number of cycles, but proof size grows much slower.
STARK proof generation is massively parallelizable. Thus, by taking advantage of multiple CPU cores we can dramatically reduce proof generation time. For example, when executed on an 16-core CPU (Apple M4 Max), the current version of Miden VM operates at around 170 KHz. And when executed on a 64-core CPU (Amazon Graviton 4), the VM operates at around 200 KHz.
In the benchmarks below, the VM executes the same Blake3 example program for 220 cycles at 96-bit target security level:
| Machine | Execution time | Proving time | Execution % | Implied Frequency |
|---|---|---|---|---|
| Apple M1 Pro (16 threads) | 9 ms | 14.2 sec | 0.1% | 70 KHz |
| Apple M4 Max (16 threads) | 6 ms | 5.9 sec | 0.2% | 170 KHz |
| Amazon Graviton 4 (64 threads) | 11 ms | 4.9 sec | 0.2% | 205 KHz |
| AMD EPYC 9R45 (64 threads) | 7.5 ms | 3.7 sec | 0.2% | 270 KHz |
| AMD Ryzen 9 9950X (16 threads) | 7.2 ms | 7.2 sec | 0.1% | 145 KHz |
| AMD Ryzen 9 9950X (32 threads) | 6.5 ms | 6.5 sec | 0.1% | 161 KHz |
Proofs in the above benchmarks are generated using BLAKE3 hash function. While this hash function is very fast, it is not very efficient to execute in Miden VM. Thus, proofs generated using BLAKE3 are not well-suited for recursive proof verification. To support efficient recursive proofs, we need to use an arithmetization-friendly hash function. Miden VM natively supports Poseidon2, which is one such hash function. One of the downsides of arithmetization-friendly hash functions is that they are noticeably slower than regular hash functions.
In the benchmarks below we execute the same Blake3 example program for 220 cycles at 96-bit target security level using Poseidon2 hash function instead of BLAKE3:
| Machine | Execution time | Proving time | Slowdown vs BLAKE3 |
|---|---|---|---|
| Apple M1 Pro (16 threads) | 9 ms | 25.5 sec | 1.8x |
| Apple M4 Max (16 threads) | 6 ms | 10.1 sec | 1.7x |
| Amazon Graviton 4 (64 threads) | 11 ms | 7.7 sec | 1.6x |
| AMD EPYC 9R45 (64 threads) | 7.5 ms | 6.9 sec | 1.9x |
| AMD Ryzen 9 9950X (16 threads) | 7.2 ms | 16.0 sec | 2.2x |
| AMD Ryzen 9 9950X (32 threads) | 6.5 ms | 12.9 sec | 2.0x |
Proofs of execution generated by Miden VM are based on STARKs. A STARK is a novel proof-of-computation scheme that allows you to create an efficiently verifiable proof that a computation was executed correctly. The scheme was developed by Eli Ben-Sasson, Michael Riabzev et al. at Technion - Israel Institute of Technology. STARKs do not require an initial trusted setup, and rely on very few cryptographic assumptions.
Here are some resources to learn more about STARKs:
Vitalik Buterin's blog series on zk-STARKs:
Alan Szepieniec's STARK tutorials:
StarkWare's STARK Math blog series:
StarkWare's STARK tutorial:
Any contribution intentionally submitted for inclusion in this repository, as defined in the Apache-2.0 license, shall be dual licensed under the MIT and Apache 2.0 licenses, without any additional terms or conditions.
FAQs
Unknown package

Product
Put vulnerability remediation on autopilot with automated security patches and intelligent dependency upgrades across your GitHub repositories.

Product
Socket Zero automates vulnerability remediation with upgrades and targeted patches, including fixes for 100% of known, patchable RubyGems CVEs.

Product
Explore Socket’s redesigned Alerts UI, multi-branch repository monitoring, and new tools for resolving findings, searching scans, and filtering security alerts.