Lean 4.35.0 Kernel · leanrust-core-1 · HottubHTTP + HottubDB

Check Rust with the Lean 4 kernel.

LeanRust extracts a total fragment of Rust into machine-checked Lean 4.35.0 theorems — proving functional #[ensures] specifications and Volpano–Smith–Irvine Confidentiality & Integrity noninterference. Either the kernel accepts the proof, or there is no certificate.

Lean 4.35.0 Kernel-checked proofs · zero sorry
2-Lattice IFC Secrecy × Integrity noninterference
Rust + WASM Real leanrust-core running in this tab
HottubHTTP + DB Served by LeanRust-verified code on AWS

Live LeanRust Extractor (Rust → Lean 4 in WASM)

Loading leanrust_bg.wasm…

CERTIFIED

          
          
        
What "Unhackable" Means

Two machine-checked theorems — and an honest split

A function marked #[unhackable] requires a functional spec, a noninterference proof, or both. Programs with no secret and no trusted cell are refused — there is nothing there to protect.

Theorem 1 · Functional Spec

Unhackable cmd pre post

Every initial store satisfying pre (including exact integer type width bounds uint8..uint64, int32..int64, bit) evaluates to a final store satisfying every #[ensures] clause.

Used for authorization logic like withdraw where an untrusted caller legitimately influences a trusted balance under strict preconditions.

def Unhackable (c : Cmd)
    (pre : Store → Prop)
    (post : Store → Store → Prop) : Prop :=
  ∀ s, pre s → post s (evalCmd c s)
Theorem 2 · Information Flow

Noninterfering v Γ cmd

Proved once in LeanRust.Soundness.ni_soundness from the Volpano–Smith–Irvine rule pc ⊔ label(expr) ≤ label(cell) across branches and counted loop trip counts.

One proof covers both views: secret cells never influence public outputs (confidentiality), and tainted inputs never alter trusted state (integrity).

theorem ni_soundness {v : View} {Γ : Context}
    {pc : Label} {c : Cmd} (h : TypedCmd Γ pc c) :
    ∀ {s1 s2}, viewEq v Γ s1 s2 →
      viewEq v Γ (evalCmd c s1) (evalCmd c s2)
Certified Rust in Production

From tiny vaults to the web server serving this page

LeanRust attributes erase at compile time with zero runtime overhead. Run leanrust prove to generate Prove.lean, build the Lean 4.35.0 kernel, and mint a fingerprinted certificate.

Authorization spec vs. strict noninterference

In examples/vault, withdraw rejects strict noninterference because the tainted caller controls whether the trusted account.balance changes. LeanRust still proves all 7 authorization clauses (owner check, no overdraw, immutable key & owner).

Meanwhile quoted_balance proves both its spec and full Confidentiality + Integrity noninterference — mathematically guaranteeing the secret key can never leak into the return value.

examples/vault/src/lib.rsfnv1a64:b487c15670f11b89
#[derive(leanrust::Labels)]
pub struct Account {
    #[label(secret, trusted)] pub key: u64,
    #[label(trusted)]         pub balance: u64,
    #[label(trusted)]         pub owner: u64,
}

#[unhackable]
#[ensures("caller != old(account.owner) -> result.balance == old(account.balance)")]
#[ensures("caller == old(account.owner) && old(account.balance) >= amount
           -> result.balance == old(account.balance) - amount")]
#[input(account, trusted)]
pub fn withdraw(mut account: Account, amount: u64, caller: u64) -> Account

Total counted loops with Lean 4 induction

while and unbounded loop are excluded so evaluation stays a total function in Lean. Counted loops for i in 0..bound carry invariant!("..."), which LeanRust lowers into a full Nat induction proof using evalFor_step.

The loop trip count is treated as an implicit flow: the body executes at pc ⊔ label(bound), blocking secret-length loop leaks automatically.

examples/count/src/lib.rsfnv1a64:b3e1e3971373aaf9
#[unhackable]
#[noninterference]
#[trusted]
#[ensures("result == old(acc) + old(n)")]
#[input(acc, trusted)]
#[input(n, trusted)]
pub fn add_n(mut acc: u64, n: u64) -> u64 {
    for i in 0..n {
        invariant!("acc == old(acc) + i");
        acc += 1;
    }
    acc
}

Serving leanrust.com live on HottubHTTP + HottubDB

This website is served on AWS Graviton ARM64 by HottubHTTP — an Apache-compatible Rust+WASM server whose 12 core decision kernels (anti-CVE-2021-41773 path confinement, RFC 9112 CL+TE anti-smuggling, MPM bounds, Range DoS defense, and /server-status secret isolation) are certified by LeanRust itself.

Certificate records are stored in HottubDB — a zero-dependency, BLAKE3 hash-chained Rust+WASM database running natively on the AWS host and inside your browser tab.

Verify locally in secondsLean 4.35.0 + Cargo
cargo build
cargo run -p leanrust-cli -- check examples/vault/src/lib.rs
cargo run -p leanrust-cli -- prove examples/vault/src/lib.rs
cargo run -p leanrust-cli -- prove examples/count/src/lib.rs
lake build  # verify LeanRust.Soundness & reference proofs
Tamper-Evident Certificate Registry

Live HottubDB BLAKE3 Proof Ledger

Every certified LeanRust program is committed to an append-only HottubDB log with dual CRC-32C checksums and cryptographic BLAKE3 commit chaining.

Connecting to HottubDB…
Verifying BLAKE3 commit chain… Inspect full AWS ledger & telemetry →
Trusted Computing Base

What is proved — and what is explicitly not

Real formal verification states its assumptions plainly. The generated target/leanrust/Prove.lean is the exact model the Lean 4.35.0 kernel checks. Read it.

Inside the Trusted Computing Base

  • The Lean 4.35.0 kernel checking every generated theorem with zero sorry.
  • LeanRust.Soundness: machine-checked confinement and noninterference soundness across branches and counted loops.
  • The leanrust-core-1 extractor lowering Rust ASTs into target/leanrust/Prove.lean.
  • Your #[ensures] clauses and trusted input labels, which define the security claim.

Explicitly Outside the Proof

  • Code outside leanrust-core-1: while/loop, heap allocation, aliasing references, nested structs, bitwise ops, unsafe, and external calls.
  • rustc, LLVM, the OS, and hardware below the source model.
  • Timing side channels: big-step semantics observes the final store, not wall-clock execution time.
  • Wrapping machine arithmetic: inputs carry exact width bounds (u8..u64, i32..i64), but operations model mathematical integers.
  • declassify and endorse: rejected statically; there is no uncertified downgrade.