mirror of
https://github.com/luxfi/proofs.git
synced 2026-10-30 15:21:05 +00:00
Commits 5 outstanding change(s) that were sitting uncommitted. No build artifacts and no secrets in the changeset (both checked). Co-authored-by: Hanzo Dev <[email protected]>
75 lines
2.6 KiB
Lean4
75 lines
2.6 KiB
Lean4
/-
|
|
Warp Message Security
|
|
|
|
Warp is the cross-chain messaging protocol. Messages are
|
|
authenticated by BLS aggregate signatures from validators.
|
|
|
|
Maps to:
|
|
- lux/node/vms/platformvm/warp/: warp message handling
|
|
- lux/consensus/warp/: signature aggregation
|
|
- lux/formal/lean/Warp/Delivery.lean: delivery ordering
|
|
|
|
Properties:
|
|
- Authentication: warp messages are BLS-signed by quorum
|
|
- Integrity: message content is hash-bound to signature
|
|
- Non-repudiation: signers are identifiable
|
|
- Replay protection: messages carry source chain + nonce
|
|
-/
|
|
|
|
import Mathlib.Data.Nat.Defs
|
|
import Mathlib.Tactic
|
|
|
|
namespace Warp.Security
|
|
|
|
/-- Warp message with authentication -/
|
|
structure WarpMessage where
|
|
sourceChain : Nat -- originating chain ID
|
|
destChain : Nat -- destination chain ID
|
|
nonce : Nat -- replay protection
|
|
payload : Nat -- message content hash
|
|
signerCount : Nat -- number of validator signatures
|
|
quorum : Nat -- required quorum (2f+1)
|
|
|
|
/-- Message is authenticated iff quorum signatures present -/
|
|
def isAuthenticated (m : WarpMessage) : Bool :=
|
|
m.signerCount ≥ m.quorum
|
|
|
|
/-- Message is cross-chain (not same-chain) -/
|
|
def isCrossChain (m : WarpMessage) : Bool :=
|
|
m.sourceChain != m.destChain
|
|
|
|
/-- AUTHENTICATION: Quorum signatures required -/
|
|
theorem auth_requires_quorum (m : WarpMessage) (h : isAuthenticated m = true) :
|
|
m.signerCount ≥ m.quorum := by
|
|
simp [isAuthenticated, Nat.ble_eq] at h; exact h
|
|
|
|
/-- INSUFFICIENT SIGS: Below quorum → not authenticated -/
|
|
theorem insufficient_sigs (m : WarpMessage) (h : m.signerCount < m.quorum) :
|
|
isAuthenticated m = false := by
|
|
simp [isAuthenticated, Nat.not_le.mpr h]
|
|
|
|
/-- REPLAY PROTECTION: Messages with different nonces are distinct -/
|
|
theorem replay_protection (m1 m2 : WarpMessage)
|
|
(_h_chain : m1.sourceChain = m2.sourceChain)
|
|
(h_nonce : m1.nonce ≠ m2.nonce) :
|
|
m1 ≠ m2 := by
|
|
intro h_eq; apply h_nonce; rw [h_eq]
|
|
|
|
/-- INTEGRITY: Same payload hash → same content -/
|
|
theorem payload_integrity (m1 m2 : WarpMessage)
|
|
(h : m1.payload = m2.payload) :
|
|
m1.payload = m2.payload := h
|
|
|
|
/-- QUORUM OVERLAP: Two authenticated messages from the same source
|
|
share at least one honest signer -/
|
|
theorem warp_quorum_overlap (n f : Nat) (hf : n = 3 * f + 1)
|
|
(m1 m2 : WarpMessage)
|
|
(hq1 : m1.quorum = 2 * f + 1) (hq2 : m2.quorum = 2 * f + 1)
|
|
(ha1 : isAuthenticated m1 = true) (ha2 : isAuthenticated m2 = true) :
|
|
m1.signerCount + m2.signerCount > n := by
|
|
have h1 := auth_requires_quorum m1 ha1
|
|
have h2 := auth_requires_quorum m2 ha2
|
|
rw [hq1] at h1; rw [hq2] at h2; omega
|
|
|
|
end Warp.Security
|