Keth is an open-source, proving backend for the Ethereum Execution Layer built with Kakarot Core EVM and Starkware's provable VM, Cairo.
Keth makes it possible to prove a given state transition asynchronously by:
For instance, this can be run for a given block to prove the Ethereum protocol's State Transition Function (STF).
The project uses uv to manage python dependencies and run commands. To install uv:
curl -LsSf https://astral.sh/uv/install.sh | sh
Moreover, the project uses rust to manage rust dependencies.
Everything is managed by uv, see the uv docs for the full documentation.
Apart from uv, you just need to copy the .env.example file to .env, making
sure to set the CAIRO_PATH environment variable to the path to the cairo
libraries. To have cairo-ls working, you need to source .env before even
opening your IDE. To avoid doing this manually, you can add the following to
your shell's rc file:
cd() {
builtin cd "$@" || return
if [ -f "$PWD/.env" ]; then
echo "Loading environment variables from $PWD/.env"
source "$PWD/.env"
fi
}
This will automatically source the .env file when you cd into a directory
containing it. You can also update this to load only when you enter the keth
directory.
Additionally, you can set the LOG_FORMAT environment variable to control the
output format of logs from the Rust components. Supported values are:
plain (default): Human-readable, colored log output.json: Structured JSON logging, useful to be stored.Keth provides two main CLI tools for different use cases.
First, you'll need to compile the Cairo programs.
uv run compile_keth
uv run keth)The main Keth CLI for generating execution traces and proofs for Ethereum blocks using STWO.
trace - Generate execution traces from Ethereum block data
main (run everything sequentially),
init, body, teardown, aggregator.prove - Generate STWO proofs from prover input files
verify - Verify generated proofs
e2e - End-to-end pipeline (trace + prove + verify)
generate-ar-inputs - Generate all prover inputs / Cairo PIEs for an
Applicative Recursion run.
# Generate a trace for block 22615247
uv run keth trace -b 22615247
# Run end-to-end pipeline with verification
uv run keth e2e -b 22615247 --verify
# Generate all AR Cairo PIEs for recursive proving
uv run keth generate-ar-inputs -b 22615247 --cairo-pie
uv run prove-cairo)A tool for running and proving arbitrary Cairo programs.
run-and-prove - Execute Cairo programs and generate proofs
uv run prove-cairo --compiled-program cairo/tests/programs/fibonacci.json --arguments 1,1,20000
To generate a proof for an Ethereum block, you'll need:
uv run compile_keth)# Generate proof for a specific block
uv run keth e2e -b <BLOCK_NUMBER>
# Or use the legacy prove-block script
uv run prove-block <BLOCK_NUMBER>
Run uv run keth --help for detailed command options and parameters.
For development-specific information including testing, profiling, and contributing guidelines, see docs/development.md.
Coming soon 🏗️.
Keth is a work in progress (WIP ⚠️) and as such is not suitable for production.
Cairo
51.0%
Python
39.5%
Rust
9.0%
Keth is an open-source, proving backend for the Ethereum Execution Layer built with Kakarot Core EVM and Starkware's provable VM, Cairo.
Keth makes it possible to prove a given state transition asynchronously by:
For instance, this can be run for a given block to prove the Ethereum protocol's State Transition Function (STF).
The project uses uv to manage python dependencies and run commands. To install uv:
curl -LsSf https://astral.sh/uv/install.sh | sh
Moreover, the project uses rust to manage rust dependencies.
Everything is managed by uv, see the uv docs for the full documentation.
Apart from uv, you just need to copy the .env.example file to .env, making
sure to set the CAIRO_PATH environment variable to the path to the cairo
libraries. To have cairo-ls working, you need to source .env before even
opening your IDE. To avoid doing this manually, you can add the following to
your shell's rc file:
cd() {
builtin cd "$@" || return
if [ -f "$PWD/.env" ]; then
echo "Loading environment variables from $PWD/.env"
source "$PWD/.env"
fi
}
This will automatically source the .env file when you cd into a directory
containing it. You can also update this to load only when you enter the keth
directory.
Additionally, you can set the LOG_FORMAT environment variable to control the
output format of logs from the Rust components. Supported values are:
plain (default): Human-readable, colored log output.json: Structured JSON logging, useful to be stored.Keth provides two main CLI tools for different use cases.
First, you'll need to compile the Cairo programs.
uv run compile_keth
uv run keth)The main Keth CLI for generating execution traces and proofs for Ethereum blocks using STWO.
trace - Generate execution traces from Ethereum block data
main (run everything sequentially),
init, body, teardown, aggregator.prove - Generate STWO proofs from prover input files
verify - Verify generated proofs
e2e - End-to-end pipeline (trace + prove + verify)
generate-ar-inputs - Generate all prover inputs / Cairo PIEs for an
Applicative Recursion run.
# Generate a trace for block 22615247
uv run keth trace -b 22615247
# Run end-to-end pipeline with verification
uv run keth e2e -b 22615247 --verify
# Generate all AR Cairo PIEs for recursive proving
uv run keth generate-ar-inputs -b 22615247 --cairo-pie
uv run prove-cairo)A tool for running and proving arbitrary Cairo programs.
run-and-prove - Execute Cairo programs and generate proofs
uv run prove-cairo --compiled-program cairo/tests/programs/fibonacci.json --arguments 1,1,20000
To generate a proof for an Ethereum block, you'll need:
uv run compile_keth)# Generate proof for a specific block
uv run keth e2e -b <BLOCK_NUMBER>
# Or use the legacy prove-block script
uv run prove-block <BLOCK_NUMBER>
Run uv run keth --help for detailed command options and parameters.
For development-specific information including testing, profiling, and contributing guidelines, see docs/development.md.
Coming soon 🏗️.
Keth is a work in progress (WIP ⚠️) and as such is not suitable for production.
Cairo
51.0%
Python
39.5%
Rust
9.0%