Skip to content
Lean Key
Safety

Trust boundaries

Exactly what the Lean proofs cover, what is only tested, and what you have to trust, including the devnet upgrade authority.

Lean Key's program is written in Lean and comes with 51 theorems that Lean's kernel checks. That is a strong statement about some things and no statement at all about others. This page draws the line. Lean Key is an unaudited beta.

Summary

PartStatus
WOTS+ specification: completeness, cost, no forgery by walking forwardProven (program/Twokey/Proofs/Wots.lean)
A state-machine model of the program: both keys required, intent binding, rotation, conservation, rent, no reopening, no admin pathProven about the model (program/Twokey/Proofs/Machine.lean)
The program's Lean source: every withdrawal handler checks the owner's signature, the vault's program ownership and the stored ownerProven about the Lean definitions, under lean-svm's model of the machine (program/Twokey/Proofs/Code.lean)
The program's WOTS+ verifier equals the specificationTested with test vectors computed by Lean, not proven
The program behaves as the modelTested (LiteSVM, local validator), not proven
SHA-256 is one-wayAssumed
The compiler from Lean to sBPF (lean-svm)Trusted
The Lean kernelTrusted
The Solana runtime, validator and the System and token programsTrusted
The TypeScript client, the CLI, the extension, the siteTested, not proven
The RPC nodeNot trusted for funds; trusted for what it shows you
The browser and the operating systemTrusted
The devnet deploymentUpgradeable: its upgrade authority can replace the program

What is proven

The proofs use only Lean's standard axioms (propext, Quot.sound, Classical.choice) and contain no sorry. leankey proofs and /proofs list every theorem with its file, line and axioms. The toolchain is leanprover/lean4:v4.36.0 with lean-svm at revision a49cc65f84682eca6c5ddaefc5c22a5a19a55b48.

The WOTS+ specification

program/Twokey/Spec/Wots.lean defines the scheme. About it:

  • wots_complete: an honest signature of any intent verifies under the key that made it.
  • verifySteps_eq, verifySteps_bounds: verification computes 255 × (⌊checksum / 256⌋ + 2) chain steps, between 510 and 6,375.
  • wots_no_domination: for two intents with different digits, the second is strictly lower than the first on some chain. With a single signature, nobody can reach another intent's signature by hashing forward.

These say nothing about SHA-256. That walking a chain backward is infeasible, and hence that a signature cannot be forged, is the hash assumption.

The model

program/Twokey/Spec/Machine.lean is the program written as a state machine over one vault address: the same checks in the same order, over abstract accounts. The theorems about it:

TheoremStatement, for every successful instruction of the model
withdraw_requires_owner_signerAn instruction carrying a hash signature had account 0 sign, and account 0 is the vault's owner.
withdraw_requires_valid_wotsIt carried a valid WOTS+ signature, under the vault's current key, of an intent for this program, this vault and the current key index.
withdraw_rotates_keyThe key index goes up by one, the key hash becomes the intent's next key hash, and the owner stays.
intent_binds_transferFor a SOL withdrawal, the signed intent names exactly the destination and amount that moved.
intent_binds_token_transferFor a token withdrawal, the signed intent names exactly the mint, destination token account and amount that moved.
lamports_conservedLamports move between two accounts only, and their sum stays the same.
token_amount_conservedToken amounts move between two token accounts only, and their sum stays the same.
vault_stays_rent_exemptAn open vault never drops below the rent-exempt minimum, and opening one funds it to at least that.
close_requires_bothClosing a vault needed the owner's signature and a valid WOTS+ signature.
init_onceOpening needs a free address, the owner's signature and the right derived address.
no_reopenOpening fails at an address that already holds a vault.
no_admin_pathEvery successful instruction is either an opening by the owner or carries both the owner's signature and a valid WOTS+ signature. There is no third kind.
public_owner_key_cannot_move_fundsFor any sequence of instructions, signed by anyone, in which no instruction carries a valid WOTS+ signature for the vault's key current at that moment, the state afterwards equals the state before.

The last theorem is conditional on that hypothesis. It shows that the owner key alone can change nothing. That nobody can produce a valid WOTS+ signature without the seed is, again, the hash assumption.

The model makes these choices, stated in its source:

  • Balances are unbounded natural numbers. The program uses checked 64-bit arithmetic and fails where a sum would exceed 2^64 − 1.
  • The vault's address is an abstract function of owner and vault number. The program computes the derivation with SHA-256.
  • A token account is its owner, mint and amount. Every refusal of the token program (not enough tokens, a mint mismatch, closing a non-empty account) is one error in the model.

The program's Lean source

program/Twokey/Proofs/Code.lean proves facts about the actual functions in program/Twokey/Program.lean, the code that lean-svm compiles, under lean-svm's model of the sBPF machine state (memory, the input account layout, syscalls):

  • checkVault_ok: if checkVault passes, account 0's signer flag is set, the vault account is owned by the program, and the owner stored at vault data offset 2 equals account 0's address. It changes no state.
  • withdrawSol_checks, withdrawToken_checks, closeTokenAccount_checks, closeVault_checks: if the handler succeeds, those three facts held for some vault account.
  • initVault_requires_signer: if InitVault succeeds, account 0 signed.

These theorems say nothing about the WOTS+ verification inside the handlers, the amounts, or the token CPIs. They do not connect the Lean source to the model above.

What is tested, not proven

  • The verifier equals the specification. The program's verifyWots is a separate implementation over a byte buffer. Lean computes test vectors from the specification (make vectors, program/release/vectors.json): hash tags, chain values, public keys, five complete intents and their signatures. The compiled program must accept the Lean signature and reject it for another amount or with one byte changed. packages/core must reproduce every byte.
  • The program behaves as the model. The LiteSVM tests in program/tests run the compiled .so (14,688 bytes) through the checks and refusals of every instruction, including nine attacks with the owner's own key (a replay of a public signature, zero, random and reused signatures, a signature from another seed, a re-opening), after which the vault is unchanged and still usable. The local-validator test scripts/localnet/e2e.ts runs the CLI against solana-test-validator 4.4.2 with the same .so: 26 of 26 passed.
  • The address derivation. The program computes SHA-256(seeds ‖ bump ‖ program_id ‖ "ProgramDerivedAddress") itself. The tests open vaults at addresses derived by @solana/web3.js and check that a wrong bump and a keypair address are refused.

A difference between the program and the model, or between verifyWots and the specification, that the tests do not exercise would not be caught by the proofs.

What you have to trust

The hash assumption

WOTS+ is secure if the attacker cannot invert SHA-256, including its first 24 bytes as used for chain values, or find a second input with the same output. Hash-based signatures rest on this kind of assumption, and it is what makes them a candidate against quantum computers. It is an assumption, not a theorem.

The compiler: lean-svm

lean-svm turns the Lean program into sBPF v3 bytecode. lean-svm proves parts of its own pipeline and offers a --certify mode that checks more of it per build. The Lean Key release is built without --certify:

lake exe lean-svm build Twokey.Program Twokey.entrypoint -o build/twokey.so

So for this binary, the whole compiler is trusted: the lowering from Lean (which runs in Lean's meta-level MetaM), the optimizer, register allocation, code generation, the peephole optimizer and the ELF writer. lean-svm's README marks it as "Educational & Research Purposes Only — Not Audited for Production Use".

lean-svm has compiled two kinds of Lean construct wrongly without an error: values of sum types with a payload (Option, Except, Sum, custom inductive types) passed through a branch, and Nat arithmetic, which becomes wrapping 64-bit arithmetic. make audit (program/scripts/audit.py) refuses both in Program.lean; the program uses UInt64, UInt8 and lean-svm's result type only.

The Lean kernel

The theorems are as trustworthy as Lean's kernel and the three standard axioms.

The Solana runtime

The program relies on the runtime to: verify Ed25519 signatures and set the signer flag; enforce account ownership, writability and lamport rules; execute sol_sha256, sol_log_64 and the sysvar calls correctly; run cross-program invocations with the vault's derived-address signature. The release targets sBPF v3, which needs Agave 4.x or newer. The System Program, SPL Token, Token-2022 and the Associated Token Account program are trusted to do what they specify.

The clients

packages/core (TypeScript), the CLI, the extension and the site are not proven. They decide which intent is signed and what you are shown before signing. They use @noble/hashes for SHA-256 and scrypt, @scure/bip39 for the word list, WebCrypto for AES-256-GCM and @solana/web3.js for transactions. What is tested:

  • packages/core reproduces every test vector from Lean (bun test).
  • The CLI against a local validator, 26 of 26 cases (scripts/localnet/e2e-report.json).
  • The extension in Chromium through Playwright, 18 of 18 cases (apps/extension/tests/e2e-report.json).

A client bug could sign an intent other than the one you meant, or show you the wrong one. The program would execute exactly the intent that was signed.

The RPC node

Clients read the vault, balances, simulations and history from the RPC you configure. A dishonest RPC can show wrong numbers, withhold or delay transactions, and see the signatures you simulate. It cannot move funds without both signatures, and it cannot make the clients sign two intents for one key, because the journal decides that locally.

The browser and the operating system

The extension keeps the encrypted seed in storage.local and, while unlocked, the decrypted seed in storage.session. It trusts the browser to isolate extension storage from web pages and other extensions, and WebCrypto and crypto.getRandomValues to work as specified. Malware on the machine while the extension is unlocked can read the seed.

The deployments are upgradeable

The devnet program TwoKhewkScEnH75rbs9nC5ScrsFQT93DrHsSSZvpVHn is owned by the BPF upgradeable loader and has an upgrade authority. leankey verify on 2026-12-03 printed:

program    TwoKhewkScEnH75rbs9nC5ScrsFQT93DrHsSSZvpVHn (devnet)
loader     BPF upgradeable loader, deployed at slot 528813873
authority  6MYxzskeNrvpDJLtuyYubAvNrDM7m7c7fLbZxy7PcvG9
on chain   sha256 4e174b5a9bdd90ca5092b8db8bb4b0b158b722902a75d863ffc47ae684e69b1d (14688 B of 14688 B)
release    sha256 4e174b5a9bdd90ca5092b8db8bb4b0b158b722902a75d863ffc47ae684e69b1d (program/release/program.json)
result     the deployed program is byte-for-byte the release build

What this means:

  • Today the deployed bytes are exactly the release build that the tests ran against.
  • Whoever holds the key of 6MYxzskeNrvpDJLtuyYubAvNrDM7m7c7fLbZxy7PcvG9 can replace the program with different code at any time. Replaced code is not covered by any proof or test on this page, and could move funds from every devnet vault.
  • An immutable program would show authority none: the program is immutable.

The mainnet program KeyW6VkKqn3awBMcun9aLPKJuCP77BFM7KE66CyzCjE, deployed on 2026-12-03 at slot 476990156, is the same release build (sha256 4e174b5a…69b1d) with the same upgrade authority 6MYxzskeNrvpDJLtuyYubAvNrDM7m7c7fLbZxy7PcvG9, so the same applies to every mainnet vault.

The program on a local validator started by leankey localnet is also upgradeable, with an authority generated in ~/.leankey/localnet.

Check it yourself, at any time, with leankey verify KeyW6VkKqn3awBMcun9aLPKJuCP77BFM7KE66CyzCjE --network mainnet (or the devnet id with --network devnet) or on /verify.

Checking the claims yourself

ClaimHow
The deployed program is the release buildleankey verify PROGRAM_ID, or /verify
A vault is a real Lean Key vault at its derived addressleankey verify VAULT
The theorems and their axiomsleankey proofs --all, or /proofs; in program/, make proofs rebuilds them with Lean
The test vectorsprogram/release/vectors.json; in program/, make vectors recomputes them
The owner key alone cannot move funds on devnetThe Open Key Challenge at /challenge publishes the owner key of a funded devnet vault

Connect a wallet

Your wallet signs as the owner (Key A). Lean Key adds the post-quantum key (Key B).

Wallets

Any wallet that supports the Solana Wallet Standard appears under Installed. Lean Key never asks for your seed phrase on this site.