> For the complete documentation index, see [llms.txt](https://thias-organization.gitbook.io/p256-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://thias-organization.gitbook.io/p256-documentation/zero-knowledge-proofs/risc-zero.md).

# RISC Zero

The following assumes some basic knowledge about RISC Zero and what it does

## RISC Zero zkVM

But first, why do we want to use zkVM?

* zkVM lets us generate zero knowledge proofs of computational correctness for Rust programs, while maintaining full privacy of the input data
* zkVM allows us to build a ZK application without having to build a circuit and without writing in a custom language
* leverages the maturity of the Rust ecosystem

## Guest Code

In RISC Zero, code written in the [guest program](https://dev.risczero.com/api/zkvm/guest-code-101) is the code that will be executed and proven by the zkVM.&#x20;

To prove the correct execution of the guest program:

1. The [guest program](https://dev.risczero.com/api/zkvm/guest-code-101) is compiled to an [ELF binary](https://dev.risczero.com/terminology#elf-binary).
2. The [executor](https://dev.risczero.com/terminology#executor) runs the [ELF binary](https://dev.risczero.com/terminology#elf-binary) and records the [session](https://dev.risczero.com/terminology#session).
3. The [prover](https://dev.risczero.com/terminology#prover) checks and proves the validity of the [session](https://dev.risczero.com/terminology#session), outputting a [receipt](https://dev.risczero.com/api/zkvm/receipts).

## Receipt

A [receipt](https://dev.risczero.com/terminology#receipt) gives the results of the guest program along with proof that they were produced honestly. Receipts can be passed to third parties and [verified](https://dev.risczero.com/terminology#verify) in order to cryptographically attest to the validity of the application's output.

The receipt consists of a [journal](https://dev.risczero.com/terminology#journal) and a [seal](https://dev.risczero.com/terminology#seal). The journal attests to the public outputs of the program, and the seal is the opaque blob that cryptographically attests to the validity of the receipt.

## A high level idea of how ZKP works in zkVM

To have a ZKP that the guest code is executed correctly, it is first converted into binary code.&#x20;

For each operation, the executor executes the binary and generates a trace. After executing the program, all of the traces are sent to the prover.&#x20;

The prover constructs a ZKP for each operation in the trace to proof that each execution is correct. Finally, all the proofs are aggregated by the prover and the prover sends a single proof as a receipt for verification.

## STARK Protocol

RISC Zero's [receipts](https://docs.rs/risc0-zkvm/*/risc0_zkvm/struct.Receipt.html) are built on the shoulders of several recent advances in the world of zero-knowledge cryptography. The core of the proof system is [STARK](https://dev.risczero.com/reference-docs/about-starks)-based.

This proof system is used to generate zero-knowledge validity proofs for RISC Zero's RISC-V circuit and RISC Zero's recursion circuit.

### Resources

* [RISC Zero STARK Protocol](https://dev.risczero.com/proof-system/proof-system-sequence-diagram)
* [STARK by Hand](https://dev.risczero.com/proof-system/stark-by-hand)
* [RISC Zero ZKP White Paper](https://dev.risczero.com/proof-system-in-detail.pdf)
