{"id":51116353,"url":"https://github.com/blockblaz/zig-libp2p","last_synced_at":"2026-06-24T22:30:26.675Z","repository":{"id":356535995,"uuid":"1232906636","full_name":"blockblaz/zig-libp2p","owner":"blockblaz","description":"A pure Zig implementation of the libp2p (WIP)","archived":false,"fork":false,"pushed_at":"2026-06-17T20:21:22.000Z","size":1353,"stargazers_count":2,"open_issues_count":17,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-17T22:06:48.396Z","etag":null,"topics":["decentralisation","decentralization","libp2p","networking","peer-to-peer","zig"],"latest_commit_sha":null,"homepage":"","language":"Zig","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/blockblaz.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"docs/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-05-08T11:53:04.000Z","updated_at":"2026-06-17T20:14:05.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/blockblaz/zig-libp2p","commit_stats":null,"previous_names":["ch4r10t33r/zig-libp2p","blockblaz/zig-libp2p"],"tags_count":96,"template":false,"template_full_name":null,"purl":"pkg:github/blockblaz/zig-libp2p","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blockblaz%2Fzig-libp2p","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blockblaz%2Fzig-libp2p/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blockblaz%2Fzig-libp2p/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blockblaz%2Fzig-libp2p/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/blockblaz","download_url":"https://codeload.github.com/blockblaz/zig-libp2p/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blockblaz%2Fzig-libp2p/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34752465,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-24T02:00:07.484Z","response_time":106,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["decentralisation","decentralization","libp2p","networking","peer-to-peer","zig"],"created_at":"2026-06-24T22:30:23.216Z","updated_at":"2026-06-24T22:30:26.653Z","avatar_url":"https://github.com/blockblaz.png","language":"Zig","funding_links":[],"categories":[],"sub_categories":[],"readme":"# zig-libp2p\n\n[![project-libp2p](https://img.shields.io/badge/project-libp2p-yellow.svg?style=flat-square)](https://libp2p.io/)\n[![CI](https://img.shields.io/github/actions/workflow/status/blockblaz/zig-libp2p/ci.yml?branch=main\u0026style=flat-square\u0026label=CI)](https://github.com/blockblaz/zig-libp2p/actions/workflows/ci.yml)\n[![Zig](https://img.shields.io/badge/zig-0.16.0-f7a41d.svg?style=flat-square)](https://ziglang.org/)\n[![Release](https://img.shields.io/github/v/tag/blockblaz/zig-libp2p?style=flat-square\u0026label=release\u0026sort=semver)](https://github.com/blockblaz/zig-libp2p/releases)\n[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](LICENSE)\n\nA pure-Zig implementation of [libp2p](https://libp2p.io/), the modular peer-to-peer\nnetworking stack. zig-libp2p targets the **lean-consensus / Ethereum-consensus\nsubset** of libp2p — QUIC transport, gossipsub, and request/response — and is\nverified to interoperate with [go-libp2p](https://github.com/libp2p/go-libp2p)\nand [rust-libp2p](https://github.com/libp2p/rust-libp2p) on the wire.\n\nIt was built for the [zeam](https://github.com/blockblaz/zeam) lean-Ethereum\nclient, but the `Host` API is client-agnostic and usable by any Zig project that\nneeds a libp2p node.\n\n\u003e **Status: pre-1.0.** The public API is still evolving toward a 1.0 freeze\n\u003e ([#172](https://github.com/blockblaz/zig-libp2p/issues/172)). Pin a release\n\u003e tag in your `build.zig.zon` and review the [changelog](CHANGELOG.md) before\n\u003e upgrading.\n\n## Highlights\n\n- **QUIC-first transport** (RFC 9000/9001) with libp2p TLS 1.3, backed by the\n  companion [`zquic`](https://github.com/ch4r10t33r/zquic) stack — no C\n  dependencies, builds in a `FROM scratch` container.\n- **Gossipsub v1.1** (StrictNoSign) with mesh maintenance, peer scoring, PX,\n  IDONTWANT, direct peers, and FANOUT.\n- **Request/response** with length-prefixed SSZ + snappy framing.\n- **Cross-implementation interop** continuously exercised in CI against\n  go-libp2p and rust-libp2p (handshake, ping, gossipsub, req/resp).\n- **Single dependency, single import** — `@import(\"zig_libp2p\")` exposes the\n  whole surface; one `Host` object drives transport, muxing, and protocols.\n\n## Getting started\n\n### Requirements\n\n- [Zig](https://ziglang.org/) **0.16.0**\n- [`zquic`](https://github.com/ch4r10t33r/zquic), pinned transitively and\n  re-exported as `zig_libp2p.zquic`\n\n### Add it to your build\n\nAdd the dependency to your `build.zig.zon` (pin a released tag):\n\n```sh\nzig fetch --save \"https://github.com/blockblaz/zig-libp2p/archive/refs/tags/v0.2.13.tar.gz\"\n```\n\nThen wire it into `build.zig`:\n\n```zig\nconst zig_libp2p = b.dependency(\"zig_libp2p\", .{\n    .target = target,\n    .optimize = optimize,\n});\nexe.root_module.addImport(\"zig_libp2p\", zig_libp2p.module(\"zig_libp2p\"));\n```\n\n### Shadow simulator\n\nThe transitively-pinned [`zquic`](https://github.com/ch4r10t33r/zquic) (v1.7.49+)\nsupports the [Shadow network simulator](https://shadow.github.io/) — deterministic,\nbit-exact multi-peer replays — via the `-Dshadow=true` build flag. Because\nzig-libp2p sits entirely on top of zquic for QUIC transport (no direct syscalls\nof its own beyond what zquic re-exports), running a libp2p node under Shadow\njust means building zquic with that flag transitively.\n\nEmbedders forward the flag through their own `build.zig`:\n\n```zig\nconst shadow = b.option(bool, \"shadow\", \"Build for the Shadow simulator\") orelse false;\n\nconst zig_libp2p_dep = b.dependency(\"zig_libp2p\", .{\n    .target = target,\n    .optimize = optimize,\n    // Forwarded into the zquic dep — zquic owns the syscall layer. When zquic\n    // is built with -Dshadow=true it links libc and routes time / random / UDP\n    // through libc so Shadow's LD_PRELOAD shim can intercept.\n    .shadow = shadow,\n});\n```\n\nBuild with:\n\n```sh\nzig build -Dtarget=x86_64-linux-gnu -Dshadow=true -Doptimize=ReleaseSafe\nfile zig-out/bin/your-node   # → dynamically linked, /lib64/ld-linux-x86-64.so.2\n```\n\nThe dynamically-linked-against-glibc binary is what Shadow's shim injects into.\nThe default no-libc Linux build is unaffected. See\n[zquic/docs/shadow.md](https://github.com/ch4r10t33r/zquic/blob/master/docs/shadow.md)\nfor the full list of behavior knobs that flip (libc-routed `clock_gettime` /\n`getrandom`, `sendmmsg`/`recvmmsg` disabled in favor of per-message I/O), a\nminimal `shadow.yaml`, and known limitations.\n\n### Hello, node\n\nThe public surface lives in [`src/root.zig`](src/root.zig); the canonical\nend-to-end wiring (host creation, QUIC listen/dial, gossipsub, req/resp, event\nloop) is [`examples/host_quic_node.zig`](examples/host_quic_node.zig). Build the\nexamples and run it with:\n\n```sh\nzig build examples\n./zig-out/bin/example-host-quic-node\n```\n\n## libp2p spec coverage\n\nCoverage of the [libp2p specifications](https://github.com/libp2p/specs),\norganized by spec area. zig-libp2p targets the subset required by lean /\nEthereum consensus, so some libp2p features are intentionally out of scope.\n\n**Legend:** ✅ implemented · 🚧 partial / experimental · ⬜ planned · ⛔ out of scope\n\n### Transports\n\n| Spec | Status | Notes |\n|------|:------:|-------|\n| TCP | ✅ | `transport.tcp` |\n| QUIC v1 (RFC 9000/9001) | ✅ | primary transport, via `zquic`; interop go ✅ · rust ✅ |\n| WebSocket — `/ws` (RFC 6455) | ✅ | `transport.ws*`; unit-tested |\n| Secure WebSocket — `/wss` | ⬜ | [#94](https://github.com/blockblaz/zig-libp2p/issues/94) |\n| WebTransport | ⬜ | [#94](https://github.com/blockblaz/zig-libp2p/issues/94) |\n| WebRTC | ⬜ | [#94](https://github.com/blockblaz/zig-libp2p/issues/94) |\n\n### Secure channels\n\n| Spec | Status | Notes |\n|------|:------:|-------|\n| TLS 1.3 (libp2p TLS, RFC 0001) | ✅ | over QUIC and TCP (`/tls/1.0.0`); interop go ✅ · rust ✅ |\n| Noise (`/noise`, XX) | ✅ | RSA, ECDSA-P256, secp256k1, ed25519 identities |\n\n### Stream multiplexing\n\n| Spec | Status | Notes |\n|------|:------:|-------|\n| QUIC native streams | ✅ | default for the QUIC transport |\n| yamux | ✅ | `transport.yamux` |\n| mplex | ✅ | `transport.mplex` |\n\n### Protocol negotiation\n\n| Spec | Status | Notes |\n|------|:------:|-------|\n| multistream-select 1.0 | ✅ | `transport.stream_multistream` |\n\n### Peer identity\n\n| Spec | Status | Notes |\n|------|:------:|-------|\n| Peer IDs / keypairs | ✅ | `identity`, `keypair` |\n| Signed peer records (RFC 0002) | ✅ | `identify.verifySignedPeerRecord` |\n\n### Publish / subscribe\n\n| Spec | Status | Notes |\n|------|:------:|-------|\n| gossipsub v1.1 (StrictNoSign) | ✅ | mesh, peer scoring ([#199](https://github.com/blockblaz/zig-libp2p/issues/199)), PX, IDONTWANT, direct peers, FANOUT; interop go ✅ · rust ✅ |\n| floodsub | ⛔ | superseded by gossipsub |\n\n### Peer discovery \u0026 content routing\n\n| Spec | Status | Notes |\n|------|:------:|-------|\n| Bootstrap (static dial) | ✅ | `connect_peers` via `connection_manager` |\n| Kademlia DHT | ✅ | `kad_dht`, `host`; lifecycle ([#203](https://github.com/blockblaz/zig-libp2p/issues/203)), record validators ([#198](https://github.com/blockblaz/zig-libp2p/issues/198)) |\n| mDNS (LAN discovery) | ✅ | `discovery.mdns`, `host`; `peer_discovered` events ([#207](https://github.com/blockblaz/zig-libp2p/issues/207)) |\n| Rendezvous | ✅ | `rendezvous` client/server, cookie paging, `peer_discovered` ([#209](https://github.com/blockblaz/zig-libp2p/issues/209)) |\n\n### NAT traversal\n\n| Spec | Status | Notes |\n|------|:------:|-------|\n| AutoNAT v1 | ✅ | `autonat`; active probing, dial-back verification, sliding-window vote aggregation ([#206](https://github.com/blockblaz/zig-libp2p/issues/206)). v2 wire codecs present; v2 transport wiring pending |\n| Circuit Relay v2 | 🚧 | `relay`, QUIC runtime; `/p2p-circuit` dial + reservation refresh ([#204](https://github.com/blockblaz/zig-libp2p/issues/204)) |\n| DCUtR (hole punching) | ✅ | `dcutr`; auto-trigger on relayed connections with retry ([#205](https://github.com/blockblaz/zig-libp2p/issues/205)) |\n\n### Utility \u0026 application protocols\n\n| Spec | Status | Notes |\n|------|:------:|-------|\n| ping (`/ipfs/ping/1.0.0`) | ✅ | interop go ✅ · rust ✅ |\n| identify (`/ipfs/id/1.0.0`) | ✅ | `identify` |\n| identify-push (`/ipfs/id/push/1.0.0`) | ✅ | `identify`, `host`, QUIC runtime auto-opens push streams |\n| Request/response (length-prefixed, SSZ-snappy) | ✅ | `req_resp`; interop go ✅ · rust ✅ |\n\n### Not yet implemented\n\n| Spec | Status | Notes |\n|------|:------:|-------|\n| Private networks (PSK / pnet) | ⬜ | [#171](https://github.com/blockblaz/zig-libp2p/issues/171) |\n| Resource manager (scope-based limits) | ⬜ | [#169](https://github.com/blockblaz/zig-libp2p/issues/169) |\n\nThe live cross-impl interop matrix is in\n[`harness/quic/README.md`](harness/quic/README.md); the full module map is\n[`src/root.zig`](src/root.zig) and the layout rationale is\n[`docs/REPO_LAYOUT.md`](docs/REPO_LAYOUT.md).\n\n## Interoperability\n\nCross-implementation conformance is part of CI. To run the QUIC matrix locally:\n\n```sh\nzig build -Doptimize=ReleaseFast\n(cd harness/quic/impls/go-libp2p \u0026\u0026 go build -o interop-quic-node-go .)\n(cd harness/quic/impls/rust-libp2p \u0026\u0026 cargo build --release --locked)\nharness/quic/run_matrix.sh zig,go-libp2p handshake,ping,gossipsub,reqresp\nharness/quic/run_matrix.sh zig,rust-libp2p handshake,ping,gossipsub,reqresp\n```\n\nOr `zig build interop-matrix` for a quick zig↔go handshake+ping smoke. Harness details and the full status table\nlive in [`harness/README.md`](harness/README.md).\n\n## Examples\n\nAll examples are under [`examples/`](examples/) and install to `zig-out/bin/`\nvia `zig build`:\n\n| Example | What it shows |\n|---------|---------------|\n| `example-host-quic-node` | Full `Host` + QUIC lifecycle (production wiring) |\n| `interop-quic-node` | Env-driven endpoint used by the cross-impl matrix |\n| `gen-libp2p-cert` | Mint a libp2p TLS certificate + derive its peer id |\n| `example-gossipsub-mesh` | Gossipsub publish/subscribe over a mesh |\n| `example-quic-ping-loopback` | QUIC ping round-trip on loopback |\n| `example-autonat-membuf`, `example-kad-dht-membuf` | In-memory AutoNAT / Kademlia smoke |\n\nSee [`examples/README.md`](examples/README.md) for the complete list.\n\n## Repository layout\n\nOrganized by libp2p **layer** (`primitives → core → protocols → transport`),\nnot by transport. Each folder below has its own `README` describing its modules;\nthe public API is the facade in [`src/root.zig`](src/root.zig).\n\n```\nzig-libp2p/\n├── src/                  → library source — see src/README.md\n│   ├── primitives/       wire-agnostic building blocks (identity, varint, multistream, protobuf)\n│   ├── core/             node runtime: Host, Swarm, connection manager, events\n│   ├── protocols/        one folder per libp2p protocol (gossipsub, kad-dht, autonat, relay, …)\n│   ├── transport/        QUIC stack, TCP, WebSocket, yamux/mplex\n│   └── security/         libp2p TLS 1.3 + Noise\n├── examples/             runnable examples — see examples/README.md\n├── harness/              cross-impl interop harnesses (quic/, tcp/) — see harness/README.md\n├── bench/                micro-benchmarks\n├── build/                build helpers (deps, examples, fuzz, soak, interop)\n├── docs/                 design docs (architecture, security, per-protocol)\n├── tests/                integration tests — see tests/interop/README.md\n├── fixtures/             shared test fixtures\n└── vendor/               vendored TLS/RSA, outside src/ — see vendor/README.md\n```\n\n| Folder | README |\n|--------|--------|\n| `src/` overview | [`src/README.md`](src/README.md) |\n| `src/primitives/` | [`src/primitives/README.md`](src/primitives/README.md) |\n| `src/core/` | [`src/core/README.md`](src/core/README.md) |\n| `src/protocols/` | [`src/protocols/README.md`](src/protocols/README.md) |\n| `src/transport/` | [`src/transport/README.md`](src/transport/README.md) |\n| `src/security/` | [`src/security/README.md`](src/security/README.md) |\n| `examples/` | [`examples/README.md`](examples/README.md) |\n| `harness/` | [`harness/README.md`](harness/README.md) |\n| `vendor/` | [`vendor/README.md`](vendor/README.md) |\n\nFull rationale and the migration phases are in\n[`docs/REPO_LAYOUT.md`](docs/REPO_LAYOUT.md); the layer diagram is in\n[`docs/ARCHITECTURE.md`](docs/ARCHITECTURE.md). Legacy `src/*.zig` import paths\nremain as compatibility shims through the 1.0 freeze.\n\n## Documentation\n\n- **Repository layout** — [`docs/REPO_LAYOUT.md`](docs/REPO_LAYOUT.md) · **Architecture** — [`docs/ARCHITECTURE.md`](docs/ARCHITECTURE.md)\n- **Security model \u0026 wire limits** — [`docs/SECURITY.md`](docs/SECURITY.md)\n- **AutoNAT** — [`docs/AUTONAT.md`](docs/AUTONAT.md) · **Kademlia DHT** — [`docs/KAD_DHT.md`](docs/KAD_DHT.md) · **mDNS** — [`docs/MDNS.md`](docs/MDNS.md)\n- **Async swarm design** — [`docs/async-swarm.md`](docs/async-swarm.md)\n- **zeam integration notes** — [`docs/zeam-parity.md`](docs/zeam-parity.md)\n\n## Roadmap\n\nPer-protocol gaps are tracked in the spec-coverage tables above. The broader\nmilestones toward a stable release:\n\n- **1.0-RC API freeze + semver** — [#172](https://github.com/blockblaz/zig-libp2p/issues/172)\n- **Third-party security audit + disclosure policy** — [#170](https://github.com/blockblaz/zig-libp2p/issues/170)\n- **Async swarm** (`std.Io` co-scheduled, moving off the threaded runtime) — [#57](https://github.com/blockblaz/zig-libp2p/issues/57)\n\nSpec-compliance umbrella: [#80](https://github.com/blockblaz/zig-libp2p/issues/80).\n\n## Development\n\n```sh\nzig fmt --check .     # formatting\nzig build test        # unit tests + example smoke-runs\nzig build soak-test   # opt-in 60s QUIC gossipsub soak (#235)\nzig build fuzz        # wire-decoder fuzzing via std.testing.fuzz\n```\n\nCI workflows live in [`.github/workflows/`](.github/workflows/).\n\nReleases are cut **manually**: tag the chosen commit and publish a GitHub\nrelease (`gh release create vX.Y.Z --target main --notes …`), bumping\n`.version` in [`build.zig.zon`](build.zig.zon) and the install snippet above in\nthe same change.\n\n## Contributing\n\nContributions are welcome. Please open an issue to discuss substantial changes\nfirst, keep `zig fmt` clean, and make sure `zig build test` passes. New protocol\nbehaviour should come with unit tests and, where it crosses the wire, an entry\nin the interop matrix.\n\n## Security\n\nWire-size limits and the threat model are documented in\n[`docs/SECURITY.md`](docs/SECURITY.md). A coordinated-disclosure policy is\ntracked in [#170](https://github.com/blockblaz/zig-libp2p/issues/170); until it\nlands, please report vulnerabilities privately to the maintainer rather than via\npublic issues.\n\n## License\n\nReleased under the [MIT License](LICENSE).\n\n## Acknowledgements\n\nBuilt on the [libp2p specifications](https://github.com/libp2p/specs) and\nverified against [go-libp2p](https://github.com/libp2p/go-libp2p) and\n[rust-libp2p](https://github.com/libp2p/rust-libp2p).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblockblaz%2Fzig-libp2p","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fblockblaz%2Fzig-libp2p","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblockblaz%2Fzig-libp2p/lists"}