Skip to main content

CLI Commands

In the hello world guide we executed leo run. This command runs several other Leo CLI commands before verifying a proof.

leo run

Step by step#

Let's walk through each command called by leo run and get a better understanding of what's happening under the hood. First, remove all build files with:

leo clean
console output:
Done Finished in 10 milliseconds

1. Build#

The leo build command compiles the program file main.leo. Leo will check program syntax and produce the circuit.

leo build

To avoid unnecessary future compilations, Leo creates a checksum at outputs/hello-world.sum. The outputs directory will store all files generated by the Leo CLI.

console output:
Compiling Starting...
Compiling Compiling main program... ("hello-world/src/main.leo")
Compiling Complete
Done Finished in 10 milliseconds

2. Setup#

The leo setup command generates a proving key at outputs/hello-world.lpk and a verifying key at outputs/hello-world.lvk.

leo setup
console output:
Setup Starting...
Setup Saving proving key ("hello-world/outputs/hello-world.lpk")
Setup Complete
Setup Saving verification key ("hello-world/outputs/hello-world.lvk")
Setup Complete
Done Finished in 10 milliseconds

3. Prove#

The leo prove command generates a proof at outputs/hello-world.proof using the inputs at inputs/hello-world.in and proving key at outputs/hello-world.lpk`.

leo prove
console output:
Setup Detected saved setup
Setup Loading proving key...
Setup Complete
Setup Loading verification key...
Setup Complete
Done Finished in 10 milliseconds
Proving Starting...
Proving Saving proof... ("hello-world/outputs/hello-world.proof")
Done Finished in 10 milliseconds

4. Verify#

The leo run command verifies the proof at outputs/hello-world.proof using the verifying key outputs/hello-world.lvk and outputs the verifier result to console.

leo run
console output:
Verifying Starting...
Verifying Proof is valid
Done Finished in 10 milliseconds

The leo run command will attempt to verify a proof only if all previous steps completed successfully. Under the hood, the Leo CLI will check for existing .sum, .lpk, .lvk, or .proof files in the outputs directory before running each command. This ensures that we don't run unnecessary commands.

5. Program Outputs#

The return value of the main function is stored in the program's output file outputs/hello-world.out

outputs/hello-world.out
[registers]
r0: u32 = 3;

Try editing the inputs in input/hello-world.in and then executing leo run. If you provided different input values to the program, then you should see different results written to the output registers. Be sure to run leo clean to delete the old checksum.

The Leo Language#

To learn more about how to use the Leo Language, start here.

The Leo CLI#

To learn more about how to use the Leo CLI, start here.