mirror of
https://github.com/zooai/proofs.git
synced 2026-10-30 14:49:47 +00:00
The lean/ proof library (88 files) had ~180 type-check errors across ~45 files plus 31 proof-by-assumption axiom cheats. It now type-checks cleanly under Lean 4.14.0 + Mathlib, with every theorem genuinely proven from definitions. Errors fixed: - Stale Mathlib imports: Data.Nat.Basic / Data.Int.Basic were removed this rev -> Data.Nat.Defs / Data.Int.Defs (57 files). - Shared AI/Agent/Governance/Contract/DeFi/Ecology draft files: same proof-rot as the zoo-labs sibling library (now reconciled): omega missing in-scope bounds, dead tactics after simp, simp over-reduction, doc-comment placement, reserved-word binders, deriving Repr on Finset-bearing structs, noncomputable defs over opaque primitives. - Consensus/Liveness: collapsed a 74-error cascade (undefined shared state model inlined from Safety.lean; the |>. pipe-projection vs comparison parse trap on 14 lines rewritten to explicit dot projection). - Crypto (BLS/FROST/Corona/Hybrid/threshold/FHE), Consensus, Protocol, Warp, Trust, GPU, Compute, Network, DeFi: brought structure invariants into scope for omega, Nat-division bounds via Nat.div_le_of_le_mul / Nat.div_mul_le_self, noncomputable over opaque crypto ops, deriving Inhabited for index access. Integrity: - Removed all 31 `theorem X := X_ax` cheats (axiom asserting the identical statement) and proved each from definitions; removed the UNSOUND content_addressed axiom (hash-injectivity over a struct with free fields). - Quorum-intersection theorems (BFT/Quasar/Flare/Warp/BLS/GPU/Bridge): the draft hypothesis 3f<n is insufficient (n unbounded above makes them false); tightened to the optimal-resilience invariant n=3f+1 / 2t>n. Statement intent preserved. - Net axiom change: -35 / +1 (the one addition, honesty_static, is a fixed-validator-set modeling assumption matching sibling files). - Remaining axioms are trusted-base only: opaque crypto primitives (groups, pairings, hardness, hashes, FHE encrypt/decrypt, BLS soundness, forward secrecy, Fisher-Yates uniformity) and protocol modeling assumptions. No sorry/admit/native_decide. Verified all theorems trace to [propext, Classical.choice, Quot.sound] plus those primitives. Co-authored-by: Hanzo Dev <[email protected]>
90 lines
2.8 KiB
Lean4
90 lines
2.8 KiB
Lean4
/-
|
|
Authors: Antje Worring, Zach Kelling
|
|
|
|
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
|