EIP-8425 recovery proof

Run these commands from assets/eip-8425. The guest derives the account and binds the request to its seed. The verifier checks the proof and the state model installs the authorized code.

Build and run fast tests

On a clean checkout these tests check witness encoding, the public journal, recursion parameters, seal length and recovery state transitions. To exercise the guest and full STARK verifier, run the proof tests.

cargo +1.96.0 build --release --locked --manifest-path zk/host/Cargo.toml
prover=zk/host/target/release/eip8425
cargo +1.96.0 test --release --locked --manifest-path zk/host/Cargo.toml
python3 -m pip install 'eth-hash[pycryptodome]'
python3 -m unittest discover -p 'test_recovery.py' -v

Build the guest

The shared witness decoder uses slice::as_chunks, stabilized in Rust 1.88. The locked host and guest dependencies require at least Rust 1.90 through ruint 1.21.1. The host tests and benchmarks use Rust 1.96.0.

To reproduce the guest ELF, use the pinned builder on native or emulated Linux/amd64. It uses the RISC Zero Rust toolchain r0.1.97.0 and cargo-risczero 3.1.0. Check the ELF against the expected image ID.

docker buildx build --platform linux/amd64 \
  --output type=local,dest=zk/guest/elfs zk/guest
elf=zk/guest/elfs/eip8425-seed.elf
test "$("$prover" image-id "$elf")" = "$(cat zk/image-id.hex)"

ELF SHA-256 is 3ec52bf99ed042c6e9f5f80598bb609110eefc024d3387e665b2da628ee82aa6. The outer control ID list reproduces the pinned recursion set. The EIP specifies the claim encoding. RISC Zero documents the FRI parameters and security assumptions.

Full proof tests

Install r0vm with rzup install r0vm 3.1.0 and put it on PATH or set RISC0_SERVER_PATH to its executable. The generator uses the 16-byte seed and path m/0'/1 from BIP-32 test vector 1 to produce the 144-byte request and 222,668-byte proof for the public test case.

python3 generate_vector.py &&
"$prover" verify zk/vectors/bip32-vector-1-request.bin zk/vectors/bip32-vector-1-proof.bin &&
cargo +1.96.0 test --release --locked --manifest-path zk/host/Cargo.toml -- --include-ignored &&
python3 -m unittest discover -p 'test_recovery.py' -v

The verifier needs only the request and proof. It exits 0 on success, 2 for invalid input and 1 for a local error. Valid proof bytes may differ between runs for the same request.

For another account, pipe the output of witness.py to "$prover" prove "$elf" REQUEST_OUT PROOF_OUT. Supply the wallet’s actual full BIP-32 path with the required --path argument, for example --path "m/0'/1". Use --path m for the master key. The helper prompts privately for the BIP-39 mnemonic and passphrase. Use --raw-seed to enter the original BIP-32 seed in hex at the hidden prompt. The seed and path are private prover inputs. Share only the public request and proof.

The EIP reports prover measurements for the test vector and a depth-255 path, and verification timings for the test proof.

Assemble the recovery frame

The example below uses the locally generated BIP-32 test vector 1. The sponsor checks the chain ID and target, approves payment in an earlier frame and inserts the decoded recovery frame last in the EIP-8141 transaction.

python3 -m pip install 'rlp==4.1.0'
python3 - <<'PY'
from pathlib import Path
import rlp

request = Path("zk/vectors/bip32-vector-1-request.bin").read_bytes()
proof = Path("zk/vectors/bip32-vector-1-proof.bin").read_bytes()
assert len(request) == 144 and int.from_bytes(request[:32], "big") == 1
target = request[32:52]
assert target.hex() == "29379f45f515c494483298225d1b347f73d1babf"
frame = [7, 0, target, [2_100_000, 183_600], 0, request[52:] + proof]
Path("recover-frame.rlp").write_bytes(rlp.encode(frame))
PY