This crate contains several examples of Miden VM programs and demonstrates how these programs can be executed on Miden VM.
To run examples of executing programs and verifying proofs of their execution, do the following:
First, compile an optimized version of the miden
binary by running:
cargo build --release
Or, if you want to compile the with multi-threaded support enabled, run:
cargo build --release --manifest-path examples/Cargo.toml --features concurrent
In either case, the binary will be located in target/release
directory, and you can run it like so:
./target/release/miden [FLAGS] [OPTIONS] <SUBCOMMAND>
Where each example can be invoked using a distinct subcommand. To view the list of all available options and examples you can look up help like so:
./target/release/miden -h
This will print out something similar to this:
Miden 0.1.0
Miden examples
USAGE:
miden.exe [OPTIONS] <SUBCOMMAND>
FLAGS:
-h, --help Prints help information
-V, --version Prints version information
OPTIONS:
-s, --security <security> Security level for execution proofs generated by the VM [default: 96bits]
SUBCOMMANDS:
collatz Compute a Collatz sequence from the specified starting value
comparison If provided value is less than 9, multiplies it by 9; otherwise add 9 to it
conditional If provided value is 0, outputs 15; if provided value is 1, outputs 8
fib Compute a Fibonacci sequence of the specified length
help Prints this message or the help of the given subcommand(s)
merkle Computes a root of a randomly generated Merkle branch of the specified depth
range Determines how many of the randomly generated values are less than 2^63
Currently, the only available option for all examples is -s
for specifying security level for the generated proofs. This can be set to one of two values:
- 96bits - for 96-bit security level (the default).
- 128bits - for 128-bit security level.
For example, to execute Fibonacci calculator at 128-bit security level, you can run the following:
./target/release/miden -s 128bits fib
To view additional options available for specific examples, you can run the following:
./target/release/miden help <example name>
For example, executing:
./target/release/miden help collatz
Will print something like this:
miden.exe-collatz 0.1.0
Compute a Collatz sequence from the specified starting value
USAGE:
miden.exe collatz [OPTIONS]
FLAGS:
-h, --help Prints help information
-V, --version Prints version information
OPTIONS:
-n <start-value> Starting value of the Collatz sequence [default: 511]
Thus, to compute Collatz sequence with a different starting value, you could execute something like this:
./target/release/miden collatz -n 513
This project is MIT licensed.