A Lean 4 + Mathlib project accompanying a 90-minute workshop on formal verification of cryptographic protocols for Web3.
FormalVerificationForWeb3/Basic.lean— All Lean 4 code from the workshop: definitions, theorems, and interactive exercises (with solutions as comments).doc/Formal_Verification_for_Web3.md— Marp slide deck covering motivation, Lean 4 foundations, and three cryptographic protocols.
| Protocol | Key property | Lean model |
|---|---|---|
| One-Time Pad | XOR involution: |
Vector (ZMod 2) n |
| RSA | Euler's theorem: |
ZMod (p * q) |
| Diffie-Hellman | Commutativity: |
ZMod p |
All proofs use a deterministic algebraic model — correctness of protocol operations, not computational security assumptions.
rfl, intro, exact, simp, omega, ring/ring_nf, have/calc, unfold, rw, ext, decide
Requires elan (Lean version manager).
lake buildOn first build, Mathlib will be fetched and its cache decompressed. Subsequent builds are fast.
Requires Marp CLI and Node.js >= 20.
# Install Marp CLI globally
npm install -g @marp-team/marp-cli
# Install Shiki (for Lean 4 syntax highlighting) in doc/
cd doc && npm install && cd ..
# Generate PDF with Lean 4 syntax highlighting
marp --no-stdin --engine ./doc/engine.mjs doc/Formal_Verification_for_Web3.md -o doc/Formal_Verification_for_Web3.pdf --allow-local-files
# Generate HTML
marp --no-stdin --engine ./doc/engine.mjs doc/Formal_Verification_for_Web3.md -o doc/Formal_Verification_for_Web3.html --allow-local-filesThe custom engine (doc/engine.mjs) replaces Marp's default highlighter with Shiki, which supports the Lean 4 TextMate grammar. Comments are rendered in green.