# Usage

Before you can use Miden VM, you'll need to make sure you have Rust installed. Miden VM v0.2 requires Rust version 1.62 or greater.

Miden VM consists of several crates, each of which exposes a small set of functionality. The most notable of these crates are:

• miden-processor, which can be used to execute Miden VM programs.
• miden-prover, which can be used to execute Miden VM programs and generate proofs of their execution.
• miden-verifier, which can be used to verify proofs of program execution generated by Miden VM prover.

The above functionality is also exposed via the single miden crate, which also provides a CLI interface for interacting with Miden VM.

## CLI interface​

### Compiling Miden VM​

To compile Miden VM into a binary, you can run the following command:

cargo build --release --features executable

This will place miden executable in the ./target/release directory.

By default, the executable will be compiled in the single-threaded mode. If you would like to enable multi-threaded proof generation, you can compile Miden VM using the following command:

cargo build --release --features "executable concurrent"

### Controlling parallelism​

Internally, Miden VM uses Rayon for parallel computations. To control the number of threads used to generate a STARK proof, you can use RAYON_NUM_THREADS environment variable.

### Running Miden VM​

Once the executable has been compiled, you can run Miden VM like so:

./target/release/miden [subcommand] [parameters]

Currently, Miden VM can be executed with the following subcommands:

• run - this will execute a Miden assembly program and output the result, but will not generate a proof of execution.
• prove - this will execute a Miden assembly program, and will also generate a STARK proof of execution.
• verify - this will verify a previously generated proof of execution for a given program.
• compile - this will compile a Miden assembly program (i.e., build a program MAST) and outputs stats about the compilation process.
• analyze - this will run a Miden assembly program against specific inputs and will output stats about its execution.

All of the above subcommands require various parameters to be provided. To get more detailed help on what is needed for a given subcommand, you can run the following:

./target/release/miden [subcommand] --help

For example:

./target/release/miden prove --help

### Fibonacci example​

In the miden/examples/fib directory, we provide a very simple Fibonacci calculator example. This example computes the 1000th term of the Fibonacci sequence. You can execute this example on Miden VM like so:

./target/release/miden run -a miden/examples/fib/fib.masm -n 1

This will run the example code to completion and will output the top element remaining on the stack.