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

101 lines
3.3 KiB
Lean4

/-
Content-Addressed Build Attestation
Every build artifact is content-addressed via uor.foundation URIs.
Discharge proofs attest what happened during a build.
Signatures bind ALL security-relevant fields.
Address scheme: uor.foundation/{hash}/{name}
Maps to:
- hanzo/attest: attestation service (Go)
- hanzo/kms: signing keys
- lux/mpc: threshold signing for attestations
- lux/consensus: on-chain attestation recording
Properties:
- Content addressing is injective (modulo hash axiom)
- Attestation signatures are unforgeable
- Reproducible builds have no time/random accesses
-/
import Mathlib.Data.Nat.Defs
import Mathlib.Tactic
namespace Build.Attestation
/-- Content-addressed store path: uor.foundation/{hash}/{name} -/
structure StorePath where
hash : Nat -- SHA-256 of content
name : String -- Human-readable name
deriving DecidableEq, Repr
/-- Hash function (axiomatized) -/
axiom contentHash : Nat → Nat
/-- Random oracle: hash is injective (strongest axiom) -/
axiom hash_injective : ∀ a b : Nat, contentHash a = contentHash b → a = b
/-- Build derivation: recipe for producing artifacts -/
structure Derivation where
inputs : List StorePath
builder : StorePath
args : List String
deriving DecidableEq, Repr
/-- Derivation hash covers ALL fields -/
axiom derivationHash : Derivation → Nat
/-- Discharge proof: evidence of what a build did -/
structure DischargeProof where
derivation : Nat -- hash of derivation
outputHashes : List Nat -- hashes of outputs
builder : Nat -- builder's public key
startTime : Nat -- build start
endTime : Nat -- build end
hasTimeAccess : Bool -- did it read the clock?
hasRandomAccess : Bool -- did it use entropy?
/-- Proof message binds ALL fields (prevents replay) -/
def proofMessage (p : DischargeProof) : Nat :=
-- In practice: hash of (derivation, outputs, builder, times)
p.derivation + p.outputHashes.length + p.builder + p.startTime + p.endTime
/-- Signature verification (axiomatized) -/
axiom sigVerify : Nat → Nat → Nat → Bool
/-- A proof is reproducible iff no time or random access -/
def DischargeProof.isReproducible (p : DischargeProof) : Bool :=
!p.hasTimeAccess && !p.hasRandomAccess
/-- Reproducible proofs have no time access -/
theorem reproducible_no_time (p : DischargeProof)
(h : p.isReproducible = true) :
p.hasTimeAccess = false := by
simp [DischargeProof.isReproducible, Bool.and_eq_true, Bool.not_eq_true'] at h
exact h.1
/-- Reproducible proofs have no random access -/
theorem reproducible_no_random (p : DischargeProof)
(h : p.isReproducible = true) :
p.hasRandomAccess = false := by
simp [DischargeProof.isReproducible, Bool.and_eq_true, Bool.not_eq_true'] at h
exact h.2
/-- Same content → same hash → same store path -/
theorem content_determines_path (a b : Nat)
(h : contentHash a = contentHash b) : a = b :=
hash_injective a b h
/-- uor.foundation URI construction -/
def toURI (sp : StorePath) : String :=
s!"uor.foundation/{sp.hash}/{sp.name}"
/-- Two store paths with same hash and name produce same URI -/
theorem same_path_same_uri (a b : StorePath)
(hh : a.hash = b.hash) (hn : a.name = b.name) :
toURI a = toURI b := by
simp [toURI, hh, hn]
end Build.Attestation