// notable accomplishment · formal verification at the infra layer · devcon 8
leanp2p
Bringing libp2p to Lean 4: towards verified networking for Ethereum.
A Lean 4 implementation of libp2p, beginning with Ethereum consensus-layer networking — shared on stage at the Resilient Networking Hub during the Devcon 8 workshop “Building Resilient Ethereum”.
// package structure
A layered, independently testable stack
base/
conc · bytes
Foundational concurrency primitives and the byte model used throughout.
codec/
varint · multiformats · proto
Varint, multihash, multibase, base58, CID, multiaddr and protobuf wire encoding.
crypto/
facade · pure · backend · secp256k1 · P-256 · SHA-256 · keccak
A common cryptographic interface with pure-Lean and external backends.
net/
streams · yamux
Stream abstractions, buffered readers, framing, TCP and Yamux.
libp2p/
identity · core · security · mux · negotiate · host · protocols
Peer identity, core abstractions, security, multiplexing, negotiation, host and application protocols.
cli/
demo node · ping node · interop harness
Executable demonstration nodes, ping and interoperability testing infrastructure.
// dependency discipline
Each group imports only groups to its right
cli → libp2p → net → crypto → codec → base
Lower-level packages never depend on libp2p, so other Lean projects can reuse them — and the stack stays easier to test, reason about and evolve. Everything else libp2p offers remains a deferred extension point behind well-defined interfaces.
// dependency strategy
FFI first
Mature implementations connect through small interfaces and C shims, so effort goes into protocol semantics, verification and interoperability. A native Lean backend can later replace an external one without changing the interface.
- OpenSSL 3 for cryptographic backend functionality
- Snappy through an external implementation
- Future QUIC implementations through the same interface-oriented approach
The crypto backend supports secp256k1, P-256, SHA-256 and Keccak via the etheorem hazmat packages. Toolchain: Lean 4 v4.34 · OpenSSL 3 · lake test, also passing under +RTS -N1 to detect concurrency starvation.