> For the complete documentation index, see [llms.txt](https://o1js-blobstream.gitbook.io/o1js-blobstream/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://o1js-blobstream.gitbook.io/o1js-blobstream/system-flow/sp1-based-blobstream-x/generate-sp1-proofs.md).

# Generate SP1 proofs

### Overview

To generate these proofs, the developer must use the [`blob-stream-inclusion`](https://github.com/geometers/blob-stream-inclusion) repository which contains the associated program code. These programs must be compiled using the SP1 Rust toolchain.&#x20;

The compiled programs, along with the required inputs, can then be sent to the SP1 prover network which will generate the requested proofs. This takes roughly 10 - 15 minutes per proof. While these proofs may be generated locally, doing so requires a very large amount of system memory (about 128 GB) which may be prohibitive to most developers.

The result should be a `proof-with-pis.json` file for each proof (the blobstream and blob inclusion proofs).

### SP1 blobstream proof

To run the default example, start from the base of the `blob-stream-inclusion` repo and execute the following.

```
cd blobstream/script && \
cargo run --release -- \
    --trusted-block=1865870 
    --target-block=1865890
```

The output should look something like this:

```
   Compiling blobstream-script v0.1.0 (/Users/grjte/src/geometry/mina-celestia/blob-stream-inclusion/blobstream/script)
warning: blobstream-script@0.1.0: blobstream-program built at 2024-07-25 16:23:55
    Finished `release` profile [optimized] target(s) in 11.87s
     Running `target/release/prove --trusted-block=1865870 --target-block=1865890`
Fetching light blocks in range: 1865870 to 1865890
Finished fetching light blocks!
Successfully generated proof!
Running blobstream prove_plonk() took 912 seconds.
[sp1] plonk bn254 artifacts already seem to exist at /Users/grjte/.sp1/circuits/plonk_bn254/v1.0.1. if you want to re-download them, delete the directory
ignoring uninitialized slice: Vars []frontend.Variable
ignoring uninitialized slice: Vars []frontend.Variable
ignoring uninitialized slice: Vars []frontend.Variable
15:39:29 DBG verifier done backend=plonk curve=bn254 took=2.180875
```

#### Proving arbitrary blocks

You can run this proof for different target blocks or starting from a different trusted block number by modifying the command:

```
cd blobstream/script && \
cargo run --release -- \
    --trusted-block=<TRUSTED_BLOCK_NUMBER>
    --target-block=<TARGET_BLOCK_NUMBER>
```

### SP1 blob inclusion proof

Start from the base of the `blob-stream-inclusion` repo.&#x20;

The blob(s) for which you will prove inclusion are specified in `blob_inclusion/script/requests.json` along with their block numbers. Before you can generate the inclusion proof, your light node (or the 3rd-party RPC you specify) must have synced past the specified block(s).&#x20;

For the default example in the repo, the specified blob is in block is `1865877`. You can check the sync status of your light node using the [Celestia-node RPC CLI](https://docs.celestia.org/developers/node-tutorial).

To run the default example, execute the following:

<pre><code>cd blob_inclusion/script &#x26;&#x26; \
cargo run --release -- \
    --start-height=1865870 \
    --end-height=1865890 \
<strong>    --num-requests=1 \
</strong>    --request-path=requests.json
</code></pre>

The output should look something like this:

```
warning: patch for `nmt-rs` uses the features mechanism. default-features and features will not take effect because the patch dependency does not support this mechanism
   Compiling blob-inclusion-script v0.1.0 (/Users/grjte/src/geometry/mina-celestia/blob-stream-inclusion/blob_inclusion/script)
warning: blob-inclusion-script@0.1.0: blob-inclusion-program built at 2024-07-25 16:30:38
    Finished `release` profile [optimized] target(s) in 16.70s
     Running `target/release/prove --start-height=1865870 --end-height=1865890 --num-requests=1 --request-path=requests.json`
Fetching light blocks in range: 1865870 to 1865890
Finished fetching light blocks!
Successfully generated proof!
Running blob_inclusion prove_plonk() took 780 seconds.
[sp1] plonk bn254 artifacts already seem to exist at /Users/grjte/.sp1/circuits/plonk_bn254/v1.0.1. if you want to re-download them, delete the directory
ignoring uninitialized slice: Vars []frontend.Variable
ignoring uninitialized slice: Vars []frontend.Variable
ignoring uninitialized slice: Vars []frontend.Variable
15:44:03 DBG verifier done backend=plonk curve=bn254 took=2.053542
```

#### Proving arbitrary blobs

You can run the proof for different blobs by editing `blob_inclusion/script/requests.json` and modifying the following command. `NUM_REQUESTED_BLOBS` should match the number of blobs specified in the `requests.json` file.

```
cd blob_inclusion/script && \
cargo run --release -- \
    --start-height=<TRUSTED_BLOCK_NUMBER> \
    --end-height=<TARGET_BLOCK_NUMBER> \
    --num-requests=<NUM_REQUESTED_BLOBS> \
    --request-path=requests.json
```

*NOTE: In order to verify these proofs inside the provided example Mina contracts, the blob size must be 212 bytes.*
