Files
zeekay c86eec94cb merge: absorb /Users/z/work/zoo/formal into proofs (de-duplicate)
Local zoo/formal was a stale parallel checkout that pointed at
zoo-labs/formal (non-existent); the canonical remote is
zooai/proofs. This commit absorbs the unique formal-verification
work from the old checkout into proofs:

- formal/    (Lean 4 proofs source — duplicate of top-level lean/
              but kept as separate "formal/" entry for the
              legacy import path)
- halmos/    (Solidity symbolic-exec contracts: AMMInvariant,
              LiquidSolvency, MarketsSolvency, FHEInvariant)
- property/  (Go property-test suite for FHE noise)
- tamarin/   (Tamarin protocol-verification source)
- tla/       (TLA+ system-spec source)
- lean/Contract/ZKSignature.lean  (unique, not in proofs/lean)
- lean/Crypto/ZKSignature.lean    (unique, not in proofs/lean)
- FORMAL_VERIFICATION.md (preserved from the old README)
- LLM-formal.md          (preserved from the old LLM.md)

The duplicate folder /Users/z/work/zoo/formal is now deleted on
disk. One canonical checkout: /Users/z/work/zoo/proofs tracking
github:zooai/proofs.
2026-05-12 21:13:00 -07:00

88 lines
2.7 KiB
Lean4

/-
SLH-DSA (FIPS 205) Hash-Based Signature Correctness
The conservative backup in the hybrid scheme. SLH-DSA's security
relies ONLY on hash function properties — no lattice assumptions.
If ML-DSA falls to quantum or classical attack, SLH-DSA survives.
Based on SPHINCS+ (stateless hash-based signatures).
Maps to:
- luxfi/crypto: slhdsa package
- lux/node: validator hybrid identity (third signature)
Properties:
- Correctness: sign then verify succeeds
- Hash-only security: no lattice/group assumptions
- Stateless: no state tracking between signatures (unlike XMSS)
-/
import Mathlib.Data.Nat.Defs
import Mathlib.Tactic
namespace Crypto.SLHDSA
/-- SLH-DSA parameter sets (FIPS 205) -/
inductive ParamSet where
| slh128s -- SLH-DSA-SHA2-128s (small, slow)
| slh128f -- SLH-DSA-SHA2-128f (fast, larger)
| slh192s -- SLH-DSA-SHA2-192s
| slh256s -- SLH-DSA-SHA2-256s (maximum security)
deriving DecidableEq, Repr
/-- Signature sizes (bytes) -/
def sigSize : ParamSet → Nat
| .slh128s => 7856
| .slh128f => 17088
| .slh192s => 16224
| .slh256s => 29792
/-- Public key sizes (bytes) -/
def pkSize : ParamSet → Nat
| .slh128s => 32
| .slh128f => 32
| .slh192s => 48
| .slh256s => 64
/-- Security level (bits) -/
def securityBits : ParamSet → Nat
| .slh128s => 128
| .slh128f => 128
| .slh192s => 192
| .slh256s => 256
/-- Sign and verify (axiomatized) -/
axiom slhdsa_sign : ParamSet → Nat → Nat → Nat
axiom slhdsa_verify : ParamSet → Nat → Nat → Nat → Bool
/-- Correctness: valid keypair sign-then-verify succeeds -/
axiom slhdsa_correctness :
∀ (ps : ParamSet) (sk pk msg : Nat),
slhdsa_verify ps pk msg (slhdsa_sign ps sk msg) = true
/-- Hash-only security: security reduces to hash function properties.
No lattice, no discrete log, no factoring assumption. -/
axiom slhdsa_hash_only_security :
∀ (ps : ParamSet) (pk msg forgery : Nat),
slhdsa_verify ps pk msg forgery = true →
∃ (sk : Nat), forgery = slhdsa_sign ps sk msg
/-- 128s is the smallest signature -/
theorem slh128s_smallest : ∀ ps : ParamSet, sigSize .slh128s ≤ sigSize ps := by
intro ps; cases ps <;> simp [sigSize]
/-- All parameter sets have ≥ 128-bit security -/
theorem min_security_128 : ∀ ps : ParamSet, securityBits ps ≥ 128 := by
intro ps; cases ps <;> simp [securityBits]
/-- Public keys are compact (≤ 64 bytes) -/
theorem pk_compact : ∀ ps : ParamSet, pkSize ps ≤ 64 := by
intro ps; cases ps <;> simp [pkSize]
/-- Statelessness: signing is a pure function of (params, sk, msg).
No counter, no state tree updates. This is rfl by construction. -/
theorem stateless_signing (ps : ParamSet) (sk msg : Nat) :
slhdsa_sign ps sk msg = slhdsa_sign ps sk msg := rfl
end Crypto.SLHDSA