Skip to content
Lean Key
Formal verification

Proofs

Every theorem below is checked by Lean's kernel when the program is built. The list is generated from the build, not written by hand.

Theorems
51
21 headline, the rest lemmas
sorry
0
the build refuses to write proofs.json otherwise
Axioms
3
Classical.choice, Quot.sound, propext
Program
14,688 B
sha256 4e174b5a9bdd90ca…
Lean
leanprover/lean4:v4.36.0
lean-svm
a49cc65f8468
commit
none (the source tree is not a git checkout; see the source hash)
source hash
3793a67737889fdf9fa2cea6fc5b1951ce838b5e69ea8cdab273aafb95a78bac
program sha256
4e174b5a9bdd90ca5092b8db8bb4b0b158b722902a75d863ffc47ae684e69b1d
proofs built
2026-12-02T23:11:39.662Z
CI
no hosted CI yet: run make -C program proofs to reproduce

Authorization

Who can make the program move funds, and what exactly a signature allows.

Owner signature

withdraw_requires_owner_signer
✓ kernel-checked

Every instruction other than `InitVault` succeeds only when the vault is open and its recorded owner signed the transaction.

theorem withdraw_requires_owner_signer (h : step e w c = .ok w') (hop : c.op.sig? = some sig) :
    c.signed = true ∧ ∃ v, w.vault = some v ∧ v.owner = c.owner
axioms: propext, Classical.choice, Quot.soundTwokey/Proofs/Machine.lean:127

Hash signature

withdraw_requires_valid_wots
✓ kernel-checked

Every instruction that moves anything succeeds only when its WOTS+ signature verifies, under the vault's current one-time key, for an intent naming this program, this vault and the current key index.

theorem withdraw_requires_valid_wots (h : step e w c = .ok w') (hop : c.op.sig? = some sig) :
    ∃ v i, w.vault = some v ∧ i.programId = e.programId ∧ i.vault = e.addr ∧
      i.keyIndex = v.keyIndex ∧ verify (ctxOf e v) (Intent.encode i) sig v.pkHash = true
axioms: propext, Classical.choice, Quot.soundTwokey/Proofs/Machine.lean:139

The intent is the transfer (SOL)

intent_binds_transfer
✓ kernel-checked

What moves is exactly the signed intent's amount, from the vault to the intent's destination, and the intent is a SOL intent.

theorem intent_binds_transfer {amount : UInt64} {next : Bytes} {sig : List Bytes}
    (h : step e w c = .ok w') (hop : c.op = .withdrawSol amount next sig) :
    ∃ v, w.vault = some v ∧
      verify (ctxOf e v) (intentOf e v actWithdrawSol zero32 amount c.dest next).encode sig v.pkHash = true ∧
      (intentOf e v actWithdrawSol zero32 amount c.dest next).asset = zero32 ∧
      w'.lamports (intentOf e v actWithdrawSol zero32 amount c.dest next).destination =
        w.lamports c.dest + (intentOf e v actWithdrawSol zero32 amount c.dest next).amount.toNat ∧
      w'.lamports e.addr =
        w.lamports e.addr - (intentOf e v actWithdrawSol zero32 amount c.dest next).amount.toNat
axioms: propext, Classical.choice, Quot.soundTwokey/Proofs/Machine.lean:169

The intent is the transfer (tokens)

intent_binds_token_transfer
✓ kernel-checked

The tokens that move are the intent's amount of the intent's asset (the mint), from the vault's own token account to the intent's destination.

theorem intent_binds_token_transfer {amount : UInt64} {next : Bytes} {sig : List Bytes}
    (h : step e w c = .ok w') (hop : c.op = .withdrawToken amount next sig) :
    ∃ v s d, w.vault = some v ∧ w.tokens c.src = some s ∧ w.tokens c.dest = some d ∧
      verify (ctxOf e v) (intentOf e v actWithdrawToken c.mint amount c.dest next).encode sig v.pkHash = true ∧
      s.owner = e.addr ∧ s.mint = (intentOf e v actWithdrawToken c.mint amount c.dest next).asset ∧
      d.mint = (intentOf e v actWithdrawToken c.mint amount c.dest next).asset ∧
      w'.tokens (intentOf e v actWithdrawToken c.mint amount c.dest next).destination =
        some { d with amount
axioms: propext, Classical.choice, Quot.soundTwokey/Proofs/Machine.lean:187

Closing needs both keys

close_requires_both
✓ kernel-checked

`CloseVault` succeeds only with the owner's signature and a valid hash signature of the closing intent.

theorem close_requires_both {next : Bytes} {sig : List Bytes} (h : step e w c = .ok w')
    (hop : c.op = .closeVault next sig) :
    c.signed = true ∧ ∃ v, w.vault = some v ∧ v.owner = c.owner ∧
      verify (ctxOf e v) (intentOf e v actCloseVault zero32 0 c.dest next).encode sig v.pkHash = true
axioms: propext, Classical.choice, Quot.soundTwokey/Proofs/Machine.lean:285

No admin path

no_admin_path
✓ kernel-checked

Every successful instruction is either the opening of an unopened vault by its owner, or carries both the owner's signature and a valid hash signature for the vault's current key. There is no other way to change anything.

theorem no_admin_path (h : step e w c = .ok w') :
    (∃ vid pk0, c.op = .init vid pk0 ∧ w.vault = none ∧ c.signed = true ∧ e.addr = e.pda c.owner vid) ∨
    (c.signed = true ∧ (∃ v, w.vault = some v ∧ v.owner = c.owner) ∧ HashAuthorized e w c)
axioms: propext, Classical.choice, Quot.soundTwokey/Proofs/Machine.lean:324

The owner's wallet key alone moves nothing

public_owner_key_cannot_move_funds
✓ kernel-checked

Take any sequence of instructions, signed by anyone, the vault's owner key included (a drainer holding it, or a quantum computer that recovered it, or the Open Key Challenge where it is public). If none of them carries a valid WOTS+ signature for the vault's one-time key current when it runs, the world is exactly as before: not a lamport, not a token, not the key moves, so nothing is stolen and the vault is not locked.

theorem public_owner_key_cannot_move_funds :
    ∀ (calls : List Call) (w : World), w.vault.isSome = true → NoHashSignature e w calls →
      run e w calls = w
axioms: propext, Classical.choice, Quot.soundTwokey/Proofs/Machine.lean:365

hashAuthorized_of_ok

hashAuthorized_of_ok
✓ kernel-checked

An instruction with a hash signature succeeds only when that signature is valid for the vault's current key.

theorem hashAuthorized_of_ok (h : step e w c = .ok w') (hop : c.op.sig? = some sig) :
    HashAuthorized e w c
axioms: propext, Classical.choice, Quot.soundTwokey/Proofs/Machine.lean:316

apply_unauthorized

apply_unauthorized
✓ kernel-checked

With a vault open, a call without a valid hash signature changes nothing at all.

theorem apply_unauthorized (hv : w.vault.isSome = true) (hno : ¬ HashAuthorized e w c) :
    apply e w c = w
axioms: propext, Classical.choice, Quot.soundTwokey/Proofs/Machine.lean:349

Conservation

What a successful instruction does to balances: nothing appears, nothing vanishes, rent stays.

Lamports are conserved

lamports_conserved
✓ kernel-checked

Every successful instruction moves lamports between two distinct accounts at most: their sum is unchanged and every other account is untouched.

theorem lamports_conserved (h : step e w c = .ok w') :
    ∃ a b, a ≠ b ∧ (∀ k, k ≠ a → k ≠ b → w'.lamports k = w.lamports k) ∧
      w'.lamports a + w'.lamports b = w.lamports a + w.lamports b
axioms: propext, Classical.choice, Quot.soundTwokey/Proofs/Machine.lean:205

Tokens are conserved

token_amount_conserved
✓ kernel-checked

Every successful instruction changes at most two token accounts, and the sum of their amounts stays the same (a closed account held 0).

theorem token_amount_conserved (h : step e w c = .ok w') :
    ∃ a b, a ≠ b ∧ (∀ k, k ≠ a → k ≠ b → w'.tokens k = w.tokens k) ∧
      amt w' a + amt w' b = amt w a + amt w b
axioms: propext, Classical.choice, Quot.soundTwokey/Proofs/Machine.lean:236

Rent

vault_stays_rent_exempt
✓ kernel-checked

No instruction takes an open vault below its rent-exempt minimum, and opening one funds it to at least that minimum.

theorem vault_stays_rent_exempt (hinv : RentExempt e w) (h : step e w c = .ok w') : RentExempt e w'
axioms: propext, Classical.choice, Quot.soundTwokey/Proofs/Machine.lean:266

setL_same

setL_same
✓ kernel-checked
theorem setL_same (f : Key → Nat) (k : Key) (n : Nat) : setL f k n k = n

setL_other

setL_other
✓ kernel-checked
theorem setL_other (f : Key → Nat) (k k' : Key) (n : Nat) (h : k' ≠ k) : setL f k n k' = f k'

setT_same

setT_same
✓ kernel-checked
theorem setT_same (f : Key → Option TokenAcct) (k : Key) (t : Option TokenAcct) : setT f k t k = t

setT_other

setT_other
✓ kernel-checked
theorem setT_other (f : Key → Option TokenAcct) (k k' : Key) (t : Option TokenAcct) (h : k' ≠ k) :
    setT f k t k' = f k'

Lifecycle

Opening, rotating keys, closing: the order of a vault's life.

Rotation

withdraw_rotates_key
✓ kernel-checked

After every such success the vault holds the next one-time key: its index is one more and its hash is the one the intent named. The owner never changes.

theorem withdraw_rotates_key (h : step e w c = .ok w') (hop : c.op.next? = some next) :
    ∃ v v', w.vault = some v ∧ w'.vault = some v' ∧ v'.keyIndex = v.keyIndex + 1 ∧
      v'.pkHash = next ∧ v'.owner = c.owner ∧ v'.owner = v.owner
axioms: propext, Classical.choice, Quot.soundTwokey/Proofs/Machine.lean:153

Once

init_once
✓ kernel-checked

`InitVault` succeeds only where no vault is open, and the vault it opens belongs to the signer whose address derivation it is.

theorem init_once {vid : UInt64} {pk0 : Bytes} (h : step e w c = .ok w') (hop : c.op = .init vid pk0) :
    w.vault = none ∧ c.signed = true ∧ e.addr = e.pda c.owner vid ∧
      w'.vault = some { owner
axioms: propext, Classical.choice, Quot.soundTwokey/Proofs/Machine.lean:296

stepInit_ok

stepInit_ok
✓ kernel-checked
theorem stepInit_ok {vid : UInt64} {pk0 : Bytes} (h : stepInit e w c vid pk0 = .ok w') :
    c.owner ≠ e.addr ∧ c.signed = true ∧ w.vault = none ∧ pk0 ≠ zero32 ∧
    e.addr = e.pda c.owner vid ∧ w.rentMin - w.lamports e.addr ≤ w.lamports c.owner ∧
    w' = { w with
      vault
axioms: propext, Quot.soundTwokey/Proofs/Machine.lean:14

stepSol_ok

stepSol_ok
✓ kernel-checked
theorem stepSol_ok {amount : UInt64} {next : Bytes} {sig : List Bytes}
    (h : stepSol e w c amount next sig = .ok w') :
    c.dest ≠ e.addr ∧ c.signed = true ∧ ∃ v, w.vault = some v ∧ v.owner = c.owner ∧ amount ≠ 0 ∧
      next ≠ zero32 ∧
      verify (ctxOf e v) (intentOf e v actWithdrawSol zero32 amount c.dest next).encode sig v.pkHash = true ∧
      w.rentMin ≤ w.lamports e.addr ∧ amount.toNat ≤ w.lamports e.addr - w.rentMin ∧ v.keyIndex ≠ maxU64 ∧
      w' = { w with
        lamports
axioms: propext, Classical.choice, Quot.soundTwokey/Proofs/Machine.lean:29

stepToken_ok

stepToken_ok
✓ kernel-checked
theorem stepToken_ok {amount : UInt64} {next : Bytes} {sig : List Bytes}
    (h : stepToken e w c amount next sig = .ok w') :
    c.src ≠ e.addr ∧ c.dest ≠ e.addr ∧ c.src ≠ c.dest ∧ c.signed = true ∧
    ∃ v s d, w.vault = some v ∧ v.owner = c.owner ∧ w.tokens c.src = some s ∧
      w.tokens c.dest = some d ∧ s.owner = e.addr ∧ s.mint = c.mint ∧ w.hook c.mint = false ∧
      amount ≠ 0 ∧ next ≠ zero32 ∧
      verify (ctxOf e v) (intentOf e v actWithdrawToken c.mint amount c.dest next).encode sig v.pkHash = true ∧
      d.mint = c.mint ∧ amount.toNat ≤ s.amount ∧ v.keyIndex ≠ maxU64 ∧
      w' = { w with
        tokens
axioms: propext, Classical.choice, Quot.soundTwokey/Proofs/Machine.lean:47

stepCloseToken_ok

stepCloseToken_ok
✓ kernel-checked
theorem stepCloseToken_ok {next : Bytes} {sig : List Bytes}
    (h : stepCloseToken e w c next sig = .ok w') :
    c.src ≠ e.addr ∧ c.dest ≠ e.addr ∧ c.src ≠ c.dest ∧ c.signed = true ∧
    ∃ v s, w.vault = some v ∧ v.owner = c.owner ∧ w.tokens c.src = some s ∧ s.owner = e.addr ∧
      next ≠ zero32 ∧
      verify (ctxOf e v) (intentOf e v actCloseTokenAccount s.mint 0 c.dest next).encode sig v.pkHash = true ∧
      s.amount = 0 ∧ v.keyIndex ≠ maxU64 ∧
      w' = { w with
        tokens
axioms: propext, Classical.choice, Quot.soundTwokey/Proofs/Machine.lean:69

stepCloseVault_ok

stepCloseVault_ok
✓ kernel-checked
theorem stepCloseVault_ok {next : Bytes} {sig : List Bytes}
    (h : stepCloseVault e w c next sig = .ok w') :
    c.dest ≠ e.addr ∧ c.signed = true ∧ ∃ v, w.vault = some v ∧ v.owner = c.owner ∧ next ≠ zero32 ∧
      verify (ctxOf e v) (intentOf e v actCloseVault zero32 0 c.dest next).encode sig v.pkHash = true ∧
      w.rentMin ≤ w.lamports e.addr ∧ v.keyIndex ≠ maxU64 ∧
      w' = { w with
        lamports
axioms: propext, Classical.choice, Quot.soundTwokey/Proofs/Machine.lean:89

no_reopen

no_reopen
✓ kernel-checked

Once a vault is open (closed vaults included: closing leaves a tombstone), it cannot be opened again, by anyone.

theorem no_reopen {vid : UInt64} {pk0 : Bytes} (hv : w.vault.isSome = true) (hop : c.op = .init vid pk0) :
    ∃ err, step e w c = .error err
axioms: propext, Classical.choice, Quot.soundTwokey/Proofs/Machine.lean:306

WOTS+

The one-time hash signature itself, as specified in Lean.

Completeness

wots_complete
✓ kernel-checked

An honest signature of any intent verifies under the key it was made with.

theorem wots_complete (seed : Bytes) (c : KeyCtx) (x : Bytes) :
    verify c x (sign seed c x) (pkHash c (publicEnds seed c)) = true
axioms: propext, Classical.choice, Quot.soundTwokey/Proofs/Wots.lean:81

The cost of verifying

verifySteps_eq
✓ kernel-checked

The verifier hashes `Σ (255 − d_i)` times, which is always `255 × (⌊checksum / 256⌋ + 2)`: from 510 to 6,375 hashes. The program's compute units follow it.

theorem verifySteps_eq (x : Bytes) :
    verifySteps x = 255 * (checksum (msgDigits x) / 256 + 2)
axioms: propext, Quot.soundTwokey/Proofs/Wots.lean:87

No forgery by walking forward

wots_no_domination
✓ kernel-checked

If two intents have different digits, the second has a digit strictly below the first's on some chain: a signature of the first never yields one of the second without inverting the hash.

theorem wots_no_domination (x y : Bytes) (h : digits x ≠ digits y) :
    ∃ i, i < chainCount ∧ digitAt y i < digitAt x i
axioms: propext, Classical.choice, Quot.soundTwokey/Proofs/Wots.lean:152

chain_split

chain_split
✓ kernel-checked

Walking `a + b` steps is walking `a` steps, then `b` more from where that ended.

theorem chain_split (c : KeyCtx) (i : Nat) :
    ∀ (a s b : Nat) (x : Bytes), chain c i s (a + b) x = chain c i (s + a) b (chain c i s a x)
axioms: propext, Quot.soundTwokey/Proofs/Wots.lean:11

getD_map_range

getD_map_range
✓ kernel-checked
theorem getD_map_range {α : Type} (f : Nat → α) (n i : Nat) (d : α) (h : i < n) :
    ((List.range n).map f).getD i d = f i

msgDigits_length

msgDigits_length
✓ kernel-checked
theorem msgDigits_length (x : Bytes) : (msgDigits x).length = 24
axioms: propext, Quot.soundTwokey/Proofs/Wots.lean:23

msgDigits_le

msgDigits_le
✓ kernel-checked
theorem msgDigits_le (x : Bytes) : ∀ d ∈ msgDigits x, d ≤ 255
axioms: propext, Quot.soundTwokey/Proofs/Wots.lean:26

checksum_le

checksum_le
✓ kernel-checked
theorem checksum_le (m : List Nat) : checksum m ≤ 255 * m.length
axioms: propext, Quot.soundTwokey/Proofs/Wots.lean:33

checksum_msg_le

checksum_msg_le
✓ kernel-checked
theorem checksum_msg_le (x : Bytes) : checksum (msgDigits x) ≤ 6120
axioms: propext, Quot.soundTwokey/Proofs/Wots.lean:40

digits_le

digits_le
✓ kernel-checked

Every digit is a byte: 0..255.

theorem digits_le (x : Bytes) : ∀ d ∈ digits x, d ≤ 255
axioms: propext, Quot.soundTwokey/Proofs/Wots.lean:46

digits_length

digits_length
✓ kernel-checked
theorem digits_length (x : Bytes) : (digits x).length = 26
axioms: propext, Quot.soundTwokey/Proofs/Wots.lean:55

digitAt_le

digitAt_le
✓ kernel-checked
theorem digitAt_le (x : Bytes) (i : Nat) : digitAt x i ≤ 255
axioms: propext, Quot.soundTwokey/Proofs/Wots.lean:58

recover_sign

recover_sign
✓ kernel-checked

A signature walked to the end of its chains gives back the public key.

theorem recover_sign (seed : Bytes) (c : KeyCtx) (x : Bytes) :
    recoverEnds c x (sign seed c x) = publicEnds seed c
axioms: propext, Quot.soundTwokey/Proofs/Wots.lean:68

verifySteps_bounds

verifySteps_bounds
✓ kernel-checked
theorem verifySteps_bounds (x : Bytes) : 510 ≤ verifySteps x ∧ verifySteps x ≤ 6375
axioms: propext, Classical.choice, Quot.soundTwokey/Proofs/Wots.lean:95

checksum_mono_eq

checksum_mono_eq
✓ kernel-checked
theorem checksum_mono_eq : ∀ (a b : List Nat), a.length = b.length → PointwiseLe a b →
    (∀ d ∈ b, d ≤ 255) → checksum b ≤ checksum a ∧ (checksum b = checksum a → a = b)
axioms: propext, Classical.choice, Quot.soundTwokey/Proofs/Wots.lean:110

getD_append_left'

getD_append_left'
✓ kernel-checked
theorem getD_append_left' (l l' : List Nat) (n : Nat) (h : n < l.length) :
    (l ++ l').getD n 0 = l.getD n 0

getD_append_right'

getD_append_right'
✓ kernel-checked
theorem getD_append_right' (l l' : List Nat) (n : Nat) (h : l.length ≤ n) :
    (l ++ l').getD n 0 = l'.getD (n - l.length) 0

digitAt_msg

digitAt_msg
✓ kernel-checked
theorem digitAt_msg (x : Bytes) (i : Nat) (h : i < 24) : digitAt x i = (msgDigits x).getD i 0
axioms: propext, Quot.soundTwokey/Proofs/Wots.lean:135

digitAt_24

digitAt_24
✓ kernel-checked
theorem digitAt_24 (x : Bytes) : digitAt x 24 = checksum (msgDigits x) / 256
axioms: propext, Quot.soundTwokey/Proofs/Wots.lean:139

digitAt_25

digitAt_25
✓ kernel-checked
theorem digitAt_25 (x : Bytes) : digitAt x 25 = checksum (msgDigits x) % 256
axioms: propext, Quot.soundTwokey/Proofs/Wots.lean:144

Program source

Properties of the program's SolanaM source, the code lean-svm compiles to sBPF, under lean-svm's model of the runtime. The compiler itself is trusted.

`checkVault` in the program's source

checkVault_ok
✓ kernel-checked

It passes only if the owner account signed, the vault is owned by this program, and the vault's stored owner is the owner account's address.

theorem checkVault_ok {owner vault progId : UInt64} {s s' : SvmState}
    (h : checkVault owner vault progId s = .ok () s') :
    VaultChecked s owner vault progId ∧ s' = s
axioms: propext, Classical.choice, Quot.soundTwokey/Proofs/Code.lean:37

`WithdrawSol` in the program's source

withdrawSol_checks
✓ kernel-checked

succeeds only after `checkVault` passed on the state it started from: the owner signed and the vault is this program's and records that owner.

theorem withdrawSol_checks (a0 progId ix : UInt64) (s s' : SvmState)
    (h : withdrawSol a0 progId ix s = .ok () s') : ∃ vault, VaultChecked s a0 vault progId
axioms: propext, Classical.choice, Quot.soundTwokey/Proofs/Code.lean:74

`CloseVault` in the program's source

closeVault_checks
✓ kernel-checked

: the same checks.

theorem closeVault_checks (a0 progId ix : UInt64) (s s' : SvmState)
    (h : closeVault a0 progId ix s = .ok () s') : ∃ vault, VaultChecked s a0 vault progId
axioms: propext, Classical.choice, Quot.soundTwokey/Proofs/Code.lean:93

`WithdrawToken` in the program's source

withdrawToken_checks
✓ kernel-checked

: the same checks.

theorem withdrawToken_checks (a0 progId ix : UInt64) (s s' : SvmState)
    (h : withdrawToken a0 progId ix s = .ok () s') : ∃ vault, VaultChecked s a0 vault progId
axioms: propext, Classical.choice, Quot.soundTwokey/Proofs/Code.lean:112

`CloseTokenAccount` in the program's source

closeTokenAccount_checks
✓ kernel-checked

: the same checks.

theorem closeTokenAccount_checks (a0 progId ix : UInt64) (s s' : SvmState)
    (h : closeTokenAccount a0 progId ix s = .ok () s') : ∃ vault, VaultChecked s a0 vault progId
axioms: propext, Classical.choice, Quot.soundTwokey/Proofs/Code.lean:137

`InitVault` in the program's source

initVault_requires_signer
✓ kernel-checked

succeeds only if the owner account signed.

theorem initVault_requires_signer (a0 progId ix : UInt64) (s s' : SvmState)
    (h : initVault a0 progId ix s = .ok () s') : s.readU8 (a0 + ABI.accIsSignerOffset) ≠ 0
axioms: propext, Classical.choice, Quot.soundTwokey/Proofs/Code.lean:162

nextDistinct_state

nextDistinct_state
✓ kernel-checked
theorem nextDistinct_state (acc : AccountView) (s s' : SvmState) (x : AccountView)
    (h : nextDistinct acc s = .ok x s') : s' = s
axioms: propext, Classical.choice, Quot.soundTwokey/Proofs/Code.lean:17

Trust boundaries

A proof is about a model. These theorems are about the Lean specification and the SolanaM code that lean-svm compiles. They do not cover the lean-svm compiler itself, the sBPF runtime and validator, SHA-256 being a good hash, the TypeScript client, the extension, the RPC you use or your browser. The full list, and what each gap means for you, is in the documentation.

Read Trust boundaries →

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.